Skip to content

Siemens S7

The S7 plugin talks to Siemens PLCs through snap7, reading data blocks over TCP. It polls: at the rate you set, it asks the PLC for the bytes your signals are in and turns each response into one sample.

It only reads. VizuaLog never writes to a PLC.

Several S7 interfaces can run in one session, so a cell with several controllers is one session with one interface per PLC.

FieldTypeDefaultNotes
IPtext192.168.0.1The PLC’s address. Validated as IPv4
Racknumber00 – 10
Slotnumber20 – 10. Typically 1 for S7-1200/1500, 2 for S7-300/400
Portnumber102102 – 65535. ISO-TSAP is 102; change it only behind a gateway
Poll interval (Hz)slider2010 – 100
Placeholder image
FieldRequiredMeaning
dbYesData block number. Its presence is what marks a signal as S7
byteOffsetYesByte position of the value within that data block
bitbool onlyBit 0–7 within the byte. Defaults to 0

Signals are grouped by data block. For each block the plugin reads one range in one request, from the lowest byteOffset to the end of the highest, then picks each signal’s value out of the bytes.

Each signal’s dataType decides how many bytes are read at its offset and how they are read. You can write the types as TIA Portal shows them:

TIA PortalWriteBytes
Boolbool1 (one bit of it, selected by bit)
Byteuint81
SInt / USIntint8 / uint81
Int / UIntint16 / uint162
Worduint162
DInt / UDIntint32 / uint324
DWorduint324
Realfloat324
LRealfloat648

Both spellings work. A signal with a db key is read in the S7 dialect, so "Real", "DInt" and "Word" are accepted alongside the canonical names. You can copy a data block as it is.

Every poll emits one value per signal, in signal order. A signal without a usable db or byteOffset keeps its slot and reads NaN, so it cannot shift the signals after it. NaN instead of 0.0 keeps an unread signal distinct from a real zero.

A data block with signals at offset 0 and offset 1200 is read as one 1200-byte range. Keep logged signals close together in the DB to keep polls small.

A PLC accepting the connection does not mean data arrives. With wrong data block numbers the CPU answers and then returns nothing, so the states are:

StateMeans
Waiting for data…The PLC answered. No poll has returned data yet
ConnectedA poll has succeeded and readings are arriving
Not receiving data!Readings were arriving and stopped, after three poll intervals or one second, whichever is longer
Connection failed…The connection attempt failed, or the schema has no S7 addressing
Connection lost!Reads failed repeatedly and the link was given up

A schema with no S7 addressing refuses to start: “No signals with S7 addressing (db + byteOffset) — nothing to read”. Every signal needs both db and byteOffset.

Two REALs and two BOOLs in DB 100, written in TIA Portal spellings:

{
"dataSignals": [
{
"name": "MotorTemp",
"description": "Drive-end bearing temperature",
"unit": "°C",
"dataType": "Real",
"minValue": 0,
"maxValue": 150,
"db": 100,
"byteOffset": 0
},
{
"name": "MotorSpeed",
"unit": "rpm",
"dataType": "Real",
"minValue": 0,
"maxValue": 3000,
"db": 100,
"byteOffset": 4
},
{
"name": "MotorRunning",
"dataType": "Bool",
"db": 100,
"byteOffset": 8,
"bit": 0
},
{
"name": "OverTempAlarm",
"dataType": "Bool",
"db": 100,
"byteOffset": 8,
"bit": 1
}
]
}

The db, byteOffset and bit values in your file must match the PLC’s layout. VizuaLog cannot check them against the program, and a wrong offset returns a plausible but wrong number.

On an S7-1200 or S7-1500, snap7 can only read data blocks after two changes in TIA Portal:

  • In the CPU properties, under Protection & Security → Connection mechanisms, enable Permit access with PUT/GET communication from remote partner.
  • In the properties of each data block you read, under Attributes, clear Optimized block access. An optimized block has no fixed byte layout, so byteOffset has nothing to point at.

Compile and download the program to the CPU afterwards. S7-300 and S7-400 CPUs need neither change.

  • A block is read across its whole extent. Signals at offset 0 and 5000 in one DB read 5000 bytes every cycle. Keep polled signals near each other, or split them across data blocks.
  • No poll-overrun detection. If a cycle takes longer than the interval, because of a large extent, a busy CPU or a slow network, the real rate drops with no warning. Check timestamps in a recording if the rate matters.
SymptomWhere to look
Cannot connectAddress, rack and slot. Slot is 1 on most S7-1200/1500 and 2 on S7-300/400, and a wrong slot fails exactly like a wrong address
Connection failed immediately, with a message about addressingThe schema has no signal with both db and byteOffset, so the poll is refused
Stuck on Waiting for data…The CPU answered but no poll has returned. Wrong data block numbers do exactly this. On an S7-1200/1500, so do PUT/GET access being off and optimized data blocks (see PLC-side setup)
Connects, then dropsAnother master may hold the connection resource, or the poll rate is more than the PLC will serve; lower it
Stays on Reconnecting…The PLC is still unreachable: power, cable, network or a stopped PLCSIM. It picks up on its own when the PLC is back; press Disconnect to stop retrying
A signal reads NaNIt has no db or no byteOffset in the file
Values are wrong but stableOffsets are off, or the declared type does not match the DB layout. A DINT read as Real is the classic
Values update far slower than the poll rateThe DB span being read is large. Check how far apart the offsets in that block are

All of these messages are kept in full in the event log after the toast has gone.