Wild Bill

PID setup

22 posts in this topic

I need help with setting up a PID control and have never done this. Using a SLC 5/04 with a 2 input/2 output 0 to 10 volt DC analog card in slot 1. I need to control temperature in an oven from 260 to 300 degrees with a setpoint of 280 degrees. Yes I make cookies and we are now installing AB SLC's to do the controls and I have very little training and AB's site is not too user friendly. I need information on just how to program this into the PLC. Any help would be really appreciated and I'll even include a box of cookies. WildBill

Share this post


Link to post
Share on other sites
Bill what you describe should not be too hard, but a little more info would be better. As I understand it you'll need to read in your temperature and then possibly scale it into degrees. Then use this number in your PID Instruction as the Process Variable. The control Variable produced by the PID will then be scaled and sent to your analog output to open / close the gas valve or close a relay for applying electric top the oven heaters. I'd also suggest searching this forum as it has some other PID topics. Edited by BobLfoot

Share this post


Link to post
Share on other sites
Bob, Thanks for getting back. My input is going to a SCP instruction which is simple enough. Setting up the PID seems simple enough. My big problem is with the set up screen for the PID. I'm kind of lost there.

Share this post


Link to post
Share on other sites
Here is a link to a thread on another forum that may help. http://www.plctalk.net/qanda/showthread.ph...p;highlight=pid You can also search this forum and the other forum for sliding mode control.

Share this post


Link to post
Share on other sites
I am not PID Guru but try the following: Enter a block of 23 Integers for your COntrol Variable. I used N18:0 Enter an Integer for your Process Variable I used N17:0 Enter an Integer for your Control Variable I used N17:1 On the Setup Screen Try a KC of 10 , TI of 1 and TD of 0. Loop Update is the TIme Interval between when this rung fires. Try 3 secs and use a timer of 3 secs to enable also. I chose Setpoint Max of 500 and Output Max of 100. Took Defaults for the rest. YOu'll need a rung whihc loads your setpoint into N18:2 I used 280. I think this should work. Wikepedia had a good PID article I saw recommended in another post. Hope this comes close to helping. Other with more PID experience may find holes and patch them.

Share this post


Link to post
Share on other sites
What is the final control element? Is it a proportional device, or just on/off? Most electrical ovens are on/off, if so you will have to use a time proportional control scheme. If it's gas fired, then you most likely can modulate the gas flow to control the temperature.

Share this post


Link to post
Share on other sites
Greetings Bill, as everyone else has already said, we need more information in order to give you specific detailed help ... for one thing, we need to know how your analog input and your analog output will be scaled ... basic idea: the PV (input) for the PID should be scaled from 0 to 16383 in order to give optimum results ... some modules allow "scaled for PID" selections which will take care of this for you ... other modules require something like an SCP instruction to do the scaling ... the CV for the output module needs to follow the same basic plan ... 0 is off ... 16383 is full on ... suggested plan of attack: take the PID rung completely out of your program to begin with ... let me put it this way ... if we were designing a cruise-control system for a car, we'd make sure that the gas pedal and the speedometer both worked correctly BEFORE we tried to set up automatic control ... hooking up the automatic cruise-control too soon just adds an additional level of complexity to the problem ... once the PID has been removed, then make sure that you can MANUALLY enter values into the CV location and MANUALLY control the temperature of the oven ... for example: with a CV setting of 0, the oven should have ZERO heat input ... with a CV setting of 16383, the oven should go to FULL heat ... if these values won't perform as I've just outlined, then you need to work on the CV scaling BEFORE you try adding the PID control ... secret handshake: the PID instruction's output will ALWAYS fall between the values of 0 and 16383 ... then once you can MANUALLY control the oven's heating cycle, make sure that the PV location ranges between the values of 0 to 16383 ... secret handshake: the PID expects to see values in this range ... if you scale the input values BEFORE they reach the PID, then you'll be cramping the PID's ability to control the system ... basic idea: instead of watching your system's temperature through a picture window (with full resolution), the PID will be peeping at the temperature through a keyhole (with reduced resolution) ... the ability to control the system usually suffers when this happens ... once you've confirmed that you can MANUALLY control the system (using values of 0 to 16383) - and that you can obtain input values which range from 0 to 16383 - then you're finally ready to insert the PID instruction on an UNCONDITIONAL (all-by-itself) rung ... I'd recommend that you put it right in ladder file #2 ... the figure below should help get you started - but please remember that it's just a STARTING point ... the values that I've highlighted in yellow are the ones that you'll eventually have to adjust as you "tune" the PID controller to match the characteristics of your own particular system ... that operation could require a whole series of posts all by itself ... note: turning on the "RG" bit (circled in blue) will give you the extra digits of resolution for the "Kc" and the "Ti" settings ... note that the "scaling" values for "Setpoint MAX" and for "Setpoint MIN" that I've entered above assume (gosh I hate that word) that a PV reading of 0 equals a temperature of 0 degrees F ... and that a PV reading of 16383 equals a temperature of 500 degrees F ... naturally you'll have to adjust the values if my assumptions are incorrect ... you should be able to read the oven's temperature (in degrees F) at the "Process Variable PV" location (circled in red) ... make sure that this is correct before you proceed ... once you're reached this point, I'd recommend that you turn the system on and make sure that the PID is operating the output (electrical heater, gas valve, ???) in the correct direction ... don't get your hopes up ... the "getting started" settings that I've given will NOT properly control the temperature ... now change the value of "Reset Ti" to "1.00" and see what happens ... the PID should start increasing (ramping) the output in an effort to increase the temperature ... once this much is in operation, then you're ready to try your hand at "tuning" the PID ... let us know how it goes ... good luck ...

