Can’t seem to determine quadrature encoder resolution

encoderpicquadrature

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!

WRONG!

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!

Best Answer

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.