IMDHMIControls LibraryShop main store

How-to

Modbus TCP tag maps and PLC-triggered logging for SCADA

SCADA and data logging Published 6 min read

Short answer

Map only the tags your client needs into contiguous register blocks, keep every 32-bit value in a word order both sides agree on, and log one record per machine cycle on the rising edge of a PLC handshake coil that the SCADA clears after a successful database insert.

On this page
  1. Assign addresses only to the tags the client reads
  2. Size the map so one read replaces many
  3. Keep every 32-bit value in matching word order
  4. Log on the rising edge of a coil the client clears
  5. The decisions
  6. Questions asked

Assign Modbus addresses only to the tags your SCADA client actually reads, group them into contiguous blocks by data type and poll rate, keep every 32-bit value in a word order both sides agree on, and log records on the rising edge of a handshake coil that the client clears after a successful insert. Build the map before you build screens: ad-hoc address assignment is the largest source of rework in these projects, and a timer-based logger either floods the database with rows you do not want or misses the one record the machine just finished. The steps below take you from an empty tag database to a logger that inserts exactly one row per machine cycle.

Assign addresses only to the tags the client reads #

A PLC does not expose its tag database over Modbus TCP automatically. Every tag a client can see got its address on purpose, in the controller's tag database, before the first screen was drawn.

  1. In the PLC tag database, enable the Modbus address column and assign an address to each tag the SCADA needs. Leave internal scratch tags unassigned: an unassigned tag is invisible to any Modbus client, which is exactly what you want for program-internal values.
  2. Group the assigned tags into contiguous blocks by data type and poll rate: coils for bit data in one block, holding registers for 16-bit integers in another, floats in a third. A read that spans a gap in the map returns an exception instead of data, so keep every block inside a populated range — see Modbus exception 02 when a read crosses a register map gap for what that fault looks like.
  3. Where you need single bits inside a word register, work out the bit position once and write it into the map, following the same convention the SCADA item reference uses — the bit numbering inside a Modbus register in a SCADA item reference is easy to get wrong in two different directions.
  4. Reserve spare registers at the end of each block so adding tags later never forces you to renumber a live map that screens, trends and historians already point at.
  5. Document the map in a spreadsheet stored with the PLC project archive, and export the tag database beside it. The spreadsheet is the contract between the PLC program and every client that follows.
  6. Configure the CPU as a Modbus TCP server on its Ethernet port and confirm the SCADA host can reach TCP port 502; the PLC-side work is the same whether the client is a full SCADA package or a small logger — see what you must configure on the PLC side for Modbus TCP.

Size the map so one read replaces many #

Every Modbus TCP read is one request and one response, whatever the register count inside it. Sixty tags scattered across the map as sixty single-register reads cost sixty transactions per poll; the same sixty tags grouped into three blocks of 32, 16 and 12 registers cost three.

Worked example, at one poll per second: the scattered map generates 60 transactions per second, or 5,184,000 per day, and the grouped map generates 3 per second, or 259,200 per day — a twentyfold cut in traffic for the same data. The blocking also decides whether the poll cycle fits. As an illustrative round trip of 20 ms per transaction on the plant network, the grouped map completes in 3 × 20 ms = 60 ms and every tag is fresh. The scattered map serializes 60 × 20 ms = 1.2 s, longer than the 1 s poll period itself, so the last registers in the cycle land in the database already stale. Your real round trip will differ; measure it once at the SCADA host and keep each block read comfortably inside the poll period.

Keep every 32-bit value in matching word order #

Modbus defines no floating-point or 32-bit data type. A 32-bit IEEE-754 value occupies two consecutive holding registers, four word and byte orderings exist in the field, and most PLCs transmit the high word first.

Worked example: the PLC writes 1234.5 as 0x449A followed by 0x5000. A client configured for the opposite word order assembles 0x5000449A, which decodes to about 8.6 billion — a number that looks like a scaling error but is not. Swap the word-order setting in the client driver before you touch scaling, ranges or wiring; this one setting fixes the majority of garbage-float reports. Treat 32-bit integers the same way, and note that a sign mismatch is a separate fault: an unsigned 16-bit Modbus word read as a signed integer is covered in converting an unsigned 16-bit Modbus word to a signed integer.

Log on the rising edge of a coil the client clears #

