I'm experimenting with differential encoder and I have some questions now. First specs: motor reduction is 14:1 on official page, encoder count 512 pulses per revolution so that mean that on one full rotation I got 512 * 14 * 4 = 28672 pulses. x4 because count rising and falling edges of both channels (A and B). Analog comparator in IC form is used to deal with differential signal (AM26LS32AC).

I assume that I need to got exactly 28672 pulses per revolution but for some reason I don't get that value. It is especially expressed when I rotate encoder 50 revolution and on 50 revolutions error is huge. I try different MCU and always got some results. I catch that error is ~0.00405% or ~116.53 pulses. My conclusion is next: error is deterministic and I "solve" problem with changing expected pulses per revolution to 28672 + 116.53. What can cause this problem? I calculate that motor reduction isn't 14 it's more 14.0567. So why encoder give wrong number of pulses? Any idea is welcome

  • \$\begingroup\$ How exactly are you counting the pulses ? Interrupts on the MCU pin or manual polling ? How are you converting the negative going edges ? by setting the interrupt in MCU to both edges ? How fast is your interrupt handling routine ? \$\endgroup\$
    – AJN
    Commented Jul 9, 2020 at 13:35
  • \$\begingroup\$ Also how sure are you about the gear ratio ? I assume you did 50 revolutions so that any positioning error is effectively divided by 50. \$\endgroup\$
    – AJN
    Commented Jul 9, 2020 at 13:37
  • \$\begingroup\$ @AJN I count pulses in two ways: 1.External interrupt 2. Timer encoder mode, MCU works on 168MHz which is more then enough. \$\endgroup\$
    – macola995
    Commented Jul 9, 2020 at 13:38
  • \$\begingroup\$ @AJN I'm sure that gear ration in dahasheet is 14:1, error is ~1.5 degree per revolution. I need to get 28672 pulses per revolution or 1433600 pulses per 50 revolution but I got different values \$\endgroup\$
    – macola995
    Commented Jul 9, 2020 at 13:42
  • 1
    \$\begingroup\$ If you have a huge gearbox, sometimes they provide more an approximate value of the transmission ratio for mechanical engineers, but then you sometimes get an exact ratio as quotient of gearbox teeth, for example : 348/32 in some datasheet, but not always. Post a link of the gearbox. \$\endgroup\$ Commented Jul 9, 2020 at 13:47

1 Answer 1


enter image description here

The reduction is 225/16 = 14.0625

  • \$\begingroup\$ Thanks man! I have one more question now. Now result is much better (calculating position is near perfect but there is still small offset which is noticeable after 100 rotation, error is small, few degree). Is it possible that reduction isn't equal to 14.0625, I calculate that if reduction is 14.06840625 I got perfect result. What can cause this behavior? Calculation: 14.0625 * 512 * 4 = 28800 (official absolute reduction) vs 14.06840625 * 512 * 4 = 28812.096 (error is now compensated) \$\endgroup\$
    – macola995
    Commented Jul 10, 2020 at 8:12
  • \$\begingroup\$ @subavet995 the gear ratio is exact. Turn several turns forth and back., you may loose some pulses. Does the MCU have a quadrature counter embedded? \$\endgroup\$ Commented Jul 10, 2020 at 8:43
  • \$\begingroup\$ 28812.096 means 13 pulses lost, this is close to 14- each turn you loose one pulse. Make sure your calculation is correct: 512 encoder pulses means 0 to 511, the 512-th pulse is a 0 pulse. \$\endgroup\$ Commented Jul 10, 2020 at 8:59
  • \$\begingroup\$ MCU have Timer encoder peripheral (STM32F405VGT), encoder don't lost position when turns forth and back because error will be compensated. Basically if turn encoder in CW direction 100 rotations (position 36000 degree)(14.0625 reduction is used for calculation) small error in position will occur, but if turn 100 rotations in CCW direction now error will be 0 (position 0 degree) \$\endgroup\$
    – macola995
    Commented Jul 10, 2020 at 9:04
  • 1
    \$\begingroup\$ @subavet995 Post the calculation method. This error can be due to floating point arithmetics. A very rude check: 28800 x 100 = 2880000, this number 21.5 bits long, the mantissa of IEEE754 is 23 bits, so you may loose some precision while doing the math with float numbers. Reset the MCU counter, turn 100 times and look the pulse number in the MCU - unsigned 32 bit number, not the computed angle. \$\endgroup\$ Commented Jul 10, 2020 at 12:09

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.