Supported platforms: CODESYS 3.5 SAFETY

 

How to adjust safety parameters from a display

This section describes how to adjust safety related application parameters from safety control unit using Parameters V4 library.

 

The following Epec libraries are required:

  • CANVXD API version 4.0.0.1

  • CANopen library version 4.0.0.22 or above

  • Parameters library version 4.0.1.1 or above

  • Safe Data Validation library

 

 

6000 series device description 1.3.1.X and code template which supports the above library versions is required. These are included in SDK3.0.

 

This example uses the following POUs:

Parameters library

 

 

The safety control unit requires reboot after parameter saving if safety parameter adjustment has been authenticated.

 

The following is a recommended sequence when adjusting safety parameter values in a safety control unit:

 

  1. Read parameter .csv configurations using Parameters_ReadCSV.

  2. Validate .csv compatibility with control units using ParameterCsvUniqueIDHandler (FB).

  3. The application's parameter adjustment functionality needs to determine if the selected parameter is a safety parameter:

  4. The application can determine which safety control unit OD indexes are safety parameters using SafetyParReadIndexList (FB).

  5. Authenticate safety parameter adjustment using SafetyParAuthentication (FB).

  6. Read selected parameter's OD index data using SafetyParReadIndexData (FB).

  7. Initialize the CRC handler using SafetyParCrcHandler (FB) Init method.

  8. Adjust parameter value using Parameters_Edit (FB).

  9. Update the adjusted parameter value to SafetyParCrcHandler (FB) using UpdateValue method.

  10. Update the safety parameter CRC value to the safety control unit using SafetyParCrcHandler (FB).

  11. Steps 6 - 10 can be repeated to adjust different safety parameters.

  12. Save parameters using ParametersSave (FB) after all parameters have been adjusted. The ParameterSave (FB) commands the safety control unit to start safety parameter CRC validation.

  13. Reboot

 

Saving safety parameters only once at the end of adjustment is recommended (as in the example above).

 

It is possible to repeat the adjustment and save the sequence before reboot (steps 6 - 12).

The CRC validation always has to be triggered by writing the value FFh to OD index 13FE:00h (implemented in ParametersSave (FB)) before safety parameter saving is enabled. This is done to prevent saving safety parameters with invalid CRCs.

 

Example code

This example assumes that sequence steps 1 - 5 have already been done:

Example codes for steps 1 - 5 and step 12 can be seen in corresponding POU chapters.

 

The following examples describe sequence steps 6 - 10 (parameter adjustment sequence):

 

These steps are not necessary when adjusting non-safety parameters in a safety control unit.

Non-safety parameters can be adjusted simply by using the Parameters_Edit function block.

 

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:

 

// Array where current values are stored for UI

G_ParameterValues: ARRAY[1..G_NUMBER_OF_PARAMETERS_NETWORK1] OF DINT;

 

G_ParameterAdjustmentDone: BOOL; // From UI

 

Definitions:

 

VAR

parameterCsvData: EPEC_PAR.CSVData; // selected parameter config

pParameterValue: POINTER TO DINT; (*Adjusted parameter value*)

 

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

safetyIndexList: ARRAY [1..255] OF WORD; // Indexes read using SafetyParReadIndexList

 

readIndexData: EPEC_PAR.SafetyParReadIndexData;

crcHandler: EPEC_PAR.SafetyParCrcHandler;

parameterEdit: EPEC_PAR.Parameters_Edit;

 

sequenceCase: BYTE := SEQ_READ_SAFEINDEX_DATA;

END_VAR

VAR CONSTANT

SEQ_READ_SAFEINDEX_DATA :BYTE := 1;

SEQ_INIT_CRC :BYTE := 2;

SEQ_ADJUST :BYTE := 3;

SEQ_WRITE_CRC :BYTE := 4;

SEQ_DONE :BYTE := 5;

END_VAR

 

Init:

 

pParameterValue := ADR(G_ParameterValues[10]); // Current parameter value

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

 

Code:

 

CASE sequenceCase OF

 

SEQ_READ_SAFEINDEX_DATA:

 

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)

);

 

IF readIndexData.o_State < EPEC_PAR.SafetyParametersState.Idle THEN

; // Application specific error handling

ELSIF readIndexData.o_State = EPEC_PAR.SafetyParametersState.Idle THEN

readIndexData(i_Enable:=FALSE);

sequenceCase := SEQ_INIT_CRC;

END_IF

 

SEQ_INIT_CRC:

// Following assumes that safety parameter index list is read before adjustment process

crcHandler.Init(

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_pCurrentValues := ADR(indexData),

i_pIndexList := ADR(safetyIndexList)

);

 

IF crcHandler.o_State < EPEC_PAR.SafetyParametersState.Idle THEN

; // Application specific error handling

ELSIF crcHandler.o_State = EPEC_PAR.SafetyParametersState.Idle THEN

// Init successful

crcHandler(i_Enable := FALSE);

sequenceCase := SEQ_ADJUST;

END_IF

 

SEQ_ADJUST:

 

parameterEdit(

i_Enable := TRUE,

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

i_pValue := pParameterValue, // Pointer to parameter value which is adjusted from UI by user

i_NodeID := parameterCsvData.Node,

i_Index := parameterCsvData.Index,

i_SubIndex := parameterCsvData.SubIndex,

i_StartBit := parameterCsvData.StartBit,

i_DataType := parameterCsvData.ParameterType,

i_Min := parameterCsvData.LowLimit,

i_Max := parameterCsvData.HighLimit,

i_Update := TRUE,

i_Timeout := T#1S,

);

 

IF parameterEdit.o_Error <> EPEC_PAR.Parameters_EditError.NoError THEN

; // Application specific error handling

ELSIF parameterEdit.o_State = EPEC_PAR.Parameters_EditState.Idle THEN

 

// During this step parameter value can be adjusted in UI

 

crcHandler.UpdateValue(

i_SubIndex := parameterCsvData.SubIndex,

i_pNewValue := pParameterValue

);

 

IF G_ParameterAdjustmentDone THEN

G_ParameterAdjustmentDone := FALSE;

parameterEdit(i_Enable := FALSE);

sequenceCase := SEQ_WRITE_CRC;

END_IF

END_IF

 

SEQ_WRITE_CRC:

crcHandler(

i_Enable := TRUE

);

 

IF crcHandler.o_State < EPEC_PAR.SafetyParametersState.Idle THEN

; // Application specific error handling

ELSIF crcHandler.o_State = EPEC_PAR.SafetyParametersState.Idle THEN

sequenceCase := SEQ_DONE;

END_IF

 

SEQ_DONE:

;

 

 

See also

 

 

Source file topic100441.htm

Last updated 19-Dec-2024