Supported platforms: CODESYS 2.3, CODESYS 3.5

 

JCD_Joystick (FB)

Description

JCD_Joystick function block is  used for one axis of a basic joystick. The FB includes functionality for calibrating, progression and diagnostics.

FB uses:

 

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.

Limitations

 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.

Inputs

CODESYS 2.3CODESYS 2.3

 

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.

 

CODESYS 3.5CODESYS 3.5

 

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.

 

Outputs

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.

 

Example code

See also

 

Source file Topic000357.htm

Last updated 21-Feb-2025