Supported platforms: CODESYS 3.5

 

Joystick (FB)

Description

The joystick FB scales input voltage to calibrated control signal.

Dead band and progression are included in scaling.

The FB includes calibration functionality.

Calibration parameters, dead band and progression are checked for

valid range and that calibration values increase logically: maximum ≥ middle ≥ minimum.

A startup error is diagnosed if control is requested on the rising edge of i_Enable.

The output control signal is set to zero if i_Enable is FALSE, parameter error is diagnosed or startup error is diagnosed.  

 

All internal FB initializations are done on the rising edge of i_Enable.

All errors are reset on the rising edge of i_Enable.

 

Limitations

Joystick must be connected to voltage input.

 

The FB uses internally

- S_Joystick FB from SafeJoystickCalibrationAndDiagnostic library.

 

Following parameters are taken into use at the rising edge of i_Enable:

- i_pCalibratedMin

- i_pCalibratedMid

- i_pCalibratedMax

- i_DeadBand

- i_ProgressionPosDir

- i_ProgressionNegDir

- i_SignalErrorTolerance

+ Any initialized event code.

 

Inputs

Input variable name

Data type

Range

Description

i_Enable

BOOL

FALSE/TRUE

Enables controlling of o_Control output

i_SignalVoltage

DINT

hardware specific

Voltage measured from joystick output pin (mV).

i_ReferenceVoltage

DINT

hardware specific

Voltage measured from joystick supply pin (mV).

i_pCalibratedMax

POINTER TO DINT

500…1000

Pointer to maximum calibration value of joystick. Value is given in per mil of supply voltage (1000 = 100,0%).

i_pCalibratedMid

POINTER TO DINT

250…750

Pointer to middle calibration value of joystick. Value is given in per mil of supply voltage (1000 = 100,0%).

i_pCalibratedMin

POINTER TO DINT

0…500

Pointer to minimum calibration value of joystick. Value is given in per mil of supply voltage (1000 = 100,0%).

i_Deadband

DINT

0…1000

Dead band of joystick in center position, value given in per mil of position range 

i_Progression_PosDir

DINT

-100…100

Positive direction’s progression curve factor.

i_Progression_NegDir

DINT

-100…100

Negative direction’s progression curve factor.

i_SignalErrorTolerance

DINT

-1, 0…500

Defines how many volts Signal is allowed to be out of calibrated range. Value is given in per mil of supply voltage (500 = 50,0%), range depends on selected value type. With value -1, diagnostics is not used.

i_CalibrationMode

BOOL

FALSE/TRUE

Enables calibration of o_Control output.

Outputs

Output variable name

Data type

Range

Description

o_Control

INT

 

Calibrated control signal value.

o_SignalTooHigh

BOOL

FALSE/TRUE

Signal input value is higher than maximum tolerated value

o_SignalTooLow

BOOL

FALSE/TRUE

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.

o_StartupError

BOOL

FALSE/TRUE

Joystick not released when i_Enable rises.

o_CalibrationDone

BOOL

FALSE/TRUE

Joystick calibration finished successfully.

o_CalibrationError

BOOL

FALSE/TRUE

Joystick calibration error.

 

 

EventCodeInit (Public Method)

This optional method sets pointer for event code.

 

Inputs

Input variable name

Data type

Description

i_Enable

BOOL

Enable operation.

i_pEventCode

POINTER TO EPEC_DITF.EventCode

Pointer to signal event code value provided by the application.

 

 

Error diagnostic

See Diagnostic Interface library description of error status and event code functionality.

 

FunctionID and EventID are only set if EventCode is used.

 

A parameter error is diagnosed if:

  • pointer to any calibration parameter is 0, OR

  • i_DeadBand out of range OR

  • i_ProgressionPosDir out of range OR

  • i_ProgressionNegDir out of range OR

  • i_SignalErrorTolerance out of range OR

  • i_CalibratedMin is out of range OR

  • i_CalibratedMid is out of range OR

  • i_CalibratedMax is out of range OR

  • i_CalibratedMin > i_CalibratedMid OR

  • i_CalibratedMid > i_CalibratedMax

 

 

Conditions

o_Control

Output error set TRUE

Event code FunctionID

Event code EventID

i_Enable TRUE

AND

parameter error  

0

o_ParameterError

JOYSTICK  

PARAMETER_ERROR

i_Enable rises AND

 parameters ok AND

signal voltage outside dead band

0

o_StartupError

JOYSTICK

STARTUP_ERROR

i_Enable rises AND

 parameters ok AND

signal voltage within dead band

Scaled control value

-

NO_FUNC

NO_ERROR

i_Enable TRUE AND

parameters ok AND

no startup error AND

signal > calibrated maximum value + error tolerance

0

o_SignalTooHigh

JOYSTICK  

INPUT_TOO_HIGH

i_Enable TRUE AND

parameters ok AND

no startup error AND

signal < calibrated minimum value - error tolerance

0

o_SignalTooLow

JOYSTICK

 INPUT_TOO_LOW

 

 

Example code

 

 

 

 

 

See also

 

 

 

 

Source file topic100742.htm

Last updated 19-Dec-2024