Sign in to follow this  
Followers 0
PlasticsDude

P-I-D raw programming help

9 posts in this topic

I'm working with a programmer on a C code P-I-D loop. I've done successful P-I-D's in PLC's, but we're having trouble making a home-grown loop. If we start with just the proportional part of the loop, what exactly should our forumla and output look like? I understand that the "P" part should be: P=gain*error where error = (setpoint - Pv) The question then becomes what do we do with that calculated "P"? For example, if the loop is controlling an electric resistance heater, and the setpoint is 200F, but we're currently at 100F, and it requires 50% heater voltage to sustain 200F perfectly, and we start out with 25% heater voltage, what should the output of the PID do to that 25% so that we hit 50% without signifigant overshoot?

Share this post


Link to post
Share on other sites
Not long after I got out of college I was working with an 8088 based embedded controller and had to write my own loop. Here is a part of what I wrote. Its a primitive PID, but it worked very well for controlling a three zone vacuum furnace. There are a lot of things I would do differently now from what I did then. control.zip

Share this post


Link to post
Share on other sites
Thanks. I think the problem we're having is that if the Pv is below the setpoint, the proportional part of the PID will want to increase the output to the heater, as it should. The temperature will then of course get closer to setpoint, but it will still be below the setpoint, so the PID will still want to increase the output, and the output will continue to increase until setpoint is reached, except by then it just blows right by the setpoint. Then the PID will generate a negative correction and come back down. So basically no matter what, we're always blowing by the setpoint. A good PID will ramp up and level off right at the setpoint. We must be doing something seriously wrong...

Share this post


Link to post
Share on other sites
Greetings PlasticsDude ... if I understand your posts, so far you're not using PID - but P-Only for control ... that’s true - but again, if I understand your posts, so far you’re not using PID - but P-Only ... moving forward ... there are two articles which I keep posted on my website that I think you might find helpful ... “What is P in PID?” ... and “Proportional-Only Control - Why Won't It Work?” ... you can find these in .PDF format in the “Sample Lessons” section by clicking the link under my forum signature ... good luck with your project ...

Share this post


Link to post
Share on other sites
Thanks. So it's actually the integral that will throttle back an out-of-control rise towards setpoint and not the derivative like I thought? So if I bring the integral part of the PID online I should start to see some controlled rise...thanks! I'll let you know how it works.

Share this post


Link to post
Share on other sites
What is producing the 25% output? Is it error * gain or is it bias?

Share this post


Link to post
Share on other sites
E is error, It is Setpoint-ProcessVariable for reverse acting applications (like heating). It is ProvessVariable-Setpoint for forward acting applications (like cooling). P is Error times the Proprotional Gain. It is a single error sample * the gain, and its redone every loop sample, it is not a continuous sum. I is an integral of error samples made over time, It is the Error times the I-gain + last eror * I-gain, + the previous error before that * I-gain + the previous error before that.... etc. etc, all the way back till the loop was started (and the reason the PID must be executed on a consistent deterministic time. D is the D-gain * the first order derivitave - rate of change - of either the Error, or Process Variable. (its another reason it must be executed on a consistent time interval) The loop output is P + I + D. Study the info Ron linked to, he explains it much better than I can. To visualize why P only control isn't working for you, imagine a loop where response is instant. Initially setpoint is 10. Output is 0. P-gain is 1. So the first time E is 10. So output goes to 10*1=10. The second time E is 0, so output goes to 0. The third time, E is 10, so output goes to 10. The fourth time, E is 0, so output goes to 0.

Share this post


Link to post
Share on other sites
Well that is the problem. PlasticsDude probably has too much integral action. PlasticsDude, why are you rolling your own? Temperature controllers are cheap compared to your time.

Share this post


Link to post
Share on other sites
Greetings PlasticsDude ... have you read the information that I mentioned? ... I think it will help answer all of the questions that you originally asked ... now your recent PM is asking new questions ... no problem - but please read the other titles (about I and D) in the same "Sample Lessons" area ... then if you still have questions we can go from there ... and there's really no need to use the PM feature ... all of the questions that you're asking are perfectly valid - and fully welcome on the open forum ... responses to Peter’s questions ... now maybe he’s added some more bells and whistles since posting that - but all I can do is base my “best guess” advice on what he’s posted ... final note to PlasticsDude ... is there any reason why you can’t post a copy of your code on the forum? ... my distinguished colleague Peter is extremely talented with the math involved in a project of this nature ... right now we’re all just kind of guessing and doing the best that we can to help ... posting the code will make it a lot easier on everyone - especially on you ... by the way, what’s your deadline on this project? ... Edited by Ron Beaufort

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0