Modbus Rtu Slave Example Program - Siemens S7-1200 System Manual

Hide thumbs Also See for S7-1200:
Table of Contents

Advertisement

Communication processor and Modbus TCP
12.5 Modbus communication
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 RS485 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.
764
S7-1200 Programmable controller
System Manual, 03/2014, A5E02486680-AG

Advertisement

Table of Contents
loading

Table of Contents