IMD SolutionComputing LibraryShop main store

Troubleshooting

Why a 40 Hz tag historian stores duplicate rows

Edge computing and IIoT Published 7 min read By IMD Solution engineering team

Short answer

The duplicates are the historian sampler outrunning the OPC subscription: a 40 Hz scan class re-stores the last delivered value on every execution while OPC delivers roughly 10 Hz, so each real value lands up to four times. Confirm the database has one writer, measure the delivery period from the raw rows, then store at the delivery rate, log on change, or buffer samples in the PLC and read them in blocks.

On this page
  1. Read the duplicate pattern in the raw rows
  2. Why the sampler outruns the subscription
  3. Isolate the delivery ceiling before changing anything
  4. Stop the repeats: store at the delivery rate
  5. Capture the full source rate in the PLC
  6. The decision for each case
  7. Questions asked

The repeated rows in the history table are not a database fault and almost never a second writer: the historian sampler is outrunning the OPC subscription. A tag group set to 40 Hz stores the tag's current value on every execution, while the OPC server delivers new values at roughly 10 Hz, so each real value lands in the table up to four times. This article shows how to read the duplicate pattern in the raw rows, isolate the effective delivery rate, stop the repeats in the historian configuration, and capture the full source rate in the PLC when the process needs every sample.

Read the duplicate pattern in the raw rows #

Pull a window of raw rows for the single tag path, sort it by timestamp, and measure three spacings: between rows that share a value, between rows where the value changes, and across the rate at which repeats begin. On the installation behind this checklist — one gateway, one SIMATIC S7-1500 publishing over OPC, and a single repeating tag — the pattern read as follows.

Observation in the raw rows What it proves
The same value stored twice, timestamps one sampler period apart Two executions of the sampler ran with nothing new delivered in between
Rows where the value changes clustering about 100 ms apart The effective delivery period — slower than the requested rate
Repeats first appearing from 8 Hz upward and worsening above it Delivery jitter leaves gaps longer than the sampler period once the two periods close on each other
A tag change script that never exceeds about 10 Hz, whatever the scan class says The script only sees values the subscription delivers, so it inherits the delivery ceiling
A direct data block read sustaining about 40 Hz with no duplicates The controller produces every sample; the limit sits in the OPC path, not the PLC program

Every row of that table points at one mechanism: storage that executes faster than its source delivers. The repeats are honest records of a stale value, which is also why their spacing looks irregular — delivery jitter turns the stale re-stores into pairs and clusters instead of a fixed count.

Why the sampler outruns the subscription #

An OPC client requests a refresh rate; the OPC server — here the controller itself — is free to answer more slowly, and a PLC services subscriptions with whatever cycle time is left over after the program. Even a delivery period around a tenth of a second is already fast for OPC in plant practice. Siemens documents the effect for the S7-1500 OPC UA server: a client requesting 100 ms updates receives messages every 200 ms, because the server enforces its own minimum publishing interval. The same document places the load trade-off on the CPU side, where the minimum cycle time lives in the device configuration under Properties > Cycle.

The historian side compounds this. The Sample Mode setting of the tag history configuration determines how often storage checks whether the tag's value should be stored; when that check runs on every execution of the tag group, it stores the last delivered value again. The arithmetic, with the delivery period about 100 ms and the sampler period 25 ms: up to 100 / 25 = 4 rows store per delivered value, assuming every execution writes one row. Jitter turns that fixed ceiling into pairs and clusters with irregular offsets, which is exactly what the raw rows show. No historian setting can recover the samples the controller never delivered — it can only stop storing the stale ones.

The same mechanism appears at slower speeds in other installations: tag history that records only every 10 seconds because the scan class runs ahead of delivery is described in why Ignition tag history records only every 10 seconds. When the sampler outruns the source entirely, the symptom can invert into missing samples instead of repeats — why Ignition history misses samples at 20 ms intervals covers that variant.

Isolate the delivery ceiling before changing anything #

  1. Confirm one writer. Query the historian database for active connections and check which hosts they come from. A backup restored onto a test server or an engineer's laptop produces a genuine second gateway inserting repeats — the one cause here that is not oversampling. This installation had exactly one gateway and one database client, which eliminates it.
  2. Measure the effective delivery period. Keep only rows where the value changed and time-difference consecutive timestamps; that delta is the pace the subscription actually delivers under present load, and it is the one number every later setting depends on.
  3. Count repeats per distinct value inside one delivery period. Two to four rows sharing a value with irregular spacing confirms oversampling; a fixed double insert at a constant offset would point at a second stream instead.
  4. Find the onset rate. Raise the tag-group rate (the scan class) in slow steps and record where repeats first appear — that onset marks the delivery ceiling with the PLC loaded exactly as it is now, and it moves if the program's load moves.
  5. Read the data block directly, outside OPC, from a small script over the controller's native Ethernet protocol, and log what arrives. On this installation the direct reader sustained the source rate with no repeats, which places the ceiling firmly in the OPC path.

Stop the repeats: store at the delivery rate #

