Skip to main content

S7 Communication

Introduction

Using S7-Communication you can access data from Siemens PLCs and the PLC part of SINUMERIK controls. S7-Communication allows you to access Inputs, Output, Merkers, Timers, Counter, and most importantly data blocks (DBs). The protocol works over Profibus, MPI, and Ethernet connections.

Reading data from the PLC

For S7-300 and S7-400 PLCs you can access the PLC without any special settings in the Step7 project. For S7-1200 and S7-1500 PLCs, you need to set the Data Block you want to access to "Non-optimized access". You also need to disable "Access protection" in the hardware configuration.

PLC addressing

In S7 communication the PLC is accessed by using the IP address (can also be the IP address of a CP), rack and slot. Rack and slot can be determined from the hardware configuration or the following list:

  • S7-300: Rack 0, Slot 2
  • S7-1200/1500: Rack 0, Slot 1
  • SINUMERIK 840D (PLC): Rack 0, Slot 2

For S7-400 CPUs you need to check the hardware configuration and use the actual rack/slot that the CPU is plugged into.

The data point addresses in VergeLink are slightly different than the variable addresses used on Step 7 or TIA Portal. Here are some examples to guide you in addressing your variables:

AddressStep7 equivalentJS Data typeDescription
DB5,X0.1DB5.DBX0.1BooleanBit 1 of byte 0 of DB 5
DB23,B1 or DB23,BYTE1DB23.DBB1NumberByte 1 (0-255) of DB 23
DB100,C2 or DB100,CHAR2DB100.DBB2StringByte 2 of DB 100 as a Char
DB42,I3 or DB42,INT3DB42.DBW3NumberSigned 16-bit number at byte 3 of DB 42
DB57,WORD4DB57.DBW4NumberUnsigned 16-bit number at byte 4 of DB 57
DB13,DI5 or DB13,DINT5DB13.DBD5NumberSigned 32-bit number at byte 5 of DB 13
DB19,DW6 or DB19,DWORD6DB19.DBD6NumberUnsigned 32-bit number at byte 6 of DB 19
DB21,R7 or DB21,REAL7DB21.DBD7NumberFloating point 32-bit number at byte 7 of DB 21
DB2,S7.10*-StringString of length 10 starting at byte 7 of DB 2
I1.0 or E1.0I1.0 or E1.0BooleanBit 0 of byte 1 of input area
Q2.1 or A2.1Q2.1 or A2.1BooleanBit 1 of byte 2 of output area
M3.2QM3.2BooleanBit 2 of byte 3 of memory area
IB4 or EB4IB4 or EB4NumberByte 4 (0 -255) of input area
QB5 or AB5QB5 or AB5NumberByte 5 (0 -255) of output area
MB6MB6NumberByte 6 (0 -255) of memory area
IC7 or EC7IB7 or EB7StringByte 7 of input area as a Char
QC8 or AC8QB8 or AB8StringByte 8 of output area as a Char
MC9MB9StringByte 9 of memory area as a Char
II10 or EI10IW10 or EW10NumberSigned 16-bit number at byte 10 of input area
QI12 or AI12QW12 or AW12NumberSigned 16-bit number at byte 12 of output area
MI14MW14NumberSigned 16-bit number at byte 14 of memory area
IW16 or EW16IW16 or EW16NumberUnsigned 16-bit number at byte 16 of input area
QW18 or AW18QW18 or AW18NumberUnsigned 16-bit number at byte 18 of output area
MW20MW20NumberUnsigned 16-bit number at byte 20 of memory area
IDI22 or EDI22ID22 or ED22NumberSigned 32-bit number at byte 22 of input area
QDI24 or ADI24QD24 or AD24NumberSigned 32-bit number at byte 24 of output area
MDI26MD26NumberSigned 32-bit number at byte 26 of memory area
ID28 or ED28ID28 or ED28NumberUnsigned 32-bit number at byte 28 of input area
QD30 or AD30QD30 or AD30NumberUnsigned 32-bit number at byte 30 of output area
MD32MD32NumberUnsigned 32-bit number at byte 32 of memory area
IR34 or ER34IR34 or ER34NumberFloating point 32-bit number at byte 34 of input area
QR36 or AR36QR36 or AR36NumberFloating point 32-bit number at byte 36 of output area
MR38MR38NumberFloating point 32-bit number at byte 38 of memory area
DB1,DT0-Date**A timestamp in the DATE_AND_TIME format
DB1,DTZ10-Date**A timestamp in the DATE_AND_TIME format, in UTC
DB2,DTL2-Date**A timestamp in the DTL format
DB2,DTLZ12-Date**A timestamp in the DTL format, in UTC
  • *) Note that strings in S7 PLCs use two extra bytes at start for size & length of the string
  • **) Note that in VergeLink, Date data types are always represented in UTC.

Advanced usage

Request Batching

An S7-Communication "client" can specify the amount of data to read from a PLC. This means that VergeLink can intelligently combine your requests for multiple data points into a single request to the PLC. This efficiency gain lowers the impact of the communication load on the PLC cycle time and also allows a higher data rate. To utilize this functionality you need to make sure that the data point addresses are near each other in a single DB.