|
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.
|