Best approach to tune PD values for motors?

I assumed that P-value directly corresponds to stiffness, thus higher the value higher the stiffness(Rapid torque response). D-value was supposed to provide stability prevent oscillations.
My motors have P value range of [500-0] and D value range of [5-0] .
I started with P= 300[middle value] and D = 1 . There was rapid oscillation when a joint trajectory(Move motor within a particular angle range [+158 to -158 ]) was commanded. By slow increasing D could prevent oscillation. I was able to zero in on D = 3. The problem is at this value, I get minor but strong vibration while commanding the joint trajectory [+158 to -158] . I also face an initial jerk when starting the trajectory.

I was wondering, If there is any other better way to do it.

Thank You

Yours SIncerely,
S.Shyam

hi S.Shyam,

the way I tune the PD gains is as follows: I set the P gain to zero and increase the D gain. While increasing the D gain, I move the joint manually. If the joint starts oscillating, then the D gain as too high. The idea is to keep the D gain a bit lower then the maximum value you found.

Then, you go and increase the P gain until you have the desired stiffness and the leg is still not shacky. Note that, given delays and other effects, you might not be able to avoid shacking when you move the robot leg to random positions and a bit of overswing / oscillation around the desired position might happen.

I assume you are computing the P and D gain on the PC and send a current command to the robot? With the latest firmware you can also run a PD controller on the udriver card at 10 kHz directly. This allows for much higher D gains.

Hope this helps.

Best,
Julian

1 Like

what code you use to control the motor?
I met the same problem when using “demo_2_motor.cpp” in blmc_drivers project.
Did you solve the problem?