Configuring motor parameters for ODrive

I’ve been using a hub motor for my eBike project, and while configuring the ODrive in the GUI, I wasn’t sure of the motor’s KV value because it wasn’t provided, so I entered an approximate value. Now that I’m further along, I want to ensure everything is set up accurately. Does anyone know a reliable way to determine the KV of my motor?

Additionally, my motor only spins in one direction, so I believe I may need to adjust the configuration to prevent the calibration sequence from attempting to spin it in the opposite direction.

This is the motor I’m using:

Unfortunately there’s no way to only calibrate in a single direction, bidirectional calibration is required to ensure proper motor calibration.

KV of the motor is effectively a scaling constant for the PID gains – if you’re only estimating, that’s fine, as long as you don’t need super accurate torque control.

That being said, if you do want to determine kv, there’s two methods for doing so experimentally:

  1. The one I use:
  • Spin the motor unloaded (no gearbox or anything connected) in velocity control, at some medium-high speed in velocity mode. Make sure you’re well below saturation speed, I usually do around ~half of the motor’s theoretical maximum speed, and try a few different points along the speed range to ensure consistency
  • Measure the velocity in rev/s with axis0.vel_estimate and look at axis0.motor.foc.v_current_control_integral_q
  • KV will be roughly 60*vel_estimate / (sqrt(3) * v_current_control_integral_q)
  • for example, if you’re spinning at 30 rev/s and v_current_control_integral_q is 8.73, then that’s a KV of 60*30/(sqrt(3) * 8.73) == 1800 / (1.732*8.73) == 119 RPM/V

Second method is with an oscilloscope, as shown here: Project HoverArm - #2 by madcowswe