These changes remove the duplicates; none of them adds samples the subscription never delivered. Use them when capture at roughly the delivery pace is enough for the application.

  1. Switch the tag's storage to on-change logging. A row is stored only when OPC delivers a new value, so repeats disappear entirely; the cost is that unchanged intervals produce no rows. One edge case to know beforehand: why an On Change tag stores the same value every second explains when a slow-changing tag still appears to repeat under on-change storage.
  2. If the application needs rows at a fixed cadence, set the tag-group rate to the measured delivery period, not the requested one, and read held values between deliveries as what they are: the last confirmed reading.
  3. Enable history at one level only. When a UDT definition and its instance both enable history, verify the table holds a single row stream per tag path afterwards; two streams for one path produce a duplicate pattern of their own.
  4. Do not reach for a tag change script as a rate workaround. It receives only the values the subscription delivers, so it inherits the same ceiling whatever the scan class says — the measured cap sat at the subscription's own pace.

Capture the full source rate in the PLC #

When the process needs every sample, move the sampling into the controller and transport blocks instead of single values:

  • In a cyclic task running at the source period, write each sample into an array of structures holding the value, the PLC's own timestamp, and a running sequence counter.
  • Size the array for the read interval plus margin. Worked example: at 40 samples per second and a 1 s read interval, the array needs 40 samples/s × 1 s = 40 samples at minimum; 80 samples leaves headroom for one missed read cycle.
  • Read the whole array in one block transaction at a slower cadence — once per second, for example — and write the buffered rows to storage with the PLC timestamps preserved.
  • Judge gaps from the sequence counter, not from arrival time. Gateway timestamps record delivery; the sequence counter records sampling.

On this installation the direct block reader sustained the source rate with no duplicates, which is the proof that the controller side supports the plan. One protection note before you build it: a block reader needs the CPU protection setting that permits external access to data blocks, so grant the narrowest access the firmware allows and keep the reader host on the OT network segment. If the reader service should not share the SCADA host, run it on its own fanless mini PC on the same network segment.

The decision for each case #

  • Capture at roughly the delivery pace is enough → switch to on-change logging or set the tag group to the measured delivery period. The repeats stop immediately and nothing on the controller changes.
  • Fixed-cadence rows are required for dashboards or shift totals → set the tag group to the measured delivery period and accept held values between deliveries as the honest record.
  • The full source rate is the requirement — a waveform, a transient, a custody-transfer calculation → buffer in the PLC and read blocks with PLC timestamps. Do not try to push the subscription faster; the server's documented minimum publishing interval sets that ceiling.
  • Repeats survive both fixes → audit database connections after every gateway backup restore on the network; a second live instance is the only cause left standing.

Questions asked

Does each duplicate row mean two measurements or one?

One. The sampler stored the tag's current value a second time because no new OPC update had arrived, so both rows carry the same reading. A trend line draws a short plateau instead of the real step, and averages over the window lean toward the held value. Counting rows per distinct value in the raw table shows how many repeats each delivery produced.

How do I measure the effective OPC delivery rate?

Pull raw rows for one tag path, keep only the rows where the value changed, and time-difference consecutive timestamps. On the system described here that delta measured about 100 ms, so delivery ran an order of magnitude slower than the requested rate. Repeat the measurement during a busy production window, because the ceiling moves with the controller's load.

Will raising the scan class make an S7-1500 OPC UA server deliver faster?

No. Siemens documents a minimum publishing interval for that server, so a fast request is answered at the slower minimum; in the documented example, messages go out every 200 ms. Read the server's documented minimum sampling and publishing intervals before you raise the request, then set the historian from the delivery you actually measure, not from the number you asked for.

Can the direct block reader replace the tag historian?

No, it feeds it. The reader pulls buffered samples out of the controller and writes them to their own table with the PLC timestamps, while the historian stays the query layer for trends and dashboards. Keep the sequence counter in every row so a missed block read shows up as a visible gap instead of silently thinning the record. On the described system the reader sustained about 40 Hz with no duplicates.

Can I just slow the PLC task down to the delivery rate instead?

Only if the process itself does not need the faster cycle. Slowing the controller task changes what is measured, not just what is logged, so a signal that genuinely steps every 25 ms loses information at the source. Slow the historian sampler instead, and leave the source task alone unless the process tolerates the slower cycle.

Keep reading

  • Troubleshooting

    Why an On Change tag stores the same value every second

    On Change history writes a row on any change event, and a quality change is an event. An overloaded OPC device flips between Good and Good Overload on successive polls, so a tag on a one-second tag group stores its unchanged value every second. Moving the tags to a slower tag group kept quality Good and stopped the repeats.

    Edge computing and IIoT

  • How-to

    Connecting a Yokogawa ExaOPC server to Canary Historian

    Yes. Canary Historian's OPC client collector reads tags straight from ExaOPC, Yokogawa's OPC server for CENTUM, over DA or UA with no custom driver. Run the DA collector on the ExaOPC host or a same-domain host: cross-host DCOM is where these links break.

    Edge computing and IIoT

  • How-to

    Deploying Edge Data Store in Docker on a controller PC

    Run Edge Data Store as a Docker container on the controller-class edge PC and let its OPC UA adapter ingest the local server over localhost. Define egress targets, buffering and forwarding schedules in the JSON configuration, size the buffer from tag count, scan rate and outage target—50 tags at 1 event/s across an 8-hour outage is about 288 MB—and sign off only after a live pulled-cable test.

    Edge computing and IIoT

Power Chart export shows duplicate history rows