Using The Modbus Slave Instructions - Siemens SIMATIC S7-200 System Manual

Programmable controller
Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

S7-200 Programmable Controller System Manual

Using the Modbus Slave Instructions

To use the Modbus Slave instructions in your S7-200 program, follow these steps:
1.
Insert the MBUS_INIT instruction in your program and execute the MBUS_INIT instruction
for one scan only. You can use the MBUS_INIT instruction either to initiate or to change the
Modbus communications parameters.
When you insert the MBUS_INIT instruction, several hidden subroutines and interrupt
routines are automatically added to your program.
2.
Use the Library Memory command to assign a starting address for the V memory required
for Modbus Slave Protocol instructions.
3.
Place only one MBUS_SLAVE instruction in your program. This instruction is called every
scan to service any requests that have been received.
4.
Connect the communications cable between Port 0 on the S7-200 and the Modbus master
device.
Caution
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 accumulators (AC0, AC1, AC2, AC3) are utilized by the Modbus slave instructions and
appear in the Cross Reference listing. Prior to execution, the values in the accumulators of a
Modbus Slave instruction are saved and restored to the accumulators before the Modbus Slave
instruction is complete, ensuring that all user data in the accumulators is preserved while
executing a Modbus Slave instruction.
The Modbus Slave Protocol instructions support the Modbus RTU protocol. These instructions
utilize the Freeport utilities of the S7-200 to support the most common Modbus functions. The
following Modbus functions are supported:
Table 12-3
Modbus Slave Protocol Functions Supported
Function
Description
1
Read single/multiple coil (discrete output) status. Function 1 returns the on/off status of any
number of output points (Qs).
2
Read single/multiple contact (discrete input) status. Function 2 returns the on/off status of any
number of input points (Is).
3
Read single/multiple holding registers. Function 3 returns the contents of V memory. Holding
registers are word values under Modbus and allow you to read up to 120 words in one request.
4
Read single/multiple input registers. Function 4 returns Analog Input values.
5
Write single coil (discrete output). Function 5 sets a discrete output point to the specified value.
The point is not forced and the program can overwrite the value written by the Modbus request.
6
Write single holding register. Function 6 writes a single holding register value to the V memory of
the S7-200.
15
Write multiple coils (discrete outputs). Function 15 writes the multiple discrete output values to the
Q image register of the S7-200. The starting output point must begin on a byte boundary (for
example, Q0.0 or Q2.0) and the number of outputs written must be a multiple of eight. This is a
restriction for the Modbus Slave Protocol instructions. The points are not forced and the program
can overwrite the values written by the Modbus request.
16
Write multiple holding registers. Function 16 writes multiple holding registers to the V memory of
the S7-200. There can be up to 120 words written in one request.
352

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents