View Full Version : PID Timing
Tom Line
12-01-2012, 22:06
If seems to me that PID Loops are time dependent. After all, you have the derivative term which is essentially monitoring the change in your error term.
My question then, is why the derivative term isn't normalized for time (divided by the loop timing) to account for loops changing speed. In the past, we've not used "D" terms, but it seems that when the cpu starts to get loaded down, the D term could cause issues due to varying loop timing.
Am I off base?
No... it doesn't sound like you are off base. Are you sure the the PID is not time compensated?
Tom Line
13-01-2012, 02:54
Well, we've always written our PID's by ourselves. The math is trivial and it's good for the kids to understand where they come from. Not a single paper I've read on PID calculation states as an assumption that the loop needs to be consistently timed. That's why I'm curious if we can improve our PID loops by incorporating a time normalization into the derivative term.
My question then, is why the derivative term isn't normalized for time (divided by the loop timing)
See attached screenshot.
Joe Ross
13-01-2012, 09:21
How are you calculating the derivative if you aren't taking into account the actual loop time? Same for the integral.
jwakeman
13-01-2012, 09:43
Things are easier if you use a "fixed dt". This means you should execute your PID algorithm at a fixed rate. Example, run the loop every 10ms or every 100ms. Otherwise you do need to adjust your gains for the time since you last ran the loop every time you run the loop.
Two solutions:
-Calculate DT with a tick count, shift register/feedback node, and subtract.
-Use a timed RT loop to guarantee time. You can not care about the dt because it is constant. Time in PID will then be counted in iterations instead of milliseconds, which is fine.
I am currently doing the second. It seems to be working well so far.
Use a timed RT loop to guarantee time.
http://www.chiefdelphi.com/forums/showpost.php?p=1053464&postcount=3
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.