Vous êtes sur la page 1sur 3

S7-1200 Programmable controller

Example: Modbus RTU master program

Example: Modbus RTU master program

Modbus_Comm_Load is initialized during start-up by using the first scan flag. Execution of
Modbus_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 Modbus_Master instruction is used in the program cycle OB to communicate with a single
slave. Additional Modbus_Master instructions can be used in the program cycle OB to
communicate with other slaves, or one Modbus_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.

Network 3: Move the first 3 words of the holding register data that has been read to some other
location, and set a DONE history bit. This network also sets an ERROR history bit and saves
the STATUS word to another location in the event of an error.

This document constitutes a free excerpt compiled by the user himself/herself from the documentation provided by Siemens for this product. Siemens disclaims
all liability for the completeness of this document. It shall only be used for the user's own internal purposes. It shall not be passed on to third parties. The complete
documentation can be found at:
/dokumentation/default.aspx?DocVersionId=93176622091&Language=en-US&TopicId=81280701451 2/1/2018
S7-1200 Programmable controller
Example: Modbus RTU master program

Network 4: Write 64 bits of data from MW600-MW607 to output bit locations 00017 to 00081
on slave #2.

Network 5: Set a DONE history bit when the write is complete. If an error occurs, the program
sets an ERROR history bit and saves the STATUS code.

This document constitutes a free excerpt compiled by the user himself/herself from the documentation provided by Siemens for this product. Siemens disclaims
all liability for the completeness of this document. It shall only be used for the user's own internal purposes. It shall not be passed on to third parties. The complete
documentation can be found at:
/dokumentation/default.aspx?DocVersionId=93176622091&Language=en-US&TopicId=81280701451 2/1/2018
S7-1200 Programmable controller
Example: Modbus RTU master program

This document constitutes a free excerpt compiled by the user himself/herself from the documentation provided by Siemens for this product. Siemens disclaims
all liability for the completeness of this document. It shall only be used for the user's own internal purposes. It shall not be passed on to third parties. The complete
documentation can be found at:
/dokumentation/default.aspx?DocVersionId=93176622091&Language=en-US&TopicId=81280701451 2/1/2018

Vous aimerez peut-être aussi