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