Skip to content
University of California, Davis Mechanical and Aerospace Engineering
ARMS Laboratory
EME154 · Interactive Lab

When a count hides the motion.

Explore the prescaler counter: reconstruct position from periodic counter readings.

Sampling design

This prescaler is a finite position counter. It is distinct from a timer clock divider.

Playback reveals one sample at a time. Animation speed does not change Ts. Select a completed sample marker or a table row to inspect its calculation.

Position and counter readings on one time axisActual position, wrapped hardware count, and sampled reconstructed position. Vertical lines connect sampling instants.

Green: actual positionAmber: hardware countBlue: reconstructed positionDashed green reference repeats actual position in the bottom plot.

Sample history

SampleTime (ms)ReadingActual ΔInferred ΔPosition error
Model assumptions and the half-range rule

The encoder produces ideal uniformly spaced decoded counts. The hardware counter wraps modulo 2ᵐ. Software selects the signed difference in [−2ᵐ⁻¹, 2ᵐ⁻¹−1] and adds it to its previous position. At exactly half the range either direction is possible; this implementation chooses the negative value. Even if that happens to match actual motion, the readings alone cannot establish the direction.

The design rule is |n| p Ts / 60 < 2ᵐ⁻¹, using effective decoded counts/revolution p. Leave margin: fractional expected counts can round to a half-range increment in an individual sampling window. Actual position is shown as a continuous reference in equivalent encoder-count units; hardware readings are integers. The initial encoder phase is a quarter count into a bin and software starts with the known initial reading.

Uniform speed, no missed edges, ideal sampling, and unlimited software position range are assumed. Direction is inferred only from counter readings; no separate direction bit is used. Noise, ISR latency, homing, and absolute encoders are outside this draft.