AutomateDirectUSAMotion LibraryIndustrial monitors & PCs

Troubleshooting

When a scan time misses an encoder cam window

Servo and stepper motion Published 6 min read By AutomateDirectUSA engineering team

Short answer

A scan-based input only catches a cam window longer than the input filter, the input update and the scan together. A 1-degree window at 12 rpm lasts 13.9 ms, so a 14 ms scan drops a few windows in a hundred. Cut the detection period below the window, or latch the event with a capture input.

On this page
  1. Turn the cam window into milliseconds first
  2. Why the window disappears between scans
  3. Likely causes in the order to check them
  4. Worked example: the arithmetic behind a five-in-a-hundred miss
  5. The decision for each case
  6. Questions asked

A scan-based input only catches a cam window that is still on when an input update lands inside it, so the whole detection path — input filter, input update and scan together — has to fit inside the window's on-time. When the on-time comes out at or below the scan period, windows start vanishing entirely between samples, a few percent at a time — the symptom in the worked example below. That is a timing miss, not a wiring fault, and the fix is to shrink the total detection period below the window, or to move the event out of the scan and latch it in hardware. The sections below give the window-time arithmetic, the checks from cheapest to most expensive, and the decision for each case.

Turn the cam window into milliseconds first #

Compute the window's on-time before touching any program or hardware. For a constant shaft speed:

window time (ms) = (window angle / 360 degrees) × (60,000 / shaft speed in rpm)

At 12 rpm one revolution takes 60,000 ÷ 12 = 5,000 ms; divide by 360 and a 1-degree window lasts 13.9 ms. That number, not the encoder's resolution, decides everything that follows. A one-degree shortcut with the same arithmetic: window time in ms equals 166.7 divided by the rpm. Window time is inversely proportional to speed — at 24 rpm the same 1-degree window lasts 6.9 ms, and at 6 rpm it lasts 27.8 ms — so always size against the fastest speed the shaft ever sees.

Measure the actual shaft speed rather than assuming it from the machine's stroke rate; calculating RPM from an absolute encoder position difference shows one way to get it from the encoder itself.

Why the window disappears between scans #

In the usual scan model, the input module copies every input's filtered state into the input image, and the program runs on that copy until the next update. A pulse that starts just after one update and ends just before the next never appears in the image: no rung ever sees it, and no logic inside the scan can recover it. When the window's on-time is close to the update period, most windows are caught and a steady few percent are missed — the classic signature of a short pulse aliasing against the scan.

The input filter sits ahead of all of this: a pulse must outlast the filter time to reach the image at all. Take the filter range and its setting from the input module's documentation. An input's response time is also a separate specification from its count rate, which is its own trap; the absolute encoder input card response time versus count rate article separates the two.

No standard fixes a scan time — it is whatever the controller and program actually take, which is why the diagnostic reading under the real program is the only usable figure. The same update-plus-scan budget sets how stale a position sample looks on a slow axis; the PLC scan time for a slow absolute encoder turntable article works that side of the problem.

Check two bits separately in the diagnostics: the raw input bit and the cam condition bit. If the raw input bit never shows the on-pulse, the cause is electrical or the filter — supply, cable, signal format, filter time — and no scan change will fix it. If the raw bit pulses but the cam bit still skips, the input update and the scan are the cause, and the arithmetic below applies.

Likely causes in the order to check them #

  • Scan time exceeds the window time. Confirming check: run the controller's scan-time diagnostic while the production-equivalent program runs, and compare the worst-case reading with the window time from the formula.
  • Filter time swallows the pulse. Confirming check: with a clean signal, set the filter to its shortest documented value and count misses again over the same number of revolutions.
  • The cam logic sits late in a long scan. Confirming check: move the cam rung to the top of the scan and watch a miss counter over several hundred revolutions.
  • The event needs capture hardware. Confirming check: if the window is shorter than the best achievable filter-plus-update-plus-scan period, latch the transition with a high-speed counter or capture input and verify that the captured count equals revolutions multiplied by windows per revolution over a test run.
  • It is an electrical miss, not a timing miss. Confirming check: if the raw input bit never toggles, check the encoder supply, cable and signal format against the input module's documented input characteristics before changing any timing.

Worked example: the arithmetic behind a five-in-a-hundred miss #

The inputs below are the reported example, not ratings:

Quantity Example value Where it comes from
Shaft speed 12 rpm reported bench setup; measure your own
Cam window angle 1 degree encoder or cam configuration
Nominal scan time 14 ms scan-time diagnostic under the real program
Missed windows about 5 in 100 reported symptom

