Libraries
9.3 Modbus library instructions
S7-200 SMART
436 System Manual, 09/2015, A5E03822230-AC
Modbus RTU master
9.3.2.1
Using the Modbus master instructions
Procedure
To use the Modbus RTU master instructions in your S7-200 SMART program, follow these
steps:
1. Insert the MBUS_CTRL instruction in your program and execute the MBUS_CTRL on
every scan. You can use the MBUS_CTRL instruction either to initiate or to change the
Modbus communications parameters. When you insert the MBUS_CTRL instruction,
several protected subroutines and interrupt routines are automatically added to your
program.
2. Click the Memory button
from the Libraries area of the File menu ribbon strip to
assign a starting address for the V-Memory that the Modbus library requires.
Alternatively, you can right-click the Program Block node in the project tree and select
"Library Memory" from the context menu.
3. Place one or more MBUS_MSG instructions in your program. You can add as many
MBUS_MSG instructions to your program as you require, but only one of these
instructions can be active at a time.
4. Connect a communications cable between the S7-200 SMART CPU port you assigned
with the MBUS_CTRL port parameter and the Modbus slave devices.
Avoiding unwanted current flow
Interconnecting equipment with different reference potentials can cause unwanted
currents to flow through the interconnecting cable. These unwanted currents can cause
communications errors or damage equipment.
Ensure that all equipment that is connected with a communications cable either shares
a common circuit reference or is isolated to prevent unwanted current flows.
The Modbus master instructions utilize the Modbus functions shown below to read or write a
specific Modbus address. The Modbus slave device must support the Modbus function(s)
required to read or write a particular Modbus address.