Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY
Purpose of the function block is to read OD index from control unit which contains list of control unit’s all safety parameter indexes.
List needs to be read once from each safety control unit and is needed for safety parameter adjustment (see SafetyParCrcHandler (FB) & How to adjust safety parameters).
Index list is returned in output o_IndexList.
List should be used to check if safety parameter sequence is required when adjusting parameters from safety control unit. |
Index list is read with following sequence when i_Enable is set TRUE (on rising edge):
o_State is set to Processing.
Initialize index list array to zeros (invalid OD indexes)
Read list’s sub-index count from OD index 21FBh sub 0
Read safety parameter index list from OD index 21FBh sub 1 to sub-count
If no error was encountered during SDO transfer, update o_IndexList and o_State is set to Idle. Otherwise o_State depends on error which was encountered.
o_AbortCode containts CANopen abort if encountered during SDO protocol.
Sequence can be reset by setting i_Enable to FALSE.
o_IndexList is reset (full of zeros) when new sequence begins.
Input variable name |
Data type |
Range |
Description |
i_Enable |
BOOL |
|
Read sequence is started when TRUE |
i_pDevice |
POINTER TO EPEC_CANopen.Device |
≠ 0 |
Used CANopen device (e.g. ADR(G_CANopen_CAN1.Device)) |
i_NodeID |
BYTE |
1..127 |
Node ID of the control unit |
i_Timeout |
TIME |
|
SDO protocol transfer timeout |
Output variable name |
Data type |
Range |
Description |
o_State |
SafetyParametersState |
see enumeration |
“Processing” while in progress, returns to “Idle” if successful, see enumeration for error codes |
o_IndexList |
ARRAY [1..255] OF WORD |
|
Safety parameter indexes for control unit, array is updated after successfully reading whole list |
o_AbortCode |
DWORD |
|
CANopen SDO abort code |
Following example reads safety parameter index list from single unit (node 1).
Application needs to determine which nodes are safety control units.
Code template definitions: |
|
/// CAN device Device: EPEC_CANopen.Device; |
Definitions: |
|
safetyIndexList: ARRAY [1..255] OF WORD; state: EPEC_PAR.SafetyParametersState; |
Init: |
|
readSafetyList(i_Enable := FALSE);
|
Code: |
|
readSafetyList( i_Enable := TRUE, i_pDevice := ADR(G_CANopen_CAN1.Device), // From code template i_NodeID := 1, i_Timeout := T#1S, o_State => state, o_IndexList => safetyIndexList, );
IF state < EPEC_PAR.SafetyParametersState.Idle THEN ; // Application error handling ELSIF state = EPEC_PAR.SafetyParametersState.Idle THEN ; // Index list read successfully to safetyIndexList array END_IF |
Source file topic100514.htm
Last updated 19-Dec-2024