Siemens S7 - Instance & item setup
How to setup a Siemens S7 instance and item in SIA
The Siemens S7 connector SIA is compatible with the S7-300, S7-400, S7-1200 and S7-1500 series.
There is support for S7-200 & LOGO! but with another Connector.
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. |
Rack | The rack where the network card in the S7 PLC is located. Default: 0 |
Slot | The slot where the network card in the S7 PLC is located. Default: 0 Typical values: S7-300: 2 (as PSU is slot 1) S7-1200: 0 S7-1500: 0 |
Item
The item parameters that is needed to read the tags in the PLC memory:
Parameter | Description |
---|---|
Address | Memory address of the tag in the S7 PLC. Check memory areas for more information of the various addressable areas |
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 | Addressing syntax | Return value |
---|---|---|
BOOL (bit) | DB2.DBX19.3 | 0 or 1 |
BYTE | DB2.DBW20 | 0 to 255 |
WORD | DB2.DBW20 | 0 to 65.535 |
INT | DB2.DBW20 | -32.767 to 32.767 |
DWORD | DB2.DBD22 | 0 to 4.294.967.295 |
DINT | DB2.DBD22 | -2.147.483.647 to 2.147.483.647 |
REAL | DB2.DBD26 | -3.4e38 to 3.4e38 |
STRING | DB2.DBB20-32 | "Hello world!" (text inside tag) |
Memory areas
Area | Addressing syntax |
---|---|
Data block tag | DB2.DBX19.3 |
Analog input | I1.0 E1.0 AI1.0 AE1.0 |
Digital input | I1.1 E1.1 DI1.1 DE1.1 |
Analog output | Q2.0 A2.0 O2.0 AA2.0 AO2.0 AQ2.0 |
Digital output | Q2.1 A2.1 O2.1 DA2.1 DO2.1 DQ2.1 |
Flags / Merkers | M3.0 MB3.0 MD3.0 MW4.0 |
Reading blocks (arrays) of data
The Siemens S7 Connector supports reading of blocks of data also known as arrays. Reading of blocks can be very handy if a big chunk of data are to be read and sent to e.g. a cloud.
It can also be used to transfer big blocks of data between PLCs if the other PLC Connector supports block readings.
In order to do this you will have to specify a start offset and an end offset. Examples are shown below:
Data type | Example | Return value (example) |
---|---|---|
BOOL (bit) | DB2.DBX10-12 | [1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0] |
WORD INT |
DB2.DBW12-22 | [14, -20, 33, 945, 1023] |
DWORD DINT REAL |
DB2.DBD20-32 | [456.4, 33.21, 45.2] |
STRING |
DB2.DBB0(27)-54 Where DBB0: Specifies the first byte of the first string in the array (27): The size of the String in BYTES. This will be the size of characters+2 - If you have a String[25], this value will be 25+2 -54: Specifies the first byte of the last String |
["STRING1","STRING2","STRING3"] |