Motor Does Not Move in Velocity Control

Hi,

I’ve been trying to get the ODrive to do velocity control for the last couple of days and I’m having trouble getting the motor to move.

Setup:
I have a T-Motor U8 and the AS5047P encoder connected to it. The motor is hooked up to axis 0. I’ve done all the basic electrical connection checks. The encoder’s ABI signals are clear and the power supply has enough power to run the motor.

Problem:
I want to run the motor in velocity control mode. The main symptom is that the motor is not moving. This is the setup script that I am using:

# Configure motor

odrv0.axis0.motor.config.current_lim = 10
odrv0.axis0.motor.config.pole_pairs = 21
odrv0.axis0.motor.config.motor_type = MOTOR_TYPE_HIGH_CURRENT

# Brake resistance

odrv0.config.brake_resistance = 0.47 # Ohms

# Enoder

odrv0.axis0.encoder.config.cpr = 4096
odrv0.axis0.encoder.config.use_index = True
odrv0.axis0.encoder.config.calib_range = 0.1

# Controller configuration

axis = odrv0.axis0
axis.controller.config.vel_limit = 170667
axis.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL #CTRL_MODE_VELOCITY_CONTROL

axis.controller.config.pos_gain = 0.0
axis.controller.config.vel_gain = 0.0015
axis.controller.config.vel_ramp_rate = 0
axis.controller.config.vel_integrator_gain = 0.00
axis.controller.config.setpoints_in_cpr = True
axis.controller.vel_ramp_enable = False

# Set needed startup procedures to true

axis.config.startup_motor_calibration = True
axis.config.startup_encoder_index_search = True
axis.config.startup_encoder_offset_calibration = True
axis.config.startup_closed_loop_control = True
axis.config.startup_sensorless_control = False

odrv0.save_configuration()

try:
    odrv0.reboot()
except:
    pass

odrv0 = odrive.find_any()

print("Found the motor again. Setting velocity setpoint")

for i in range(5):
    print("Sleeping...")
    time.sleep(1)

odrv0.axis0.controller.set_vel_setpoint(20000, 0.9)

Most of the time, the motor does not spin. Sometimes the motor spins once and then stops. On rare ocassions it’s spun twice before stopping. I’ve tried different velocities to no avail.

I’ve tried tuning the velocity gain. At lower gains the motor does not spin at all. Beyond a certain value, the motor vibrates back and forth (quite loudly and strongly) but does not spin. In between, it spins up once or twice and stops.

When the motor stops, there are no errors in the axis. ‘dump_errors’ shows no errors anywhere.

Other details:
The calibration runs just fine. In the beginning, the motor moves and searches for the index and finds it. The motor moves smoothly during this calibration. However, I’m not able to replicate this smooth motion at all.

Position control works after the gains are tuned but setting a position that is too far away from the current one fails with an OVERSPEED error.

I’ve played around with a lot of settings and I’ve read and reread the documentation multiple times. Am I missing something here?

Any help is appreciated.

Thanks!
-Ashwin

Hey! I managed to solve the problem. For others who might be having the same problem: the issue was that the encoder was operating at 5V. I assumed that this would be OK because the ODrive inputs are supposed to be 5V tolerant. Since we were out of options, we just tried to put the Encoder into 3.3V operation and the driver started working. Just like that!

2 Likes

Hello I do have the same problem. Is it still working with putting the encoder into 3.3 V? Or did you find another solution?
For my setup calibration works but in velocity control the motor just spinns to a certain position and then stops. If I try to turn the motor further by hand there is high resistance.

Hi, the setup is still working for me. Position and velocity control are working perfectly. Haven’t tested torque control yet.

I have the same problem! Switching to 3.3V did not fix the issue, motor stops and resists rotation.

@Ashwin_Narayan
Why you use feed-forward torque in your command? How can this to help you?
odrv0.axis0.controller.set_vel_setpoint(20000, 0.9)

If you have a known acceleration or load, the feed-forward term can help reduce velocity error.

1 Like

It’s great!
Did you know formula for can help me calculate feed-forward torque?