MSG_MODBUS2 (MODBUS/TCP message)

The MSG_MODBUS2 instruction sends a MODBUS/TCP message over an Ethernet Channel.
Operation details:
  • A maximum of four message requests per channel can be processed in one scan. For adder diagram programs, message requests are executed at the end of a ladder scan.
  • When MSG_MODBUS2 is enabled, the receive buffers for Read operations are cleared on the rising edge of Enable.
  • Canceling the execution of the MSG_MODBUS2 instruction does not guarantee the message request going out is Canceled, but does guarantee the response is not processed.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the L20E, L50E, and L70E controllers.
MSG_MODBUS2
MSG_MODBUS2
MSG_MODBUS2 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, idle.
Cancel
Input
BOOL
  • TRUE: Cancel the execution of the instruction block. Canceling the execution of the MSG_MODBUS2 instruction does not guarantee the message request going out is Cancelled, but does guarantee the response is not processed.
  • FALSE: When IN is TRUE.
Cancel input is dominant.
LocalCfg
Input
MODBUS2LOCPARA
Defines structure input (local device).
Define the input structure for the local device using the MODBUS2LOCPARA data type.
TargetCfg
Input
MODBUS2TARPARA
Defines structure input (target device).
Define the input structure for the target device using the MODBUS2TARPARA data type.
LocalAddr
Input
MODBUSLOCADDR
MODBUSLOCADDR data type is a 125 Word array.
LocalAddr usage:
  • For Read commands, store the data (1-125 words) returned by the Modbus slave.
  • For Write commands, 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 detected.
  • TRUE: An error occurred.
  • FALSE: No error.
ErrorID
Output
UINT
A unique numeric that identifies the error. The errors for this instruction are defined in Modbus2 error codes.
StatusBits
Output
UINT
Used to verify status bits:
  • Bit 0: EN - Enable
  • Bit 1: EW - Enable Wait
  • Bit 2: ST - Start
  • Bit 3: ER - Error
  • Bit 4: DN - Done
Other bits are reserved.
SuberrorID
Output
UINT
SubError code value when Error is TRUE.
When an MSG is triggered, or re-triggered, a previously set SubErrorID is cleared.

MSG_MODBUS2 examples

MSG_MODBUS2 function block diagram example
MSG_MODBUS2 function block diagram example
MSG_MODBUS2 ladder diagram program example
MSG_MODBUS2 ladder diagram program example
MSG_MODBUS2 structured text program example
MSG_MODBUS2 structured text program example
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal