Proper BLDC motor settings guide(unknown motor)

first of all i will say that i have two brushless sensored motor from aliexpress.
This one:

140kv version

There is not much information about them, but i think that inside are 3 hall sensors(like in hoverboard motors).

I have followed getting started from odrive website, but it looks that i need follow guide for hoverboard motors otherwise it is not working.
I have connected all three output wires from hall(A,B,Z) + GND + 3.3V from odrive board.
I have used 47nF capacitors between each A,B,Z and GND.
But as those motors are not same as HUB hoverboard motors what gains, limits i need to use?
When i set it according hoverboards guide it is spinning but it is unstable/shaky/ not working with slow speed, and it looks that close_loop is not holding motors, motors are not holding position(when i am turning them by hand they are not comming back to position),etc.
I am using 12V, 17A ATX PSU from PC for testing.

When set odrv0.axis0.motor.config.pole_pairs i have count 14 magnets(it is visible) so do ineed set this to 7?

odrv0.axis0.encoder.config.cpr = 42
according hoverboard guide 7 pair * 6
(i have 3 halls probably inside so: The hall feedback has 6 states for every pole pair in the motor)
i have check with shadow_count command and turn motors by hand and it looks that it is counting OK, so halls are probably working.

Then i have used same values as in hoverboard guide, but as i have completely different motors do not know if this is correct?
But it looks that motors are not spinning at all without those settings:

odrv0.axis0.motor.config.resistance_calib_max_voltage = 4
odrv0.axis0.motor.config.requested_current_range = 25 #Requires config save and reboot
odrv0.axis0.motor.config.current_control_bandwidth = 100

odrv0.axis0.encoder.config.bandwidth = 100
odrv0.axis0.controller.config.pos_gain = 1
odrv0.axis0.controller.config.vel_gain = 0.02
odrv0.axis0.controller.config.vel_integrator_gain = 0.1
odrv0.axis0.controller.config.vel_limit = 1000
odrv0.axis0.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL

so i am confused.

Another thing is that i do not know what is default values of all settings of odrive.
Can i get it from somewhere(all default values)?
For example do i need set odrv0.config.brake_resistance? Or default value is 2.3 Ohm as resistance of resistor what came with odrive board?
odrv0.axis0.motor.config.motor_type is default to MOTOR_TYPE_HIGH_CURRENT right?

Sorry if this is too much questions but i am lost in all those settings.

Thank you very much.

Hi marigu,

For that motor, the motor.config options can probably stay the same as the defaults without issue. It might be worthwhile to still change current_control_bandwidth to a lower value than the default of 1000. The important thing - your motor is almost the same as the ODrive D5065 motor that the default settings are written for. Motor settings should be the same. Your encoder is different, so I would expect the hoverboard settings for controller and encoder to be close to correct.

What is your application for this motor? Hall effect sensors will not allow for very good position control in general - you only have 42 positions around the motor that ODrive knows about. Unless the motor has a measurable velocity, ODrive has no idea where the motor is except for those 42 positions. In comparison, the AMT encoder in the ODrive store has 8192 positions! Almost anything is better than hall effect sensors for position control. For speed control, they work OK.

Thank you,
i am using it just for small robot, i just need to go forward and backward usualy at low speed.
for now i do not need precision positioning but i need smooth slow speed.
for now when i use:

odrv0.axis0.requested_state = AXIS_STATE_CLOSED_LOOP_CONTROL
odrv0.axis0.controller.vel_setpoint = 50

it is turning somehow but it is quite noisy and not smooth it is almost as when you powering it for 1/45 of one revolution than power off wait few ms and then it will finish revoltuion-do not know how to describe it-it is not smooth spinning , when i use 120 and more it is spinning almost OK but it is little bit noisy so i think it is not smooth as well just it is faster(so it is impossible see “breaks” during spinning), so maybe some settings are not correct

when i was using it with hoverboard motors it was fine, smooth, not noisy, it holds positions etc, but i was using it with 4 large 12V(so 48V together) battery, so maybe 12V/17A ATX PSU is not enough?

Anyway when i reset odrive to default settings and then not following hoverboard settings it is not running at all.

Sometimes i can notice when turning motor by hand and check encoder with shadow_counts that it differs by 1 count(sometimes 40 or 41 cpr instead of 42), but i do not think that this is major issue.
And i am powering HALLs from 3.3V from odrive instead 5V but it should be OK as well right?

So according to you, i will just reset all to default, then:

odrv0.axis0.motor.config.current_lim = 10
odrv0.axis0.motor.config.calibration_current = 10
odrv0.config.brake_resistance = 2.3

odrv0.axis0.motor.config.pole_pairs = 7
odrv0.axis0.motor.config.resistance_calib_max_voltage = 4
odrv0.axis0.motor.config.requested_current_range = 25 
odrv0.axis0.motor.config.current_control_bandwidth = 100

odrv0.axis0.encoder.config.mode = ENCODER_MODE_HALL
odrv0.axis0.encoder.config.cpr = 42

odrv0.axis0.encoder.config.bandwidth = 100
odrv0.axis0.controller.config.pos_gain = 1
odrv0.axis0.controller.config.vel_gain = 0.02
odrv0.axis0.controller.config.vel_integrator_gain = 0.1
odrv0.axis0.controller.config.vel_limit = 1000
odrv0.axis0.controller.config.control_mode = CTRL_MODE_VELOCITY_CONTROL


and it should be enough for settings?

Thank you

The hall-effect encoder issues will show up more at low speed and get better at higher speeds (as you have seen with 45 counts/s velocity vs 120 counts/s). One thing that might help would be to turn down the encoder.config.bandwidth even further - maybe 75 or less.

The ODrive velocity code has to “smooth out” the position data from the encoder into velocity information. If the position data is coarse, the velocity will be noisy. The encoder bandwidth sets the amount of smoothing that happens. Lower bandwidth = more “smoothing”, but slower response.

One thing that will help is adding inertia to your system. The hoverboard was probably smoother at low speed, with hall effect sensors, because it’s got more of a “flywheel action.” It’s possible that the weight of your robot will have the same effect!

I can’t guarantee that the settings will work, but it’s a start. It’s worthwhile to go through the tuning procedure here to get the controller working better after the encoder settings are worked out.

However, there is a limit to how well the hall effect sensors perform, especially at low speed. ODrive also relies on the encoder to commutate the motor, and without enough speed to cleanly interpolate the motor position between hall effect counts, torque will be coarse, too.

OK, so i have changed power of HALLs from 3.3 to 5V, no improvement.
I found out that i need exactly same settings as i have posted before for controller and encoder.
Motor says:

phase_inductance = 5.335370951797813e-05
phase_resistance = 0.1228414997458458
motor_type = 0

not sure if this is correct.

Still no change about slow speed, everything under 100 is useless
Output from HALLs looks that it is not reliable(with shadow_count check), it is somethimes -1 or 1 after odrive reboot, and full revolution is somewhere between 40 - 42.
But i think that my calculation for cpr settings 42(7 pole pairs*6 halls impulses) are correct,
i have tried set it to 40 or 41, it was not working at all so 42 is probably corect.

Now it looks that it need to be fine tuned with all gains values and probably it will be better power it from at least 24V PSU(capable of high current as well).

Or maybe use proper encoder, or motor are little bit shi…eeeeee not good quality:)