Not able to make Sensorless Mode work

Hey,

So I did make the motor to atleast spin in Sensorless Mode a few days back. But then i reflashed the firmware and starting out anew now, checked out the Getting started Docs to see what commands to make the motor run again in Sensorless Mode, but not able to make it even spin. These are the commands I am using (Motor is connected to M1, so I’m using axis1):

odrv0.axis1.requested_state = AXIS_STATE_MOTOR_CALIBRATION
odrv0.config.brake_resistance = 0.03

odrv0.axis1.controller.config.vel_gain = 0.01
odrv0.axis1.controller.config.vel_integrator_gain = 0.05
odrv0.axis1.controller.config.control_mode = 2
odrv0.axis1.controller.vel_setpoint = 400

odrv0.axis1.motor.config.direction = 1
odrv0.axis1.motor.config.pole_pairs = 14
odrv0.axis1.motor.config.current_lim = 1.2

odrv0.axis1.sensorless_estimator.config.pm_flux_linkage = 5.51328895422 / (14 * 230)

odrv0.axis1.requested_state = AXIS_STATE_SENSORLESS_CONTROL

Also according to the docs, if I request AXIS_STATE_FULL_CALIBRATION_SEQUENCE, the motor should rotate in one direction and then the reverse after the beep. But my motor is just rotating in one direction after the beep and stops. I actually don’t know the wiring scheme of the BLDC motor so i tried all 6 possible combinations of the wiring and still same effect. Only thing is for different combinations, the direction of motor rotation changes while calibration but still rotates in one direction.

These commands i’m giving is a culmination of the other posts on the topic of sensorless mode not working and still its not working for me. What am I missing?

A sensor? :slight_smile:

No, seriously. Without an encoder, you’re fundamentally limited to velocity mode operation, so you don’t get positioning or low-speed torque, which is what the odrive is really meant for.

That aside, have you tried going straight to AXIS_STATE_CLOSED_LOOP_CONTROL?
I’m not sure that the full calibration sequence is valid or possible in sensorless mode. The part it failed on sounds like encoder offset calibration, and there’s no encoder so it failed.

Try going closed loop and setting a velocity setpoint.

1 Like

@towen Yes, I forgot to mention I don’t have any encoder feedback and I intend to run it in velocity mode for now. And I was under the impression that Closed Loop mode would need a sensor?

No, sensorless is still closed loop. It’s using the motor’s generated back-emf voltage as a sensor, which is why it only works at high speeds.

I tried this immediately after switching on the ODrive :

odrv0.axis1.controller.set_vel_setpoint = 10
odrv0.axis1.controller.vel_setpoint = 10
odrv0.axis1.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL

odrv0.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

Should I be needing to add PM Flux values before these?

You still need to do AXIS_STATE_MOTOR_CALIBRATION if it’s not already saved, to detect the resistance and inductance of your motor phases.

And yes, you need to set pm flux linkage, pole count etc. if they are not saved too.

I tried these commands in order. Am i missing something again?

odrv0.config.brake_resistance = 0.03

odrv0.axis1.controller.config.vel_gain = 0.01
odrv0.axis1.controller.config.vel_integrator_gain = 0.05
odrv0.axis1.controller.vel_setpoint = 100
odrv0.axis1.controller.set_vel_setpoint = 100

odrv0.axis1.motor.config.direction = 1
odrv0.axis1.motor.config.pole_pairs = 14
odrv0.axis1.motor.config.current_lim = 1.2
odrv0.axis1.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT
odrv0.axis1.motor.config.current_lim = 3
odrv0.axis1.motor.config.calibration_current = 3

odrv0.axis1.sensorless_estimator.config.pm_flux_linkage = 5.51328895422 / (14 * 230) 

odrv0.axis1.requested_state = AXIS_STATE_MOTOR_CALIBRATION

odrv0.axis1.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL

odrv0.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

EDIT:

Under commands of the ODrive docs,

AXIS_STATE_CLOSED_LOOP_CONTROL Run closed loop control.

  • The action depends on the control mode
  • Can only be entered if the motor is calibrated ( <axis>.motor.is_calibrated ) and the encoder is ready ( <axis>.encoder.is_ready )

Meaning i can’t even enter CLOSED LOOP control without having an encoder right?

EDIT2:

So i tried all the above commands with one change being

odrv0.axis1.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL

And the motor moved just for one instant. Is this wrong wiring of phases of the motor?

Check the errors with dump_errors(odrv0). You may need to increase your velocity limit if ERROR_OVERSPEED is on the list.

You cannot get the phase wiring wrong. It is detected automatically during the calibration routines.

The docs are assuming you are in one of the normal encoder-based modes. All the default settings and documentation are geared towards use of an encoder, which is the proper way to drive any synchronous servomotor. Sensorless is more of an experimental feature, and I’d still strongly suggest that you find yourself an encoder.
AS5047P for example are very robust and easy to use. They are not sensitive to alignment- You can literally stick the magnet on to the back of the shaft with super glue, and it works fine.

1 Like

This is what I get when i run dump_errors(odrv0).

axis0
  axis: no error
  motor: no error
  encoder: no error
  controller: no error
axis1
  axis: Error(s):
    ERROR_MOTOR_DISARMED
    ERROR_MOTOR_FAILED
  motor: Error(s):
    ERROR_CURRENT_UNSTABLE
  encoder: no error
  controller: no error

I just want to see if I can make the motor run in either directions without the encoder for now. Its taking a while for delivery and I’m trying to figure out stuff meanwhile :stuck_out_tongue:

EDIT:
Checked out this error, and a similar post’s solution worked out.

Now i am able to run the motor in either directions. Thank you for helping me troubleshoot all the way :smiley: @towen

2 Likes