13.9.4
Legacy Modbus RTU examples
13.9.4.1
Example: Legacy Modbus RTU master program
MB_COMM_LOAD is initialized during start-up by using the first scan flag. Execution of
MB_COMM_LOAD in this manner should only be done when the serial port configuration will
not change at runtime.
Network 1: Configure/initialize the RS485 module communications port only once during the
first scan.
One MB_MASTER instruction is used in the program cycle OB to communicate with a single
slave. Additional MB_MASTER instructions can be used in the program cycle OB to
communicate with other slaves, or one MB_MASTER FB could be re-used to communicate
with additional slaves.
Network 2: Read 100 words of holding register data from location 400001 on slave #2 to
memory location MW500-MW698.
S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
Communication processor and Modbus TCP
13.9 Legacy Modbus RTU communication (CM/CB 1241 only)
1285