Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
959 views

S7-1200 Programmable Controller - Example - Modbus RTU Master Program

This document provides an example program for an S7-1200 programmable controller to act as a Modbus RTU master. The program initializes communications during the first scan and uses Modbus_Master instructions to read and write data from a slave device. It reads 100 words of holding register data from slave 2 and writes 64 bits of data to output bits on slave 2. Status and error bits are set upon completion or errors.

Uploaded by

Chhoan Nhun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
959 views

S7-1200 Programmable Controller - Example - Modbus RTU Master Program

This document provides an example program for an S7-1200 programmable controller to act as a Modbus RTU master. The program initializes communications during the first scan and uses Modbus_Master instructions to read and write data from a slave device. It reads 100 words of holding register data from slave 2 and writes 64 bits of data to output bits on slave 2. Status and error bits are set upon completion or errors.

Uploaded by

Chhoan Nhun
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

You might also like