Using absolute encoder off axis with gear reduction

I have an absolute encoder (AMT 232b) that I would like to use off axis with a gear reduction multiplying the resolution at 8 x 2**14. The encoder is being read by odrive ok (I’ve wired in a tri-state buffer (74HC125) for MISO). But, I get a CPR_POLE_PAIRS_MISMATCH error when trying to run offset calibration. This same motor was working fine with an incremental encoder at a 10:1 gear reduction (10 * 4000) but I don’t want to calibrate every time I power up so went to the absolute encoder instead.

Looking at the code, it appears there is no support to keep track of multiple turns of an absolute encoder for one motor revolution therefore the encoder calibration fails. Is this a correct assumption? If so, any suggestions on code that would do this?

The motor is a home built axial flux pancake style motor for a telescope.

1 Like

Yeah, absolute encoders and gear ratios don’t really work well, because the actual value sent from the encoder is in the range [0, 4000), but you’ve told the ODrive that the cpr is 10x, so it’s going to handle wrapping at 40000 instead of 4000, which pretty much just breaks.

You could try putting the absolute encoder on the motor, and then an additional incremental encoder on the output shaft of the gearbox / reduction, and using the load_encoder option. This works as long as you only need to drive one motor from each ODrive.

In other words, plug in the absolute encoder into SPI and configure it as normal.
Plug in the incremental encoder into axis 1 ABZ, and set it up:

odrv0.axis0.encoder.config.mode = ABS_SPI_AMS # or whatever the enum is
odrv0.axis0.encoder.config.cpr = 4000
odrv0.axis0.encoder.config.load_encoder = 1
odrv0.axis1.encoder.config.cpr = 40000 # Incremental encoder cpr * 10

This way, you get instant startup with the absolute, but it uses the high resolution incremental for position and velocity feedback. Best of both worlds :+1:

Thanks for the reply. I suspected as much from perusing your encoder code. I’m 3d printing brackets to attach the absolute encoder to the motor axis.

My goal was to try and increase the effective resolution of the encoders by using GT2 timing gears and belts to multiply the resolution. This seemed to work well with the incremental encoder. I realize that the belt and gears would add some “lash” in the system, though.

It seems that this resolution multiplication could be made to work with absolute encoders as well but the code would need to add a config variable for the gear ratio and another variable to += or -= the absolute count when seeing a transition from 214 to 0 or from 0 to 214.

The real goal is to not need to buy an expensive Renishaw encoder.


If you don’t mind calibrating every startup, then you can just use an incremental encoder.
If you do need startup without calibration, I think it can work to have the gear ratio be equal to the number of pole pairs in your motor, then if the cycle-count is wrong it will just alias to a different position that’s magnetically identical, so it will be ok.
If you need a higher gear ratio than that, I think it is not possible to get absolute startup without other measures.

1 Like