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.