Troubleshooting calibration errors

Hi,

I have a few problems with odrivetool. I’m using the 188W NEMA23 motor and a 2400 counts encoder. I connected everything as instructed by getting started guide. The only thing I was not super sure about is setting pole pairs - I set it to 4 as the motor’s page mentions 8 magnet poles.

When I’m running the odrivetool I’m able to trigger calibration from time to time. Sometimes it will turn on and sometimes it won’t. I tried doing the following a few times:

  1. Disconnect power supply and USB, exit odrivetool
  2. Connect everything, run odrivetool
  3. Wait 10 seconds after connecting to the motor
  4. Try to run calibration

Sometimes it will beep and turn the motor twice in one direction and twice in the other, sometimes it won’t do anything.

And even after running the calibration successfully it doesn’t behave predictably. When setting position control it will usually turn after setting pos_setpoint for the first time, but then it will not do anything for subsequent runs. When trying velocity control, it will turn, but not in an expected way, for example it will go slowly for quarter of a turn and then it will speed up for a short period of time and then get back to slow rotation.

Does it sound like some known or common issue? How can I troubleshoot it? Is it likely that the encoder is faulty?

When things aren’t working, try reading the error codes.

The problem is that when calibration does work all of the error codes are set to 0. When it doesn’t work it says 0x41, which seems to be a motor error (not sure what that’s about).

Apologies, I agree that’s unclear. I’ve updated the documentation to be a bit more clear about that. I added:

The axis error may say that some other component has failed. Say it reports ERROR_ENCODER_FAILED, then you need to go check the encoder error: hex(<axis>.encoder.error).

Sorry, I guess I should have included more info. I plugged in the motor again and here’s what I get after trying to run calibration:

Connected to ODrive 367233693037 as odrv0
In [1]: odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

In [2]: bin(odrv0.axis0.error)
Out[2]: '0b1000001'

In [3]: bin(odrv0.axis0.encoder.error)
Out[3]: '0b0'

When calibration succeeds both values are 0b0

All that said, I believe it might be a problem with the encoder. I found out about shadow_count property when searching the forum and it doesn’t change when I move the encoder’s shaft.

Your axis error says that the motor failed, can you please provide the motor error code?
Yes shadow_count should increment when you move the shaft, so you may also need to check the encoder wiring or if it’s faulty.

Sorry for confusion, it seems that shadow_count stops working after an error. When I restart ODrive it works again correctly.

Regarding the motor error, I think I have missed it - when the calibration doesn’t work it gives me 0x11.

I recorded a video of how does it look like when the calibration succeeds and I try to run in velocity control mode:

What’s interesting, when I set it to run a bit faster (2400 counts per second) it ran smoothly, but it stopped after a few seconds.

Here’s a video of the motor stopping after a short while: https://www.youtube.com/watch?v=G4cmsRnpsh0

I notice you are not using a flexible coupler: when the system is powered down, is it very easy to rotate the shafts, or is there a bit of friction?

When the system is powered down it’s easy to rotate the shafts, the only noticable friction is created by magnets. Also, I’m not sure if you’ve seen the other video as I was editing my previous post, here’s a bigger velocity setting: https://www.youtube.com/watch?v=G4cmsRnpsh0 - so I don’t think it’s a problem with friction.

One other thought is that the motor is faulty. I’m not sure what error 0x11 means, but since encoder works each time, it might be some kind of a problem with the motor.

Okay that is probably because you have a high resistance motor. Just set odrv0.axis0.motor.config.resistance_calib_max_voltage to 2 volts.

Can you read out the error codes right after it stops in that state?

After changing the resistance_calib_max_voltage value to 2 it works somewhat better, ie. it works each time I restart the controller. Setting velocity to 2400 also works better, ie. it does 10 or so revolutions before it stops, but it still stops.

After it stops the axis0.error shows 0x31, other errors are empty.

Hm very interesting, I’ve only seen error 0x31 on high inductance hoverboard motors. I guess these motors could also be high inductance, not sure.

Can you set odrv0.axis0.motor.config.resistance_calib_max_voltage to 4, then run the calibration, then read out:

  • odrv0.axis0.motor.config.phase_inductance
  • odrv0.axis0.motor.config.phase_resistance
  • odrv0.axis0.motor.current_control.p_gain
  • odrv0.axis0.motor.current_control.i_gain

Thanks

sure, here they are:

In [1]: odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE

In [2]: odrv0.axis0.motor.config.phase_inductance
Out[2]: 8.904561400413513e-05

In [3]: odrv0.axis0.motor.config.phase_resistance
Out[3]: 0.14168408513069153

In [4]: odrv0.axis0.motor.current_control.p_gain
Out[4]: 0.08904561400413513

In [5]: odrv0.axis0.motor.current_control.i_gain
Out[5]: 141.68408203125

Hm looks reasonable to me. Can you try to set the gains to half of their current value and then try closed loop control without running the calibration between? (If you run the calibration again they will be reset to what they are now again).

Setting them to half of their value improved things a bit, but it still stopped. Setting it to 1/4th and then to 1/8th improved things even further. With 1/8th it was running without stopping on 2 revolutions per second, but it still stops at 4 revolutions per second (according to the datasheet the motor is rated for 3000rpm, so it’s still an order of magnitude smaller).

Should I try to decrease it further? I could also try to run the tuning procedure manually as pointed out here: https://docs.odriverobotics.com/commands (update: ah, it seems that it’s for something a bit different)

Still with motor error 0x31? Hm that’s very odd. Can you list all the settings you changed from default?

Yes, the same error.

I changed the following:

odrv0.axis0.motor.config.calibration_current = 7
odrv0.axis0.motor.config.current_lim = 7
odrv0.axis0.controller.config.vel_limit = 12000
drv0.config.brake_resistance = 47
odrv0.axis0.motor.config.pole_pairs = 4
odrv0.axis0.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT
odrv0.axis0.encoder.config.cpr = 2400

I’m pretty confident this is the cause of the issue. This value is way too big, and you probably mean to enter 0.47 ohms which is the value included with the 24V ODrives.

1 Like

Ohhhh, crap, you’re right, I thought it’s 47Ohms. Now it works like a charm!

Sorry for wasting your time, silly mistake!

No worries, looking at the markings on the resistor I think “R47” is quite ambiguous indeed.

1 Like