Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY
Purpose of the function block is to enable safety parameter adjustment to control unit. This is mandatory before editing safety parameter values.
Note: This function block will request GFC message to be sent which will set safety control units in safe state.
Authentication is done with the following sequence when i_Enable is set to TRUE:
Read authentication status from control unit OD index 21FDh sub 0. If status is OK (1), then rest of the sequence is skipped.
Read challenge code from control unit OD index 21FEh sub 0.
Set o_GFCRequest to TRUE. Note: CANopen GFC message is sent by application.
Calculate response code with Epec Safe Data Validation library’s CalculateAccessCode function using the challenge code and i_ProjectKey (application specific).
Write response code to control unit OD index 21FFh sub 0.
Wait for control unit to validate response code.
Read authentication status from control unit OD index 21FDh sub 0.
Set o_GFCRequest to FALSE.
If authentication status is OK (1) after sequence, then o_State is set Authenticated.
If status is not OK (0), then o_State is WrongKey. Otherwise state depends on error.
o_AbortCode contains CANopen abort code if it was encountered during SDO transfers.
State and abort code are reset if i_Enable is set to FALSE.
Authentication shall be done before adjusting safety parameters. |
Authentication needs to be done for each safety control unit individually. |
CANopen GFC protocol is required in HMI to activate GFC message. |
Safety control unit requires reboot after safety parameter adjustment process. |
Input variable name |
Data type |
Range |
Description |
i_Enable |
BOOL |
|
Authentication 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 |
|
i_ProjectKey |
STRING(80) |
|
Authentication encryption key |
Output variable name |
Data type |
Range |
Description |
o_State |
AuthenticationState |
see enumeration |
State is Authenticated when sequence was successful, see AuthenticationState enumeration. |
o_AbortCode |
DWORD |
|
CANopen abort code |
o_GFCRequest |
BOOL |
|
Application is requested to send GFC CANopen message |
Following example authenticates safety parameter adjustment in a single safety control unit (node 1).
Code template definitions: |
|
/// CAN device Device: EPEC_CANopen.Device; |
Code template definitions: |
|
/// Project key, used for validating the response code ProjectKey : STRING(80):='12345678'; |
Definitions: |
|
authUnit: EPEC_PAR.SafetyParAuthentication; gfcRequest: BOOL; gfcRequestOld: BOOL; state: EPEC_PAR.AuthenticationState; |
Code: |
|
authUnit( i_Enable := TRUE, i_pDevice := ADR(G_CANopen_CAN1.Device), // From code template i_NodeID := 1, i_Timeout := T#1S, i_ProjectKey := ProjectKey, o_State => state, o_GFCRequest => gfcRequest );
IF gfcRequest AND NOT gfcRequestOld THEN G_CANopen_CAN1.GFC_Handler.Activate(); // GFC protocol from code template END_IF gfcRequestOld := gfcRequest;
IF state < EPEC_PAR.AuthenticationState.Idle THEN ; // Application specific error handling ELSIF state = EPEC_PAR.AuthenticationState.Authenticated THEN ; // Success END_IF |
Source file topic100517.htm
Last updated 19-Dec-2024