SimpleReadCoilInput

SimpleReadCoilInput (FB)

FUNCTION_BLOCK SimpleReadCoilInput

Evaluation of the actual values for function codes 01 (Read Coils) and 02 (Read Discrete Inputs)

When evaluating the actual values, only the output 'arxValue' must be considered. This is an array with 64 elements of type BOOL (1 - 64 coils/inputs). The selection of the bits to be transmitted is determined primarily by the choice of the function code (eFunctionCode), the start address (wStartAddr) and the desired number of coils/inputs ('wNumberOfCoils') in the range 1 - 64. The actual values are available as follows: The first element 'arxValue[0]' contains the state of the coil with the number 'wStartAddress' The second element 'arxValue[1]' contains the state of the coil with the number 'wStartAddress' + 1 The third element 'arxValue[2]' contains the state of the coil with the number 'wStartAddress' + 2, etc. Unused elements of 'arxValue' are set to FALSE. Task: Read the actual value of coil 17 Settings: eFunctionCode: ReadFunctionCodesCoilInput.FC01_ReadCoils wStartAddr = 17 wNumberOfCoils = 1 'arxValue[0]': actual value of coil 17 'arxValue[1]': FALSE 'arxValue[2]': FALSE … 'arxValue[63]': FALSE \

CODESYS

InOut:

Scope
Name
Type
Initial
Comment

Input

xEn

BOOL

TRUE

Enable / disable of communication ( TRUE = enabled )

Input

byUnitId

BYTE

0

Address of the device

Input

xUpdateActual

BOOL

FALSE

Update of actual values ( on each rising edge )

Input

xResError

BOOL

FALSE

Reinitialization of the outputs 'eErrorCodeCom' and/or 'eErrorCodeDev' to the no-error state (on every rising edge)

Inout

ModbusClient

ModbusClientBase

Client of the device

Output

eFunctionCodeFb

ReadFunctionCodesCoilsInputs

Feedback - Modbus function code for the Modbus telegram

Output

wStartAddrFb

WORD

Feedback - start address of the coils/inputs to be read

Output

wNumberOfCoilsFb

WORD

Feedback - number of coils/inputs to be read (1 - 64)

Output

arxValue

ARRAY [0..63] OF BOOL

Array with the current coil/input states

Output

xAlarm

BOOL

Collective fault ( TRUE = fault )

Output

xAlarmCom

BOOL

Collective fault - communication ( TRUE = fault )

Output

eErrorCodeCom

ModbusErrorCode

Error code - communication ( 0 = no error )

Output

eErrorCodeDev

SIMPLE_READ_COIL_INPUT_ERROR_CODE

Error code - device (0 = no error)

Output

xBusy

BOOL

Communication indicator ( TRUE = communication )

Input Const

wNumberOfCoils

WORD

1

Number of coils/inputs to be read (1 - 64)

Input Const

eFunctionCode

ReadFunctionCodesCoilsInputs

ReadFunctionCodesCoilsInputs.FC01_ReadCoils

Modbus function code for the Modbus telegram

Input Const

wStartAddr

WORD

Start address of the coils/inputs to be read

Input Const

tTimeUpdateActual

TIME

TIME#3s0ms

Update interval for the processes affected by the input ‘xUpdateActual’

Last updated