Configuring PLC Flow Totalization Without 1,440 Tags

Brian Holt7 min read
Data AcquisitionOther ManufacturerTutorial / How-to
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

The flow display changes normally, but the PLC has no simple way to report gallons used over the last 24 hours without creating 1,440 storage locations. Do not build 1,440 copy instructions unless the minute-by-minute history has a defined consumer. If the required result is one daily volume, integrate the flow rate in a periodic task and capture the accumulated value at the reporting boundary.

Reject the usual snapshot fix first

A once-per-minute snapshot records flow rate, not volume. Adding those 1,440 readings produces a valid volume only after applying the sample interval and the correct engineering-unit conversion. It also assumes each sample represents the entire minute, so fast flow changes between samples become measurement error.

Use one of two designs:

Requirement Design Main control
One gallons-used result Integrate flow in a 1-second periodic task Verify units, numeric range, and daily transfer
Minute-by-minute history Store 1,440 samples through pointer addressing Limit the index, reset it at the boundary, and prevent overwrites

Pointer addressing is covered by help topic P238. It lets one storage instruction use an incrementing destination rather than 1,440 separately written instructions. Use it only when another system needs the samples for trending, audit, or later analysis.

Check: Confirm whether the required deliverable is a daily volume, a minute history, or both. Do not proceed until the units and data consumer are written down.

Identify what the sensor value represents

Read the scaled PLC value and determine whether it represents flow rate, pulse count, or an accumulated volume. These signals require different calculations:

  • For gallons per minute, add flow rate × elapsed seconds / 60.
  • For gallons per second, add flow rate × elapsed seconds.
  • For a pulse input, count new pulses and multiply by the documented gallons per pulse.
  • For a sensor value that already reports total gallons, subtract successive readings and handle its rollover according to the device documentation.

Do not integrate an already-totalized value as though it were a rate. Do not use a nominal task interval if the calculation actually runs in an irregular scan; multiply by measured elapsed time or move the calculation into the periodic task.

Check the sensor scaling at zero and at a known nonzero operating point. A stable PLC number with the wrong engineering units will create a stable but wrong daily total.

Check: Manually calculate the expected increment for one execution. For a gallons-per-minute input and a 1-second task, the increment must equal the displayed rate divided by 60.

Configure the one-second accumulation task

Run the totalizer from a periodic task with a 1-second interval. Keep the calculation in that task rather than triggering it from a free-running scan and a one-second timer bit; the timer-bit approach can miss or repeat an event when scan timing, task priority, or logic order changes.

EVERY 1 SECOND:
    increment = flow in gallons per minute / 60
    running gallons = running gallons + increment

Clamp or reject invalid input before accumulation according to the process design. A negative rate may represent reverse flow, a permitted net-flow measurement, an analog underrange, or a failed instrument. Decide which case applies instead of silently forcing every negative value to zero.

Gate the calculation with a valid-data condition. During startup, communication loss, or sensor fault, either hold the total or apply the documented fallback behavior. Record a quality indication so operators can distinguish zero usage from missing measurement.

Check: Apply a steady test value and watch several executions. The running total must increase once per second by the calculated increment, with no duplicate additions when other PLC tasks run.

Select registers that cannot overflow or lose resolution

Choose storage from the maximum credible flow and the longest time the total may run without reset. Calculate the largest daily quantity from maximum flow multiplied by the reporting duration, then compare it with the numeric range and resolution of the selected register type.

A split accumulator can use a DF register for the running value up to 1 kgal and a DD register for whole kgal. At each rollover, subtract 1,000 gallons from the fractional register and add one to the whole-kgal register. Reconstruct the total as whole kgal × 1,000 + fractional gallons.

IF fractional gallons >= 1000:
    fractional gallons = fractional gallons - 1000
    whole kgal = whole kgal + 1

Use subtraction rather than clearing the fractional value. Clearing discards any amount above the threshold. If one task execution could add more than 1,000 gallons, repeat the rollover operation until the fractional value is below the threshold.

Floating-point storage provides fractions but eventually loses small increments as the accumulated magnitude grows. Integer storage avoids that behavior when the sensor resolution can be represented as scaled units. Select the method from the required resolution and calculated range.

Check: Force or simulate a value just below 1,000 gallons, add a known increment that crosses the boundary, and confirm that the reconstructed total changes by exactly that increment.

Capture the daily result before resetting

Separate the live accumulator from the completed-period result. At the boundary, copy the reconstructed volume into a retained daily-result location, mark the result valid, and then prepare the live accumulator for the next period. This ordering prevents the HMI or reporting system from reading zero between the reset and the copy.

  1. Detect the reporting boundary once.
  2. Copy the complete accumulated volume to the daily result.
  3. Update the result timestamp or period identifier.
  4. Clear the live accumulator and its rollover storage.
  5. Block a second execution of the boundary logic until the boundary condition clears.

Define whether “day” means a fixed 24-hour interval or a local calendar day.24 × 60 × 60. A calendar-day trigger can produce a different elapsed duration when the controller clock changes, so a timestamped result and actual elapsed time are needed where clock adjustments matter.

If 1,440 samples are also required, increment the pointer only after a successful write. Limit it to the allocated sample range, define what happens when the range is full, and reset it with the same single-shot boundary event.

Check: Simulate the boundary twice. The first event must publish one result and reset the live total; holding the boundary condition true must not publish or reset again.

Prove the complete measurement chain

Test with a stable input that permits an independent calculation. Record the initial total, applied flow rate, start time, stop time, final total, and quality status. For a constant gallons-per-minute signal, expected volume is rate × elapsed seconds / 60. Compare that value with the PLC result before relying on a full-day run.

  1. Verify zero flow adds no volume.
  2. Verify a known steady rate produces the calculated increment.
  3. Verify start, stop, and changing-rate conditions.
  4. Cross the 1-kgal rollover if the split DF/DD design is used.
  5. Trigger the daily transfer and confirm the reported value remains available after the live reset.
  6. Restart the controller and confirm retained and non-retained values behave as the operating requirement specifies.

For a pointer-based minute log, inspect the first location, a middle location, and the final location. Confirm that exactly one sample is written per minute and that the pointer never addresses storage outside the allocated block.

Check: The independently calculated volume, live accumulator, captured daily result, and external display must agree within the measurement resolution selected for the sensor and registers.

FAQ

Why does adding 1,440 flow readings give the wrong gallons?

Each reading is a rate snapshot, so it must be multiplied by its represented time and converted to gallons. A 1-second totalizer captures changing flow more accurately than treating each minute sample as constant.

Why does the PLC total stop changing at a large value?

The accumulator may have reached its numeric range or lost enough floating-point resolution that a small increment no longer changes it. Calculate the maximum total and use scaled integer storage or a split DF/DD accumulator sized for that range.

Why does the daily total reset twice?

The boundary condition is probably active for more than one execution. Use a one-shot event, copy the completed total first, and block another reset until the boundary condition clears.

When should I stop troubleshooting the PLC totalizer?

Stop here if pointer addressing reaches storage outside the allocated block, the task does not execute at the configured 1-second interval, or the sensor units and scaling cannot be verified. Do not run unbounded indirect addressing on production equipment. Escalate to official PLC support with the controller identification, task configuration, register types, sensor units, and observed test results.

Back to blog