Abnormal behavior of motor when physical load is applied to motor

Hi, I’m using an Odrive v3.6-56v, and I set up Odrive following the hoverboard guide.

The motor worked well. But some problems remain.

When activating the physical brake while driving the motor in a closed loop, the motor stops for a while and then starts to rotate again.

And when you activate the physical brake while driving the motor, set the speed to zero, and release the brake, the motor moves like a spring.

How do we get rid of this phenomenon?

Here are my config parameters.

odrv0.config.gpio3_mode = GPIO_MODE_PWM
odrv0.config.gpio3_pwm_mapping.min = 4
odrv0.config.gpio3_pwm_mapping.max = -4
odrv0.config.gpio3_pwm_mapping.endpoint = odrv0.axis0.controller._input_vel_property
odrv0.config.gpio4_mode = GPIO_MODE_PWM
odrv0.config.gpio4_pwm_mapping.min = -4
odrv0.config.gpio4_pwm_mapping.max = 4
odrv0.config.gpio4_pwm_mapping.endpoint = odrv0.axis1.controller._input_vel_property

odrv0.config.gpio9_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio10_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio11_mode = GPIO_MODE_DIGITAL

odrv0.config.gpio12_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio13_mode = GPIO_MODE_DIGITAL
odrv0.config.gpio14_mode = GPIO_MODE_DIGITAL

odrv0.config.dc_bus_undervoltage_trip_level = 8
odrv0.config.dc_bus_overvoltage_trip_level = 56 

odrv0.config.brake_resistance = 2.0
odrv0.config.enable_brake_resistor = True

odrv0.axis0.motor.config.pole_pairs = 10
odrv0.axis0.motor.config.calibration_current = 10
odrv0.axis0.motor.config.current_control_bandwidth = 100
odrv0.axis0.motor.config.torque_constant = 8.27 / 5.31
odrv0.axis0.motor.fet_thermistor.config.enabled = False
odrv0.axis0.encoder.config.mode = ENCODER_MODE_HALL
odrv0.axis0.encoder.config.cpr = 60     
odrv0.axis0.encoder.config.bandwidth = 250

odrv0.axis0.encoder.config.ignore_illegal_hall_state = True
odrv0.axis0.encoder.config.hall_polarity_calibrated = True

odrv0.axis0.controller.config.enable_gain_scheduling = True  
odrv0.axis0.controller.config.gain_scheduling_width = 250
odrv0.axis0.controller.config.enable_vel_limit = True
odrv0.axis0.controller.config.enable_overspeed_error = False

odrv0.axis0.controller.config.spinout_electrical_power_threshold = 100
odrv0.axis0.controller.config.spinout_mechanical_power_threshold = -100

odrv0.axis0.controller.config.pos_gain = 20
odrv0.axis0.controller.config.vel_gain = 2
odrv0.axis0.controller.config.vel_integrator_gain = 20

odrv0.axis0.config.calibration_lockin.current = 30
odrv0.axis0.config.general_lockin.current = 30
odrv0.axis0.config.calibration_lockin.vel = 20
odrv0.axis0.config.general_lockin.vel = 20
odrv0.axis0.controller.config.vel_limit = 20

odrv0.axis0.controller.config.control_mode = CONTROL_MODE_VELOCITY_CONTROL
odrv0.axis0.controller.config.input_mode = INPUT_MODE_VEL_RAMP 

odrv0.axis0.controller.config.torque_ramp_rate = 1
odrv0.axis0.controller.config.vel_ramp_rate = 4

odrv0.axis0.motor.config.current_lim = 30
odrv0.axis0.motor.config.current_lim_margin = 8
odrv0.axis0.motor.config.requested_current_range = 38

Cool robot!

What you’re seeing is the ODrive overpowering the brakes. If the ODrive’s velocity controller fails to match the user-desired velocity, it will ramp up the applied torque over time at a rate proportional to vel_error*vel_integrator_gain. When you release the brakes after setting the speed to zero, the ODrive will still have that additional ramped torque (the integrator term - this is just a PI controller), causing brief overshoot in velocity.

You can read more about this in our control structures and tuning page.

So, you have four options here:

  1. Set vel_integrator_gain to 0. This will result in worse velocity control performance, as the ODrive no longer has one of the valuable tools it uses for ensuring the wheel velocity reaches the setpoint velocity
  2. Set the vel command to zero or put the ODrive in idle when the brakes are applied. You’d need an external microcontroller such as an Arduino to read the PWM from the ESC and send the relevant commands to the ODrive using the ODriveArduino library over serial.
  3. Let the ODrive control the brake. You can use an ODrive GPIO to control the brake (through a relay or MOSFET, similar to how the RC receiver is controlling it in your robot), and it’ll automatically set the brake when the ODrive is in idle, and release it when the motor’s running. This will also require an external microcontroller such as an Arduino.
  4. Set the ODrive’s torque_lim to a value such that it’ll never exceed the maximum brake force. However, this won’t solve the brief movement when the brake is released.
1 Like

Thank you for your advice!

I changed the wiring to send an idle signal from Arduino to Odrive when the brake signal comes into Arduino.

Now my ODrive works well.:+1:

Awesome!! Glad to hear that.