ODrive settings help

Hi
I have an ODrive V3.6 24V motor driver, a T-Motor MN5212 KV340 motor with an AS5047D-TS_EK_AB encoder.

ODrive’s firmware: fw-v0.4.12

VCC: Omron S8VK-G12024 OUTPUT: 24V, 5A

Motor: https://store-en.tmotor.com/goods.php?id=377

Encoder: https://hu.mouser.com/ProductDetail/ams/AS5047D-TS_EK_AB?qs=Rt6VE0PE%2FOfe2SnbsNU7XA%3D%3D

I follow these steps but the test don’t run.

odrv0.axis0.motor.config.current_lim = 60
odrv0.axis0.motor.config.requested_current_range = 90
odrv0.axis0.controller.config.vel_limit = 2000
odrv0.axis0.motor.config.calibration_current = 4.5
odrv0.config.brake_resistance = 0 (but i tried with 69mOhm too)
odrv0.axis0.motor.config.pole_pairs = 12
odrv0.axis0.motor.config.motor_type = MOTOR_TYPE_GIMBAL
odrv0.axis0.encoder.config.cpr = 2000
Finally, save and reboot.

After that, I try the

odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

It sometimes beeping and turn right some secounds and stop.
Sometimes it just click one without beeping and moving and stop.

What do you think, what is the problame?

Why are you in this unusual mode? You should be in the default “high current” mode for that motor.

What error do you get when you run dump_errors(odrv0, True) (this also resets errors, btw, so you don’t have to reboot the drive)

How have you connected the encoder? via SPI or incremental interface?
Do you get any values in encoder.pos_estimate or encoder.count_in_cpr?

Why are you in this unusual mode? You should be in the default “high current” mode for that motor.

Because I thounght that my motor is this type but I set 0 value and it beeped and turn some degrees but didn’t turn back.

What error do you get when you run dump_errors(odrv0, True) (this also resets errors, btw, so you don’t have to reboot the drive)

image
But I don’t know what could encoder be.
Axis?

How have you connected the encoder? via SPI or incremental interface?

Sorry, The connection is Incremental Interface. I use these pins to M0 ABZ.

Do you get any values in encoder.pos_estimate or encoder.count_in_cpr ?

image
image

I can see your problem: You have used the wrong pins. You should use A/B/I for A/B/Z. The U/V/W pins are for a different function (Hall sensor emulation mode)

However, I would strongly recommend that you try out the absolute SPI mode of this encoder, using the latest 0.5.1 firmware. Having an absolute encoder allows you to do the calibration only once. You won’t need to re-calibrate anything on start-up.

Oh sorry, I gave wrong information. I use A/B/I pins for A/B/Z.

New infos


If I turn on firstly the ODrive after a hard reset I get this:

odrv0.axis0.requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH

It doesn’t do anything.

And I write these:
image
By CALIBRATION_SEQUENCE, It beeping, turns faster right, after slower right too and stop.

It should turn in one direction, and then the other. The speed should be the same.
What errors do you get after this?

I know that It should does this but it doesn’t.


It always sais Encoder_Failed.

As per another thread, these encoders can come with different CPR configured for the incremental (ABI) output.
Try setting encoder.config.cpr to 2048, 4096, 4000, 8192, 8000 and see if any of those settings work.
If you run encoder.set_linear_count(0) and then turn the motor by hand exactly one turn, you should be able to see the correct CPR in encoder.shadow_count

So, Finally, I set these parameters:
image
I set the current position to 0 with encoder.set_linear_count(0).
Save, reboot.
After the reboot says “no error”.
I run the odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE
The device is beeping and starts to turn LEFT faster, then RIGHT slower and finally STOP.
AND every time the final standing the… (It’s good.)
image

Ok, It’s so cool. I run a dump_errors(odrv0, True).
Firstly, it says: oh no, there is error but secound run, it says everythings alright…

So it’s working. But if i try the…

odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

It doesn’t give resistance agains me and it doesn’t do anything on odrv0.axis0.controller.pos_setpoint command.

No, you are still getting a cpr out of range error, even though it almost passed calibration. You reset the error with the ‘True’ argument, but you still need to re-run the calibration until there is no error immediately afterwards.
Did you try setting encoder.config.cpr to 2048 instead of 2000?

Yes, I tried. I tried with 1000, 1500, 2000, 2048, 4000, 4096, but it doesn’t work with 4000+.
The datasheet of the Encoder says that the max PPR is 500 (it is the default value), so the CPR is max 2000.


Sadly, after Calibration_Sequence I get usual Encoder_Failed and CPR_Out_Of_Range.

odrv0.axis0.motor.config.pole_pairs = 11

not 12

cpr is 4096 i think, I am using AS5047P

I counted 24db so 12 pairs but maybe you are right.
I am using AS5047D.

And an other problame. I would like to try the SPI mod but I can’t because it thinks, it is undefined.

I installed the odrivetool on last week and now I updated the firmvare to 0.5.1 but the programe says 0.4.12 and I can’t run the SPI command.

If you update with pip pip install --upgrade odrive, you should get the new 0.5.1 odrivetool with the correct enums :slight_smile:

1 Like

I am using the same motors as yours and i have been able to run it without the encoder errors. let me know if 11 works for you

So, Finally.
I succefully calibrated the ODrive.
I need 3 important settings.
CPR is 2007 (factory maximum is 2000 so it’s very interesting…)
calibration_current is 30
pole_pairs is 11 (same, I counted 24db so it’s 12 pairs but ok…)

1 Like

glad you got it working. This thread was very helpful for me also. Mine came set to 2000 cpr out of the packet. i think it was probably the pole pairs that was the issue for u.

odrv0.axis0.motor.config.pole_pairs = 12 It’s wrong,Should be 11