A timer that polls values every N seconds records what the machine happened to be doing, not that a cycle finished. Let the PLC decide when a record exists: it writes the record registers, sets a handshake coil, and waits. One safety note on where that coil lives: it must be an internal coil the ladder logic owns, never a physical output point, because a client write to an output coil drives a real device — writes into the PLC's output image deserve the care described in safe Modbus writes to PLC output registers from SCADA.

  1. The ladder finishes writing the record registers, then sets the handshake coil and holds those registers stable until the coil clears.
  2. The logger reads the coil at its poll rate and routes the boolean through a filter that blocks unchanged values. That turns the level into an edge: a coil held TRUE across ten scans produces one record, not ten.
  3. On the edge, the logger reads the data block once and inserts one row.
  4. Only after a successful insert does the logger write the coil FALSE. On a database failure it leaves the coil TRUE.
  5. The ladder waits for the coil to clear before preparing the next record, so records queue in the PLC instead of overwriting each other.

Initialize edge detection from the first read after a logger restart, not from an assumed FALSE. If the logger inserted the row and died before clearing, the coil is still TRUE, and the restarted logger must process it once and clear it. This closes both failure modes — a crash after insert but before clear, and a crash after the PLC set the coil but before any insert — with no duplicated and no lost records.

Poll the coil at one quarter of your fastest record interval: for a machine finishing one part per second, that is every 250 ms, which bounds record latency near a quarter second. The handshake makes the PLC wait for the clear, so a slow poll throttles the machine itself, not just the database.

The decisions #

  • New machine or line: build the block map and the handshake from the first download; retrofitting them after screens and trends exist is the expensive version of the same work.
  • Retrofit on a live system: leave the existing live addresses untouched, and put new tags into a fresh block at the end of the map with its own spare registers.
  • Same record twice in the database: you are logging on a level or clearing the coil on a failed insert; fix the edge detection first, then the clear condition.
  • Floats arriving as numbers in the billions: swap the client driver's word-order setting before anything else.
  • Logger restarts must never lose or repeat a record: clear the coil only after a successful insert, and take the initial edge state from the first read.

Questions asked

Why do my floats read as huge garbage numbers over Modbus TCP?

Modbus defines no floating-point type, so a 32-bit IEEE-754 value spans two registers and the word order between the PLC and the client must match. For example, 1234.5 travels as 0x449A then 0x5000; a client reading the low word first assembles 0x5000449A and shows about 8.6 billion. Swap the word-order setting in the client driver before touching scaling or wiring.

How often should the logger poll the trigger coil?

Poll at one quarter of your fastest record interval. For a machine that finishes one part per second, that is every 250 ms, which bounds record latency near a quarter second. Because the handshake coil makes the PLC wait for the clear before building the next record, a slow poll throttles the machine itself, not just the database, so the poll period must stay well under the shortest time between records.

Why does my database show the same record twice?

Two causes cover almost every duplicate. Logging on the coil level instead of a rising edge inserts one row per scan while the coil sits TRUE, so run the boolean through a filter that blocks unchanged values. Clearing the coil even when the insert failed makes the PLC overwrite the record and the next cycle insert twice. Clear only after a successful insert, and after a logger restart initialize edge detection from the first coil read.

Keep reading

  • Troubleshooting

    Two SCADA servers writing to one PLC over Modbus TCP

    Yes: a Modbus TCP server accepts multiple client connections, so both SCADA systems can read the PLC at the same time. Conflict appears only where both applications write overlapping addresses, because the last write to a register or coil wins. Inventory every writable address in both projects, then either make the second system read-only or give the PLC command ownership with a separate request area per client.

    SCADA and data logging

  • Troubleshooting

    Why Ignition Modbus TCP tags read a Click PLC wrong

    Ignition rejects the Click DF addresses because the 4- holding-register prefix is parsed as part of the register number; strip it and the tags create. Set the device to zero-based addressing under Show advanced properties when the values land one register off. DF floats occupy two registers each, so the map steps by 2; change word order only if floats stay wrong.

    SCADA and data logging

  • How-to

    Connecting Citect SCADA to a Modbus RTU gateway over MODNET

    Yes — MODNET is Citect's driver for Modbus over TCP/IP, and a true RTU-to-TCP converter presents standard Modbus TCP on its Ethernet side, so the combination works. Success then rides on two things: the gateway's operating mode, and carrying the RTU slave address and register offsets into Citect correctly, proved by reading one register whose value you can see at the device.

    SCADA and data logging