Siemens S7 Plus - Instance & item setup
How to setup a Siemens S7 Plus connection, instance and item in SIA
The Siemens S7 Plus connector SIA is compatible with optimized block and symbolic tag addressing for S7-1200 and S7-1500.
For connection with non-optimized datablocks and absolute tag addressing to S7-300, S7-400, S7-1200 and S7-1500 series please refer to Siemens S7 - Instance & item setup and for S7-200 & LOGO! please refer to Siemens LOGO! releases
Parameters
When using the Siemens S7 Connector both the instance and item have specific parameters. These parameters are required as they are needed to establish connection and to identify which memory to read from.
Instance
The instance needs the following parameters to establish a connection to the PLC:
| Parameter | Description |
|---|---|
| Address (instance default) | The IP address of the S7 PLC. |
| Timeout | Timeout for connecting, writing and reading to the PLC given in milliseconds. If the operation takes longer than the defined timeout timeout it will throw a timeout error Default: 5000 |
Item
The item parameters that is needed to read the tags in the PLC memory:
| Parameter | Description |
|---|---|
| Symbol |
Symbolic address of the tag in the Siemens S7 PLC. DB_BlockName.IntTagSymbol DB_BlockName.IntTagArraySymbol[3] (single array element) |
| Type | Data type used for determining the length of the tag in bytes and formatting it properly after a reading. Check data types for more information on each data type |
Data types
The following table shows how to address the various types of data types. In the examples it uses data block as memory area but the examples can be replaced with any of the memory areas given in memory areas.
| Data type | Return value |
|---|---|
| BOOL (bit) | 0 or 1 |
| BYTE | 0 to 255 |
| WORD | 0 to 65.535 |
| DWORD | 0 to 4.294.967.295 |
| LWORD | 0 to 18.446.744.073.709.551.615 |
| SINT | -128 to 127 |
| USINT | 0 to 255 |
| INT | -32.768 to 32.767 |
| UINT | 0 to 65.535 |
| DINT | -2.147.483.648 to 2.147.483.647 |
| UDINT | 0 to 4.294.967.295 |
| DINT | -2.147.483.647 to 2.147.483.647 |
| LINT | -9.223.372.036.854.775.808 to 9.223.372.036.854.775.807 |
| ULINT | 0 to 18.446.744.073.709.551.615 |
| REAL | -3.4e38 to 3.4e38 |
| LREAL | -1.7976931348623157e308 to +1.7976931348623157e308 |
| STRING | 0 to 254 characters, example “Hello world!” |
| WSTRING | 0 to 65.535 characters, example “Hello world, I am much longer than a STRING…!” |
Direct I/Q/M addressing
To address inputs, outputs and merkers the following syntax can be used:
| Address type | Example |
|---|---|
| Input bit | I0.0, I1.7 |
| Output bit | Q0.0, Q2.3 |
| Marker bit | M10.2 |
| Input byte/word/dword/lword | M10.2 |
| Output byte/word/dword/lword | IB0, IW2, ID4, IL8 |
| Marker byte/word/dword/lword | MB0, MW10, MD20, ML24 |
Array handling
The Siemens S7 Plus has partial support for arrays when it comes to reading and writings.
Readings
The Siemens S7 Plus Connector supports reading of arrays. All array readings will be returned as JSON arrays.
Examples are shown below:
| Data type | Example | Return value (example) |
|---|---|---|
| BOOL (bit) | DB_BlockName.BoolArray | [1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0] |
| WORD types INT types |
DB_BlockName.IntArray | [14, -20, 33, 945, 1023] |
| REAL rypes FLOAT types |
DB_BlockName.FloatArray | [456.4, 33.21, 45.2] |
| STRING types | DB_BlockName.String Array | ["STRING1","STRING2","STRING3"] |
Writing
To write to an array both a specific index can be written or a full writing of the array as below table illustrates.
| Array | Example | Return value (example) |
|---|---|---|
| Array | DB_BlockName.IntArray | [0, -23, 33, 6, 32] |
| Array index | DB_BlockName.IntArray[4] | 45 |
User-defined types
The Siemens S7 Plus has support for user-defined types (UDT) and structs.
| UDT | Example | Return or write value (example) |
|---|---|---|
| UDT object (string type) | DB_Process.Motor | { “Running”: 1, “Setpoint”: 10.2 } |
| UDT member | DB_Process.Motor.Speed | 10.2 |
UDT objects can also be partially set e.g. if writing { "Setpoint":33 } only the Setpoint parameter in the UDT will be set.