IMDHMIControls LibraryShop main store

Troubleshooting

Why a Node-RED S7 read succeeds on the wrong DB address

PLC programming Published 6 min read By IMDHMI controls team

Short answer

An S7 read by absolute DB offset is checked only against the block's byte size, so a wrong in-range offset returns parseable bytes with no error, while one out-of-bounds tag fails the whole grouped read, which is why the error named a valid address. Verify each variable's absolute DB offset in the PLC project's cross-reference, because the offset shown beside a struct member is relative to the struct, then correct the endpoint's variable list.

On this page
  1. What a clean read actually proves
  2. Why the error pointed at a valid address
  3. The byte arithmetic behind both symptoms
  4. Get the absolute offset from the PLC project
  5. Prove the corrected mapping
  6. The decision for each case
  7. Questions asked

A Node-RED S7 read that returns a value has proved exactly two things: the requested bytes lie inside the data block, and the configured parser could decode them. It has not proved the address points at the variable you meant. That is why a mistyped string address read without a complaint while a correctly addressed real was named in an error message: the failed read was one batch covering every tag on the connection, and a single out-of-bounds item fails the batch. The repair is not in Node-RED's error handling. You read each variable's absolute DB offset from the PLC project and correct the endpoint's variable list to match.

What a clean read actually proves #

The node-red-contrib-s7 package talks to the CPU by absolute address. Each PLC connection is an S7 Endpoint configuration node in which you list the variables and their addresses, and at poll time the node asks the CPU for a byte range inside a DB number. The CPU's only check is that the range fits inside the block. Nothing in that exchange consults the symbol table: absolute addressing never asks which variable lives at an offset, so any in-range offset returns bytes, and the node decodes them according to the definition you typed. A wrong offset hands you a neighbor's bytes: garbage, a plausible number, or text that even looks right.

The addresses in this failure use the node's letter notation. DB6001,S1466.100 means DB 6001, a string whose first byte is 1466 and whose declared maximum length is 100. DB6001,R1536 is a 4-byte REAL whose first byte is 1536. Other spellings exist in this node family, for example the long form DB1,REAL0, so confirm what each token means against the endpoint's documented address styles rather than assuming.

This is where S7 differs from Modbus. A Modbus server validates a request against its register map and answers an out-of-map address with an exception code, which is why a Modbus master reports a named invalid-data-address error instead of returning bytes. An S7 DB read has no map to check, only the block's end.

Why the error pointed at a valid address #

The endpoint does not poll its variables one by one. It reads its whole variable list as one batch, spanning from the lowest offset in the list to the highest, then slices the returned buffer into the individual tags. If any part of that request is rejected, because one item's range runs past the end of the block, the whole batch is marked bad, and the error text can name a tag that reads fine on its own. So seeing DB6001,R1536 in the message did not convict that address: it shared a batch with the mistyped string further down the block, and the batch died on that item. The isolation test is mechanical: delete the suspect from the endpoint's list, redeploy, and if the error leaves with it, the remaining addresses were never the problem.

The byte arithmetic behind both symptoms #

An S7-1200 STRING occupies two header bytes (current length, then maximum length) followed by its maximum number of characters. A REAL occupies four bytes. That is all you need to explain why one wrong address passed and the other failed.

Address Footprint Last byte requested What happened
DB6001,S1466.30, the intended string 2 + 30 = 32 bytes 1497 not the one entered
DB6001,S1466.100, wrong maximum length 2 + 100 = 102 bytes 1567 read, no error
DB6001,S1556.30, wrong offset 2 + 30 = 32 bytes 1587 error
DB6001,R1536, valid real 4 bytes 1539 named in the error

The accepted string ends at 1466 + 2 + 100 = 1568, so DB6001 must be at least 1568 bytes long. The rejected string would end at 1556 + 2 + 30 = 1588, so the same block must be shorter than 1588 bytes. The block's true size therefore sits between 1568 and 1587 bytes inclusive, and the real sits comfortably inside it: valid, as believed, and wrongly accused. Open the block's properties and check its size against that window; if it lands inside, both symptoms are fully explained. Note also what the wrong maximum length did: it pulled 70 bytes past the intended string's end (1568 - 1498 = 70), every one of them belonging to whatever variables follow it in the block.

Get the absolute offset from the PLC project #

  1. Open DB 6001 in the block editor and find the variable. The offset displayed beside a member of a struct is relative to the struct, not to the start of the DB; copying it as an absolute address is the classic way this failure is born.
  2. Select the variable and read its absolute DB offset from the cross-reference or the variable's properties. The cross-reference tab of the inspector is documented to show where a selected object is used.
  3. Record the declared type and, for a string, the maximum length, because the length is part of the declaration.
  4. Make sure the block is compiled with a fixed layout: in its properties, disable the optimized-layout option, otherwise the offsets you just read are not stable.
  5. Enter that absolute offset, type and length in the S7 Endpoint's variable list, and change nothing in the PLC to accommodate a client-side guess.

