Special encoder output scheme?

I am testing an inexpensive encoder and encountered a strange but consistent output pattern. In other encoders I've used, the A signal consistently has a 90 degree or -90 degree phase shift, depending on the rotation direction. Both rising and falling edges exhibit this phase shift.

The encoder I am testing right now consistently has one edge in sync, and one edge showing a phase shift. For clockwise rotation, for rising edges, signal A consistently leads signal B. For falling edges, signal A and B are in sync. For counterclockwise rotation, for rising edges signal A and B are in sync. For falling edges signal A consistently lags behind signal B.

The following Arduino Serial Monitor plots show the output. Signal A is plotted in blue, signal B is plotted in red.

Clockwise rotation Clockwise rotation

Counterclockwise rotation enter image description here

Setup for testing

I used an Arduino Uno to test the encoder. I've hooked up the encoder following the schematic below, as described in an article by Electro Schematics.

Wiring of encoder

The encoder signals are attached to pins 6 and 7 (both non-interrupt pins). I am using the Teensy Encoder library to decode the encoder output. The library is only able to parse the encoder rotating in one direction (counterclockwise). If I substitute the encoder by one that has both signal edges phase-shifted, the output is parsed perfectly.


Now if the output were noisy, or if I only encountered this issue with a single encoder I would assume the encoder to be faulty. The output however is perfectly consistent and shows this pattern every time. Furthermore, I've ordered the encoder as a pack of 5, and all encoders show the exact same output. Even more, a while ago I encountered another encoder that shows the exact same output pattern as these ones. As the output is consistent, it is technically possible to decode the output signals.

Because of this, my question is whether this is intended functionality? Is this perhaps an encoding scheme different from quadrature encoding? Could this be an encoder intended for rotation in one direction only? Or did I receive 6 different encoders with the same manufacturing error where two contacts are not offset?

The images below show the two encoder types with the strange output.

Faulty encoder 1 Faulty encoder 2

The following image is the encoder with normal quadrature output that I am able to decode.

Working encoder

  • \$\begingroup\$ So the "good" encoder in the same circuit does not show this "phase shift"? You've done a good job eliminating most of the obvious explanations. Also wondering if the scope traces are direct from the hardware, or derived after being interpreted by the firmware. \$\endgroup\$
    – gbarry
    May 5, 2018 at 19:12
  • \$\begingroup\$ The traces were made by polling the digital input pins at a fast rate. So they are not the raw voltages, but the interpreted boolean values. As the answer turned out to be a swapped COM and B pin, an actual trace could have revealed more information indeed! \$\endgroup\$ May 6, 2018 at 7:52

3 Answers 3



simulate this circuit – Schematic created using CircuitLab

Figure 1. One way of generating the incorrect output.

With incorrect wiring 'A' can only pull low when the 'B' contact is closed.

Are you sure you have wired the encoder correctly. Note that the example from Electro Schematics shows that the centre pin is common.

  • \$\begingroup\$ Thanks for the great reply, incorrect wiring turned out to be the problem indeed! The other encoders I've been testing all have [A COM B] pinout, but this brand of encoder uses [A B COM] pinout. Swapping the COM and B wires completely resolved the problem. It had not even come to mind that incorrect wiring could cause this effect, but thanks to your drawings it makes perfect sense now! \$\endgroup\$ May 6, 2018 at 7:47
  • 1
    \$\begingroup\$ Good work. You will, no doubt, have a better appreciation for the site recommendation of "No datasheet? No sale." \$\endgroup\$
    – Transistor
    May 6, 2018 at 7:52
  • \$\begingroup\$ Absolutely, I went for the "use the standard pinout and quickly check if the output seems right" approach here, but the "datasheet" route would have saved me a lot of troubleshooting here (if a datasheet had been available)! \$\endgroup\$ May 6, 2018 at 7:56

A little late, but after noting the aliexpress page refers to it as an "EC16" rotary encoder, a little googling turns up the manufacturers details and a datasheet, in case anyone wants it:



There are some mechanical encoders that have the state of only one output guaranteed when the shaft is at a detent.

That is not a problem whatsoever if you design for it.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.