Hoverboard Motors Wiggling

Hi everyone,

I’m trying to get the Odrive controller to control two hoverboard motors with a joystick. Pretty much I’m trying to do the hoverboard guide project in the documentation. No matter what I do I can’t seem to get the wheels to spin. I’ve tried position control, velocity control, and I’ve even tried sensorless mode. Currently what I’m getting is when I calibrate, the motor beeps then rotates 1.5 times in both directions and returns no errors. I then try to use vel_setpoint and the motors wiggle back and forth violently. I thought this might have to do with vel_gain but nothing I do there seems to fix it. I’ve also set vel_ramp and that doesn’t help either. I also don’t get any errors with any of this.

In [77]: odrv0.axis0.encoder.config
Out[77]:
mode = 1 (int)
use_index = False (bool)
find_idx_on_lockin_only = False (bool)
pre_calibrated = False (bool)
zero_count_on_find_idx = True (bool)
cpr = 90 (int)
offset = 72 (int)
offset_float = 0.5015027523040771 (float)
enable_phase_interpolation = True (bool)
bandwidth = 100.0 (float)
calib_range = 0.019999999552965164 (float)
calib_scan_distance = 150.0 (float)
calib_scan_omega = 12.566370964050293 (float)
idx_search_unidirectional = False (bool)
ignore_illegal_hall_state = False (bool)

In [78]: odrv0.axis0.motor.config
Out[78]:
pre_calibrated = False (bool)
pole_pairs = 15 (int)
calibration_current = 10.0 (float)
resistance_calib_max_voltage = 4.0 (float)
phase_inductance = 0.00038733400288037956 (float)
phase_resistance = 0.21913877129554749 (float)
direction = 1 (int)
motor_type = 0 (int)
current_lim = 10.0 (float)
current_lim_tolerance = 1.25 (float)
inverter_temp_limit_lower = 100.0 (float)
inverter_temp_limit_upper = 120.0 (float)
requested_current_range = 25.0 (float)
current_control_bandwidth = 100.0 (float)

In [79]: odrv0.axis0.controller.config
Out[79]:
control_mode = 2 (int)
pos_gain = 1.0 (float)
vel_gain = 0.9303749799728394 (float)
vel_integrator_gain = 4.651875019073486 (float)
vel_limit = 10.0 (float)
vel_limit_tolerance = 0.0 (float)
vel_ramp_rate = 10000.0 (float)
setpoints_in_cpr = False (bool)

Hi,
Here is my configs and how they compared to yours.
I did notice my pre_calibrated = True and yours was false.
Hope these help.

odrv0.axis0.encoder.config
Out[5]:
mode = 1 (int)
use_index = False (bool)
find_idx_on_lockin_only = False (bool)
abs_spi_cs_gpio_pin = 1 (int)
zero_count_on_find_idx = True (bool)
cpr = 162 (int)
offset = 86 (int)
pre_calibrated = True (bool)
offset_float = 1.4956541061401367 (float)
enable_phase_interpolation = True (bool)
bandwidth = 100.0 (float)
calib_range = 0.019999999552965164 (float)
calib_scan_distance = 150.0 (float)
calib_scan_omega = 12.566370964050293 (float)
idx_search_unidirectional = False (bool)
ignore_illegal_hall_state = False (bool)
sincos_gpio_pin_sin = 3 (int)
sincos_gpio_pin_cos = 4 (int)

odrv0.axis0.motor.config
Out[6]:
pre_calibrated = True (bool)
pole_pairs = 27 (int)
calibration_current = 10.0 (float)
resistance_calib_max_voltage = 9.0 (float)
phase_inductance = 0.0013313732342794538 (float)
phase_resistance = 0.8382959365844727 (float)
torque_constant = 0.8270000219345093 (float)
direction = -1 (int)
motor_type = 0 (int)
current_lim = 10.0 (float)
current_lim_margin = 8.0 (float)
torque_lim = inf (float)
inverter_temp_limit_lower = 100.0 (float)
inverter_temp_limit_upper = 120.0 (float)
requested_current_range = 25.0 (float)
current_control_bandwidth = 100.0 (float)
acim_slip_velocity = 14.706000328063965 (float)
acim_gain_min_flux = 10.0 (float)
acim_autoflux_min_Id = 10.0 (float)
acim_autoflux_enable = False (bool)
acim_autoflux_attack_gain = 10.0 (float)
acim_autoflux_decay_gain = 1.0 (float)

odrv0.axis0.controller.config
Out[7]:
gain_scheduling_width = 10.0 (float)
enable_vel_limit = True (bool)
enable_current_mode_vel_limit = True (bool)
enable_gain_scheduling = False (bool)
enable_overspeed_error = True (bool)
control_mode = 2 (int)
input_mode = 1 (int)
pos_gain = 1.0 (float)
vel_gain = 2.6794800758361816 (float)
vel_integrator_gain = 13.39739990234375 (float)
vel_limit = 10.0 (float)
vel_limit_tolerance = 1.2000000476837158 (float)
vel_ramp_rate = 1.0 (float)
torque_ramp_rate = 0.009999999776482582 (float)
circular_setpoints = False (bool)
circular_setpoint_range = 1.0 (float)
homing_speed = 0.25 (float)
inertia = 0.0 (float)
axis_to_mirror = 255 (int)
mirror_ratio = 1.0 (float)
load_encoder_axis = 0 (int)
input_filter_bandwidth = 2.0 (float)
anticogging:
index = 0 (int)
pre_calibrated = False (bool)
calib_anticogging = False (bool)
calib_pos_threshold = 1.0 (float)
calib_vel_threshold = 1.0 (float)
cogging_ratio = 1.0 (float)
anticogging_enabled = True (bool)

It sounds like the velocity control gains are unstable. The velocity controller is a PI (proportional-integral) controller. We have a tuning procedure at the end of this page Control | ODrive - you can skip the parts about pos_gain.

The basic procedure is to find a vel_gain that causes the motor to vibrate, reduce vel_gain to 50% of the vibrating value, and then increase vel_integrator_gain so that the motor maintains the velocity that you set.