Hello, everyone.
I am controlling the motor using position control (not using filtered input mode), as shown in the picture above. I have set the velocity integrator gain to 0, and I am adjusting only the position gain and velocity gain for control.
One question I have is: in this situation, am I performing P control or PD control? Can I consider the position gain as the P-gain and the velocity gain as the D-gain?
Hi! It’s the same as a PD controller, but with different gain scaling. Specifically:
A PD controller would have the equations:
torque = Kp * pos_error + Kd * d/dt pos_error
Since the derivative of position error is just -velocity
(which we’ll call vel_est
, for velocity estimate), we can simplify this to:
torque = Kp * pos_error - Kd * vel_est
However, with the cascaded velocity controller, the position controller sets a setpoint (which we’ll call vel_ref
) for the velocity controller.
We can say the velocity controller works as:
torque = vel_gain * vel_error + vel_integrator_gain * ∫vel_error
Or, setting vel_integrator_gain
to zero and substituting (setpoint-actual) for vel_error
, we get:
torque = vel_gain * (vel_ref - vel_est)
Our position controller is simpler, it’s just vel_ref = vel_gain * pos_error
If we substitute, we get:
torque = vel_gain * (pos_gain * pos_error - vel_est)
You can expand this to:
torque = vel_gain * pos_gain * pos_error - vel_gain * vel_est
Now if we compare this to the original PD equation, we can see the differences:
torque = Kp * pos_error - Kd * vel_est
So to transform from “standard” PD coefficients to the cascaded coefficients, you would set:
vel_gain = Kd
pos_gain = Kp/vel_gain
Thank you for your quick response.
Thanks to your explanation, I was able to understand it very easily.
Great to hear! Please let me know if there’s any other way I can help.
Thank you for answering my previous question.
While studying further, I came up with an additional question.
In the equation
torque = Kp * pos_error - Kd * vel_est
what are the units of each term?
In particular,
- Is pos a normalized value between 0 and 1? (i.e., not in degrees or radians)
- Is vel representing angular velocity?
I would appreciate your explanation on this additional question.
Torque is Nm (newton-meter)
vel_gain on the ODrive is Nm/(turns/s)
vel_integrator_gain is Nm/(turns/s) * s = Nm/turns
pos_gain is Nm/turns
In that example where I abstracted the ODrive’s nested control loop to a PD controller only on position, Kp would be Nm/(turns) and Kd would be Nm/(turns/s)
position (pos) is in unit of turns, so pos_error would also be unit of turns
vel_est (estimated velocity) is in units of turns/s.