|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
PID Timing
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? |
|
#2
|
|||
|
|||
|
Re: PID Timing
No... it doesn't sound like you are off base. Are you sure the the PID is not time compensated?
|
|
#3
|
||||
|
||||
|
Re: PID Timing
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.
|
|
#4
|
||||
|
||||
|
Re: PID Timing
See attached screenshot.
|
|
#5
|
||||||
|
||||||
|
Re: PID Timing
How are you calculating the derivative if you aren't taking into account the actual loop time? Same for the integral.
|
|
#6
|
|||
|
|||
|
Re: PID Timing
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.
|
|
#7
|
|||||
|
|||||
|
Re: PID Timing
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. |
|
#8
|
||||
|
||||
|
Re: PID Timing
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|