IMD SolutionComputing LibraryShop main store

Troubleshooting

Why Ignition history misses samples at 20 ms intervals

Edge computing and IIoT Published 7 min read

Short answer

Tag-based periodic history is not reliable at 20 ms on a polled Modbus TCP driver, and no scan-class setting fixes it. Count the timestamps the driver delivers against 3000 per 60 s window and stored rows against window seconds divided by 0.02. When a count falls short, log from a script that calls system.tag.storeTagHistory or record at the source device.

On this page
  1. Where the samples go missing
  2. Check 1: count the timestamps the driver delivers
  3. Check 2: count the stored rows
  4. Which logging path fits
  5. Log the samples from a script
  6. Prove the stream is complete
  7. The decision for each case
  8. Questions asked

Tag-based periodic history is not a reliable way to log a polled Modbus TCP tag every 20 ms, and no scan-class or history setting changes that. Samples go missing at three independent stages, so measure before you reconfigure: count the timestamps the driver actually delivers, then count the rows the database actually holds. When a count falls short — on a polled TCP link at this rate, expect it to — move the logging into a Python script that calls system.tag.storeTagHistory, or record at the source device and push timestamped blocks up to the gateway. This article gives both counts, the arithmetic that judges them, and the logging path that fits each result.

Where the samples go missing #

Three stages sit between the register and the trend, and each can be the bottleneck. A fix at a later stage cannot recover data an earlier stage never produced, so work them in order.

  • Device and driver. Modbus TCP is master-initiated: every poll costs one request/response round trip plus the device's processing time. The scan class rate is a target, not a guarantee — a master cannot complete a transaction faster than the round trip allows. Polled-master tools document the consequence plainly: the Modbus Poll manual states that a scan rate set lower than the transaction time has no effect. When the device's register refresh is slower than the poll, faster polling only returns repeated values.
  • Tag history engine. The historian batches writes to the database. When inserts arrive faster than the write path drains them, records pile up in store-and-forward; the manual defines Memory Buffer Size as the record count that first stage holds in memory.
  • Database. Insert latency and disk throughput cap the sustained row rate, and a trend client will smooth right over whatever gaps result.

One mechanism hides losses before any of this: with a periodic sample and deadband compression enabled, an unchanged value is not stored until the Max Time Between Samples boundary, so a quiet register produces far fewer rows than the sample rate implies. That is compression working as designed — how Tag Historian deadband compression picks stored points explains exactly which points survive.

Check 1: count the timestamps the driver delivers #

Judge this at the tag, not in the history. Attach a gateway script that counts new tag timestamps over a fixed window — one minute is a convenient length. The expected count is the window in seconds divided by the interval in seconds: 60 / 0.02 = 3000.

Measure one of three outcomes:

  • Close to the expected count, evenly spaced. The driver keeps up; move to Check 2 and judge the write path.
  • Far below the expected count, or clustered in bursts. The driver or the device cannot sustain the interval, and the historian is not at fault. Shrink the register block, move other tags off the same device connection, and read the device's own update period. No gateway-side setting recovers this case; go straight to source-side logging.
  • Close to the expected count with many identical values. The device refreshes its registers slower than the poll, so stored rows carry no new information. Drop the scan class to the device's real update period.

A measured 840 timestamps in that window, for example, is 840 / 3000 = 28 percent of the expected count — clustered in bursts, it fails here, at the driver stage, and no historian setting would have helped.

Check 2: count the stored rows #

Do not judge from a trend: trend clients downsample, interpolate and smooth, so they cannot tell you what the database holds. Count straight in SQL against the history tables:

  1. Note the window start and end timestamps from the Check 1 run.
  2. Count the rows stored for that tag between those two timestamps.
  3. Compare the count against the expected value from Check 1 — 3000 rows for that one-minute window.
  4. Open the store-and-forward status and confirm the memory buffer is draining rather than growing.

If the stored rows match, the tag path sustains the rate for this tag count and any earlier gap sat at the driver stage. If they fall short while Check 1 passed, tag-based history cannot sustain the rate on this gateway and database combination — the writes are backing up. Confirm the direction with gateway CPU load and the growing buffer before you change the architecture.

Mind the row arithmetic before you scale up. At the requested interval one tag generates up to 50 rows per second, so one day of logging is 50 × 86,400 = 4,320,000 rows for a single tag, and ten tags at the same rate produce 43,200,000 rows before compression removes any. A pass with one test tag does not carry over to a full signal list; rerun both counts with every tag enabled and the plant running normally.

Which logging path fits #

Logging path Holds the target rate? Use it when
Tag history, periodic mode, 20 ms target, polled Modbus TCP Treat as no — reported testing already showed misses at 100 ms Both checks pass at your full tag count
Python script calling system.tag.storeTagHistory Yes in reported testing, with batched writes and your own timestamps Check 1 passes and Check 2 does not
Wide table with multi-row inserts from a bounded queue Yes; bypasses tag history entirely You own the schema and need no native history trends on these signals
Log at the source, push blocks to the gateway Yes; the only path that guarantees spacing Check 1 fails — the sample clock must live in the device

One reported test on this shape of setup found that tag-based history would not reliably log every sample even at 100 ms, while a script calling the same store function did. Treat that as the practical boundary: on a polled TCP driver, any faster interval is unproven until your own two counts pass at full tag count.

