Keep the dose as one 16-bit BCD word. Load the two-word total with LDD, add the dose with the single-register ADD, and store back with OUTD to the starting word, V2212 with V2213 as its second word. Trigger the rung once per dose event, because power-flow-enabled math executes on every scan the input stays true.
A 16-bit BCD dose adds straight into a 32-bit BCD running total. Load the two-word total with LDD, add the one-word dose with ADD, and store the result back with OUTD from the starting word; the dose never needs widening. The part that bites is the trigger. LDD, ADD and OUTD are power-flow enabled, so a rung that stays true across scans adds the dose again on every scan. Drive the math from a one-shot contact, a differential contact or a self-resetting stage, and one dose event moves the total once. This page covers the widths, the two words behind a total at V2212, the trigger, a worked sum, and the ounces-to-gallons divide by K128 that usually follows a totalizer.
Can a PLC add a 16-bit BCD dose to a 32-bit BCD total?
Yes: load the two-word total with LDD, add the one-word dose with the single-register ADD, and write both words back with OUTD, so the dose stays 16-bit and the total stays 32-bit.
The accumulator in these math boxes is 32 bits wide, and that is why the mixed-width add works with no preparation. LDD brings V2212 and V2213 in as one eight-digit BCD value. ADD adds a single four-digit BCD word into that value, and the accumulator still holds a 32-bit result. OUTD writes the pair back out from the same starting address. There is no widening step for the dose and no second format to maintain. ADDD is the constant-friendly double-width add, so it is the wrong box for a dose that lives in a register; ADD is the box that takes the register.
Is 16-bit BCD the same as single precision?
No: single and double precision describe binary floating point sizes, while BCD width counts decimal digits, so a 16-bit BCD word holds four digits up to 9,999 and a 32-bit BCD pair holds eight digits up to 99,999,999.
The vocabularies collide because both are about size. Single precision is a 32-bit binary floating point format and double precision is its 64-bit version. BCD stores each decimal digit in four bits, so width translates straight into digits: 16 bit gives 4 digits, 32 bit gives 8. Pick instructions by format and operand width, and ignore the words single and double. Your dose stays under about 100 counts, so four digits carry it with room to spare. The total is the value that needs eight digits, because it grows with every batch.
Which words do you reserve for a 32-bit total at V2212?
V2212 and V2213, the next address up: a 32-bit BCD total occupies the starting word and the one above it, so nothing else in the program or on the panel may use V2213.
It is not V2211. The pair is V2212 and then V2213, two consecutive words handled as one value by LDD and OUTD. Before the first run, list every other use of V2213: adjacent words are where counters, retentive ranges and panel tags tend to land. If something else claims V2213, move the total or move the other assignment. The eight-digit total needs both words clean, and one stray reference will corrupt it silently.
Why does the BCD total climb on every scan?
Because LDD, ADD and OUTD are power-flow enabled: while the rung input is true the box executes again on every scan, so 50 enabled scans at a dose of 100 counts add 5,000 counts to the total.
That is the documented behaviour of the boxes, not a fault in them. Conditions that ride across several scans are commoner than they look: a batch-done bit the recipe holds on, a dose signal that lingers, a pushbutton a person holds a moment too long. Each extra scan carries one more full dose. At a 10 ms scan time, 50 enabled scans is about 0.5 seconds of a held input, which is shorter than a person's typical 1-second button press, so even a quick push can carry dozens of extra doses.
| What you see | What it points to | Next check |
|---|---|---|
| Total gains the dose again and again after one event | The math rung input is still true across scans | Put a one-shot in front of the boxes and confirm one gain per event |
| Total jumps by a strange amount, or the panel disagrees with the PLC | Width, format or word overlap, most often V2213 doing double duty | Monitor V2212 and V2213 live, then list every reference to both words |
| Divide box accepts K128 but the double-width divide demands an alias | The plain divide takes a constant, the double form takes a register | Keep the constant form, or store 128 in a word and reference it |
For the counting side of held inputs, how many PLC scans an HMI momentary button bit stays on works the same scan arithmetic from the input end.
How do you add once per dose event instead of every scan?
Put the math behind a trigger that is true for one scan per event: a one-shot or differential contact, a PD coil, or a stage the event sets and that resets on its own last line.
A one-shot exists to pass power flow for exactly one scan on a false-to-true edge, which is what a totalizer needs. The PD coil and the differential contact are the same idea in coil form.
The stage method reaches the same result with sequence logic: the dose event sets the stage, the stage runs LDD, ADD and OUTD once, and the stage's last line resets it, which also gives the end-of-cycle conversions, such as ounces to gallons, a natural home. Whichever you pick, prove both edges: the trigger must be false before the event, true through it, and false again after it. The reset side is where one-event logic leaks, and the reset path that lets a PLC flag trigger an event once shows what to look for. If the one-shot behaves on its own rung but misfires when it feeds a second one, a page on a one-shot instruction that will not trigger on a second rung works through that exact fault.
Example: what does one dose of 100 add to a total of 123,456?
One dose of 100 counts moves the total from 00123456 to 00123556: LDD V2212 loads the eight-digit value, ADD V3000 adds 0100, and OUTD V2212 stores 00123556 back across V2212 and V2213.
V3000 stands in for your dose word; use whatever address actually holds it. In decimal, 123,456 + 100 = 123,556, and the BCD digits tell the same story:
LDD V2212 accumulator = 00123456 (123,456)
ADD V3000 accumulator = 00123556 (123,456 + 0100)
OUTD V2212 V2212/V2213 = 00123556 (123,556)
Now the same numbers with the trigger missing. Suppose the enabling condition stays true for 50 scans, an illustrative count, because your scan time decides the real figure. At a 10 ms scan that is about 0.5 seconds. The box adds 0100 on every one of them: 123,456 + (50 × 100) = 123,456 + 5,000 = 128,456. After one physical dose the total reads 5,000 high, and the error repeats on every event the contact overstays.
Why does DIVD refuse the constant K128 when DIV accepts it?
Operand forms: DIV takes a constant, so K128 divides ounces by 128 to give gallons, while DIVD accepts only a register reference, so the constant must first live in a word; ADD and ADDD are the opposite pair.
128 fl oz makes 1 US gallon, which is where K128 comes from. DIV takes a constant or a register, so it divides straight away. When the double-width divide prompts you to create an alias, it is asking for that register reference, and 128 stored in a spare word satisfies it. Choose the box by the operand you already have. Mind the quotient: an integer divide of 1,000 fl oz returns 7 gal and drops the remainder, because 7 × 128 = 896 and 1,000 - 896 = 104. If the recipe needs the remainder, add a multiply-and-subtract step. When digits start going missing in chained BCD math, the fix for a PLC BCD conversion that loses digits in division traces where they go.
What do you check before trusting the new total?
Trigger exactly one real dose with the machine in a safe state, then confirm the two-word total rose by that dose and by nothing more: 123,456 plus 100 must read 123,556 in both words and on the panel.
- Monitor V2212 and V2213 live and read the pair as one 32-bit BCD value while the event fires.
- Let the trigger clear, hold the dose input low for at least 5 seconds of scanning, and confirm the total stays put.
- Search every rung and panel tag for references to V2213 and confirm they all belong to the total.
- Compare the panel display with the monitored pair; both must show the worked example's 00123556.
Take the machine out of automatic and treat every forced input as a live command while you run this test. If the total comes out wrong, stop totalizing and inspect the rung enable, the operands and both words; do not compensate for a double trigger by changing widths.
Recommendation: keep the dose as one 16-bit BCD word, total it with LDD V2212, ADD V3000, OUTD V2212, and drive those boxes from a one-shot contact or from a stage that resets on its own last line. Widen the dose to two words only if a single dose can pass 9,999, and never because the total is wide.
Questions
Should the dose register be widened to 32 bits anyway?
No, while a single dose stays at or under 9,999. Widening costs a second word, and every place that writes or displays the dose must then handle two words instead of one. Widen only when one dose event can exceed 9,999. The width of the total never forces the width of the dose; the 32-bit accumulator absorbs the four-digit addend either way.
What happens when the eight-digit total reaches 99,999,999?
The digits are full, and the eight-digit BCD pair has nowhere to hold a ninth. Plan the reset before you reach the cap: clear or archive the total at a batch or shift boundary while the count is comfortably below 99,999,999, and move the archived values into words your panel or a data log reads. What the value does on one more carry is not documented here, which is exactly why the reset comes first.
Does the same every-scan rule apply to subtracting from the total?
Yes. Any power-flow-enabled math box repeats on every scan its input stays true, so a correction or a purge subtraction needs the same one-event trigger as the addition. Use the matching single-word subtract instruction between the same LDD and OUTD pair, and prove the trigger's edges with one controlled event before you let the machine count on it.
Why does the panel show only part of the total?
The panel tag is reading one word of a two-word value. An eight-digit BCD total lives in V2212 and V2213 together, so set the tag's data width to the 32-bit two-word form starting at V2212. A single-word tag shows four of the eight digits and can never agree with the total; fix the tag before you suspect the math.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.