View Single Post
  #1   Spotlight this post!  
Unread 29-01-2013, 22:21
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,521
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
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.