Supported platforms: CODESYS 2.3, CODESYS 3.5
JCD_Joystick function block is used for one axis of a basic joystick. The FB includes functionality for calibrating, progression and diagnostics.
FB uses:
JCD_CompensatedVoltages to adjust joystick calibration voltages to apply with supply voltage.
JCD_Scale to scale (calibrate) the analog input value to the control signal value. Dead band is included in scaling.
JCD_Progression to change the curve shape of the scaled and filtered control signal. If Progression is set to zero, the function is not called.
JCD_ParamCheck to check that calibration, dead band and progression parameters are within the valid range. Calibration values must increase logically: Maximum >= middle >= minimum, and maximum must not be equal to minimum (maximum > minimum).
JCD_AIVoltCheck function to check that the analog input value is within the given voltage range. Tolerance is given as voltage.
maximum allowed voltage = maximum calibration voltage + tolerance voltage
minimum allowed voltage = minimum calibration voltage - tolerance voltage
If given tolerance value is -1, diagnostics is not used.
If i_Enable is inactive or in case of a parameter error or AI voltage error, the control signal is set to zero. Controlling is disabled, until the error is fixed and the joystick has been centered (AI value has been within dead band range). This prevents unexpected control of movement after power on or error situation.
Calibration has 2 operation modes: - Voltage mode: Input parameters are given in volts and joystick supply voltage is not compensated. - Percentage mode: Input parameters are given in percentage of joystick supply voltage. Due to that, changes in joystick supply voltage are compensated. |
In voltage mode ( i_ParameterType = G_JCType.Voltage), both output and input calibration parameters are handled as volts (1000 = 10,00V). In percentage mode ( i_ParameterType = G_JCType.Percentage), both output and input calibration parameters are handled as proportion (1000 = 100,0%) of joystick supply voltage. |
Joystick and pedal must be connected to voltage input. |
When i_ParameterType = G_JCType.Voltage and voltage values are used for joystick calibration, there is a reference voltage monitoring feature built in to detect drop of reference voltage level. In such case, o_Control signal output is reset and can be used again after rising edge of i_Enable. This monitoring feature can however detect only sudden drop of ref voltage level. |
It is highly recommended to set i_ParameterType to G_JCType.Percentage and to use percentage values for joystick calibration. This ensures that unexpected dropping of reference voltage level doesn’t cause o_ControlSignal output changing and unwanted response in controlled actuator. |
Input variable name |
Data type |
Range |
Description |
i_Enable |
BOOL |
FALSE/TRUE |
Enables controlling of o_ControlSignal output |
i_AISignal |
UINT |
hardware specific |
Analog input signal |
i_AIType |
BYTE |
0..G_ADScaleArrMax |
Defines the Analog input type and range |
i_AISupply |
UINT |
hardware specific |
Joystick supply voltage measurement |
i_AISupplyType |
BYTE |
0..G_ADScaleArrMax |
Joystick supply type and range |
i_ParameterType |
ENUM |
G_JCType.Percentage, G_JCType.Voltage |
G_JCType.Voltage: No voltage compensation, calibrated values are in volts. G_JCType.Percentage: Voltage compensation is in use. Calibrated values are percentage of supply voltage. |
i_CalibratedMax |
UINT |
Hardware and calibration type specific |
Maximum calibration value of joystick. Value is given in voltage (1000 = 10,00V) or percentage (1000 = 100,0%), range depends on used hardware type. |
i_CalibratedMid |
UINT |
Hardware and calibration type specific |
Middle calibration value of joystick. Value is given in voltage (1000 = 10,00V) or percentage (1000 = 100,0%), range depends on used hardware type. |
i_CalibratedMin |
UINT |
Hardware and calibration type specific |
Minimum calibration value of joystick. Value is given in voltage (1000 = 10,00V) or percentage (1000 = 100,0%), range depends on used hardware type. |
i_Deadband |
BYTE |
0…100% |
Defines the dead band of joystick in center position, value given in percentage of max-mid or mid-min range. |
i_Progression_PosDir |
BYTE |
-100…100 |
Positive direction’s progression curve factor |
i_Progression_NegDir |
BYTE |
-100…100 |
Negative direction’s progression curve factor |
i_AIErrorTolerance |
INT |
-1, 0…250 or -1, 0…500 depending on calibration type |
Defines how many volts AI signal is allowed to be out of calibrated range. Value is given in voltage (250 = 2,50V) or percentage of supply voltage (500 = 50,0%), range depends on selected value type. With value -1, diagnostics is not used. |
i_ErrorDelay |
UINT |
0…65535 ms |
Defines the time that AI signal is allowed to exceed tolerated range before error outputs are activated. |
Input variable name |
Data type |
Range |
Description |
i_Enable |
BOOL |
FALSE/TRUE |
Enables controlling of o_ControlSignal output |
i_AISignal |
UINT |
hardware specific |
Analog input signal |
i_AIType |
ADData |
G_AIType struct
|
Defines the Analog input type and range |
i_AISupply |
UINT |
hardware specific |
Joystick supply voltage measurement |
i_AISupplyType |
ADData |
G_AIType struct
|
Defines the Supply input type and range |
i_ParameterType |
ENUM |
G_JCType.Percentage, G_JCType.Voltage |
G_JCType.Voltage: No voltage compensation, calibrated values are in volts. G_JCType.Percentage: Voltage compensation is in use. Calibrated values are percentage of supply voltage. |
i_CalibratedMax |
UINT |
Hardware and calibration type specific |
Maximum calibration value of joystick. Value is given in voltage (1000 = 10,00V) or percentage (1000 = 100,0%), range depends on used hardware type. |
i_CalibratedMid |
UINT |
Hardware and calibration type specific |
Middle calibration value of joystick. Value is given in voltage (1000 = 10,00V) or percentage (1000 = 100,0%), range depends on used hardware type. |
i_CalibratedMin |
UINT |
Hardware and calibration type specific |
Minimum calibration value of joystick. Value is given in voltage (1000 = 10,00V) or percentage (1000 = 100,0%), range depends on used hardware type. |
i_Deadband |
BYTE |
0…100% |
Defines the dead band of joystick in center position, value given in percentage of max-mid or mid-min range. |
i_Progression_PosDir |
BYTE |
-100…100 |
Positive direction’s progression curve factor |
i_Progression_NegDir |
BYTE |
-100…100 |
Negative direction’s progression curve factor |
i_AIErrorTolerance |
INT |
-1, 0…250 or -1, 0…500 depending on calibration type |
Defines how many volts AI signal is allowed to be out of calibrated range. Value is given in voltage (250 = 2,50V) or percentage of supply voltage (500 = 50,0%), range depends on selected value type. With value -1, diagnostics is not used. |
i_ErrorDelay |
UINT |
0…65535 ms |
Defines the time that AI signal is allowed to exceed tolerated range before error outputs are activated. |
Output variable name |
Data type |
Range |
Description |
o_ControlSignal |
INT |
-32767..32767 |
Calibrated control signal value |
o_AISignalTooHigh |
BOOL |
FALSE/TRUE |
AI signal input value is higher than maximum tolerated value |
o_AISignalTooLow |
BOOL |
FALSE/TRUE |
AI signal input value is lower than minimum tolerated value |
o_ParameterError |
BOOL |
FALSE/TRUE |
True when incorrect parameter value in any of the monitored parameters. |
Source file Topic000357.htm
Last updated 21-Feb-2025