Share this post


Link to post
Share on other sites
Like I said, I'm new to PID. so here is the information: SLC 5/03 with a 1746NI04V 2 in/out 0 to 10 volt card. Using a Thermocouple as the input and the SCP instruction to scale for 260 to 300 degrees. My output for the SCP is N10:28. (Using the AB reference manual here). The PID control block is N10:0 Process variable is N10:28 Control variable is N10:29 And the block length is 23 My output to the oven is an analog device controlling a valve modulating from closed to full open. If i knew how to attach the RSS file, I would, but cant find any place to do an attachment on this board. If I;\'d learn to read some I'd see it below!!!!!!!! So, I have attached what I have started. I know the output must be scaled to the valve which is also 0 to 10 DC an I plan on using the SCP function here also. But, where is the output of the PID?????? Am I stupid or what or just dont see whats happening in the PID.PID_TEST.RSS

Share this post


Link to post
Share on other sites
Ron, I know the valve works with a SCP function for the output O:1/0 as I wrote a 2 rung program to scale the input and the output. By changing the input I can see the output change accordingly, so the SCP on the input works fine, I think. The RSS file I attached is a starting point and I'm using it on a test SLC 5/03 prior to going on line. With what I have I'd have a lot of fire riddled chocolate chips in the oven.

Share this post


Link to post
Share on other sites
if the .RSS program that you attached is the one that you're using, then nothing is happening in the PID ... as shown in the figure below, it looks like you're trying to use the Emulator software as your "test bed" ... sorry ... the Emulator software doesn't perform PID at all ... or do you really have a real-live SLC-5/03 system available? ... regardless of what you're using, your "Control Mode" setting looks wrong ... with the "E=PV-SP" setting that you show, the gas valve will probably close (rather than open) as the temperature in the oven drops ... this CAN be overcome with some imaginative scaling - but that would be WAY out there in left field ... also you have a "Deadband" setting of "150" ... that basically tells the PID: "if we're within 150 degrees of the setpoint, then we're close enough - don't change the output until we've drifted further off than 150 degrees" ... obviously that's not going to work at all ... put the Deadband at 0 like I showed in the screen shot of my first post ... I gave you a picture of some "getting started" settings in my earlier post ... did you even try those settings? ... if not, why are you asking for advice if you're not going to try what we're suggesting? ... we're trying hard to help - but you've got to work with us - unless deep-down-inside you really just want to "do-it-yourself" ... that's ok too - but please tell us if that's what you want ... there are a couple of other issues - but I'm out of time ... I hope this helps ... Edited by Ron Beaufort

Share this post


Link to post
Share on other sites
Ron, Yes I am rumming SIM to test the program here at home. didnt know that SIM dont do PID. when I load the program into an actual PLC it dont work. The valve does go closed at the temp decreases. Do have a thermocouple transmitter that puts out voltage. Actually the program goes nuts. I'm going to incorporate your ideas tomorrow in the shop at work and see what happens.

