I'm currently working on an autonomous terrain-mapping rover, and I've run into problems in the seemingly most straight-forward area: processing quadrature encoder data.

For any unfamiliar, a quadrature encoder is a rotary incremental encoder with 2 output channels which fire pulses 90 degrees out of sync. I.e. if ChnA's pulse leads ChnB's, you're moving forward and vice versa. And if you know the resolution of the encoder (pulses/revolution) you can easily determine the distance you've traveled.

I'm specifically using this encoder: http://www.lynxmotion.com/p-448-quadrature-motor-encoder-wcable.aspx

Now according to the encoder's specs, 400 pulses = 1 revolution.

Ok great! I'll just hook up ChnA to the input of a digital counter module, and preload the module to 400 less than its interrupt point, and every interrupt will be a rotation!


The wheel barely moves an eighth of a revolution.

Looking at the output of ChnA on my logic analyzer reveals that in one full rotation of the wheel, there are over 2400 pulses. I have no idea where that's coming from.

Does it have something to do with the gear ratio (it is attached to a motor shaft with a 30:1 gear ratio)? If that's what it was, it would be 400*30 which is way more pulses than I'm actually getting per rotation. Or am I missing some other glaringly obvious piece of information?

Thank you!

  • \$\begingroup\$ 1) Check that your counter isn't being fooled by contact bounce, and 2) A lot of encoders will make several state changes for each detent passed. Hook it up to a scope to see what the deal is with your particular part. \$\endgroup\$ Commented Feb 28, 2015 at 6:19

1 Answer 1


Well, 400 counts per revolution generally refers to counts in terms of the four possible state combinations of the two outputs. If you just count pulses on one channel, you will get 100 pulses per revolution on a 400 count per revolution encoder. You need a quadrature counter to actually get all 400 counts. 100 pulses times a gear ratio of 30 is 3000 pulses per rev, which is in the ballpark of what you are seeing.

  • \$\begingroup\$ And the datasheet he linked does say "100 cycles" per revolution. Therefore 100 black lines on the disc, 200 edges, * 2 sensors = 400 pulses. I think you're on to something with the gearing. So, by edge detection and XORing the two outputs he could get 12000 pulses/revolution. Hope there's a way to take backlash out of those gears! \$\endgroup\$
    – user16324
    Commented Feb 28, 2015 at 11:07
  • \$\begingroup\$ I think @alex nailed it. In a rover you are almost certainly using a gear motor with a large reduction driving the wheels. In many applications the encoder is attached to the motor shaft that protrudes from the rear of the motor (ungeared). And if you're just counting one channel, you're getting 1/4 the pulses/turn relative to the number of edges available in quadrature. \$\endgroup\$
    – gwideman
    Commented Apr 11, 2015 at 0:17
  • \$\begingroup\$ I hope the OP returns to this thread and lets us know if alex is correct! \$\endgroup\$
    – gwideman
    Commented Apr 11, 2015 at 0:17
  • \$\begingroup\$ I'm so sorry I forgot to approve the answer; Alex was absolutely correct. The gear ratio, combined with the rather confusing representations of the pulse count, were throwing my results off. Strangely enough, even with the exact gear ratio and other info, the results wre STILL somewhat wrong, and at the end of the day it came down to educated guessing and checking. Rather unfortunate but it all worked out in the end. \$\endgroup\$ Commented Jul 2, 2015 at 13:57

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.