Supported platforms: CODESYS 3.5 SAFETY
This section describes how to adjust safety related application parameters from safety control unit using Parameters V4 library.
The following Epec libraries are required:
|
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:
Read parameter .csv configurations using Parameters_ReadCSV.
This guide assumes that .csv is read in code template.
Validate .csv compatibility with control units using ParameterCsvUniqueIDHandler (FB).
This step is not mandatory for the control unit, but is recommended for devices or software using the .csv file, (e.g. CANmoon).
Application should check that handler's state is AllNodesOK.
If a Mismatch state is detected, functionality is up to the application. Individual node states can be checked using the GetNodeState method.
The application's parameter adjustment functionality needs to determine if the selected parameter is a safety parameter:
Is the selected node-ID a safety control unit?
Is the selected parameter OD index a safety parameter?
The application can determine which safety control unit OD indexes are safety parameters using SafetyParReadIndexList (FB).
the index list will remain constant in the safety control unit (unless software is changed or updated).
Authenticate safety parameter adjustment using SafetyParAuthentication (FB).
Adjusting the safety parameter value without authentication will be rejected with abort.
OD parameter saving is disabled after authentication. It is re-enabled after safety parameter CRCs are validated.
Read selected parameter's OD index data using SafetyParReadIndexData (FB).
Initialize the CRC handler using SafetyParCrcHandler (FB) Init method.
Adjust parameter value using Parameters_Edit (FB).
Update the adjusted parameter value to SafetyParCrcHandler (FB) using UpdateValue method.
Update the safety parameter CRC value to the safety control unit using SafetyParCrcHandler (FB).
Steps 6 - 10 can be repeated to adjust different safety parameters.
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.
the safety sequence shall be set to TRUE after adjusting safety parameters
OD parameter saving is left in the disabled state after parameters are saved to NVRAM
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. |
This example assumes that sequence steps 1 - 5 have already been done:
CSV file has been read
CSV file is validated
Selected parameter index is a safety parameter
Safety parameter index list has been read
Safety parameter adjustment is authenticated
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: ;
|
Source file topic100441.htm
Last updated 19-Dec-2024