Shop OBEX P1 Docs P2 Docs Learn Events
PID output.. — Parallax Forums

PID output..

QuadrtrFlyrQuadrtrFlyr Posts: 73
edited 2012-12-20 16:44 in Propeller 1
Hello folks,

I have a question about PID controllers. The output of my PID controller is supposed to drive two ESC's in my case with a value ranging from 1000-2000. However starting with just the P portion of the controller, do I have to specifically choose a P value that will give me this range? I understand what the PID does but I don't understand how its output is supposed to perfectly match my range.. I think it comes down to tuning the PID perfectly so its output is between 1000-2000 but I am not sure...

Thank you
Robert

Comments

  • Ray0665Ray0665 Posts: 231
    edited 2011-06-19 20:02
    I don't know what an ESC is but let me see if I can help this way. In a straight (non pid drive) the input signal drives the output directly with very little control.
    PID, when implemented takes a signal that represents (is proportional to) the output signal and "feeds it back" to the input such that when the output signal matches the input signal the drive circuit is in equilibrium.
    The problem with this straight forward arrangement is one of stability in that the circuit is prone to oscillations and in a dynamic situation may not track the desired set point close enough.
    To correct this another piece of the output signal, the differential, of the output is introduced.
    This signal is related to the rate of change of the output. and is intended to correct the tracking error.
    Lastly another piece of the signal that is the integral of the output is introduced which corrects any long term errors.
    Now to finally get to your question, since the PID control is implemented in software you need to get your terms all scaled properly and in the proper units to be able to control your device.
    For example say you have a standard servo circuit the motor signal is controlled by pulse width modulated 20 ms square wave. At the other end you want speed control from +/- 0-100. Your job now as the designer is to design your PID algorithm to work with those inputs, where you scale them and what units you work with, are what you need to decide.

    I hope I helped a little bit
  • evanhevanh Posts: 15,944
    edited 2011-06-20 04:29
    PID algorithms are a diverse bunch. You are free to modify how it behaves. There is the basic PID function itself and there is the conditioning of the inputs and, for your question, conditioning of the resulting output before it gets feed to the driver.

    What you are looking for is called clipping, limiting or bounding - take your pick. It's such a common requirement for real-world data calculations that DSPs have this sort of function built into their math instructions.

    Once this feature is added you can fiddle with the gains with no worries about out-of-bounds results.
  • graffixgraffix Posts: 389
    edited 2011-07-25 22:38
    @Ray0665 an ESC is a electronic speed control http://www.google.com/search?q=electronic+speed+control&hl=en&qscrl=1&nord=1&rlz=1T4ACGW_en___US401&biw=1920&bih=873&site=webhp&prmd=ivns&source=univ&tbm=shop&tbo=u&sa=X&ei=Q1EuTqmlMYbogQeDqO2NAQ&sqi=2&ved=0CH0QrQQ
    Thats where I get stuck is in the scaling and writing the algorithm.:( my project is a balance bot type using the BS2 preferably , memsic 2125 accelerometer, lisy 300 gyro,to LMD18200T h bridges controling two 12v drive wheels.With a single wheel encoder.

    I didnt notice it was the Propeller catagory not BS2 though I still have it breadboarded on a propeller board.IDK
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-07-26 20:30
    Actually a great book which covers this topic (though leaves most of the math to you) was written by Caxton C. Foster out of U Mass., Real Time Programming - Neglected Topics ISBN 0-201-01937-X c1981. Just skip over the interrupts section. Chapters 8-10 take you from simple closed loop through advanced control methods. By the way, PID is not just for mechanical control. I have seen it used in voltage and current control systems. He also plays with a number of other fun topics as well. Sampling systems gets the spotlight here to.

    Frank
  • JLockeJLocke Posts: 354
    edited 2011-07-26 22:43
    In a former job I worked on semiconductor fab furnaces. PID tuning was a very important part of getting the system up and running. Once worked with an engineer at Micron on adjusting the PID on a system so that it would overshoot the setpoint temperature by a very specific amount. Takes a lot of patience when working on that stuff.
  • Graham StablerGraham Stabler Posts: 2,510
    edited 2011-07-27 00:30
    graffix,

    You need to take the output of your PID and add 1000, this will make the minimum output 1000ms. You then need to limit it to 2000 max. If it goes negative then the negative numbers need to be ignored for a speed control as you will most likely allow friction to slow the motor.

    If your gain is set too high then you will always saturate (have 2000) as your output and it will be obvious, start with a low gain and build up.

    If your PID is producing really big numbers before applying gain then your gain may even have to be less than one. You can split the gain into two numbers, the nominator and denominator and then multiply by the first before dividing by the second.

    Graham
  • graffixgraffix Posts: 389
    edited 2011-07-28 00:23
    Thanks Guys!!!
  • K2K2 Posts: 693
    edited 2011-08-01 20:25
    Actually a great book which covers this topic (though leaves most of the math to you) was written by Caxton C. Foster out of U Mass., Real Time Programming - Neglected Topics ISBN 0-201-01937-X c1981.

    @Frank -This is one of the best recommendations I've found on the forum. I was taught control systems out of the classic Dorf text, which is pretty theoretical. This book by Foster is wonderfully practical. Thanks!
  • frank freedmanfrank freedman Posts: 1,983
    edited 2011-08-02 17:34
    K2 wrote: »
    @Frank -This is one of the best recommendations I've found on the forum. I was taught control systems out of the classic Dorf text, which is pretty theoretical. This book by Foster is wonderfully practical. Thanks!

    @K2
    Glad you were able to find it. It provided me much background long before I was teaching PID based KV control methods in a portable C-arm system whose predecessor was using a simpler PI controller.

    @ graham
    As to using friction is there really enough to make a difference? May be able to use either dynamic braking or possibly reversal of the H bridge or other methods to correct for overshoot. What balance each of the components to achieve the desired response as each component contributes under different conditions. And the physical response will also need to be allowed for. A high differential component may try to give max boost to a high inerta system, and if not limited the drive circuit and motor could get fried.

    Just as with imaging, there is never a free lunch,its all trade-offs.
    Just a thought,

    Frank
  • MicksterMickster Posts: 2,694
    edited 2012-12-06 13:43
    K2 wrote: »
    @Frank -This is one of the best recommendations I've found on the forum. I was taught control systems out of the classic Dorf text, which is pretty theoretical. This book by Foster is wonderfully practical. Thanks!

    +1 for this recommendation! Mine just arrived this morning and I haven't put it down. Ex library book, it cost £1 but three times that amount for S&H.... LOL.
    I love the use of mechanical examples of closed-loop control. Many thanks for this recommendation.

    Regards,

    Mickster
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-06 18:25
    Thanks for digging up this old thread Mickster. I just ordered a book from Amazon. I think it was $4 shipped.
  • tperkinstperkins Posts: 98
    edited 2012-12-20 16:44
    I feel your pain. I once had a customer try to get a new controller to match an old controller made by a different manufacturer, one with very different internal limiting, clipping, and approach control, and they wanted me to match the old response curve to within a tenth of an degree C per second. Same overshoot, same undershoot, same number of and decay to ringing. Also in the semi indus.
Sign In or Register to comment.