Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY

 

SafetyParReadIndexData (FB)

Description

Purpose of the function block is to read initial values for a single safety parameter OD index (all sub-indexes) from control unit.

Initial values are needed for safety parameter adjustment (see SafetyParCrcHandler (FB) & How to adjust safety parameters).

 

Parameter values are read with following sequence when i_Enable is set TRUE:

 

If all values were read successfully, then o_State returns to Idle. Otherwise error code is returned.

o_AbortCode contains CANopen abort if any was encountered in SDO protocol.

 

Sequence and outputs can be reset by setting i_Enable to FALSE.

Limitations

Function block should be executed before adjusting safety parameter sub-index.

 

Note that parameter values are read as non-typed raw data (DWORD) and is intended for CRC handler purposes.

 

Inputs

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_pCSVData

POINTER TO CSVData

0

Pointer to struct array

i_CSVParCount

INT

> 0

Amount of parameters in csv data array

i_NodeID

BYTE

1..127

Node ID of the control unit

i_Index

WORD

Csv specific

OD index which is read

i_Timeout

TIME

 

SDO protocol transfer timeout

i_pIndexData

POINTER TO ARRAY[0..255] OF DWORD

0

Pointer to array where sub-index values are read

 

Outputs

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_AbortCode

DWORD

 

CANopen SDO abort code

 

Errors

SafetyParametersState

 

Example code

Following example reads safety parameter index values for selected parameter index.

Selected parameter is determined in application / GUI.

 

Code template definitions:

 

 

/// CAN device

Device: EPEC_CANopen.Device;

 

Code template definitions:

 

 

///Number of parameters in network

G_NUMBER_OF_PARAMETERS_NETWORK1: INT := 91;

 

 

Code template definitions:

 

 

///Parameter CSV configuration parameters

G_NETWORK1_Parameters_CSVData: ARRAY[1..G_NUMBER_OF_PARAMETERS_NETWORK1] OF EPEC_PAR.CSVData;

 

 

Definitions:

 

parameterCsvData: EPEC_PAR.CSVData; // selected parameter config

indexData: ARRAY[0..255] OF DWORD; (*Values for whole safety parameter index*)

readIndexData: EPEC_PAR.SafetyParReadIndexData;

state: EPEC_PAR.SafetyParametersState;

 

 

Init:

 

parameterCsvData := G_NETWORK1_Parameters_CSVData[10]; // Selected parameter csv row

readIndexData(i_Enable := FALSE);

 

 

Code:

 

readIndexData(

i_Enable := TRUE,

i_pDevice := ADR(G_CANopen_CAN1.Device), // From code template

i_pCSVData := ADR(G_NETWORK1_Parameters_CSVData), // From code template

i_CSVParCount := G_NUMBER_OF_PARAMETERS_NETWORK1, // From code template

i_NodeID := parameterCsvData.Node,

i_Index := parameterCsvData.Index,

i_Timeout := T#1S,

i_pIndexData := ADR(indexData),

o_State => state,

);

 

IF state < EPEC_PAR.SafetyParametersState.Idle THEN

; // Application error handling

ELSIF state = EPEC_PAR.SafetyParametersState.Idle THEN

; // Values successfully read to indexData array

END_IF

 

See also

 

 

 

Source file topic100515.htm

Last updated 19-Dec-2024