Supported platforms: CODESYS 2.3, CODESYS 3.5
JCD_Scale function is used for scaling the analog input ADC value to the control signal within a range of 0..32767 based on calibration values and dead band value given as input.
The ControlSignal output is zero until the AI signal level exceeds the deadband voltage limit, which is calculated with the following algorithm:
Deadband voltage limit = (i_VoltageForMaxControl - i_VoltageForMinControl) * i_Deadband / 100 + i_VoltageForMinControl
Between the calculated deadband voltage limit and i_VoltageForMaxControl, o_ControlSignal increases linearly according to i_AISignal. o_ControlSignal is limited to 32767 if i_AISignal exceeds i_VoltageForMaxControl value.
i_VoltageForMaxControl and i_VoltageForMinControl values are converted to ADC values using the ADC_From_mAOrV function.
Example control value curves with i_VoltageForMinControl of 2,5V. Higher i_VoltageForMaxControl gives positive slope, and vice versa gives negative.
This function block is primarily intended for JoystickCalibrationAndDiagnostic library's internal use. |
Input variable name |
Data type |
Range |
Description |
i_AISignal |
UINT |
hardware specific |
Analog input signal |
i_AIType |
BYTE |
0..G_ADScaleArrMax |
Analog input type and range |
i_CalibratedMax |
UINT |
hardware specific |
Max calibration voltage value, value given in voltage with two decimals, range depend of used hardware type, with this value function return max control signal value (32767) |
i_CalibratedMin |
UINT |
hardware specific |
Min calibration voltage value, value given in voltage with two decimals, range depend of used hardware type, with this value function return min control signal value (0) |
i_Deadband |
BYTE |
0..100% |
Defines the dead band, value given in percentage of max-min range. |
Input variable name |
Data type |
Range |
Description |
i_AISignal |
UINT |
hardware specific |
Analog input signal |
i_AIType |
ADData |
G_AIType struct |
Analog input type and range |
i_CalibratedMax |
UINT |
hardware specific |
Max calibration voltage value, value given in voltage with two decimals, range depend of used hardware type, with this value function return max control signal value (32767) |
i_CalibratedMin |
UINT |
hardware specific |
Min calibration voltage value, value given in voltage with two decimals, range depend of used hardware type, with this value function return min control signal value (0) |
i_Deadband |
BYTE |
0..100% |
Defines the dead band, value given in percentage of max-min range. |
Return value |
Data type |
Range |
Description |
|
INT |
0...32767 |
Calibrated control signal value |
Source file Topic000362.htm
Last updated 21-Feb-2025