Supported platforms: CODESYS 3.5, CODESYS 3.5 SAFETY

 

Parameters_Edit (FB)

Description

The function block reads and adjusts the given parameter value and writes it to control unit.

The function block can be used with the parameter CSV file (see also Parameters_ReadCSV).

 

When the function block is called and i_Enable is set to TRUE, the parameter value is read from the control unit.

This is also done, when i_NodeID, i_Index, i_SubIndex or i_StartBit changes.

Also rising edge of the i_Update input forces reading of current value from the control unit.

 

When a parameter value is changed, it will be written to the control unit.

If the changed parameter value exceeds i_Min or i_Max, the value is limited to minimum or maximum value.

 

POU can also adjust unit’s own parameters. Own node-id is read from used CANopen device.

When i_NodeID = unit’s node-id then unit's own OD parameters are adjusted.

 

Setting i_Enable to FALSE disables all parameter read and write functionality.

 

The file location in the unit for 6505 and 6510 is /opt/Project/PlcLogic.

In the units 6107, 6200, 6807 and 6112 the location is /opt/user/userapp.

Limitations

Read and write permissions for parameters according to user levels are handled by application.

 

Function block does not determine if adjusted parameter is safety or non-safety parameter.

For safety parameter adjustment sequence, see How to adjust safety parameters

 

From library version 4.1.2.0, if start bit is defined to a parameter in CSV file, the Parameters_Edit FB handles the parameter as BOOL. The OD data is however, is as defined in CSV file (i.e. BYTE, WORD or DWORD).

 

 

Inputs

Input variable name

Data type

Range

Description

i_Enable

BOOL

 

Parameter read/write is disabled if enable is set to FALSE

i_pDevice

POINTER TO EPEC_CANopen.Device

0

Used CANopen device

(e.g. ADR(G_CANopen_CAN1.Device))

i_pValue

POINTER TO CAA.PVOID

0

Pointer to parameter value

i_NodeID

BYTE

1..127

Node ID of the control unit

i_Index

WORD

CiA 301

SDO object

i_SubIndex

BYTE

 

SDO object sub index

i_StartBit

BYTE

 

Bit number

i_DataType

CSVType

 

Parameter data type enumeration

i_Min

DINT

Depends on data type

Minimum limit for parameter value

i_Max

DINT

Depends on data type

Maximum limit for parameter value

i_Update

BOOL

 

Rising edge of i_Update forces reading of current value

i_Timeout

TIME

 

Time out for the SDO request-response pair. Transfer is aborted if the response is not received during the time out time.  

i_pValueReal

POINTER TO CAA.PVOID

(≠ 0 if REAL datatype)

Pointer to parameter value of REAL datatype.

i_MinReal

REAL

 

Minimum limit for parameter value of REAL datatype.  

i_MaxReal

REAL

 

Maximum limit for parameter value of REAL datatype.  

Outputs

Output variable name

Data type

Range

Description

o_ParameterValue

DINT

 

Actual parameter value at target unit. Last SDO read or written value.

o_State

Parameters_EditState

see enumeration

Current state

o_Error

Parameters_EditError

see enumeration

 

Error code

o_AbortCode

DWORD

 

Abort code

o_RealTypeParameter

BOOL

 

TRUE = Parameter type is REAL.

Errors

Parameters_EditError

 

Example code

Following example adjusts parameter value 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:

 

// Struct contains own variables for integer and real parameters. There is no need for struct if only integer //parameters are used.

 

TYPE ParameterValues :

STRUCT

ParameterValueDint: DINT;

ParameterValueReal: REAL;

END_STRUCT

END_TYPE

 

 

Definitions:

 

// Array where current values are stored for UI

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

 

// DINT array can be used if only integer parameters are used

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

 

Definitions:

 

parameterEdit: EPEC_PAR.Parameters_Edit;

parameterCsvData: EPEC_PAR.CSVData;

pParameterValue: POINTER TO DINT;

pParameterValueReal: POINTER TO REAL;

 

Init:

 

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

pParameterValueReal := ADR(G_ParameterValues[10].ParameterValueReal); //Current real parameter value

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

 

Following code example assumes that parameter csv has been read using Parameters_ReadCSV

Parameter value adjustment is activated when current parameter value is changed.

Code:

 

parameterEdit(

i_Enable := TRUE,

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

i_pValue := pParameterValue,

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,

i_pValueReal := pParameterValueReal,

i_MinReal := parameterCsvData.LowLimitReal,

i_MaxReal := parameterCsvData.HighLimitReal

 

);

 

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

; // Application specific error handling

ELSIF parameterEdit.o_State = EPEC_PAR.Parameters_EditState.Idle THEN

; // Parameter adjustment not active

END_IF

 

See also

 

 

Source file topic100519.htm

Last updated 13-Jun-2024