Shop OBEX P1 Docs P2 Docs Learn Events
PID question — Parallax Forums

PID question

TappermanTapperman Posts: 319
edited 2014-08-25 17:31 in Learn with BlocklyProp
Analog equivalent to digital PID:

I was reading the write up on the sticky about PID ... very cool presentation BTW ... and I happened across a 'filter' circuit discussion for A/D sampling. They gave a circuit that I care little about the subject at hand ... but, noticed something in the design.

Well, to make a short story long, I noticed the circuit (see attach) has what appears to be all 3 elements in its feedback loop. Am I off base here?

... Tim

PS - feedback for the coefficient seems to be negative?
1024 x 475 - 29K

Comments

  • edited 2014-08-14 12:08
    Thanks on the PID article. http://forums.parallax.com/showthread.php/77656-PID-Control-Intro-with-the-BASIC-Stamp

    I was happy about that because the discrete time approach seemed like it made the calculus aspects digestible. I never figured out a way to do that for a general audience with Laplace domain expressions like what's in your attachment.

    As for your filter, I do remember tuning those back in college (15 years ago now), and recall something about expressing it with a second order polynomial in the denominator for PID tuning... Hmmm, it might take more hours than I have to refresh on that right now... Ah, here we go, a Google Search for PID and Sallen-Key delivered this nugget:

    http://books.google.com/books?id=3WvnAgAAQBAJ&pg=PA517&lpg=PA517&dq=PID+sallen+Key&source=bl&ots=ibWMtC2DGR&sig=_i0jCJLnlt7E4Z-UD9W1AUqqNlM&hl=en&sa=X&ei=mQTtU-C5FpD_oQT_jYGgBg&ved=0CBwQ6AEwADgK#v=onepage&q=PID%20sallen%20Key&f=false
  • macrobeakmacrobeak Posts: 354
    edited 2014-08-19 18:45
    Andy, Your PID article is very good for understanding practical control. I want to ask about the integral term. I see you continuously accumulate the error over the entire history. How do you quantify the effect if you only accumulate errors over a lesser history (say) the last 10 steps, or even a shorter history (say) the last 3 steps?
  • edited 2014-08-20 09:09
    Hmmm, I should probably change that so that the amount accumulated by the integral term is limited to a certain max and min. The most common use of the integral term is to accumulate small errors to match the output to the set point, which the proportional term often cannot do on its own. Without limiting how much integral can accumulate, conditions could occur that cause it to accumulate so much that it disables its ability to take over when proportional correction runs out of steam close to the set point. For example, if the integral term accumulates to -100 during a big change in the system because it is not limited, it would take a lot of adding errors of 2 or 3 to finally bring the integral term back so that it's doing fine corrections.

    Like limiting the amount the integral term can accumulate, limiting the history to a certain number of samples is another way of preventing the integral term from accumulating too much under certain conditions, and you can still limit the final value it adds up to. You would want to take enough samples so that they add up to a high enough value to take over when proportional is unable to push the system past that minute error and all the way to the set point. You'll want to adjust the value of Ki so that it tends to correct the system to the set point. If Ki x I can get too large, you might see overshoot (over correction) and even oscillation (over correct in one direction, then over correct in the other direction) around the set point.

    Andy
  • jonesjones Posts: 281
    edited 2014-08-20 21:46
    Macrobeak, I'm by no means a wizard of closed-loop control, but here is one way to think about the integral term. Consider a PID temperature controller that maintains the temperature of an incubator. Like any real enclosure, the insulation is not perfect and the incubator leaks heat to the surroundings. With only proportional and derivative terms, the temperature will never be stable because you need a deviation from setpoint to have any power fed to the heater so the controller can only chase those deviations. For stability, you need to have the heater putting enough heat into the incubator even at the setpoint to compensate for the losses from leakage. That's what the integral term is for in this example. If you don't integrate long enough, the integral may never get large enough to compensate for the heat loss, compromising stability. Naturally, if someone holds the door open too long, the integral can grow too large and cause problems, so you may have to limit it, or stop integrating during large deviations from setpoint. Just make sure it can still do its job over the expected range of conditions.
  • TappermanTapperman Posts: 319
    edited 2014-08-25 10:10
    Hmmm, I should probably change that ...

    Andy,

    Before you make any changes ... would you 'consider' looking at my moon tracker?

    I have the same issues when tracking ... However, since my robot doesn't know where the moon really is ... I can not use 'proportional', as the difference between where it is and where it should be is not known. So, I rely on the integral of 'errors' (you'll have to see how I define 'error', in my application) to tell me where the moon is.

    Clearing after a period of time or limiting its size or only the last 3 etc, may be the wrong suggestion ... depending on the application. But, those techniques may work well in others.

    http://forums.parallax.com/showthread.php/133265-Lunar-Tracker?p=1289327#post1289327

    ... Tim
  • TappermanTapperman Posts: 319
    edited 2014-08-25 17:31
    macrobeak wrote: »
    ... I want to ask about the integral term. I see you continuously accumulate the error over the entire history. How do you quantify the effect if you only accumulate errors over a lesser history (say) the last 10 steps, or even a shorter history (say) the last 3 steps?

    @macrobeak

    I’m responding to your message because I had the very same question about the integral that you have. And since most of us drive cars, I thought I’d use this as an analogy to help explain what I discovered about that single element, of the three terms in the feedback loop.

    If you drive a car that has a ‘cruise control’ built in … then you are using a form of PID. After you set the speed, the control attempts to keep your speed constant.

    But we drive on terrain that is not always flat, chances are you may have to adjust the throttle. And, when the car must go up a gentle incline … the accumulated error increases and adds more throttle. When the slope changes back to level, the accumulated error goes down (by adding negative errors) and the car continues at a speed where the instant error is zero … but the accumulated error is not zero. In fact, while the cruise control is being used, the accumulated error never reaches zero. As long as you have throttle, you have accumulated error.

    I hope this helps visualize PID as I see it. After all, I could be wrong.

    ... Tim

    PS - If loads were always constant ... we would have no need for PID
Sign In or Register to comment.