This simulator opens up an optical incremental encoder. A slotted disk turns between offset detectors, producing channels A and B in quadrature and a once-per-revolution index. You change speed, direction and resolution and watch the decoder turn signal edges into counts and angle, then break it by dropping transitions.
• A 3D optical code disk, channel A and B detectors, an index mark and a quadrature counter with live waveform display. • Sliders for shaft speed (-30 to 30 rpm) and cycles per channel per revolution (4-32 PPR), plus a check box that drops every tenth decoded transition. • Readouts of true unwrapped shaft angle, decoded angle, reported x4 count, position error and the instantaneous A, B and index states. • Experiments such as one revolution at 15 rpm, where after 4 s the ideal x4 count is 64, and a lost-transition case where raw waveforms stay valid but the reported count falls behind.
Channels A and B are offset by a quarter of a cycle, so the pair steps through the Gray sequence 00 → 10 → 11 → 01 → 00 in one direction and in reverse order when the shaft reverses. Counting every edge of both channels (x4 decoding) gives Ncounts/rev = 4 × PPR, and the decoded angle is count × 360° / (4 PPR). Because an incremental encoder only reports change, it needs a reference: the index pulse lets a homing routine define a known zero.
The encoder is ideal: binary channels, constant shaft speed and no optical noise or electrical bandwidth limit. The fault option discards decoder transitions without altering the raw A and B signals, and the index is a one-count-wide teaching window.
PPR is the number of signal cycles per channel per revolution. With x4 quadrature decoding every edge of A and B is counted, so one revolution produces 4 × PPR counts. A 16 PPR encoder gives 64 counts per revolution.
The A and B channels are a quarter cycle apart. Which channel leads tells the decoder the direction: reversing the shaft reverses the order of the A/B state transitions, so the count goes down instead of up.
An incremental encoder only tracks change since power-up. The index pulse marks one fixed shaft angle per revolution, which a homing routine can use to establish an absolute reference.
The reported count drifts from the true position because the lost edges are never recovered. The lab's fault option shows the raw waveforms still valid while the decoded angle and position error grow.