Share this post


Link to post
Share on other sites
I posted a file called hotrod.zip in the download area of plcs.net. This file is a ML1500/SLC program that emulates Ron Beaufort's hotrod trainers. All you need is RS500 and a micrologix or slc to run this program. The analog inputs, system response and analog outputs are all simulated. The trends are setup and ready to go. Another source is our ftp site: ftp://ftp.deltacompsys.com/public/PID/hotrod.zip If there is something I can do to make this better then let me know. I don't know why the PLC simulators can't simulate a plant that the simulated PID can control. I do it all the time.

Share this post


Link to post
Share on other sites
Ron, I tried your settings but was not aware that SIM didnt work with a PID. I played with the numbers trying to get something to change and after I read this post I felt like an idiot. Will give your example a try in the morning. I'm sure your information will work. Question though, why did you circle the SCP function? Am I doing this wrong or is it not needed? Something tells me that the PID needs the real analog card inputs to work and not a scaled input. ?????????? I will work with it in the AM and will let you know of mu success. Bill

Share this post


Link to post
Share on other sites
I don't know how to say this without sounding "brutal" - but I assure you I don't mean it that way ... this is just intended to be friendly advice ... PLEASE don't think that I'm trying to be rude ... if "something" is telling you to use the "real analog card inputs" and not a "scaled input", then I'd suggest that you ignore that "something" and get on with your life ... I've already told you several times in this thread that the PID needs to see an input which ranges in value from 0 to 16383 ... the following quote is from the SLC Instruction Set Reference Manual ... it's telling you the same thing that I've been saying ... once again, I hate to sound "brutal" but you keep fighting the same battle over and over ... I'm just trying to help you get over one hurdle - so that you can tackle the next one down the road ... here's a quick analogy that might help ... the PID is like a blind accountant ... he can't actually see the input signal - so he goes by feel instead ... a PV value of 0 FEELS LIKE a "rock-bottom" input to the PID ... a PV value of 16383 FEELS LIKE a "wide-open" input to the PID ... once he gets an accurate FEELING of the input (PV) signal, then he's able to calculate an appropriate output (CV) signal to control the process ... here's another thought that might help ... some people confuse the meaning of the word "scaled" ... they assume that a signal is "scaled" only when the numbers represent something like "PSI" or "degrees" ... actually the range 0 to 16383 can (and should be) considered to be "scaled" too ... it's "scaled" in the sense that the blind accountant inside the PID instruction understands that range as his native language ... (side note for PLC-5 users: the range of values is 0 to 4095 for that particular system) ... so whatever range of values we (as humans) might happen to see in the outside world, that range of values needs to be "scaled" into a range of 0 to 16383 in order for the PID accountant to make the optimum use of the PV input signal ... yes, other ranges CAN be made to work - but using those "unorthodox" ranges is just making the whole PID experience a lot harder than it needs to be ... and it usually gives poor results too ... I hope this helps ... if anything above is incorrect, my excuse is that I've been teaching all last week and I'm exhausted ... also I'll be teaching non-stop both this week and the next week too - so I doubt that I'll be able to contribute much more to this project ... but I'm quite sure that my distinguished colleagues BobLfoot, Bob O, Ken Moore, and Peter Nachtwey (listed in order of appearance) will be able to help you nail this down ... and I'll bet that others will chime in also ... my closing advice is this: give them details ... give them details ... give them details ... remember that they can't see your system ... they'll only know what you tell them ... good luck ... Edited by Ron Beaufort

Share this post


Link to post
Share on other sites
Ron, Thanks for all the information. I was able to get the thing to work but see where you are comming from on the thermocouple transmitter voltage. No its not 0 volts at 260 degrees Its like around 2.3 volts. So I have some work to do yet but I think I have a handle on it now. I'm sorry about the SIM program. Wasn't aware that AB would have a simulator that only works on part of the functions. After you mentioned that, I researched the SIM 500 program and saw that there is a lot of stuff it does not support. Thats kind of odd for a simulator to only work on half the functions. But the good news is that I have some sembalance of a program working now and I see that you cant use a SCP function for the input to the PID. It dont like that too much. Faulted every time. I used your snap shot and finally got an output and now will work on the fine tuning of it. God, I did a lot of reading over the weekend on this but it is paying off. Again thanks for all the input. BobLfoot, Bob O, Ken and Peter were a big help also so I need to let the all know. Now, off to see if I can maintain an over temperature. After seeing all the bad about thermocouples, I will most likely suggest going to a RTD for better stability and accuracy. Thanks Bob. Your great!!!

