ModbusRequest (FB)¶
FUNCTION_BLOCK ModbusRequest
In addition to the predefined Modbus commands defined in the tab Modbus Slave Channel, this function block allows to execute dynamically additional commands in the application. For this programmatically created commands CODESYS does not provide an I/O mapping but input/output data ranges of type ARRAY OF BYTE or ARRAY OF WORD.
- InOut:
Scope
Name
Type
Initial
Comment
Inout
slaveInput
xExecuteBOOL- Rising edge: Action start
Falling edge: Resets outputs If a falling edge occurs before the function block has completed its action, the outputs operate in the usual manner and are only reset if either the action is completed or aborted (xAbort), or in the event of an error. In this case, the corresponding output values (xDone, xError, iError) are present at the outputs for exactly one cycle.
xAbortBOOLIf this input is TRUE, the action is stopped immediately and all outputs are reset to their initial values.
usiUnitIDUSINT16#FF
- This field is used for routing purpose when addressing a MODBUS serial line sub-network.
On TCP/IP, the MODBUS server is addressed using its IP address, the MODBUS Unit Identifier is useless (value 0xFF has to be used). On serial line, Modbus devcies are adressed with Uint-IDs from 1 to 247, 0 is used as broadcast address.
ModbusCommandThe Modbus Command to be executed. Supports FCs for bit and word access
pSendDataPOINTER TO BYTE
- Pointer to a buffer holding the data to be send to the Slave
For Register access the buffer is of type ARRAY[0..ModbusCommand.uiWriteLen - 1] OF WORD. For Bit access the buffer is of type ARRAY[0..ModbusCommand.uiWriteLen / 8] OF BYTE
pRecvDataPOINTER TO BYTE
- Pointer to a buffer for writing the data received from a Slave
For Register access the buffer is of type ARRAY[0..ModbusCommand.uiReadLen - 1] OF WORD. For Bit access the buffer is of type ARRAY[0..ModbusCommand.uiReadLen / 8] OF BYTE
Output
xBusyBOOLIs TRUE as long as a request is in progress
xDoneBOOLIs TRUE if a request finished successfully
xErrorBOOLIs TRUE if a request finished unsuccessfully
xAbortedBOOLIs TRUE after a request in progress has been aborted by “xAbort”
ModbusErrorMB_ErrorCodes.UNDEFINED
Specifies the current error as defined in the “MB_ErrorCodes” enumeration