Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY
This section describes how to read and validate 2 channel joystick signals.
This example uses the following libraries: SafeConversion library SafeDataValidation library
SafeJoystickCalibrationAndDiagnostic library
, or alternatively non-safe library SensorsAndActuators library
|
S_ADCToVoltageOrCurrent POU is included in code template generated by MultiTool Creator.
|
The following image is an architecture example for 2-channel joystick validation.
When the following example is used with non-safety I/O, the I/O variables are generated in Inputs program instead of S_Inputs. |
The following example demonstrates the reading and validating of 2 channel joystick signals (Joystick_X_A and Joystick_X_B AI signals defined in MultiTool Creator).
Code at safe PRG: |
|
Init method: |
IF NOT initDone THEN initDone:=TRUE;
|
Validation init with SafeDataValidation V1.0.0.7Validation init with SafeDataValidation V1.0.0.7
Init method: |
S_Validate_X_Axis.Init( S_i_InvertedCh2 := TRUE, S_i_DiagnosticDelay := UINT#40, S_i_SafeOutputValue := DINT#0, S_i_Tolerance := DINT#50, S_i_SumValue := EPEC_HW.Constants.G_AI_5V_HIGH_VOLTAGE, // tolerance sum value for inverted mode validation i_pEventCode := ADR(S_Inputs.o_EventCode_Joystick_X_A), i_pEventCodeCh2 := ADR(S_Inputs.o_EventCode_Joystick_X_B) ); |
Init method: |
S_Validate_X_Axis.Init( S_i_InvertedCh2 := TRUE, S_i_DiagnosticDelay := UINT#40, S_i_SafeOutputValue := DINT#0, S_i_Tolerance := DINT#50, S_i_SumValue := EPEC_HW.Constants.G_AI_5V_HIGH_VOLTAGE, // tolerance sum value for inverted mode validation S_i_ReferenceValue := DINT#0, // reference value is not used in inverted mode i_pEventCode:=ADR(S_Inputs.o_EventCode_Joystick_X_A), i_pEventCodeCh2:=ADR(S_Inputs.o_EventCode_Joystick_X_B) ); |
Init method: |
S_BoomJoystick_X.Init( S_i_Deadband:=5 , S_i_ProgressionPosDir:=0 , S_i_ProgressionNegDir:=0 , S_i_SignalErrorTolerance:=5 , S_i_pCalibratedMinPosition:= ADR(S_JoystickMinPosition), S_i_pCalibratedMidPosition:= ADR(S_JoystickMidPosition), S_i_pCalibratedMaxPosition:= ADR(S_JoystickMaxPosition), i_pEventCode:=ADR(S_Inputs.o_EventCode_Joystick) );
END_IF |
The following example code reads 2-channel joystick with alternative non-safe wrapper POU.
Code at non-safe PRG: |
|
S_ValidateAI (FB)
S_Joystick (FB)
SensorsAndActuators library
Joystick2ChCompare (FB)
Source file topic100384.htm
Last updated 19-Dec-2024