Overview of S7 protocol for MindConnect IoT2040¶
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
- For S7 300 : 400 PLCs, CPU can be dynamically located in any slot in the rack, In this case you can use manual configuration to locate CPU instead of auto find.
Symbolic access
This solution does not allow full symbolic access.
S7 data point parameter¶
To collect the data of your S7 device, click "Add Datapoint" to add new datapoint.
The following image shows the data point parameter window:
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 | Industrial IoT | |||
---|---|---|---|---|
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 USInt | 1 byte / unsigned | INT (4 bytes) LONG (8 bytes) DOUBLE *(8 bytes)*¹⁾ | DB15.DBB4²⁾ DB15.DBBYTE4 | Reads an unsigned byte starting from offset 4 out of datablock 15. |
SInt | 1 byte / signed | INT (4 bytes) LONG (8 bytes) DOUBLE *(8 bytes)*¹⁾ | DB15.DBB4²⁾ DB15.DBBYTE4 | Reads an unsigned byte starting from offset 4 out of datablock 15. |
Char | 1 byte / signed | INT (4 bytes) LONG (8 bytes) DOUBLE *(8 bytes)*¹⁾ | DB15.DBCHAR6 | Reads a char starting from offset 6 of datablock 15. |
Word | 2 bytes / unsigned | INT (4 bytes) LONG (8 bytes) DOUBLE *(8 bytes)*¹⁾ | DB15.DBW10²⁾ | Reads an unsigned word |
UInt | 2 bytes / unsigned | INT (4 bytes) LONG (8 bytes) DOUBLE *(8 bytes)*¹⁾ | DB15.DBWORD10 | starting from offset 10 of datablock 15. |
Int | 2 bytes / signed | INT (4 bytes) LONG (8 bytes) DOUBLE *(8 bytes)*¹⁾ | DB15.DBINT12 | Reads a signed integer starting from offset 12 out of datablock 15. |
DINT | 4 bytes / signed | INT (4 bytes) LONG (8 bytes) DOUBLE *(8 bytes)*¹⁾ | 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 | 4 bytes / unsigned | 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, max. 254 bytes | STRING (max. 254 bytes) | DB15.DBSTRING10 | The maximum string length (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 the second read result by considering Byte11's value. |
String | Min. 100 bytes , max. 254 byte | STRING (max. 254 bytes) | DB15.DBSTRING10,100 | Reads 100 bytes of string 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.
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.
Real data type
If you want to write a value to REAL data type, you have to use “REAL” instead of “DBD” in the address.
Example:
DB15.DBD32 or DB15.REAL32 can be used for reading. You can use DB15.REAL32 for writing.
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 Industrial IoT data types:
Industrial IoT data types:
Data type | Length | Date range |
---|---|---|
BOOLEAN | 1 bit | True to False |
INT | 4 bytes | −2147483648 to 2147483647 |
LONG | 8 bytes | −9223372036854775808 to 9223372036854775807 |
DOUBLE | 8 bytes | -9.9999999999999999999999999999999999999E+125 to 9.9999999999999999999999999999999999999E+125 |
STRING | 1-255 bytes | -9.9999999999999999999999999999999999999E+125 to 9.9999999999999999999999999999999999999E+125 |
The following table shows the S7 data types:
S7 data types:
Data type | Length | Date range |
---|---|---|
Bool | 1 bit | True to False |
Byte (unsigned) | 1 byte | 0 to 255 |
Word (unsigned) | 2 bytes | 0 to 65.535 |
DWord (unsigned) | 4 bytes | 0 to 4294967295 |
Char (signed) | 1 byte | −128 to 127 |
Int (signed) | 2 bytes | −32768 to 32767 |
DINT (signed) | 4 bytes | −2147483648 to 2147483647 |
Real | 4 bytes | ±1,18e-38 to ±3.40e+38 |
String | 1- 254 bytes | ±1,18e-38 to ±3.40e+38 |
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) |