Setting up Sensorless Mode

Hi. I am trying to set up ODrive v3.6 with the ODrive D6374-150KV motor in sensorless mode. I followed the online guide but the motors were not moving at all. Every time that I ran odrv0.axis0.requested_state = AXIS_STATE_SENSORLESS_CONTROL I would only get ERROR_INVALID_STATE as the result (after using dump_errors(odrv0)).

I then ran odrv0.axis0.requested_state = AXIS_STATE_FULL_CALIBRATION_SEQUENCE and the motor spun one way but not the other. This sequence was getting stuck on the encoder calibration and gave out ERROR_ENCODER_FAILED (which is completely understandable as the encoder isn’t even attached).

Eventually, I found an old thread that seemed to be about the same issue here: “ERROR_INVALID_STATE in sensorless mode”. Now, it says that odrv0.axis0.motor.is_calibrated is True and no errors came up when I used odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION so I am assuming I implemented the fix correctly. But nothing has changed.

I have tried seemingly every combination of wirings and code and nothing seems to help the issue. I always, without fail, get ERROR_INVALID_STATE instead of a motor that moves.

This is functionally what I have run so far:

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 / (7 * 150)

odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION

odrv0.save_configuration() 
odrv0.reboot()

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

Is there something that I’m missing in setting up sensorless mode?

You need to either set <axis>.motor.config.pre_calibrated = True before you save config and reboot, or you can skip rebooting after the AXIS_STATE_MOTOR_CALIBRATION, and go straight to trying to run sensorless.

Thanks! That worked!

I am following same steps, yet my motor does not move.
These are my steps:

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 / (18 * 120)
odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION
odrv0.save_configuration()
odrv0.axis0.controller.vel_setpoint = 400
odrv0.axis0.requested_state = AXIS_STATE_SENSORLESS_CONTROL

I’m also having problems running sensorless. My configuration so far, starting from a clear EEPROM:

odrv0.axis0.motor.config.calibration_current = 10
odrv0.config.brake_resistance = 1
odrv0.axis0.motor.config.pole_pairs = 7
odrv0.axis0.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT

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.controller.vel_setpoint = 400
odrv0.axis0.sensorless_estimator.config.pm_flux_linkage = 5.51328895422 / (7 * 30)
odrv0.save_configuration()
odrv0.reboot()

after that, i run

odrv0.axis0.requested_state = AXIS_STATE_MOTOR_CALIBRATION

which makes what i suppose is a correct calibration (current draw gets to about 0.8A@24V which makes sense with 10A being drawn at 2V through the coils), the rotor locks, and then the motor beeps.

In [201]: odrv0.axis0.motor.is_calibrated
Out[201]: True

and dump errors gives nothing. But then, if I type

In [203]: odrv0.axis0.controller.vel_setpoint = 400

In [204]: odrv0.axis0.requested_state = AXIS_STATE_SENSORLESS_CONTROL

In [205]: dump_errors(odrv0)
axis0
axis: Error(s):
ERROR_INVALID_STATE
motor: no error
encoder: no error
controller: no error

If i’ve read correctly, if the motor is calibrated and sensorless is configured, the last command should start spinning the motor but instead throws that error. Any clue on what might be happening?

I’m running the 0.4.10 firmware on a odrive 3.5 48V. I had some problems with the DFU tool but as the board is running i don’t think its related. I also have some problems when calibrating, some times (maybe 1 out of 3-4) the motor spins but stops instantly and I get the error ERROR_PHASE_RESISTANCE_OUT_OF_RANGE, but rebooting and trying again seems to work, so i haven’t given it any importanec.

Thank you very much!

I’m also getting the same error, using a 24V Odrive V3.6 and odrivetool v0.4.9. I’ve tried both setting <axis>.motor.config.pre_calibrated = True and skipping rebooting after the motor calibration.

In [36]: odrv0.axis0.motor.is_calibrated
Out[36]: True

In [37]: odrv0.axis0.controller.config.control_mode
Out[37]: 2

In [38]: dump_errors(odrv0)
axis0
  axis: no error
  motor: no error
  encoder: no error
  controller: no error
axis1
  axis: no error
  motor: no error
  encoder: no error
  controller: no error

In [39]: odrv0.axis0.requested_state = AXIS_STATE_SENSORLESS_CONTROL

In [40]: dump_errors(odrv0)
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

maybe try setting
odrv0.axis0.motor.config.direction=1
?