

The Modbus communication in the program is conducted between the 0 communication ports of two S7-200 CPUs (it is best if each CPU has two communication ports). On the master side, communication can also be established using the corresponding library files “MBUS_CTRL_P1” and “MBUS_MSG_P1” through communication port 1. Communication port 1 connects with PG or PC using Micro/WIN, and the communication ports 0 of the two CPUs are connected via Profibus cable (the cable pin connections are 3, 3, 8, 8 -> see Figure 01). Additionally, it is necessary to logically connect M.
For MODBUS communication, the master side requires the program libraries “MBUS_CTRL” and “MBUS_MSG”, while the slave side requires the program libraries “MBUS_INIT” and “MBUS_SLAVE”.
In Micro/WIN, you need to create a new project for both the master and slave sides, with program and parameter settings as shown in Figure 02. It is essential to ensure that the “Baud” and “Parity” parameters are consistent between the master and slave, and that the “Slave” address in the program block “MBUS_MSG” matches the “Addr” set in the program block “MBUS_INIT” (see Figure 02).
The baud rate of communication port 0 set in the “System Block” of Micro/WIN is unrelated to the MODBUS protocol (“Mode” = “1”).
MasterMBUS_CTRL
MBUS_MSG
SlaveMBUS_INIT
MBUS_SLAVE
After completing the project, the library’s storage address must be defined in Micro/WIN. Once the storage area is defined, it must not be used by other programs under any circumstances (Master side: “DataPtr” + “Count” Slave side: “HoldStart” + “MaxHold”).
After downloading the program to the corresponding CPU, you can assign values to the V storage area on the master side in the status table, and then monitor the changes in values on the slave side.
When the master side’s I0.0 is enabled, the contents of VW2 are sent to the slave and written into the slave’s VW2.
The pointer “DataPtr” represents the starting address of the V area being read. The parameter “Count” specifies the number of words to be written to the address “Addr” = “4xxxx” (holding register). The corresponding variables in the V storage area will be written to the holding register starting address “Addr” = “40002” (“RW” = “1”). The holding register is transmitted in words, and it corresponds to the V area address of the slave.
The pointer “HoldStart” specifies the initial address of the V storage area corresponding to the holding register starting address 40001.
You can calculate the target pointer of the slave’s V area using the following formula: 2 * (Addr – 40001) + HoldStart = 2 * (40002 – 40001) + &VB0 = &VB2. Additionally, ensure that the data area to be written by the master side is included within the area defined by “MaxHold”: MaxHold >= Addr – 40001 + Count = 40002 – 40001 + 1 = 2.
Disclaimer: This article is reproduced from the internet, and the copyright belongs to the original author. If there are any copyright issues regarding the work, please contact us promptly for deletion. Thank you!
2021 Electrical Beginner Exam Question Bank Complete Edition (with Answers)
3 Essential Tools for Electricians, Open with WeChat in One Click!
[Collection] The “Path” of a Decade-Old Electrician, Secrets to Earning Over 10,000 a Month!
Which of the Five Major Electrical Drawing Software (CAD, Eplan, CADe_simu…) Do You Choose?
Latest Electrical CAD Drawing Software, with Detailed Installation Tutorial!
Latest Electrical Drawing Software EPLAN, with Detailed Installation Tutorial!
Common Issues for Beginners Using S7-200 SMART Programming Software (with Download Links)
Comprehensive Electrical Calculation EXCEL Sheets, Automatically Generated! No Need to Ask for Electrical Calculations!
Bluetooth Headphones, Electrician/PLC Introductory Books Given Away? Come and Claim Your Electrical Gifts!
Basic Skills in PLC Programming: Ladder Diagrams and Control Circuits (with 1164 Practical Cases for Mitsubishi PLC)
Still Can’t Understand Electrical Diagrams? Grab the Basics of Electrical Drawing and Simulation Software, Quickly Get Started with Theory and Practice!
12 Free Electrical Video Courses, 10GB Software/E-book Resources, 30 Days of Free Live Electrical Courses!