Log the samples from a script #

system.tag.storeTagHistory is the documented Python scripting function that inserts rows into the tag history system, so the samples land in the same provider, the same tables and the same queries as tag-based history. That makes it the first replacement to try when Check 1 passes and Check 2 does not.

  1. Turn periodic history off on every tag the script writes — two writers on one tag produce duplicate rows.
  2. Timestamp each sample where it is born: take the time from the device's buffered block or from the tag change event, never from the moment the script happens to run.
  3. Queue samples in memory and flush them in batches from a timer or background thread. Do not call the function once per sample from the tag change thread; one batched call per second moves the same data at a fraction of the overhead.
  4. Size the in-memory queue to ride out a short database outage, and keep the flush interval short enough that the queue cannot grow without bound while the database stalls. Store-and-forward then absorbs the burst on the write side.
  5. Point the writes at tag paths that exist in the tag provider you name, and store honest quality codes — a bad value recorded as good poisons every later analysis.

Prove the stream is complete #

The count proves volume; timestamp deltas prove spacing. Sort the stored timestamps and subtract each one from the next. In a source-timestamped stream every delta equals the interval, and any delta of several intervals marks a gap — a delta three times the interval spans three sample slots and hides two missing samples. To grab recent timestamps for this diff without writing SQL, pull the last N stored records from a tag history query.

Run the delta check again with the full tag list and the gateway under normal load. The architecture is proven only when the row count still matches, the deltas come back clean and the store-and-forward buffer stays flat.

The decision for each case #

Commit by the two counts, not by the symptom:

  • Check 1 fails. Log at the source: the sample clock, the timestamps and the buffer all live in the PLC or edge device, which transfers blocks to the gateway at a slower poll. No gateway-side setting recovers samples the link never delivered, and this is the only path that guarantees spacing, because round-trip jitter, network load and gateway runtime all enter a polled driver's sample times.
  • Check 1 passes, Check 2 fails. Switch the write path: batched script inserts through the tag history system, or a wide table with multi-row inserts when native trends are not required on these signals.
  • Both checks pass. Keep tag-based periodic history for that tag count, and rerun both counts with every tag enabled before trusting it in service.
  • Identical values dominate. The device updates slower than the poll; drop the scan class to the device's real update period, because faster polling only duplicates rows.

If these analog trends back a safety decision — evidence that a trip actually occurred, for instance — the sample clock belongs in the device performing the function. A historian fed over a polled TCP link is a record, not a safety function.

Questions asked

Does a faster CPU fix the dropped samples at high logging rates?

Not on its own. The reported case already ran on a 2.4 GHz i7 and still lost samples, because the binding limits are the polled round trip on the driver side and insert throughput on the write side. Extra CPU helps only when the second count shows the store-and-forward memory buffer growing, which means the gateway has compute headroom but the writes are queuing. Run both counts before touching hardware.

What interval can tag-based history hold on a polled Modbus TCP link?

In one reported test, tag-based history missed samples at 100 ms already, so treat every faster interval on a polled TCP driver as unproven until your own two counts pass. The test is cheap: driver timestamps against window seconds divided by the interval, then stored rows against the same number. Whatever holds at your full tag count under normal load is the rate you can log.

Can samples lost in a confirmed gap be recovered afterward?

No. On a polled link nothing observes the moments between polls, so a window that came up short stays short permanently. Only logging at the source, with device timestamps and a buffer, prevents the same loss going forward, and only source-side protocols with event backfill can replay a gap after a reconnect. Polled Modbus TCP offers no replay, so treat any confirmed gap as gone.

Do script-inserted rows still show up in native trends and queries?

Yes. system.tag.storeTagHistory inserts into the tag history system, so the samples appear in the same provider, the same tag history queries and the same trend bindings as tag-based history. What changes is ownership: you supply the timestamps, the batching and the sample schedule, and you prove spacing with the timestamp-delta check instead of trusting the historian's periodic clock.

Keep reading

  • Troubleshooting

    Why Ignition tag history records only every 10 seconds

    History that lands only every 10 seconds, dropping peaks shorter than that, is the historical scan class at work: in the case traced here the Default Historical scan class sat at a 10-second interval while 1 second was expected. SQL Express, Windows 7 and the hardware were not involved. Read the interval on the tag's assigned scan class, set it to the rate your data needs, and prove the fix with a brief test peak in a history query.

    Edge computing and IIoT

  • Troubleshooting

    Event logging in Ignition Edge with one delimited string tag

    Arrays, datasets, UDTs and alarm associated data each break event logging on Edge: arrays split one event into one row per element, dataset history is not stored, and associated data cannot be queried centrally after sync. Historize a single delimited expression string tag in a tag group with rate negative one, trigger it from a tag change script, and parse the stored strings back into columns for tables and reports.

    Edge computing and IIoT

  • Comparison

    Ignition tag historian versus transaction groups

    Use the Ignition tag historian for trends: it logs by exception against a deadband, compresses what it stores (around 54% average compression observed in the field), and partitions data into monthly tables. Keep transaction groups wherever an outside SQL consumer such as a PHP report reads a table you designed. Run both, and give each tag one home based on who consumes it.

    Edge computing and IIoT

Log analog millivolt signals as booleans in Ignition