 # Basic questions for tuning motor

Hi all

just 2 beginner questions about motor tuning:

• Do I need to perform the tuning of the motor while it is connected to a load?

• about the bandwidth, I used liveplotter and sent a position command from 1 turn to 2 turns, and it seems that the time it took was around 12 ms. So I set the integrator gain as 0.5 * 1/0.012 * 0.11 (0.11 my vel gain).

Is this correct? What I find confusing here is that if I would have sent another position command, for example 5 turns, then the time would be longer and the integrator gain smaller? So is this also something where you need to choose “realistic” position values or am I missing something?

thank you

Yes. You need to tune the whole system, not just the motor.

No. The bandwidth is more accurately described as the frequency of a sine wave that you want to be able to track with ~ -3dB amplitude loss. How fast do you need your motor to go back and forth say… 1 turn?

Well, my motor rotates very slowly (i use trap_traj) so perhaps it is not that relevant to me. But I would still like to learn how it should be done for future projects.

Lets hypothetically say that the motor goes back and forward 1 turn in, I dunno, 50 ms?

Ok, so then I need to multiply this value of 20Hz with vel_gain to get the integrator_gain? Because in the explanation here:

The integrator can be set to 0.5 * bandwidth * vel_gain, where bandwidth is the overall resulting tracking bandwidth of your system. Say your tuning made it track commands with a settling time of 100ms (the time from when the setpoint changes to when the system arrives at the new setpoint); this means the bandwidth was 1/(100ms) = 1/(0.1s) = 10hz. In this case you should set the vel_integrator_gain = 0.5 * 10 * vel_gain.

there is also a factor 0.5, which I assumes is because in the above explanation you still need to account for only going one way but not going back again? But since you calculated with the time to go forward AND back again, the 0.5 is not needed?

Hi all,

Bumping this thread again, I am trying to improve my understanding of this tuning process… Sorry in advance for a lot of questions…

I found something online which is what the odrive docs seem to refer to: link

And also some articles referring to what Wetmelon said: link

I think the docs from odrive describe a method that does not require a complex sine wave but a simple step? I guess at some time odrivetool could not provide these complex motions?

I just discovered that odrive has an input_mode_tuning specifically for tuning described at the bottom of this page

``````INPUT_MODE_Tuning  —  8

Implements a tuning mode

Used for tuning your odrive, this mode allows the user to set different frequencies.
Set control_mode for the loop you want to tune, then set the frequency desired.
The ODrive will send a 1 turn amplitude sine wave to the controller with the given
frequency and phase.
``````

where exactly can i control the frequency and phase? I thought here? But there is no phase mentioned there?

Also, could you help me understand what exactly happens when we set the integrator gain to 0.5 * bandwidth * vel_gain?

• Is this a rule of thumb or based on a formula?
• My understanding is that when the motor can no longer track the sine wave and there is a loss of 3dB amplitude, the system is considered to have lost control? And we “tell” the system that trying to control anything above this bandwidth is a waste of energy? But what I don’t get is what we exactly accomplish by setting the integrator gain to 0.5 * bandwidth * vel_gain? Have we implicitly told the system what the bandwidth is?
• Would it not make more sense to tell the odrive directly the bandwidth and let it calculate the integrator gain by itself?

thanks all