Odrive set up struggles and encoder error '0x20'

Hello,

I am using the AS5047P encoder with V3.5 Odrive 24V and the following brushless DC motor:

[https://www.iflight-rc.com/index.php?route=product/category&path=25_35] (https://www.iflight-rc.com/index.php?route=product/category&path=25_35)

After the full calibration at set up - the motor only moves in one direction and gives the encoder error ‘0x2’ - which from the docs says that the index of the encoder cant be found yet - I have tried setting different parameters and checked the I (which is the same as Z?) pin of the encoder on an oscilloscope and it outputs the expected square wave.

Any ideas on what is going wrong? Thanks!

Are you sure that the error is 0x2 and not 0x02?

It is true that 0x2 means ERROR_INDEX_NOT_FOUND_YET, but it should fire immediately without turning the motor. If it is 0x02, that means ERROR_CPR_OUT_OF_RANGE and this means that there is probably something wrong with the cpr setting or the pole pair setting of your motor.

It is also not really needed to calibrate the encoder offset every time when you boot when using an index pin. It is sufficient to just search for the index signal.

Could you also dump your ODrive configs?

When I print the error code it does appear to be 0x2 but when I do an index search it it does find it I think - plot below is of cpr counts:

image

However, if I don’t bother with the offset calibration, the error doesn’t show up so do I just not need to do it? Even when I don’t do it, when I try to get the motor to move to a certain position, there is no response to the command.

Here is a dump of the Odrive configs:

Thank you for help! I am new to this so I really appreciate it!

Normally with an encoder index signal you only have to do the encoder offset calibration once. After that you can just search for the index every startup.

Are you having the problem while doing index search or when calibrating the encoder offset?

Can you post the following outputs? The best is right after startup and also after doing a calibration.

odrv0
odrv0.axis0
odrv0.axis0.encoder
odrv0.axis0.motor

The index search seems to go fine, when I try to do the offset calibration after, the 0x2 encoder error is output.

There is a pdf on GitHub for the outputs at start up and after I try to calibrate it - it just seems weird that it throws the index cant be found error during offset calibration after which the index search has already been done. Thanks again!

https://github.com/RachelDunwoody/Odrive_Code.git

I checked the output, and this is what I think:


As you can see in this dump (after calibration), not only is the error 0x0002 but it says that the index has been found. This means that the error is not ERROR_INDEX_NOT_FOUND_YET but rather ERROR_CPR_OUT_OF_RANGE. I don’t really know why the terminal says 0x2 when accessing the error (probably something to do with conversion) but the fact that the index has been found excludes ERROR_INDEX_NOT_FOUND_YET.

The error ERROR_CPR_OUT_OF_RANGE means that the encoder is responding correctly and is predictable when the motor turns, but that the ODrive got something odd while measuring the cpr value and comparing it to the given value. So I would check the following things:

  • Is the cpr of the encoder set correctly? Your encoder can handle a cpr of 4000 but it is programmable. So perhaps the encoder is configured for a different cpr?
  • Make sure that the pole pair count is correctly set. This can also cause this error.
  • Make sure the motor can rotate freely during calibration without load other than normal friction and resistance.

Looking at the motor brand you are using and doing some research, my guess is that your pole pair count is wrong. I don’t know what motor you are exactly using but take the GBM2804H-100T as an example:
image
As you can see, the configuration is 12N14P. This (I guess) means that there are 12 ‘stator arms’ (not really important for us) and 14 permanent magnets, or poles. Then there is the fact that ODrive whants the pole pair count, and not the pole count. So the value that you will need to enter using this example motor is 14 / 2 = 7, and not 14.

Hopefully it is solved now :wink: !

Hint: 0x2 is the same as 0x02 and 0x000002 (assuming it’s not sign-extending) :wink:

I made the same mistake myself the other day.

Rachel: You don’t have to use the Index search if you don’t want it. But that doesn’t seem to be the issue anyway…

It was the pole pairing! The specs for the motor that iflight sent me did say 24P but turns out it is 28P - just had to do trial and error of a few common values!

Thanks so much for you help !

Okay great to know that, thank you for your help!