|
Velocity PID Programming: Terms dependent on time
Several of the simplified position PID's I've seen fail to mention you need to incorporate time into your formulas for the I and D terms.
So, it seems that would carry over to a velocity PID.
Let's say I have a simple velocity PID in pseudo-code (note - this pseudocode is not correct).
(Desired_Velocity - Actual_Velocity) * Prop Gain = Prop_Term;
(This_Velocity_Error - Last Velocity Error) * Der Gain =Der_Term;
Last_PID_Output = Feed_Forward;
PID Output = Prop_Term + Der_Term + Int_Term + Feed_Forward;
Which of these terms need to be normalized by dividing them by the loop timing?
Ok, so I'm going to put the corrected velocity PID here, to make sure no one uses the incorrect one above:
Correct pseudocode
Prop = (setpoint - measured_value) * Prop Gain
Der = (error - previous_error)/dt * Der Gain
Feed_Forward = Last_Output
Output = prop + int + Feed_Forward
Last edited by Tom Line : 30-01-2013 at 11:26.
|