AxisError.INVALID_STATE

Hello!

I am trying to run 325KV motor in Sensorless mode. However, I keep getting this error

system: not found
axis0
  axis: Error(s):
    AxisError.INVALID_STATE
  motor: no error
  DRV fault: not found
  sensorless_estimator: no error
  encoder: no error
  controller: no error
axis1
  axis: no error
  motor: no error
  DRV fault: not found
  sensorless_estimator: no error
  encoder: no error
  controller: no error
None

This is my code:

import odrive
from odrive.enums import *
import time

odrv0 = odrive.find_any()
print(str(odrv0.vbus_voltage))

print("Erasing pre-exsisting configuration...")
try:
    odrv0.erase_configuration()
except Exception:
    pass

odrv0 = odrive.find_any()

odrv0.config.brake_resistance = 2.0  #(based on the resistor used for the Odrive)
# odrv0.config.dc_max_positive_current = 20.0  #(whatever is the max current that the power supply or the battery can give)
odrv0.config.dc_max_negative_current = -3.0  #(whatever is the max current that the power supply or the battery can absorb)
odrv0.config.max_regen_current = 1.5  #(usually 0)
# odrv0.config.dc_bus_undervoltage_trip_level = 5
# odrv0.config.dc_bus_overvoltage_trip_level = 20

odrv0.axis0.motor.config.pole_pairs = 7
odrv0.axis0.motor.config.resistance_calib_max_voltage = 4
odrv0.axis0.motor.config.requested_current_range = 20
odrv0.axis0.motor.config.current_control_bandwidth = 100
odrv0.axis0.motor.config.current_lim = 60
odrv0.axis0.motor.config.calibration_current = 15
odrv0.axis0.controller.config.vel_limit = 100
odrv0.axis0.controller.config.vel_gain = 0.02
odrv0.axis0.controller.config.vel_integrator_gain = 0.2
odrv0.axis0.sensorless_estimator.config.pm_flux_linkage = 5.51328895422 / (7*325)
odrv0.axis0.controller.config.control_mode = CONTROL_MODE_VELOCITY_CONTROL


try:
    odrv0.save_configuration()
except:
    pass
odrv0 = odrive.find_any()

odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION
time.sleep(15)
odrv0.axis0.motor.config.pre_calibrated = True
print(str(odrive.utils.dump_errors(odrv0)))
print('Motor Calibration Sequence for motor 1')


try:
    odrv0.save_configuration()
except:
    pass

try:
    odrv0.reboot()
except:
    pass

odrv0 = odrive.find_any()
odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION
odrv0.axis0.requested_state = AXIS_STATE_SENSORLESS_CONTROL

print(str(odrive.utils.dump_errors(odrv0)))

odrv0.axis0.config.startup_sensorless_control = True

print(str(odrive.utils.dump_errors(odrv0)))
print('Saving config before running')
try:
    odrv0.save_configuration()
except:
    pass

try:
    odrv0.reboot()
except:
    pass

time.sleep(5)

odrv0 = odrive.find_any()
print(str(odrive.utils.dump_errors(odrv0)))
odrv0.axis0.controller.input_vel = 5

The strange thing is that despite it makes a sound that we usually get before calibration, motor does not turn at all.

Thank you!

  1. You need to wait for MOTOR_CALIBRATION to be complete, it will take a few seconds.
  2. Please read the docs for what’s needed to enable sensorless Parameters & Commands — ODrive Documentation 0.5.6 documentation. After that, it will engage automatically when you enter closed loop control.