Uncontrollably spin after offset calibration

We are trying to get odrive running without having to do the full calibration sequence each time. We are using an AMT102 encoder and the KEDA 63-64 motor. After doing the first calibration it seems to work without any problem. But after a reboot and powering off it behaves strange. When changing to closed loop position control it sometimes starts spinning uncontrollably.
The problem is, that it doesn’t happen all the time. We feel like it’s mostly after turning the motor manually a bit in between encoder index search and closed loop control but not in a reproducible way.

Did we miss something during calibration?

For the first calibration we were using the following code:

import odrive
from odrive.enums import *
from fibre.protocol import ChannelBrokenException

drive = odrive.find_any()

drive.erase_configuration()
    
drive.config.brake_resistance = 1    
drive.axis0.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT    
drive.axis0.motor.config.pole_pairs = 7
drive.axis0.encoder.config.cpr = 8192
    
drive.save_configuration()
try:
    drive.reboot()
except ChannelBrokenException:
    pass
    
drive = odrive.find_any()
    
drive.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION
while drive.axis0.current_state is not  AXIS_STATE_IDLE:
    pass

drive.axis0.encoder.config.use_index = True
drive.axis0.requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH
while drive.axis0.current_state is not AXIS_STATE_IDLE:
    pass

drive.axis0.requested_state = AXIS_STATE_ENCODER_OFFSET_CALIBRATION
while drive.axis0.current_state is not AXIS_STATE_IDLE:
    pass

print("Error Code: "+ str(hex(drive.axis0.error)))

drive.axis0.encoder.config.pre_calibrated = True
drive.axis0.motor.config.pre_calibrated = True

drive.save_configuration()
try:
    drive.reboot()
except ChannelBrokenException:
    pass

The example program that causes some problems is:

import odrive
from odrive.enums import *

drive = odrive.find_any()

drive.axis0.requested_state = AXIS_STATE_ENCODER_INDEX_SEARCH
while drive.axis0.current_state != AXIS_STATE_IDLE:
    pass


input("after pressing enter here it will sometimes start spinning")
drive.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
drive.axis0.controller.config.control_mode = CTRL_MODE_POSITION_CONTROL
print("Error Code: "+ str(hex(drive.axis0.error)))

There are no odrive error codes returned.

Thanks for providing the script, I looked through it and it looks correct.

What firmware version are you on? There was an issue exactly like this that we fixed on v0.4.3. You can check by typing in odrivetool odrv0, and reading the fw_version_xxx values.

Are you using the AMT102 with the shielded cable that we provide? Any noise on the index line could also cause an issue like this.

After confirming the above and there are still problems, I’ll use your script on my rig and double check that everything works fine over here.

Thanks a lot for your fast answer! After updating the firmware from v0.4.2 it looks like the problem is solved.

By the way: For us odrivetool dfu only worked with sudo

1 Like