Prove the corrected mapping #

An error-free read is still not proof, so finish with a controlled check:

  • Read the corrected string alone, with the rest of the list disabled, and confirm the value against the online monitor in the PLC project.
  • Change the variable deliberately, with the machine in a safe state, and confirm Node-RED follows; then change a neighboring variable and confirm Node-RED does not move. The second half is what catches a wrong offset.
  • Restore the full variable list and confirm the batch completes with every item good.

The dangerous twin of this fault is a write: the same bounds-only check passes, the CPU acknowledges, and the bytes of a neighboring variable are overwritten in production data with no error anywhere. Prove offsets with reads before any write-enabled endpoint points at them. The same lesson holds across tools, since a SCADA write to a PLC real address can fail silently when its address form does not resolve, so silence proves nothing in either direction.

The decision for each case #

Case A, the read succeeds but the value is wrong or suspicious: the offset or length is in range but points at the wrong bytes. Take the absolute offset from the cross-reference, never from the column beside a struct member, correct the endpoint entry, and prove it with the two-way change test above.

Case B, the error names an address you have verified as valid: stop defending that address and find the real culprit. Split the endpoint's variable list, test tags one at a time, and compute each suspect's footprint from its type and length; the failing tag is the one whose last byte crosses the block's size. Correct it, then restore the group.

Questions asked

Can the wrongly addressed string still display correct text in Node-RED?

Yes, and that is what makes this fault sneaky. The wrong entry keeps the same first byte as the intended string, so the current-length header still trims the parse and the displayed text looks right. The request still spans dozens of bytes of neighboring variables, and on a shorter block the same entry would throw the error its sibling did. Plausible text on one day proves nothing about the mapping.

Why does an optimized data block break offset addressing?

An optimized block gives the compiler freedom to reorder and pack members, so no variable keeps a fixed absolute offset between compilations. A read that works today can point at a different variable after the next download, with no error either time. Absolute byte offsets require a block compiled with the fixed layout; otherwise use symbolic access instead of offsets.

What happens if the same offset mistake sits in a write?

The CPU applies the same bounds-only check, the write lands on whatever occupies those bytes, and the operation reports success. A neighboring production variable is overwritten silently. Prove every offset with reads and a scratch variable before enabling writes, and keep write-enabled endpoints down to the few tags the application must actually change.

Will a larger PDU or a slower poll rate clear the batch error?

No. The rejected item requests bytes past the end of the block, and no transport setting makes the CPU return them. Connection parameters such as the PDU length change how much data moves per request, not which addresses exist. Only correcting the address or the length removes the error.

Should I move or renumber the PLC variables so the old Node-RED addresses work?

No. The PLC block is the source of truth, and reshuffling it to match a client-side typo risks the program logic and silently breaks every other client reading that block. Correct the endpoint entries from cross-reference data instead; the client follows the controller, never the reverse.

Keep reading

  • Troubleshooting

    Fix TIA Portal assign IP address failing on an S7-1200

    When a project downloaded with Set IP address in the project is running, Assign IP address and PRONETA cannot permanently change an S7-1200 address, and the SIMATIC Automation Tool writes only a temporary one that drops at the next power cycle. The fix is editing the Ethernet addresses in the project and downloading again, or switching the interface to direct-at-device mode.

    PLC programming

  • How-to

    Read DP slave diagnostic addresses with SFC51 on an S7-300

    SFC51 RDSYSST with SSL ID 0x00B4 selects a DP slave by its configured diagnostic address, and that address never comes from the 0x0092 station list: station numbers and diagnostic addresses live in separate addressing domains with no conversion between them. Read the address from the documented 0x00B status list family or from the hardware configuration, then call 0x00B4 once per address.

    PLC programming

  • Troubleshooting

    Why an S7-1200 analog output reads 3 mA at any command

    A 0-20 mA output that reads 3 mA at every command is not scaling wrong — the meter and the drive are in the circuit incorrectly, or the output stage has lost its 24 V DC supply. Confirm the channel is set to current mode and 20.4-28.8 V DC at L+, then command 0 and 27000 from a watch table with the drive disconnected and the meter in series. A healthy channel tracks both writes; a flat reading with the supply verified means a failed output stage.

    PLC programming

Why 1769 modules show a red X in RSLinx