A CTU on the end-of-line eye of a takeaway running 0.500 m/s read 12,480 at the end of a shift in which the palletiser stacked 12,116 cartons, and it had been drifting the same way, 2.6% to 3.4% high, for three weeks. Counting cartons was one contact and a counter, and there was nothing wrong with either of them. The 364 extra counts came from three places: 268 from strap ends and flaps that re-made the beam for 20 to 60 ms in the middle of a carton, 61 from things that blocked the beam for less than a tenth of a second, and 35 from a belt-running permissive in series with the eye that gave the counter a fresh edge every time the belt restarted with a carton sitting on the beam.
A counter counts edges. The whole job is deciding which edges are cartons, and that takes two timers and a rule about where the permissive goes.
Everything below is the end of the takeaway from the tracking article: a 5069-L320ER CompactLogix, a polarised retroreflective 42EF as PE_EOL 0.4 m before the palletiser infeed, into a 5069-IB16 with its 1 ms default filter, belt at 0.500 m/s measured with a chalk mark, products of 300, 600 and 1219 mm, and a smallest gap of 210 mm at this eye over a shift, measured the way the gapping article measures it. The counting logic runs in the 50 ms conveyor task until the last section, which moves it.
What the eye sees, in milliseconds
At 0.500 m/s the arithmetic is a division, and every number in this article comes out of it.
A 300 mm tote blocks the beam for 600 ms, a 600 mm carton for 1200 ms, the 1219 mm carton for 2438 ms, and the 210 mm gap between two of them clears it for 420 ms. The sensor answers in 1 ms and the 5069-IB16 adds 1 ms of filter, so the input image is never more than 2 ms behind the beam; the 50 ms task then samples that image, which turns each edge into a 25 mm uncertainty on the belt and, more to the point, means a short event is seen only if a scan happens to land inside it. A strap end that swings across the beam and re-makes it for 30 ms is caught by the 50 ms task on about six passes in ten, which is why the drift was never the same number two shifts running and why nobody could reproduce it by walking a carton through by hand. A re-make of 60 ms is caught every time.
Six passes in ten is a drift nobody can reproduce on demand.
None of those re-makes is the sensor’s fault. The 42EF’s output indicator flashes at 1.4 Hz when the received light is between 0.8 and 1.5 times the switching threshold, and the technical data calls that unstable light; an eye that has drifted into that band on a dusty reflector will chatter on every carton edge, and the fix for that one is a cloth and the green margin indicator, which comes on at 1.5 times. On this line the indicator was steady. The beam was genuinely being re-made, by a strap, and the sensor reported it correctly.

