View Single Post
  #11   Spotlight this post!  
Unread 30-01-2013, 12:36
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Velocity PID Programming: Terms dependent on time

The short answer, in my OPINION is:

The Proportional and Feed Forward terms need no time normalization. They are instantaneous terms.

The Integral term must be multiplied by the time interval. You should be doing this before accumulating the error each cycle (accumulator += error * t). Don't multiply your accumulated values by the time interval my mistake.

The Derivative term must be divided by the time interval ((error - lasterror) / t).

This will allow you to keep consistent P, I and D constants that are independent of your PID loop interval.

I say in my OPINION because there are countless ways to play with these to try and optimize performance, and if you ask two people, you'll probably get two different answers.

This results in the following pseudo-code:

FF = Kff * setpoint

P = Kp * error

accumulator += error * timeInterval
I = Ki * accumulator

D = Kd * (error - lasterror) / timeInterval

Output = FF + P + I + D
__________________
In life, what you give, you keep. What you fail to give, you lose forever...

Last edited by Mr. Lim : 30-01-2013 at 12:48.