Siemens S7 Data Access
This chapter outlines all possible native addresses. These addresses must be configured within the device configuration.
Format
A native Siemens S7 address has following format:
{memory base}.{memory type}.{data type}:{address}
{address} = {MemoryTypeNumber}.{MemoryTypeOffset}.{SliceAccessor}
Example: Plc1.DataBlock.Float32:118.14
This will read 4 Bytes (Float32) of data block (DB) 118 with Offset 14.
Example: Plc1.DataBlock.Bool:118.14.0
This will read the first bit of 1 Byte at offset 14 of data block (DB) 118.
In case of Input or Output Memory input value 0 at the memory type section.
The slice accessor is optional and only valid if a bit is declared as data type. It must be a value between 0 and 7.
Or in case of a single variable:
{memory base}.{memory type}.{data type}:{variable name}
Memory Base
As a Plc only has one memory channel the resulting memory base is always Plc1 (except for diagnosis values):
Memory Channel | Description |
---|---|
Plc1 | PLC 1 memory base |
Global | Global memory base |
Memory Type
The PLC control provides different channels for memory:
Memory Channel | Description |
---|---|
Input | Global Input Memory (only available in Plc1 memory base) |
Output | Global Output Memory (only available in Plc1 memory base) |
DataBlock | Global DataBlock Memory (only available in Plc1 memory base) |
Memory | Global Memory (User constants, Global Variables, ...; only available in Plc1 memory base) |
Timer | Global Timer Memory (only available in Plc1 memory base) |
Counter | Global Counter Memory (only available in Plc1 memory base) |
Diag | Global Diagnosis Values (only available in Global memory base) |
Data Types
Data types are part of a HumanOS® data address. Common conversions are:
Data Type (Siemens) | Description | System Data Type | HumanOS® Adress Data Type |
---|---|---|---|
BOOL | Bit information. 0 = not set; 1 = set | System.Boolean | Bool |
BYTE | Byte information (unsigned 8bit integer) | System.Byte | Uint8 |
SINT | Byte information (signed 8bit integer) | System.Int8 | Int8 |
USINT | Byte information (unsigned 8bit integer) | System.UInt8 | Uint8 |
WORD | Word information (unsigned 16bit integer) | System.UInt16 | Uint16 |
INT | Int information (signed 16bit integer) | System.Int16 | Int16 |
UINT | Uint information (unsigned 16bit integer) | System.UInt16 | Uint16 |
DWORD | Dword information (unsigned 16bit integer) | System.UInt32 | Uint32 |
DINT | Dint information (signed 32bit integer) | System.Int32 | Int32 |
UDINT | Udint information (unsigned 32bit integer) | System.UInt32 | Uint32 |
REAL | Floating point number (signed 32bit) | System.Single | Float32 |
LREAL | Floating point number (signed 64bit) | System.Double | Float64 |
LWORD | Lword information (unsigned 64bit integer) | System.UInt64 | Uint64 |
LINT | Lint information (signed 64bit integer) | System.Int64 | Int64 |
ULINT | Ulint information (unsigned 64bit integer) | System.UInt64 | Uint64 |
ARRAY OF BYTE | Array of Bytes (Array of unsigned 8bit integer) | System.Byte[] | ByteArray |
STRING / STRING[n] | String information | System.String | String |
Strings must be specified from their address offset. See example in memory configuration datablock. Ignoring to do so will result in faulty values. If the string is specified with a length indicator in the plc, remember to calculate your length => string[x] : x+2 bytes
Memory Type Number
The memory type number is limited by the memory type:
Memory ranges depend on the memory type:
- Input/Output: always 0
- DataBlock/ Memory/Timer/Counter: 0-65535
Memory Type Configuration
Input
The input channel can only be read or monitored. Writing is not possible.
Address Example | Description | Data Type |
---|---|---|
Plc1.Input.Float32:0.14 | Reads 4 Bytes from I 14.0 | System.Double |
Plc1.Input.Bool:0.1 | Reads second bit from first byte | System.Boolean |
Output
The configuration can only be read or monitored. For writing, use the appropriate command.
Address Example | Description | Data Type |
---|---|---|
Plc1.Output.Float32:0.14 | Reads 4 Bytes from Q 14.0 | System.Double |
DataBlock
The values can only be read or monitored. For writing, use the appropriate command.
Address Example | Description | Data Type |
---|---|---|
Plc1.DataBlock.Float32:100.14 | Reads 4 Bytes from DB 100 offset 14 | System.Double |
Plc1.DataBlock.String:2.20[4] | Reads a string with length of 2 Bytes (offset 22) from DB 2 offset 20 | System.String |
Plc1.DataBlock.Bool:2.0.1 | Reads second bit from first byte from DB 2 | System.Boolean |
Counter
The values can only be read or monitored. This does not work on all cpus.
Address Example | Description | Data Type |
---|---|---|
Plc1.Counter.Int32:1 | Reads the global counter value from C1 | System.Int32 |
Timer
The values can only be read or monitored. This does not work on all cpus.
Address Example | Description | Data Type |
---|---|---|
Plc1.Timer.Int32:1 | Reads the global timer value from T1 | System.Int32 |
Memory
The values can only be read or monitored.
Address Example | Description | Data Type |
---|---|---|
Plc1.Memory.Int32:1 | Reads the global Memory from Byte 1 -- see the appropriate Memory location in the PLC for Offsets | System.Int32 |
Variable
Variables are very inefficient in terms of speed. A separate call is made to the PLC for each variable. Use memory types if possible.
All 64-bit values are not supported.
The values can only be read or monitored. For writing, use the appropriate command. Reading arrays is not possible (Strings also count as arrays), use the appropriate memory type for that.
Address Example | Description | Data Type |
---|---|---|
Plc1.Variable.Uint16:DB10.DBW20 | Reads the Word with offset 20 in the DB 10 | System.Uint16 |
Plc1.Variable.Int16:DB10.DBW20 | Reads the int with offset 20 in the DB 10 | System.Int16 |
Plc1.Variable.Int32:DB2.DBD1338 | Reads the int with offset 1338 in the DB 2 | System.Int32 |
Plc1.Variable.Float32:DB2.DBD14 | Reads the float with offset 14 in the DB 2 | System.Single |
Plc1.Variable.Bool:DB2.DBX0.0 | Reads the first bool with offset 0 in the DB 2 | System.Boolean |
Plc1.Variable.Uint8:DB2.DBB1320 | Reads the byte with offset 1320 in the DB 2 | System.Byte |
Plc1.Variable.Int8:DB2.DBB1342 | Reads the int with offset 1342 in the DB 2 | System.Int16 |
Accepted data and memory type definitions
Definer(s) | Memory Type | Data Length (bytes) |
---|---|---|
DBB | Datablock | 1 |
DBW | Datablock | 2 |
DBD | Datablock | 4 |
DBX | Datablock | 1 (reads bit x from 1 byte) |
IB / EB | Input | 1 |
IW / EW | Input | 2 |
ID / ED | Input | 4 |
E / I | Input | 1 (reads bit x from 1 byte) |
QB / AB / OB | Output | 1 |
QW / AW / OW | Output | 2 |
QD / AD / OD | Output | 4 |
Q / A / O | Output | 1 (reads bit x from 1 byte) |
MB | Global Memory | 1 |
MW | Global Memory | 2 |
MD | Global Memory | 4 |
M | Global Memory | 1 (reads bit x from 1 byte) |
Diag
The values can only be read or monitored. Supported values are:
Address Example | Description | Data Type |
---|---|---|
Global.Diag.Int32:1 | Connection status to PLC (1=Connected) | System.Int32 |
Global.Diag.Int32:2 | Connection life bit (toggling in 1Hz) | System.Int32 |
Device Info Example
{
"Id": "d5baf54a-10e6-4cf4-866e-bfbae46e01c2",
"Name": "S7 Control",
"DriverId": "F25F68F9-C720-4DD9-8A28-957C84AAA98C",
"Address": "Cpu=S7400;Address=192.168.44.86;Rack=0;Slot=5",
"Properties": [
{
"Name": "TcpTimeout",
"Value": 5000,
"DataType": "System.Int32"
}
],
"DataNodes": [
{
"Id": "a89475ce-66c2-4025-acba-e96b9ed5921d",
"Name": "MyValues",
"DataType": "System.Double",
"DataClass": "Event",
"Address": "Plc1.DataBlock.Float32:151.14",
"Access": {
"Read": true,
"Receive": true
}
}
],
"AlarmEventPool": {
"Id": "0efafbcd-447a-4fb6-900d-51affdc25e8f",
"Name": "Alarming",
"HistoryMode": {
"Retention": 20,
"SamplingRate": 2000
},
"Tasks": [
{
"Id": "66d0a44d-83e8-494d-9e15-5af16df60d55",
"Name": "Alarm Messages",
"Address": "Plc1.OEMAlarmEvent:0",
"Properties": [
{
"Name": "MessageMappingFile",
"Value": "Signallist.json"
},
{
"Name": "MessageCount",
"Value": 187,
"DataType": "System.Int32"
},
{
"Name": "StartAddress",
"Value": "Plc1.DataBlock.ByteArray:970.0[47]"
},
{
"Name": "MessageFormat",
"Value": "BitMessage"
},
{
"Name": "Message:Type",
"Value": "Raise"
}
]
},
{
"Id": "f2280557-9806-414d-b002-aa3e30fb79b5",
"Name": "Alarm Confirm Messages",
"Address": "Plc1.OEMAlarmEvent:0",
"Properties": [
{
"Name": "MessageMappingFile",
"Value": "Signallist.json"
},
{
"Name": "MessageCount",
"Value": 187,
"DataType": "System.Int32"
},
{
"Name": "StartAddress",
"Value": "Plc1.DataBlock.ByteArray:971.0[47]"
},
{
"Name": "MessageFormat",
"Value": "BitMessage"
},
{
"Name": "Message:Type",
"Value": "Confirm"
}
]
}
]
}
}