The shortest product blocks the beam for 600 ms and the shortest gap clears it for 420 ms. A strap re-makes it for 30. The timers below live between those numbers.
Three ways a good rung gets counting cartons wrong
Rung one, the way it was written: XIC PE_EOL XIC Belt_Run CTU Cnt_EOL
The general instructions reference says the CTU increments each time rung-condition-in transitions from false to true, and rung-condition-in is the whole rung in front of the counter, not the eye. With Belt_Run in series, the rung goes false when the belt stops and true when it starts again, and if a carton is standing on the eye at that moment the counter sees a fresh edge and counts it a second time. Thirty-five restarts in a shift with a carton on the beam, thirty-five extra. Take the permissive out of the count rung, and put it where it belongs, on the timer that qualifies the block, so a stopped belt freezes the qualification rather than manufacturing an edge.
Thirty-five restarts, thirty-five extra counts, and the counter did exactly what it says.
The second way is the re-make. A strap end, a loose flap, a label corner, anything that lets the beam through for a few tens of milliseconds while the carton is still on the eye, produces clear then blocked, and blocked is an edge. Two hundred and sixty-eight of them.
The third is the short block: a hanging piece of tape, a moth, the corner of a carton on the parallel lane clipping the beam as it turns. Sixty-one blocks of under 100 ms, each one an edge.
Three causes, one symptom. The count only ever goes up, never down.
The instinct on the second and third is to wind the module’s input filter up. The 5069-IB16 allows 0 to 50 ms, and the manual’s definition of the filter is that a transition is valid only if the input stays in the new state for the whole filter time, so a 50 ms filter does drop a 30 ms re-make. It also drops a 40 ms one only sometimes, passes a 60 ms one always, delays every real edge by 50 ms, and does nothing at all about the restart problem. The filter is for contact bounce and noise. Cartons need a rule written in the logic, where the numbers can be chosen from the product, not from a list of module settings.
Fifty milliseconds of filter buys nothing against a sixty-millisecond strap.
Qualify the block, arm on the gap, count the qualification
Two timers, one latch, and a counter that never sees the eye directly.
The first timer qualifies a block. PE_EOL blocked runs a TON, Blk_Q, with a preset of 300 ms, half the 600 ms the shortest product blocks the beam for. Anything shorter than 300 ms never reaches DN and is never counted; the 61 short blocks vanish. The belt-running permissive goes in series with this timer, so a stopped belt holds the timer rather than resetting the count rung, and because a TON clears its accumulator when its rung goes false, a stop-and-restart with a carton on the eye simply starts the qualification again from zero; the carton is counted once, when the 300 ms completes after the restart, or was already counted before the stop. Either way, once. The second timer arms the counter on a gap. PE_EOL clear runs a TON, Clr_Q, preset 150 ms, and its DN sets a latch Cnt_Armed. The count rung is XIC Blk_Q.DN XIC Cnt_Armed ONS CTU, and the same rung resets Cnt_Armed. A strap re-make of 30 or 60 ms never reaches 150 ms of continuous clear, so the counter is never re-armed inside a carton and the second edge is thrown away, however many there are. A real gap of 210 mm clears the beam for 420 ms, which re-arms it every time with 270 ms to spare. The 150 is chosen to sit above the longest re-make anybody has ever measured on this product, which was 60 ms, and well below the shortest gap the line can produce, and the two numbers are written on the rung as comments with the products they came from.
(* ConveyorTask - end of line count, one carton per qualified block *)
Blk_Q.PRE := 300; (* half the shortest product's 600 ms at 0.500 m/s *)
Clr_Q.PRE := 150; (* above the 60 ms strap re-make, under the 420 ms gap *)
TON(Blk_Q, PE_EOL AND Belt_Run); (* a block only counts if it lasts *)
TON(Clr_Q, NOT PE_EOL); (* a gap only re-arms if it lasts *)
IF Clr_Q.DN THEN
Cnt_Armed := 1;
END_IF;
IF Blk_Q.DN AND Cnt_Armed AND NOT Blk_Q_Last THEN (* rising edge of the qualified block *)
Cnt_EOL.CountUp();
Cnt_Armed := 0;
END_IF;
Blk_Q_Last := Blk_Q.DN;
The ONS, or the Blk_Q_Last bit in the ST version, is what the reference guide describes: the rest of the rung is true once per false-to-true transition, and the storage bit remembers the last state. It is doing the same thing the CTU already does internally, and it is there for a reason: with the ONS on the rung, the counter’s own edge detection is never presented with anything but a clean single-scan pulse, so nobody has to reason about whether an added permissive later will give the CTU a second edge. It will not, because the ONS will not.
Count the qualified block, arm on the qualified gap, and keep every permissive out of the count rung.

Rung 50 holds when the belt stops. Rung 51 never completes inside a carton. Rung 53 sees one edge per carton, whatever the strap does.
Two things the counter itself does that are worth knowing while it is on the rung. The reference guide says .CU is set true at prescan to prevent an invalid increment on the first program scan, so a carton on the eye at power-up is not counted by the transition into RUN; and the counter counts to a DINT limit that a carton line will not reach in a lifetime, so the reset is a management decision, not an overflow one. On this line Cnt_EOL is reset by the shift handshake from the MES exchange, after the accumulated value has been copied into the shift record, and the copy is done in the same scan as the reset so that no carton can land between them.
The task period, and when the module should count instead
The 50 ms task is the reason the drift was random, and it is also fine once the timers are in.
With the qualification logic, a 30 ms re-make that the task happens to see is a 30 ms clear that never reaches 150, and one the task does not see is nothing at all; both outcomes are a single count. The task period only matters if somebody wants the count to be exact to the carton within a second of it passing, or wants to measure the block time for a length check, and then the counting routine moves to a 10 ms periodic task the way the gap eye did, where the timers gain 40 ms of precision and cost the controller nothing it will notice. The scan time article has the measuring method for what a second periodic task adds.
Simple Count mode on the module is the wrong tool here, and it is worth saying why because it looks like the right one. The 5069-IB16 will count input pulses in the module at up to 500 Hz, the 5069-IB16F at 30 kHz, with the count compared against a preset and no task involved; but the module counts every valid transition, so it counts the strap re-make as faithfully as the task did, and there is no place in a module counter to put a 150 ms rule. Where the fast module earns its keep is diagnosis. The 5069-IB16F records a CIP Sync time stamp on each edge of each point with a stated ±10 µs accuracy, and its chatter detection flags a point that transitions more than a chosen count, 2 to 127, inside a chosen window, 1 to 10000 ms. Set that to three transitions in 500 ms on PE_EOL and the module tells you which cartons are the strap problem, with a time on each, before anyone has to stand at the eye with a stopwatch.
The module counts transitions. Only the logic knows which transitions were cartons.
What the number looked like, before and after
The manual count is the palletiser’s: layers times the pattern, checked against the stack count on the wrap station, and it is the only count the site trusts because a missing carton shows up as a hole in a layer.
The stack is the count the site trusts. The PLC has to earn the same trust.
Against it, the original rung ran high from the first hour and kept climbing, 364 over by the end of the shift, and the slope changed with the product: the 300 mm totes have no straps and contributed almost nothing, while the strapped 1219 mm cartons produced most of the 268 re-makes in the two hours they ran. With the qualified rung in place the difference over the same shift pattern was within three either way, and those three were traced to two side-by-side totes that arrived touching, which this eye cannot separate and which is a different article.

Worked from the article’s numbers, not a stock plot. The slope tracks the strapped product; the flat line is what a counter should look like against a stack.
The thing everyone checks first
The counter preset, the reset and the HMI.
A drifting count sends people to the CTU, and the CTU is the one part of the loop that cannot be wrong, because it does exactly one thing and the reference guide says what. Then the HMI numeric display, then whether the reset is firing twice. Put the eye’s raw bit and Blk_Q.DN on a trend at the task period for one hour of the strapped product before touching any of that, and count the edges on each trace against the cartons on the video from the wrap station. The raw trace will have more edges than cartons. The qualified trace will not, and the difference between the two is the number you were looking for.
Next step
Measure the block time of the shortest product and the clear time of the shortest gap at your belt speed, with a stopwatch or a TONR on the eye, and choose the two presets between them: the block qualifier under half the shortest block, the gap arm above the longest re-make you can provoke and under the shortest gap. Then take every permissive out of the count rung and put it on the qualifier. If the eye itself is chattering with no strap in sight, the light-operate and dark-operate article covers the indicator states that say whether it is margin, and the timer and counter instruction page is where the TON and CTU bits used here are laid out one at a time.