SIMATIC - IntelliSense With S7-1200 Modbus RTU
SIMATIC - IntelliSense With S7-1200 Modbus RTU
SIMATIC - IntelliSense With S7-1200 Modbus RTU
Application Note
Table of Contents
INTRODUCTION . . . . . . . . . . . . . . . . . . . . . . . 3
HARDWARE SETUP. . . . . . . . . . . . . . . . . . . . . 3
MODBUS RTU CONFIGURATION . . . . . . . . . . . 4
MODBUS DATA LAYOUT . . . . . . . . . . . . . . . . . 5
02/24/15
rev1.0 2
Application Note
Introduction
This application note is intended to be used in conjunction with sample code file App_Note_S7_1200_
CM_1200 and serves as an example for basic Modbus RTU communication. The main hardware used
for this example was a Siemens S7-1200 PLC, Bimba IntelliSense Starter Kit (ISK-SMA_), with a Bimba
IntelliSense Junction Block (ISH-R04). The Siemens sample code MODBUS_RTU_V11 SP2 Upd5 was
used as a programing template, and the Siemens manual s71200_system_manual_en-US_en-US.pdf was
used for reference.
Hardware Setup
For this example, a 2-wire RS-485 Modbus network was implemented using the IntelliSense Junction
Block. SIM DIP switches 5 and 6 were set high to tie the RX/TX terminals together. DIP switch 7 was also
set high to enable the internal 150 ohm terminating resistor. Power for the SIM unit was supplied using
pins 7 and 8 of the junction block.
02/24/15
rev1.0 3
Application Note
Modbus RTU Configuration
Modbus RTU is a serial Master-Slave protocol. This means the Master device (PLC in this case) controls
when each Slave device on the network acts upon the Masters commands. Only one Slave device can
transmit back to the Master at a time. There can be a maximum of 32 devices on a RS485 Modbus RTU
network.
The IntelliSense SIM unit is capable of utilizing a variety of 8 bit serial communication configurations.
A baud rate of 9,600 bps, no-parity, 8 bit, and 1 stop bit configuration was set in the SIM. The CM1241 module was set for half-duplex (2-wire) mode in the properties section of the module. All other
communication settings are set when the program runs. See Network 1 for Communications Initialize
block. You may adjust these settings for your application, but the settings must match on all devices on
the Modbus RTU network. Keep in mind the Modbus Master assumes the address value of 0.
CM-1241 Module
IntelliSense SIM
02/24/15
rev1.0 4
Application Note
Modbus Data Layout
The Modbus RTU protocol defines how the data registers of a Modbus device are laid out. The
IntelliSense SIM unit currently only utilizes Holding Registers.
0x = Coil = 00001-09999
1x = Discrete Input = 10001-19999
3x = Input Register = 30001-39999
4x = Holding Register = 40001-49999
The Holding Registers of the IntelliSense SIM units are defined using the following table:
Register Description
Size
40001
2 Bytes
40002
2 Bytes
40003
2 Bytes
40004
2 Bytes
40005
2 Bytes
40006
2 Bytes
40007
2 Bytes
40008
2 Bytes
40009
Rod Position
2 Bytes
40010
2 Bytes
40011
2 Bytes
40012
2 Bytes
40013
2 Bytes
40014
2 Bytes
40015
40016
Register Description
40024
Leakage Failure
Size
2 Bytes
Temperature Failure
2 Bytes
Extent Failure
2 Bytes
2 Bytes
2 Bytes
40028
2 Bytes
2 Bytes
40017
2 Bytes
40029
2 Bytes
40018
2 Bytes
40019
2 Bytes
40020
2 Bytes
40021
2 Bytes
40022
Sensor Status
2 Bytes
Bit 0 - 1 Streaming
Bit 1 - 2 Streaming
Bit 3 - 1 Recognized
Bit 4 - 2 Recognized
40023
Pressure Failure
Bit 0 - Line Pressure High
Bit 1 - Line Pressure Low
Bit 2 - Sensor 1 Pressure High
Bit 3 - Sensor 1 Pressure Low
Bit 4 - Sensor 1 Pressure High
Bit 5 - Sensor 1 Pressure Low
02/24/15
2 Bytes
2 Bytes
40031
2 Bytes
40032
2 Bytes
40501
RTC Seconds
2 Bytes
40502
RTC Minutes
2 Bytes
40503
2 Bytes
40504
2 Bytes
40505
RTC AM/PM
2 Bytes
40506
RTC Day
2 Bytes
40507
RTC Month
2 Bytes
40508
2 Bytes
40510
ID 1 String
60 Bytes
40540
ID 2 String
40 Bytes
40560
Part Number
30 Bytes
rev1.0 5
Application Note
A Modbus Master transmits function codes to specific Modbus Slave addresses. Each function has its own
code number:
01
Read Coils
02
Read Discrete Inputs
03
Read Holding Registers
04
Read Input Register
05
Write Single Coil
06
Write Single Register
The IntelliSense SIM module only supports the Read Holding Register (function 3). This function code
allows you to poll the network Slave for the current values in a single register or a consecutive series of
registers using a single command. For this example, two (2) message requests are sent to Slave address 1.
The first request polls registers 1-32 and the second requests the same data. This could easily be adjusted
to poll multiple SIMs.
Comms Initialization
02/24/15
rev1.0 6
Application Note
Message 1 Setup
Message 2 Setup
02/24/15
rev1.0 7
Application Note
The values returned from the SIM unit are configured to populated integer register DB3.DBX6.0 Master_
data.Receive.
This example solution can be adapted for increased message requests to include multiple Modbus Slave
addresses. After copying networks 6-7 and pasting them after the current rung seven (7), change the In
value of the MOV instruction located on rung seven (7) to the next consecutive message step, and adjust
the three (3) new EQU conditions so that the compared value is equal to the new message step value.
Keep in mind the new message instruction will have to be setup with the Data Table Address in the PLC,
number of elements, beginning location of data registers being polled, and correct Slave address.
02/24/15
rev1.0 8