Bind the HMI numeric display to a second PLC tag that rounds the live counter to the nearest five counts, and leave the raw counter wired to control. The article gives the rounding formula, the integer version for one rung, the negative-count trap, a sixteenth-of-an-inch scaling example, and the checks to run before operators trust the readout.
An HMI readout that changes one count at a time looks broken even when the machine is fine. A quadrature input adds four counts per encoder line, so the raw value can move a dozen counts in a second and the last digits blur. The fix belongs in the presentation: compute a second tag that rounds the live count to the nearest five, and bind the numeric display object to that tag. The raw counter keeps driving the machine, unchanged. Where the readout sits on the machine is a separate choice; how to display a PLC counter value where operators can see it covers placement. This article gives the rounding formula, the integer version that fits one rung, the negative-count trap, the decimal places that keep a sixteenth-of-an-inch readout exact, and the checks to run before operators trust the number.
Why one count is too much display
A raw count is accurate and unreadable at the same time. On a carriage scaled at 0.0625 in per count, a slow drift walks the readout through 77.3125, 77.3750 and 77.4375 within a couple of seconds. Operators read the last digits, and digits that change faster than a person can read them register as jitter. Set the step at the smallest change an operator should notice: five counts here is 0.3125 in, a change a person can see, note and act on. Everything finer stays in the raw count, which stays wired to the control logic.
What you need
- Editor access to the PLC program that owns the counter.
- The HMI project with the numeric display object.
- The count-to-unit scale: inches, millimeters or pieces per count. Take it from the commissioning notes, or measure it: move the axis a known distance and divide the distance by the count change.
- The raw counter tag name and its data type.
- A test window with the machine stopped or on hand jog.
Steps
- Confirm the scale. The running example uses 0.0625 in per count, one sixteenth of an inch. Five counts is then 5 × 0.0625 = 0.3125 in. If the program already scales this counter somewhere, use that scale and add no second one.
- Add a display tag. Same data type as the raw counter, named for what it is, so nobody wires it into an interlock. These two names are examples; use your project's naming. If the count can pass 32,767, the tag and the HMI object both need a 32-bit type: a 16-bit object wraps 32,768 to -32,768. A mismatch between tag and object truncates or wraps a value, and changing an HMI tag data type without rebuilding every object is the clean way to fix a type across a whole project.
- Round to the nearest step.
display_count = round(live_count / 5) * 5. The integer version is(live_count + 2) / 5 * 5with integer division: the +2 is half the step, 5 ÷ 2 = 2.5 floored to 2, and an odd step means no whole count ever sits exactly on a tie. This holds for counts of 0 and up. If the axis can run below zero, integer division can truncate toward zero and misround: (-3 + 2) ÷ 5 = 0 where the nearest step is -5. Use a floating-point divide with the round function for a signed range, then test -1 through -7: expect 0 for -1 and -2, and -5 for -3 through -7. - Scale once, in the PLC.
display_in = display_count * 0.0625. One scale, applied in one place. The panel adds decimal places; it never adds a second scale factor. - Set the object format. Four decimal places, because a 0.3125 in step has four. Leave the object's own scaling off. Setting raw-to-engineering scaling on a numeric object works the same way as showing decimal flow values on an HMI numeric display.
- Compute every scan. Derive the display tag fresh from the live count on every scan and store nothing. A restart then needs no extra logic, and a count that jumps several steps in one scan still lands on the right step.
- Bind the object to the display tag. Leave the raw counter tag to the control logic. If the object reads zero or stays blank after binding, check the tag address first.
Worked example: a saw carriage read in sixteenths
The carriage counter reads 1,237 counts. The raw position is 1,237 × 0.0625 = 77.3125 in, which is 77 5/16 in (0.3125 × 16 = 5). The display tag rounds it: (1,237 + 2) ÷ 5 = 1,239 ÷ 5 = 247 with a remainder of 4 dropped, then 247 × 5 = 1,235 counts. Scaled: 1,235 × 0.0625 = 77.1875 in, shown as 77.1875, which is 77 3/16 in (0.1875 × 16 = 3).
| Raw count | Display tag | Readout |
|---|---|---|
| 1,233 | 1,235 | 77.1875 in |
| 1,237 | 1,235 | 77.1875 in |
| 1,238 | 1,240 | 77.5000 in |
| 1,242 | 1,240 | 77.5000 in |
| 1,243 | 1,245 | 77.8125 in |
Every display move is 5 counts, 0.3125 in, and the raw count keeps its single-count resolution underneath. If the carriage jumps from 1,230 to 1,249 between scans, (1,249 + 2) ÷ 5 = 250 and the display lands on 1,250 counts, 78.1250 in, in one move; a tag that added 5 per scan would have needed four scans to catch up.
How to check it worked
Run these with the machine stopped or on hand jog, before the readout goes into service.
- Jog across a boundary in both directions, say 1,236 to 1,240 and back. The raw count moves by 1s, the display by 5s. The display holds 1,235 until the raw count reaches 1,238, steps to 1,240, and returns to 1,235 on the way down at 1,237.
- Watch the screen through a minute of slow drift: one change at a time, no flicker between two values.
- Power the HMI down and up, and restart the PLC program. The display recomputes from the live count, with no stored value to go stale.
- Reset the counter the way a shift change does; the display follows the new count. If the shift total matters, save the previous count before the reset.
- Trip the machine's own count-based function, a cut length or a batch mark. It fires at the raw count, 1,237, while the display shows 1,235: control logic reads the raw tag, and only the readout is rounded.
When five is the wrong step
Five counts is right when one count is finer than any operator needs and the noise sits within a couple of counts. Pick the step from the smallest change an operator should notice: a batching count worth one piece per count shows every count, and a rough position fluttering plus or minus 4 counts needs a step of 10, which clears the whole 8-count noise span. If the count feeds a control decision, a cut length, a batch total or an interlock, that logic reads the raw tag; the rounded tag exists only for the screen. And if the same number belongs on a floor board by the line, that is a separate screen fed separately; live factory data display: signage or dashboard? covers the split between the two.
Recommendation: Round in the PLC with a derived tag: step of five counts on a readout scaled at 0.0625 in per count, four decimal places on the object, raw counter left wired to control. Skip quantization when the operator needs single-count resolution, and add hysteresis to the display tag when the count parks near a step boundary.
Questions
The display still flickers between two adjacent steps. What changes?
A raw count parked on a boundary does this: with a 5-count step, 1,237 rounds down and 1,238 rounds up, so noise of plus or minus 2 counts flips the readout between 1,235 and 1,240. Add hysteresis: update the display tag only when the raw count has moved a full step, 5 counts, beyond the value now shown. The readout then lags by up to one step, and the flicker stops.
Can the HMI show the count as a fraction like 77 3/16?
Most numeric display objects format decimals only; a fraction such as 77 3/16 is a text string, and a text object is a different object. Check the format list configured on the object in your HMI project before promising a fraction readout. The dependable route is the decimal equivalent: scale in the PLC at 0.0625 in per count, show four decimal places, and the readout prints 77.1875, which an operator can read straight off the tape as 77 3/16.
Does the rounded display survive a power cut and restart?
It comes back correct when the tag is computed every scan from the live count, which is how the steps in this article work: nothing is stored, so there is nothing to go stale. A latched version, one that adds 5 counts each time a condition trips, keeps its last value through a power cut and restarts wrong unless the program initializes it from the raw counter at startup. Prefer the computed tag.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.