The full power of TDengine, now free forever for up to 5,000 tags.

Explore More

Calculate Usage from Historian Totalizers After a Rollover or Reset

Juno Qiu

November 9, 2026 /

Calculate Usage from Historian Totalizers After a Rollover or Reset

Subtracting two totalizer readings gives period usage only when the counter’s meaning and continuity are known. A rollover needs the documented rollover size and a bound on how many wraps occurred. A reset or meter replacement needs its own boundary evidence. Replacing every negative difference with zero hides consumption; adding a rollover constant to every negative difference can invent it.

For a historian engineer, the first task is to classify the cumulative signal before choosing an aggregate. This article concerns a nondecreasing cumulative quantity between defined discontinuities. A signed net-energy register, a reversible flow total or a batch counter with different semantics needs a different rule.

Establish the counter contract

Record the unit, data type, resolution, rollover behavior, reset conditions, instrument identity and available quality/status fields. Distinguish the largest displayed value from the size of a complete cycle. An unsigned integer covering 0 through 65,535 has cycle size 65,536, not 65,535.

Obtain this information for the actual register and device revision. A display may wrap while a wider communications register continues increasing. A power cycle may preserve one total and reset another. A separate rollover count is useful only if the integration reads it consistently with the base counter.

The public flow-meter calculation discussion includes the practical concern: hourly volume calculations across many meters, followed by a question about periodically resetting totals. It supports the need to handle discontinuities explicitly, not a general recommendation to change meter or PLC logic.

A known rollover has conditional arithmetic

Assume a fictional integer counter measures liters and wraps modulo 65,536. Its two good readings are 65,530 and 9, one minute apart. If the total increment is known to be nonnegative and less than one full cycle, usage is:

(9 − 65,530) mod 65,536 = 15 liters

Equivalently, six increments take the counter from 65,530 through wrap to zero, followed by nine more. This is a synthetic arithmetic example, not a specification for a real meter.

Evidence Permitted interpretation
Known modulo counter; interval increment below one cycle; no reset 15 L
Same endpoints; additional full cycles possible 15 L plus an unknown multiple of 65,536 L
Same endpoints; reset or replacement possible Usage cannot be recovered from these endpoints alone
Counter unit or scaling changed between endpoints Values need a documented transformation or separate epochs before subtraction

Even increasing endpoints do not prove that no wrap occurred. A full cycle followed by a small increment can finish above the previous reading. For modulo reconstruction, bound the total increment between accepted observations, not merely the number of visibly negative transitions.

For example, an independently justified maximum rate of 100 L/s over 60 seconds bounds usage at 6,000 L, below one cycle. That supports the single-cycle increment assumption for this fictional counter. Over 20 minutes, the bound becomes 120,000 L and the endpoints no longer identify a unique increment. A configured nominal rate is not automatically a physical upper bound; the source owner must validate it.

A reset creates a different problem

Suppose a resettable meter reads 1,250 L at 10:00, is reset at 10:03, and reads 20 L at 10:05. If the accepted reading immediately before reset was 1,280 L and reset started a new zero-based epoch, the interval usage is:

(1,280 − 1,250) + 20 = 50 L

Without the pre-reset total, the unknown increment from 10:00 until reset cannot be reconstructed from 1,250 and 20. Reporting 20 L would omit an unknown amount. Reporting a rollover-based total would impose a mechanism that did not occur.

Retain a reset event, its effective boundary and the final old-epoch and initial new-epoch values when the source supports them. For meter replacement, preserve both instrument identities and the approved relationship to the logical measurement. If a reset occurs between polls without sufficient evidence, flag the affected usage interval incomplete rather than assigning a precise total.

Flow’s official Counter aggregation method describes product-specific handling of negative changes and an optional rollover setting. That illustrates why aggregate settings matter. It does not prove that every negative change in another system means a reset, or that every historian uses the same algorithm. For TDengine TSDB calculations, review DIFF’s treatment of negative differences.

Check numeric fidelity and reporting boundaries

A totalizer can also stop changing numerically because its representation cannot preserve small increments at a large magnitude. Schneider Electric’s SCADAPack floating-point FAQ documents that failure mechanism for 32-bit floating-point accumulation. Enlarging a historian column after the source has lost an increment cannot restore it.

For an exact reporting period, obtain valid counter values at the required boundaries using a source-supported method. If only nearby readings are available, a difference measures usage between those readings, not necessarily the exact shift. Interpolation is an estimate and is particularly hazardous across a reset. State any allocation method and uncertainty beside the result.

Quality and identity remain part of the calculation. A bad zero is not a confirmed reset, and an out-of-order older reading is not a rollover. Sort by the chosen event-time contract, resolve duplicates and revisions, and retain unusable intervals visibly. The historian quality article explains why a numeric value alone cannot establish usability.

Validate before using the total

Use a controlled dataset containing normal increase, known one-cycle wrap, an unexplained negative change, a reset with and without its final value, and a gap long enough to allow additional wraps. Keep the expected outcome for ambiguous cases as unknown or incomplete; a test that always returns a number cannot demonstrate honest uncertainty.

Record the register definition, unit, identity/epoch, boundary rule, quality policy and accepted increment bound with the reported usage. Recalculate affected periods when late data or corrected reset evidence arrives. The result is trustworthy when its arithmetic and its continuity assumptions can both be checked.

Related Articles