PID output..
QuadrtrFlyr
Posts: 73
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
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
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
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.
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
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
@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
+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