105BCommunication processor
12.5 Modbus communication
S7-1200 Programmable controller
System Manual, 11/2011, A5E02486680-05
617
12.5.3.5
Modbus RTU slave example program
MB_COMM_LOAD shown below is initialized each time "Tag_1" is enabled.
Execution of MB_COMM_LOAD in this manner should only be done when the serial port
configuration will change at runtime, as a result of HMI configuration.
Network 1 Initialize the RS-485 module parameters each time they are changed by an HMI
device.
MB_SLAVE shown below is placed in a cyclic OB that is executed every 10ms. While this
does not give the absolute fastest response by the slave, it does provide good performance
at 9600 baud for short messages (20 bytes or less in the request).
Network 2 Check for Modbus master requests during each scan. The Modbus holding
register is configured for 100 words starting at MW1000.