When a count hides the motion.
Explore the prescaler counter: reconstruct position from periodic counter readings.
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.
Green: actual positionAmber: hardware countBlue: reconstructed positionDashed green reference repeats actual position in the bottom plot.
Sample history
| Sample | Time (ms) | Reading | Actual Δ | 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.