Help with Closed Loop Control Tuning

I’m trying to drive a pair of 190KV BLDC motors with integrated hall sensors. I’ve gotten past motor and encoder calibration, but since I don’t really understand closed-loop motor control, I don’t really grok the tuning process.

With the values I currently have, when I set a target velocity, the motor (I can only run one at a time before hitting some current limit) takes ~30 seconds to start spinning, and then gradually pics up speed. Then when I try to set the velocity back to 0, nothing happens: the only way to stop it is to set its state from CLOSED_LOOP_CONTROL to IDLE.

Here’s my setup code:

def set_config(odrv):
  # Settings to protect battery
  odrv.config.dc_bus_overvoltage_trip_level = 24.7
  odrv.config.dc_bus_undervoltage_trip_level = 19.2
  odrv.config.brake_resistance =  0.5
  for axis in [odrv.axis1, odrv.axis0]:
    axis.motor.config.current_lim = 45

    axis.motor.config.pole_pairs = 7
    axis.motor.config.resistance_calib_max_voltage = 4
    axis.motor.config.requested_current_range = 90 #Requires config save and reboot
    axis.motor.config.current_control_bandwidth = 100
    axis.encoder.config.mode = ENCODER_MODE_HALL
    axis.encoder.config.cpr = 45
    axis.encoder.config.bandwidth = 100
    # I think the issue is in these 3 lines?
    axis.controller.config.pos_gain = 1
    axis.controller.config.vel_gain = 0.02
    axis.controller.config.vel_integrator_gain = .1

    axis.controller.config.vel_limit = 1000
    axis.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL

Can anyone give pointers on the tuning process? I looked through, but still don’t understand + the issues listed there aren’t the same as what I’m see.

For clarification, there’s no error code or anything.


The ODrive hoverboard motor code is pretty shit ngl.
This code actually works Motor Current Unstable error
make sure if u are using rc to put the pwm shit in. Sensorless also works pretty well with the hoverboard motors, I can hook u up with mine if needed.

Have a great fucking day