Encoder Position Sensing Simulator — Quadrature A/B Decoding, x4 Resolution & Wiring Faults

Interactive encoder simulator — rotate an optical code wheel, decode A/B quadrature transitions into a signed x4 count and angle, reverse the shaft and inject swapped or stuck channels.

← Mechatronics Labs
About this tool — how it works & FAQOpen ▾Close ▴

About the Encoder Position Sensing Simulator

You inspect a rotating optical code wheel, A/B photodetectors and a four-state decoder. Every ideal quadrature transition is decoded, including reverse rotation. You can inject swapped channels or a stuck B channel and compare the reported angle with the true shaft angle.

What the simulator shows

• A slotted optical code wheel, A and B optical read heads, a quadrature transition decoder, channel-level indicators and a once-per-revolution index detector. • Controls for shaft speed (-30 to 30 rpm), optical cycles per revolution (4-32) and signal condition (normal, swapped A and B, B stuck low). • Readouts of true unwrapped angle, decoded relative angle, signed x4 count, angular count increment and channel A and B levels. • Experiments: reverse rotation, swapped wiring, and a broken B channel.

The model behind it

x4 resolution = 360/(4N) degrees per count and the true angle is 6 × rpm × t degrees. The state index is floor(angle/resolution) on the signed unwrapped angle, stepping through the Gray sequence 00, 01, 11, 10. All crossed transitions are processed, and swapped channels reverse the counts.

Model boundaries

This is an ideal digital encoder with exact crossing detection and no sampling aliasing, propagation delay, noise or missed optical edges. The relative count starts at zero. Stuck-channel decoding can oscillate or undercount, and the index is displayed but not used for homing.

Frequently asked questions

Does x4 mean four physical tracks?

No. It counts all four edges per A/B electrical cycle.

Does the index automatically imply absolute multi-turn position?

No. The index repeats once per revolution and the counter is relative.

What happens when channels A and B are swapped?

The decoder reports the opposite direction, because swapped channels reverse the counts.

Can one channel alone give position and direction?

No. With B stuck low, one channel alone cannot provide reliable quadrature position or direction; decoding can oscillate or undercount.

Related tools & guides