Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY

 

ParametersSave (FB)

Description

Purpose of the function block is to handle application parameter save sequence using CANopenSDOClient (FB).

 

For saving display's own parameters, use CANopenODSave library.

See also Saving/Restoring Parameters.

 

Steps performed depends on i_UseSafetySequence & i_CheckSaveStatus flags.

 

i_UseSafetySequence shall be set to TRUE when saving safety parameters (safety control unit is authenticated).

i_CheckSaveStatus can be used to read status from OD index 21FAh but it requires support from control unit.

Save status is always checked when using safety sequence.

 

By setting both i_UseSafetySequence and i_CheckSaveStatus to FALSE, the POU can be used for saving parameters in e.g. 3000 or 5000 series control units.

 

Save sequence is started when i_Enable is set to TRUE.

  1. o_State is set to Processing
  2. Following steps are executed only when i_UseSafetySequence is TRUE:
    1. Write control unit’s OD index 13FEh sub 0 (configuration valid flag) to FFh so control unit will start safety parameter CRC validation
    2. Wait 50ms
    3. Read control unit’s configuration valid flag value
      1. If value is A5h, then CRCs are valid and sequence moves to next step
      2. If value is 0, then CRCs are invalid and save sequence is aborted. o_State is set to CRCError.
      3. If value is FFh, then sequence moves back to wait step and reads configuration valid flag again after delay
  3. Send save command to control unit’s OD index 1010h. Save method depends on i_SubIndex value (1=save all, 2=save communication, 3=save app parameters).
  4. Following steps are executed when i_UseSafetySequence OR i_CheckSaveStatus is TRUE. Otherwise sequence has finished and o_State is set to SaveOK.
    1. Wait 50ms
    2. Read control unit’s OD index 21FAh sub 0 (save status).
      1. If status is OK (1), then sequence is finished and o_State is set to SaveOK.
      2. If status is not OK (0), then sequence is finished and save was unsuccessful. o_State is set to SaveStatusError.
      3. If status is in-progress (FFh), then sequence moves back to wait step before reading save status again.

 

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

Limitations

Safety control unit requires reboot after saving safety parameters.

See also How to adjust safety parameters.

 

Non-safety parameters in a safety control unit can be saved while unit is operational (authentication is not done). In this case i_UseSafetySequence is set to FALSE.

 

Inputs

Input variable name

Data type

Range

Description

i_Enable

BOOL

 

Save 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_SubIndex

BYTE

 

Save method: 1=save all, 2=save communication, 3=save app parameters

i_Timeout

TIME

 

SDO protocol transfer timeout

i_UseSafetySequence

BOOL

 

When TRUE, save is done according to safety control unit sequence

i_CheckSaveStatus

BOOL

 

When TRUE, checks save result after command, always done with safety sequence

Outputs

Output variable name

Data type

Range

Description

o_State

SaveState

see enumeration

"Idle" on initialization,

“Processing” while in progress,

"SaveOK" when executed successfully,

see enumeration for error codes

o_AbortCode

DWORD

 

CANopen SDO abort code

Errors

SaveState

 

Example code

Following example saves application parameters to single unit (node 1) using safety parameter sequence.

 

Code template definitions:

 

 

/// CAN device

Device: EPEC_CANopen.Device;

 

Definitions:

 

saveParameters: EPEC_PAR.ParametersSave;

state : EPEC_PAR.SaveState;

 

Init:

 

saveParameters(i_Enable := FALSE);

 

 

Code:

 

// Application needs to determine if safety sequence is required

// (unit type = safety control unit AND safety parameters authenticated)

saveParameters(

i_Enable := TRUE,

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

i_NodeID := 1,

i_SubIndex := 3, // Save application parameters command

i_Timeout := T#1S,

i_UseSafetySequence := TRUE,

i_CheckSaveStatus := FALSE,

o_State => state

);

 

IF state < EPEC_PAR.SaveState.Idle THEN

; // Application error handling, if CRCError is given then safety parameter CRCs are invalid

ELSIF state = EPEC_PAR.SaveState.SaveOK THEN

; // save successfull

END_IF

 

 

See also

 

 

 

 

Source file topic100520.htm

Last updated 19-Dec-2024