View Single Post
Old February 20th, 2003, 06:57 PM   #7
Peter Nachtwey
United States

Peter Nachtwey is offline
Peter Nachtwey's Avatar
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 6,837
Your got

Originally posted by Allen Nelson

It's easy enough to roll your own (although a bit more than 3 multiplies, unless you are willing to combine constants, (LoopUpdateTime is a constant, and SUM(E*k) = k*SUM(E), from the distubive principle that you should have learned in 4th grade)

So the equation becomes:

CV = P*E + I*(Totalized{E}) + D*(Current PV - Last PV) + Bias

P = Kp ;
I = Ki * LoopUpdateTime;
D = Kd / LoopUpdateTime
That is how I combine the constants. Now it is just 3 multiplies and adds and some limiting. Oh yeah, a subtract is required to get the error. Still fast and simple.


When I saw that you were changing the LoopUpdateTime three-fold, I thought that you'd have to do the inverse to Ki in order to keep the 'I' term the same.

But since you changed the trigger time as well, there was only 1/3 as many values of 'E' in the totalized(E), which is why you say you didn't de-tune the loop.

But that doesn't take the derivative portion into account. There, there is no historical sampling of E, and so (I think) that you effectively divided the derivative portion by 3. I doubt that derivative by itself would produce the drastic changes in your graphs (that's due, as you point out, to the CV not being adjusted frequently enough to control the PV adequately) but it might explain the detuning that happened when you updated even more frequently (Fig 6).
In your equation the change in PV is divided by the loop time.

Kd*(Current PV - Last PV)/LoopUpdateTime

If the loop time is 1/3 as long and the PV changes 1/3 as much in the same time, then the result stays the same.
  Reply With Quote