Share this post


Link to post
Share on other sites
short on time ... yes, you CAN use an SCP for the PID's input ... but if the signal coming INTO the SCP is too high or too low, then a math overflow error may result ... this is something that you might need to research ... good luck ...

Share this post


Link to post
Share on other sites
I've attached a quick example that I threw together real quick, so it may have an error to two, but it should point you in the right direction. PID_EXMP.RSS PID_EXMP.pdf

Share this post


Link to post
Share on other sites
Ron, Just a note to let you know that your input was of real great value. We are now running on a test basis and seems to be working pretty well. Need some minor adjustments but looks good so far. thanks for all your help. It's greatly appreciated. Bill

Share this post


Link to post
Share on other sites
you're welcome, Bill ... wish I had more time to help ... good luck - and keep us posted ...

Share this post


Link to post
Share on other sites
Frankly, you're much better off using the PD data files the first time and NOT the integer ones. Mostly because it is much easier to remember the mnemonics. When you go to create a PD data file, watch your memory usage! These things are pigs so most people don't set the data file length to more than 10-20 elements. If you do that, then on the setup, don't worry about the "tieback" for now. Just give it any available integer. Key in the location of your temperature variable as an input (PV). You *can* do all the scaling in the PID loop directly without bothering with your SCP instruction, which is kind of convenient. You need to trigger the loop on a fairly regular timing interval. Personally I put all of my PID's in a single ladder (along with the interface code) and simply trigger them from the PLC's STI input (software timer interrupt). This gaurantees nice and even timing...and I know exactly what to plug into the loop timing information (the firing rate of the STI). Remember to look at your actual scan times and don't set the STI to fire close to the current scan times or you can end up firing it several times per scan which will royally slow your normal ladders down. Next, the interfacing is easy. The PID loop assumes that the PV (input variable) is an unscaled value from 0 to 4095. Key in the values of 0 and 4095 (from raw input variables) into the engineering units. If you prefer not to do it that way, then just use "0" and "4095". Either way, PDxx:yy.PV is the "scaled" input of the PID loop that you can use for display purposes. PDxx:yy.OUT is the output signal. It will be spanned from 0-100% as a floating point variable. Scale appropriately and move it into your output. If you are using a 12 bit output card, simply do something like "MUL PDxx:yy.OUT 40.95 Nxx:yy". PDxx:yy.SWM and PDxx:yy.MO are your friends. The PID loop is meant to have this whole disconnected remote manual loop but there's a much easier way. Simply toggle .SWM on when you want to go into "manual" mode and then input your manual signal (0-100 in floating point values) into .MO. Toggle it back to a 0 for "automatic" mode. When it is in manual mode, the .MO value will be copied directly to the .OUT value. When you switch back to automatic, it will do a "bumpless" transfer...the PID loop will begin adjusting the output as-is. If you don't do it this way, then the "tieback" and all the other manual-mode related stuff has to be set up which is a pain. Another word of warning. The first time you attempt to set up a PID loop, the moment you put the instruction in if you are in remote online mode, it WILL fault your PLC the first time when the PID loop initializes. This is a one-time "gotcha" that happens when you are programming it the first time...not every startup. Another "gotcha" is that if your input value ever falls outside the engineering unit limits, it will fault. So make sure to set it up correctly and guard your inputs if you are not simply pointing it to raw values off an input card. Once you get that far, look around for "model based control" for tuning rules. Use independent gains as it is much easier than the "integrated" equation to tune. Since you're doing an oven, you really will probably only need a "PI" loop in most cases. Derivative terms help when you have lots of external disturbances and you need to "anticipate" corrections to the output. This is how I'd do it by hand. First get into online programming mode. Set up a trend chart in Logix. You want the chart to show 3 things: the set point (PDxx:yy.SP), the process variable (PDxx:yy.PV), and the output signal (PDxx:yy.OUT). Initially get everything running in manual mode. Set the "P" term to 1. Now flip on the auto bit. Watch what happens. Is it slower than molasses? Or is it oscillating wildly? You will need to increase/decrease the proportional gain to get it to get fairly close to the correct output without too much oscillation. Initially increase/decrease the P term by a factor of 10 at a time. Once it is getting close, drop down to doubling/halving the value. If you've got a nice trending pattern, you will have to either switch to manual and purposely screw up the output or else give it different set points to give the system something to do as you watch how it responds. Once you have that much, then set the integral term equal to 10% of the proportional term. Watch the trend chart and it should lock it fairly quickly on your set point. As you adjust the integral term to larger values it will reach the set point faster but if you go too far, it will overshoot and tend to oscillate. You will probably tend to have "slow" loops when you tune by hand. This is usually considered OK by most folks. If you push the tuning (increase the gains) enough, you will eventually have some oscillations but the loop will react faster. If you really want a fast loop, you'll probably end up shelling out for one of the tuning programs out there. Since you're dealing with an oven, I have found one exception to the rule. I just got through tuning the oven where I work at and it was a pain in the rear. See, this particular oven has "flat" burners. It heats primarily by indirect firing...it heats the refractory which in turn heats the product. The problem is that the refractory tends to make the whole thing act "second order". On top of that, the product has a large amount of thermal mass itself, so the system "gains" are not very predictable...you can never optimally tune this loop. In this case, I tuned the loop with a huge derivative gain, a somewhat smaller proportional gain, and a much smaller integral gain. Whenever there is a disturbance, the oven reacts very quickly to turn up/down the gas. Once this is underway, then the derivative term fine tunes the gas over a much larger time span to move the oven back towards the set point. The old discrete controllers (Omega 4000 series) used a "fuzzy logic" loop which mostly just tended to constantly run in oscillation back and forth between low and high fire. It was that fuzzy logic loop that actually had everyone fooled into believing that the oven was an on/off control which in reality it was continuous!

