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
MSG_MODBUS
MSG_MODBUS parameters
Parameter
Parameter Type
Data Type
Description
IN
Input
BOOL
Rung input state.
  • TRUE: Rising edge detected, start the instruction block with the precondition that the last operation has been completed.
  • FALSE: Rising edge not detected, not started.
Cancel
Input
BOOL
  • TRUE: Cancel the execution of the instruction block.
  • FALSE: When IN is TRUE.
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.
  • TRUE: MSG instruction finished successfully.
  • FALSE: MSG instruction is not finished.
Error
Output
BOOL
Indicates an error occurred.
  • TRUE: An error is detected.
  • FALSE: No error.
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

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 function block diagram example
MSG_MODBUS ladder diagram example
MSG_MODBUS ladder diagram example
MSG_MODBUS structured text example
MSG_MODBUS structured text example
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal