Académique Documents
Professionnel Documents
Culture Documents
> Software for SIMATIC Controller > STEP 7 programming software > STEP 7 - Micro / WIN
STEP 7 Micro/WIN -- Setting up development environments -- Installing and upgrading software
Why is the "WinHlp32.exe" file for the Field PGs not installed automatically when you install
STEP 7 Micro/WIN V4.0 in Windows 7?
Which SIMATIC software can you install in 64-bit operating systems?
How can you carry out an upgrade on an operating system that no longer supports the existing
STEP 7 Micro/WIN version?
How do you implement MODBUS communication with S7-200?
Where in STEP 7 Micro/WIN can I find the operations libraries for the Modbus RTU protocol
and USS protocol?
How to uninstall STEP 7-Micro/WIN V4.0 after aborted installation?
S7-200 CPUs -- Configuring and programming communication -- Communication with USS, Modbus
or Freeport
How do you implement MODBUS communication with S7-200?
Instructions:
Taking the following example you can setup a simple MODBUS master-slave communication between
two S7-200 CPUs.
The example concerns the MODBUS function code 6 (Write to slave-holding register) and can be
considered as a basis for step-by-step changing of the parameters for the other function codes
supported: 1, 2, 3, 4, 5, 15 and 16.
Requirement:
To operate the MODBUS protocol you must first procure and install first the STEP 7 Micro/WIN
command library, then STEP 7 Micro/WIN (Entry ID 17470979).
The MODBUS-Master protocol is supported only from STEP 7 Micro/WIN V4.0 Service Pack 5
onwards.
1. Hardware setup
2. Parameter matching
3. Memory addressing for the libraries
4. Holding register value transfer
1. Hardware setup
The example is set up for a MODBUS communication between the Ports 0 of two S7-200 CPUs
(preferably each with 2 communication interfaces). On the master side it would also be possible to
select Port 1 with the corresponding library block selection "MBUS_CTRL_P1" and "MBUS_MSG_P1".
Port 1 is connected in each case with a PC or PG with the Micro/WIN software. Communication
between the CPUs via Port 0 is made via a PROFIBUS cable (serial connection of Pins 3, 3, 7 and 8 > see Fig. 01). In addition, you must make sure that the encoder ground (M) is connected.
Fig. 01
2. Parameter matching
For MODBUS communication, on the master side you need library blocks "MBUS_CTRL" and
"MBUS_MSG", and "MBUS_INIT" and "MBUS_SLAVE" on the slave side.
In Micro/WIN you create a new project for the master and the slave with the networks and parameters
shown in Fig. 02.
Here you must make sure that the "Baud" and "Parity" parameters are identical and that the "Slave"
address of the "MBUS_MSG" block matches the "Addr" parameter of the "MBUS_INIT" block (see Fig.
02).
The baud rate setting for the Port 0 interface in the "System data block" view in Micro/WIN is
irrelevant for the MODBUS protocol ("Mode" = "1").
Fig. 02
The following tables describe the meanings and selection options of the library block parameters.
MASTER
MBUS_CTRL
Parameter Meaning
Selection options
EN
Release
Mode
Protocol specification
0=PPI, 1=MODBUS
Baud
Parity
Parity
Timeout
Done
'Finished' message
Error
Error code
1)
Table 01
1) See STEP 7 Micro/WIN Help: "Error codes for the execution of the MODBUS master operation
MBUS_MSG"
MBUS_MSG
Parameter Meaning
Selection options
EN
Release
First
Activation
Slave
Slave address
RW
"Read" or "Write"
0=read, 1=write
Addr
AIW62
40001 .. 49999 = holding register 2
Count
DataPtr
Done
'Finished' message
Error
Error code
1)
Table 02
1) See STEP 7 Micro/WIN Help: "Error codes for the execution of the MODBUS master operation
MBUS_MSG"
SLAVE
MBUS_INIT
Parameter Meaning
Selection options
EN
Release
Mode
Protocol specification
Addr
Slave address
Baud
Parity
Parity
Delay
Signal stretching in ms
MaxIQ
2)
MaxAI
2)
MaxHold
2)
HoldStart
Done
'Finished' message
Error
Error code
0=PPI, 1=MODBUS
3)
Table 03
2) The maximum addresses that can be really used depends on the CPU type used and its maximum
values.
3) See STEP 7 Micro/WIN Help: "Error codes for the execution of the MODBUS slave protocol"
MBUS_SLAVE
Parameter
Meaning
EN
Release
Done
'Finished' message
Error
Error code
Table 04
Selection options
3)
3) See STEP 7 Micro/WIN Help: "Error codes for the execution of the MODBUS slave protocol"
Fig. 03
4. Holding register value transfer
After loading the projects into the appropriate CPU you can write to the selected master variable
memory area by activating the table status and monitor on the slave side.
When the master input I0.0 is activated, the content of variable word VW2 is sent to the slave CPU
and written here to the variable word VW2.
This holding register value transfer is shown in Fig. 04.
The pointer "DataPtr" represents the start of the variable memory to be read.
The "Count" parameter specifies the number of words to be written to the address "Addr" = "4xxxx"
(holding register).
The variable memory area selected will be written to the holding register start address "Addr" =
"40002" ("RW" = "1").
The holding register works word for word as a placeholder to the slave variable memory area.
The "HoldStart" pointer specifies the initial address of the variable memory equivalent to the holding
register start address 40001.
You can calculate the slave variable memory target pointer as follows:
2 * (Addr - 40001) + HoldStart = 2 * (40002 - 40001) + &VB0 = &VB2
In addition, you must make sure that the maximum number of holding register word entries "MaxHold"
also covers this area:
MaxHold >= Addr - 40001 + Count = 40002 - 40001 + 1 = 2
Fig. 04
More information on the STEP 7 Micro/WIN MOBDUS library is available in the S7-200 system
manual ( Entry ID 1109582) and in the STEP 7 Micro/WIN Help.
Fig. 01
Fig. 02
Fig. 03
Fig. 04