Overview of S7 protocol¶
The following image shows the data source input window for the S7 protocol:
You can choose between automatic and manual connection type.
- Automatic: This mode tries to find slot and rack number automatically.
- Manual: In this mode you can enter the rack and slot number manually.
For S7 connection type the PG type-programmer-type-connection is used thus you will not be able to make use of PG connection.
Note
Symbolic access
This solution does not allow full symbolic access.
Requirements for S7-1200 and S7-1500¶
- Put/Get communication must be permitted (can be found e.g. S7-1500 -> Properties -> Protection & Security -> Connection mechanisms).
- The “Optimized block access” of the data blocks that you want to read must be deactivated (can be found in the data block properties).
Address format examples¶
Detailed examples:
Example address format DB15.DBX6.3:
DB15.DBX6.3¶
Area indicator | Data type | Offset address | ||||
---|---|---|---|---|---|---|
DB15 | - | DB | X | 6 | - | 3 |
Datablock address | Separator | Datablock | Bool | Offset Byte | Separator | Offset Bit |
Reads 3rd bit of byte 6 of datablock 15 |
Example address format IW10:
IW10¶
Area indicator | Data type | Offset address |
---|---|---|
I | W | 10 |
Process Input | Word | Offset Byte |
Reads a word of input starting from offset 10 |
Overview¶
If you want to read data out of other areas, please replace “DB15.DB“ from the examples with the area indicator from the list below:
Attention: only certain address examples work with Inputs and Outputs (see²⁾).
S7 | MindSphere | |||
---|---|---|---|---|
Data type | Length/unsigned/signed | Data type (length) | Address example | Description |
Bool | 1 bit | BOOLEAN (1 bit) | DB15.DBX6.3²⁾ | Reads 3rd bit of byte |
6 of datablock 15 | ||||
Byte | 1 byte / unsigned | INT (4 bytes) LONG | DB15.DBB4²⁾ | Reads an unsigned byte |
USInt | (8 bytes) DOUBLE | DB15.DBBYTE4 | starting from offset 4 | |
*(8 bytes)*¹⁾ | out of datablock 15. | |||
SInt | 1 byte / signed | |||
Char | 1 byte / signed | DB15.DBCHAR6 | Reads a char starting | |
from offset 6 of | ||||
datablock 15. | ||||
Word | 2 bytes / unsigned | DB15.DBW10²⁾ | Reads an unsigned word | |
UInt | DB15.DBWORD10 | starting from offset 10 | ||
of datablock 15. | ||||
Int | 2 bytes / signed | DB15.DBINT12 | Reads a signed integer | |
starting from offset 12 | ||||
out of datablock 15. | ||||
DINT | 4 bytes / signed | DB15.DBDINT28 | Reads a signed double | |
integer starting from | ||||
offset 28 of datablock 15. | ||||
DWord | 4 bytes / unsigned | LONG (8 bytes) | DB15.DBDW24²⁾ | Reads an unsigned double |
UDInt | DOUBLE *(8 bytes)*¹⁾ | DB15.DBDWORD24 | word starting from offset | |
24 of datablock 15. | ||||
Real | 4 bytes / signed | DOUBLE (8 bytes) | DB15.DBD32²⁾ | Reads a floating-point |
DB15.DBREAL32 | number starting from | |||
offset 32 of datablock 15. | ||||
String | Length of variable, | STRING | DB15.DBSTRING10 | The maximum string length |
max. 254 bytes | (max. 254 bytes) | (Byte10) is read first. | ||
Then the number of bytes | ||||
that Byte10 indicates are | ||||
number read. After that | ||||
the of bytes that Byte11 | ||||
indicates are extracted | ||||
from the byte array that | ||||
is the result of second | ||||
read operation. | ||||
For example: | ||||
- (Byte10)- 30 | ||||
- (Byte11)-4 | ||||
- (Byte12-Byte15)-TEST | ||||
First read result: 30 | ||||
Second read result: 4TEST | ||||
We will extract TEST from | ||||
the second read result by | ||||
considering Byte11's value. | ||||
String | Min. 100 bytes , | DB15.DBSTRING10,100 | Reads 100 bytes of string | |
max. 254 bytes | starting from offset 10. |
¹⁾ When DOUBLE is used for integers, they are converted to a floating-point number.
²⁾ For the areas Inputs and Outputs only certain address examples work.
Note
Signed values
If you want to read a signed value, you have to use the respective signed datablock.
Example:
DB1831.DBW508 is unsigned. You can use DB1831.DBINT508 instead.
Area Types¶
S7 datapoint addresses must contain an area type.
Area indicator | Area types | Description |
---|---|---|
C | Counter | Reads Counter value of hardware. |
DB | Datablock | Reads datablock value from hardware. |
DI | Instance Data | Reads data directly from hardware. |
I | Process Input | Reads Input value of Process image. |
M | Memory | Reads Memory value of hardware. |
PI | Peripheral Input | Reads Input value directly from hardware. |
PQ | Peripheral Output | Reads Output value directly from hardware. |
Q | Process Output | Reads Input value of Process image. |
T | Timer | Reads Timer value of hardware. |
Area Number¶
S7 datapoint addresses must contain area number.
E.g.: DB10 (10. datablock)
Data Types¶
The following table shows the MindSphere data types:
MindSphere data types:
Data type | Length | Date range: From | Data range: To |
---|---|---|---|
BOOLEAN | 1 bit | True | False |
INT | 4 bytes | −2147483648 | 2147483647 |
LONG | 8 bytes | −9223372036854775808 | 9223372036854775807 |
DOUBLE | 8 bytes | -9.9999999999999999999999999999999999999E+125 | 9.9999999999999999999999999999999999999E+125 |
STRING | 1-255 bytes |
The following table shows the S7 data types:
S7 data types:
Data type | Length | Date range: From | Data range: To |
---|---|---|---|
Bool | 1 bit | True | False |
Byte (unsigned) | 1 byte | 0 | 255 |
Word (unsigned) | 2 bytes | 0 | 65.535 |
DWord (unsigned) | 4 bytes | 0 | 4294967295 |
Char (signed) | 1 byte | −128 | 127 |
Int (signed) | 2 bytes | −32768 | 32767 |
DINT (signed) | 4 bytes | −2147483648 | 2147483647 |
Real | 4 bytes | ±1,18e-38 | ±3.40e+38 |
String | 1- 254 bytes |
Offset¶
Variable types must have an offset. Offset is the starting byte number.
E.g. DW4 (a double word starting from byte 4)
String¶
Data type | Length in bytes | Format |
---|---|---|
STRING[n] or STRING | n+2 | ASCII character of any length. n specifies the length of the character string. A maximum length of 254 characters is permitted. If no length is specified, the default setting is 254 characters. |
Data type | Examples of format used |
---|---|
STRING[2] | 'AB' |
STRING[55] | 'The character string can consist of up to 55 characters' |
Note
You must enclose your character string in single quotation marks.
The following example shows the byte order when specifying the datatype STRING[4] with the output value 'AB'.
* Tod
TIME_OF_DAY (Time) | 32 | Time is in steps of 1 ms | TOD#0.0.0.0 to TOD#23:59:59.999 | L TOD#1:10:3.3 |
L TIME_OF_DAY#1:10:3.3 |
* Time
Returns milliseconds.
Format:
The DT (DATE_AND_TIME) datatype saves the information on date and time of day in BCD format.
The following table shows the properties of datatype DT:
Length (bytes) | Format | Range of values | Example of value input |
---|---|---|---|
8 | Date and time (year-month-day) |
Any questions left?
Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.