ERROR_INVALID_STATE in sensorless mode

Hi, I’m trying to set up a ODrive v3.6 (24 V) with a hobby (drone) BLDC motor in sensorless mode. I followed the “Getting Started” guide, but I can’t get the motor to move at all, I only get and ERROR_INVALID_STATE error.

Here is what I did:

odrv0.config.brake_resistance = 0
odrv0.axis0.motor.config.pole_pairs = 12

odrv0.axis0.controller.config.vel_gain = 0.01
odrv0.axis0.controller.config.vel_integrator_gain = 0.05
odrv0.axis0.controller.config.control_mode = 2
odrv0.axis0.sensorless_estimator.config.pm_flux_linkage = 5.51328895422 / (12 * 380)


odrv0.save_configuration() 
odrv0.reboot()

odrv0.axis0.controller.vel_setpoint = 400
odrv0.axis0.requested_state = AXIS_STATE_SENSORLESS_CONTROL

At this point, I believe the motor should start spinning? In my case, nothing happens, instead if I use dump_errors I get:

Axis0:
  axis: Error(s):
    ERROR_INVALID_STATE
  motor: no error
  encoder: no error
  controller: no error
Axis1:
  axis: no error
  motor: no error
  encoder: no error
  controller: no error

I noticed the vel_setpoint is also getting reset to 0.0.

Is there anything I am missing to get sensorless up and running?

Answering my own question:

Problem is I had not done motor calibration (I though calibration was only for encoder commutation). So:

odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION

And now the motor spins happily :slight_smile: