MSG_MODBUS (Modbus message)
The MSG_MODBUS instruction sends a Modbus message over a serial port.
Operation details:
- A maximum of four message requests per channel can be processed in one scan. For ladder diagram programs, message requests are executed at the end of a ladder scan.
- If a trigger is set to continuous, error codes are also continuously cleared. To view error codes, add a rung before the MSG_MODBUS instruction.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the L20E, L50E, and L70E controllers.
MSG_MODBUS

Parameter | Parameter Type | Data Type | Description |
---|---|---|---|
IN | Input | BOOL | Rung input state.
|
Cancel | Input | BOOL |
Cancel input is dominant. |
LocalCfg | Input | MODBUSLOCPARA | Define structure input (local device). Define the input structure for the local device using the MODBUSLOCPARA data type. |
TargetCfg | Input | MODBUSTARPARA | Define structure input (target device). Define the input structure for the target device using the MODBUSTARPARA data type. |
LocalAddr | Input | MODBUSLOCADDR | MODBUSLOCADDR is a 125 Word array that is used by Read commands to store the data (1-125 words) returned by the Modbus slave and by Write commands to buffer the data (1-125 words) to be sent to the Modbus slave. |
Q | Output | BOOL | Outputs of this instruction are updated asynchronously from the program scan. Output Q cannot be used to re-trigger the instruction because IN is edge triggered.
|
Error | Output | BOOL | Indicates an error occurred.
|
ErrorID | Output | UINT | A unique numeric that identifies the error. The errors for this instruction are defined in MSG_MODBUS error codes. |
MSG_MODBUS error codes
Error Code | Description |
---|---|
3 | The value of the TriggerType has been changed from 2 to 255. |
20 | The local communication driver is incompatible with the MSG instruction. |
21 | A local channel configuration parameter error exists. |
22 | The Target or Local Bridge address is higher than the maximum node address. |
33 | A bad MSG file parameter exists. |
54 | A lost modem. |
55 | The message timed out in the local processor. A link layer timeout. |
217 | The user cancelled the message. |
129 | An illegal function. |
130 | An illegal data address. |
131 | An illegal data value. |
132 | A slave device failure. |
133 | Acknowledge. |
134 | The slave device is busy. |
135 | Negative acknowledge. |
136 | A memory parity error. |
137 | A non-standard reply. |
255 | The channel has been shut down. |
MSG_MODBUS examples
MSG_MODBUS function block diagram example

MSG_MODBUS ladder diagram example

MSG_MODBUS structured text example

Provide Feedback