Share this post


Link to post
Share on other sites
Yes Paulengr, I don't think it is wise to offer advise on how to tune a system except for the part about the model based control. Everyone's systems is different. Also, whey you say at the integral term to 10 percent of the proporitonal term, exactly what are you saying? The proportional term is a unitless gain whereas the integral gain is really a time constant on most PLC. So what are you saying? Are you refering to the integrator gain as a gain or a time constant? My advice is to check out the procedure on the Control Guru forum since I know it works. I know how the equations ,that the Control Guru uses, are derived. Second order systems are more difficult, but not impossible. The problem is that sometimes a simple PID often isn't enough for good control. The first step in tuning it to know the system you are about to tune. Getting a RSTrend to see how the system reacts is the first step. .

Share this post


Link to post
Share on other sites
Greetings paulengr, first of all thanks for your input ... some of the points that you made might certainly come in handy to other readers in the future ... unfortunately they won't be much good to our friend Wild Bill since he is using either an SLC-5/03 or SLC-5/04 processor in his system ... (he mentioned both along the way) ... this statement indicates that you're somehow blurring the distinction between the PLC-5 family of processors and the SLC-500 family ... the setups for the PID instructions in the two platforms are quite different in many respects ... for one specific instance, the SLC-5/03 and SLC-5/04 processors that Wild Bill mentioned don't support the PD-type files you suggested - so Bill is pretty much tied to the integer-type setup whether he likes it or not ... also most of the helpful "scaling" tips that you mentioned are more appropriate for the PLC-5 platform - but won't work at all for the SLC family of processors ... some of the other issues (tieback, independent gains, etc.) fall into this same "PLC-yes-but-SLC-no" category ... you're probably already well aware of all of this - and most likely you simply missed the part at the beginning of the thread where the SLC platform was mentioned ... my main reason for mentioning this is not to "correct" you - but just to prevent any unnecessary confusion for Wild Bill and for all of the other readers who will be running across this thread in the future ... (these things hang around for years - and this one will keep turning up whenever people search for help on the topic of PID) ... and so a note to all ... there's Allen-Bradley PID - and then there's Allen-Bradley PID ... as with just about everything else involved in this trade, the DETAILS make the difference between success and failure ... one size does NOT fit all ... and your mileage may vary ... finally to paulengr ... please continue to contribute ... your ideas are always welcome ... 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