The arithmetic:

  • Revolution period: 60,000 ms ÷ 12 rpm = 5,000 ms.
  • Window time: 5,000 ms × (1/360) = 13.9 ms.
  • Margin at the nominal scan: 13.9 ms - 14 ms = -0.1 ms, so the scan alone already overruns the window.
  • For a pulse of on-time w shorter than the effective update period T, the missed fraction is (T - w) ÷ T. Solving (T - 13.9) ÷ T = 0.05 gives T = 13.9 ÷ 0.95 = 14.6 ms: about 0.6 ms of input update and scan jitter added to the nominal scan reproduces the reported rate.

This is a calculated example for these inputs, not a measured result, and your own numbers move it quickly: double the speed and the window halves, so the same scan that barely misses now loses roughly half the windows. The margin target from these inputs: keep the total detection period at or below about 7 ms — half the window time — for scan logic to catch every window.

The decision for each case #

Compute the window time at the fastest shaft speed and the worst-case detection period — filter plus input update plus scan — then take the row that matches:

  • Window at least twice the detection period: scan logic is adequate. Keep the cam rung near the top of the scan, keep the filter well under the window, and leave a miss counter running in production as ongoing proof.
  • Window longer than the detection period but with less than twice the margin: shorten the path. Trim the filter toward its documented minimum, move the cam logic into a timed interrupt no slower than half the window — for the worked example's window, a 5 ms interrupt qualifies — or use a faster controller variant if that is what brings the period down.
  • Window shorter than the detection period, or a precise timestamp needed: stop sampling and latch the event in hardware — a high-speed counter, a capture or strobe input, or the drive's own encoder input. That is the documented way to catch a pulse shorter than one scan, and it is the only one of these fixes that does not depend on program length at all.

One safety note: if the cam window participates in stopping or guarding a press, that function belongs to the machine's risk assessment and the applicable press-safeguarding requirements — in the United States, the mechanical power press rule in 29 CFR 1910.217 — and scan-time tuning for production timing never substitutes for a validated safety function.

Questions asked

How do I measure the scan time my logic actually takes?

Run the controller's scan-time or task-time diagnostic while the production-equivalent program executes, not alongside an empty test program. Record the maximum as well as the average, because one long scan is enough to swallow a short window. Compare that worst-case figure against the window time computed from shaft speed and window angle.

Does the input filter count against the window time?

Yes. A pulse must last longer than the filter time to be recognized at all, so the filter sits in the detection path ahead of the input update and the scan. Take the filter range and its current setting from the input module's documentation, and keep it well under the window time.

Up to what speed can scan logic catch a 1-degree window?

It depends on your detection period. With the 7 ms period that meets the 2:1 margin target, a 1-degree window lasts 166.7 divided by the shaft speed in rpm, in milliseconds, so it stays catchable up to about 12 rpm. Above that speed the window drops below your margin, and the event belongs on a capture input.

Will a faster CPU fix a missed cam window on its own?

Only if it brings the whole detection period below the window with margin to spare. The input filter, the input update time and any interrupt latency remain whatever the processor does. Verify the change with a miss counter over several hundred revolutions at the maximum operating speed before trusting it in production.

Can I fix a missed window without touching the controller?

Often yes: widen the window. If the machine's timing allows a wider cam or a wider window definition, doubling the on-time to 27.8 ms at the worked example's speed hands the same scan a 2:1 margin with no hardware or program change. Confirm first that no other event needs the narrower resolution.

Keep reading

  • Troubleshooting

    PLC scan time for a slow absolute encoder turntable

    At its rated 3 RPM, a turntable encoder tagged 720 counts per revolution hands the PLC a new position every 27.8 ms. A small PLC scanning in the low milliseconds reads every one through ordinary inputs - the real risks are the unresolved nameplate, the input filters, and a stop strategy that catches the last count while the table creeps.

    Servo and stepper motion

  • How-to

    Counting Encoder Pulses on a PLC Without Losing Position

    Count encoder pulses with a hardware high-speed counter input wired for quadrature, never with a count instruction in the scan. At 214 rpm and 75 pulses per revolution the encoder delivers 267.5 pulses per second, one every 3.7 ms, while a 10 ms scan cannot guarantee seeing even one in three. Zero the counter at a reference switch and treat every target as counts from that switch.

    Sensors, encoders and machine vision on the machine

  • Troubleshooting

    Servo External Scale Error Alarm: Fix the Feedback Path

    An external scale error alarm fires when the drive's scale-error input sits OFF while scale-error monitoring is enabled and the axis runs full-closed or hybrid control on an external encoder. Check the cable and connectors, then the scale mounting, then the scale-type and monitoring parameters, in that order. Do not silence the alarm by disabling monitoring; fix the feedback path and restore the setting before the axis runs again.

    Servo and stepper motion