PID - MicroLogix Temperature Control

Join Date
Apr 2002
Location
No income tax, no capital gains tax. Freedom!
Posts
8,351
Temperature Control using Micro Logix PID

The link is to a .zip file that contains a .rss file that implements PID temperature control on a MicroLogix. The program uses the simulation techniques that have been used in the Excel spread sheets.

To experiment try changing N7:0. The number should be in the range of about 700 to 4300 or 70.0 to 430.0 degrees and then monitor the trend.

Now I have some questions. The PID control seems very coarse. The time constants only allow a few digits of precision. Also, the controller gain Kc I used was 3.61 degree/% output, but I had to mulitply this by 163.84 to get the real controller gain that works.
163.84 is 16384 counts/100%. ALso, I had to leave the set point max at 16384 even though the highest set point I would use is about 430 degree (4300).

Any clues as to how to make this better are welcome.

pid-temp-ml.jpg
 
Thanks

Peter,

This could be perfect timing for me. I have a temperature application coming up in about 3 weeks using a Micrologix 1500. I will be controlling two IR heaters in a small thermoforming that I am building.
I have downloaded your program to my test bench and I will install the TC card for the above app. and help do testing if you like.

Thanks,
Bob
 
Greetings Peter,

please check the link in your first post ... I'd like to take a look at your code, but the link's not working for me ...
 
My FTP Site

I just checked the link and it works for me too. I usually check each link just after I post it.

My FTP Site

The files for the PID posts are in the PID folder. You can just browse and download what you want.

Ron B. I am interested in your comments since you have spent a lot if time with Rockwell PIDs. I know you have spent a lot of time at the mrplc.com forum helping people with Rockwell PIDs. I haven't said much because I know they have been in capable hands and I really don't know much about using other peoples PID. Would you believe this is my FIRST plc PID that I wrote?

Bob O. If you can supply the .dbf file from a trend, I can supply the tuning parameters.


I used the data from Ron Beaufort's 'Hot Rod' system from the Summer of 2003.

I like the performance of the SMC better.
 
Greetings Peter,

I'm not sure why the first link wouldn't work for me ... I'll just put it down to my company's network security settings ...

I'm looking forward to going over this in great detail just as soon as my workload permits ... hopefully this weekend ...

here's one minor thing that you might want to take a look at in the meantime ... research the PID's "RG" bit ... I always recommend turning it on for the extra decimal place it allows for the Proportional and Integral settings ...

again, I'm looking forward to seeing everything that you've come up with here ... to be perfectly honest, most of the math that you use is way above my head ... but now that you've nailed it down into ladder logic format, maybe (hopefully) I can make better sense of it ... I'll be back in touch just as soon as I've had a chance to dig through it all ...
 
Ron Beaufort said:
here's one minor thing that you might want to take a look at in the meantime ... research the PID's "RG" bit ... I always recommend turning it on for the extra decimal place it allows for the Proportional and Integral settings ...

I will set the RG bit tonight and make any other necessary changes before I update these files on my FTP site.
The on- line help said the RG ( what does that stand for? ) bit was only for SLC5/03 SLC5/04 and SLC5/05. As I said above. I can't get the simulation to work out perfectly. One can see there is a little overshoot and the CV is very (TOO) ragged. This meanns the PID gains and calculations do not use enough precision. I know the simulator part is correct because I varified the results with my mathcad and all the calculations are done in floating point.

For everyone else. Just load it up, change the set point N7:0 and watch the trend. Enjoy.

BTW. I use EITHER the PID analog output or a bit B3:0/3 can be toggled to use timed porportional output as I suggest in the
WHY PWM link
 
The RG bit is flawed!!!!!!

Compare this trend with the RG bit set and the trend without the RG bit set in the first post. You can see the trend WITHOUG the RG bit set looks much better except for the coarse control. I have serious doubts the quality of the implementation of the MicroLogix PID block. I also have questions that I can't find the answers to in the on-line help:

1. If I set the integrator time constant to zero, what does it do? Hopefully it disables the integrator.

2. What are the units for Kc? It isn't documented in the on-line help. If I KNOW the integrator is set to zero I can force an error and see the CV. This way I can check the gain of KC alone IF I know the differentiator and integrator gains are 0.

3. The documentation indicates that registers 17 and 18 are the integral sum. How can I force this to zero? You can see the PD9:0 control block does not show a integral sum register yet the documentation indicates that I can access it. HOW?

4. What is the integral sum? Is the the sum of errors or the last output?

5. If the integral sum is the sum of errors then the PID is flawed because you can change the integrator gain on-the-fly. From what I have seen it looks like the integral sum is the sum of errors which is too bad.

I was satisfied with the results without the RG bit. The response was very close to what I predicted except the output was very coarse. Still I would recommend that the RG bit NOT be used. The RG bit seems to make the differentiator much less or not effective. This causes the system to be less stable.

Also, the PID seems to use the position or absolute mode of PID. As I have pointed out during the PID spreadsheet threads, one should not use the position or absolute for of PID if the output is going to saturate. WHY? Because the position or absolute form of integrator ALWAYS overshoots the set point because that is the only way the integrator can unwind. When the PID saturates, the integrator keeps winding up which causes severe overshoot. Note. It doesn't have to but then one must know how to implement a PID.

Finally, for those that have used the MicroLogix PID, I have felt your pain.

HEY ROCKWELL, THE NEXT TIME YOU DO A PID YOU SHOULD CONTACT ME FIRST. I CAN DO IT RIGHT AND YOU KNOW I DON'T CHARGE TOO MUCH.

Two more questions:

Does anybody use the MicroLogix PID?

Quiz. How can one find out what the units of Kc, the controller gain?

For temperature control I would use the SMC program from last summer.

pid-temp-ml-rg.jpg
 
Peter,

Very interesting stuff. In answer to your questions I must have used 100's of PID loops in SLC, Micro and CLX. Overall I find them simple, stable and dead easy to use as long as I ensure the loop update times are correctly handled.

Ragged CV? Is your Loop Update time correctly set?

The value for the Integral word is in the element PD.x.IS.

KC is unitless.

Setting KI to zero disables the integrator.

Whenever the CV reaches 0 or 100% (or CVMIN/CVMAX) the integral action stops to avoid windup error.

On top of this I always use Setpoint ramping in order to ensure that I am never hitting the loop with excessive error.

For a process with a relatively constant load this works well. When tuning the loop I normally just find a value for KC that is stable, and this then defines the rate at which the PV will change.

By setting the SP ramp rate to be say 0.5 to 0.8 of this process ramp rate, I can ensure that that the PV is always close to the SP and thus avoid excesive integral errors.

If done carefully it does not compromise loop performance mush and it certainly eliminates overshoots.

I use a very primitive tuning "algorithm"...KC determines the rate of response at large errors, and KI detemines the rate of response at small errors.
Most times I get a stable loop just by watching the trend plot with just these two ideas in mind. If necessary I then run RSTune over the loop and I may or may not get a better result.

Yes I could apply more sopshisticated techniques, but most loops don't demand much more. (Which does NOT mean that I don't find the stuff you are contributing absolutely fascinating Peter!!)
 
Last edited:
PhilipW said:
Peter,

Very interesting stuff. In answer to your questions I must have used 100's of PID loops in SLC, Micro and CLX. Overall I find them simple, stable and dead easy to use as long as I ensure the loop update times are correctly handled.

Ragged CV? Is your Loop Update time correctly set?

Both the STI and Loop Update are both 1 second.
I posted a link to the files in a link above.

Originally posted by PhilipW
The value for the Integral word is in the element PD.x.IS.

When I display PD9:0 there is no IS field. I should be able to see the integral sum field wind up and down if there was one.

Originally posted by PhilipW
KC is unitless.

Does that mean an error of 100 with a gain of 41.00 yields a CV of 4100 dac counts?

Trust but verify. I am trying to wind the integrator to 0 at this time. I am forcing a negative error so the integrator winds down. I will then set the integrator and the error to 0. The CV should be equal to the integrated sum only. Hopefully this will be 0. I wish I could just set the integrated sum to 0.

Originally posted by PhilipW
Setting KI to zero disables the integrator.

Good, now I can force the integrator and differentiator time constants to 0 and the error to some know value to see what Kc is.
In the formula for PID, setting the integrator to 0 would cause a divide by 0 fault. See the formula! The integrator time constant is in the denominator.

Originally posted by PhilipW
Whenever the CV reaches 0 or 100% (or CVMIN/CVMAX) the integral action stops to avoid windup error.

I can see stopping the integral action when the ouput reaches 100%. I THINK IT IS STUPID to stop the integrator from winding down to 0.
I am forcing an error now my SP = 2500 and PV is forced to 2600. I expect the integrator to wind down but IT DOESN'T because the CV has reached 0. If I disable the integrator the CV jumps back to 34% EVEN THOUGH THE ERROR is negative!!!!!! This means the integrated error is still not 0! It is still 34%! How do I set this to 0.

Quiz! Why is it important?


Originally posted by PhilipW
On top of this I always use Setpoint ramping in order to ensure that I am never hitting the loop with excessive error.

Yes, I can see why but you should have too on a temperature system.

Originally posted by PhilipW
For a process with a relatively constant load this works well. When tuning the loop I normally just find a value for KC that is stable, and this then defines the rate at which the PV will change.

I can calculate the gains since I know the model. I can choose faster or slower response. In the case of the MicroLogix PID I had to slow down the desired response because the MicroLogix PID does not handle saturation very well.

Originally posted by PhilipW
By setting the SP ramp rate to be say 0.5 to 0.8 of this process ramp rate, I can ensure that that the PV is always close to the SP and thus avoid excesive integral errors.

If done carefully it does not compromise loop performance mush and it certainly eliminates overshoots.

Yes, but that should be necessary unless on must control the rate of temperature increase or decrease to avoid thermal stresses ( micro fractures).

I can see I will need to make a MYPID version for comparison with last summer's SMC and this PID. I didn't think that I would have all these question when I started this thread. I thought the answers to my question could be found by just experimenting, but the experiments are hard to do when the individual gains can't be tested one at a time. There must be a document for this somewhere that goes into a lot more detail than the on-line help.
 
The term PD.x.IS is documented somewhere in the MicroLogix hardcopy manual. I don't have it at home and the Rockwell Support Site is down for maintenance this weekend.

No it does not appear in the PD file display, but I have used it in the past just by using a MOV to shift it into a LONG word. ( Its 32 bit long.)

Just for interest I have dug out a MicroLogix applicaton I did about 4 years ago for a large chiller (about 4 MW). Some aspects of it I would do differently now, but the neat trick I developed for the Capacity Slide position control in File 8 Rungs 17, 18 I recall with fondness. (This was before Timed Proportional Output was part of the firmware.)

(Best viewed with the Ladder Viewer Properties set for "Symbols Only")
 
Greetings Peter,

I’m sorry that I haven’t had time to dig too deeply into this YET ... but hopefully tonight so maybe I can add more to the discussion Monday morning ...

I’ve only had time to skim the latest posts ... so I apologize in advance if this is something that you’ve already fixed ... but ...

please check your scaling ... specifically, by setting up the PID for a “Setpoint MAX” of 16383 and a “Setpoint MIN” of 0, you’ve essentially said: “I don’t want to use scaling” ... so that means that your “Scaled Set Point” also needs to be UNSCALED ... in other words, to enter a setpoint of 250 degrees (half of the Hotrod’s 0 to 500 degree range) you’d need to enter in a setpoint of 8192 into the PID ... not the 2500 (that I THINK that you’re trying to use) ...

hint: most programmers would tend to enter a “Setpoint MAX” of 500 and a “Setpoint MIN” of 0 for the Hotrod application ... then the setpoint could be entered as something like a simple 250 degrees ... but I know that you’re trying to get the greatest possible resolution out of these experiments ... so I understand why you went with the 16383 and 0 settings ... just be sure that the setpoint also stays in the same “unscaled” or “raw” units ...

as for the “units” for Kc ... once you’ve gotten the “setpoint scaling” issue nailed down, I think that the “units” issue will fall right into place ... try this experiment ... dial in a setpoint of 50% full scale (250 degrees) then force the PV to 20% of full scale (100 degrees) ... the PID should calculate an Error of 250-100=150 ... 150 divided by 500 equals an Error of 30% of full scale ... now temporarily set your Kc for 1.00 (simple unity – one-to-one) and turn the Ti and Td settings off (using a 0 setting for each) ... under these temporary “test” conditions, the PID should calculate an output of 30% ... and that’s what you should see on the PID setup screen in the “Control Output CV (%)” box ... then double the Kc setting to 2.00 and take another look at the CV % reading ... it should go to 60% ... and I'm betting that all of your issues with the Kc "units" will suddenly be fully resolved ...

disclaimer: I’m doing all of this from memory since I don’t have a MicroLogix 1500 handy right now ... sorry if I’ve dropped a stitch ... but I “think” I’m right with the math, etc. ...

I hope this helps ... I’ll try to get back to the details as soon as I can ... this weekend I’m a plumber ... I’ve been planning to install the “laundry” sink in my workshop for almost a year now ... this weekend it’s finally happening ...
 
Last edited:
RESOLUTION IS VERY IMPORTANT!!

Philip, I haven't tried accessing the .IS field. I will today. Yes, Kc is unitless.

Ron, I will have try your experiment, but I have found that setting the integrator time constant to 0 only keeps the integrator from winding up or down. It doesn't clear the .IS. I did an similar experiment to find the Kc is unitless EXCEPT I just looked for change in the output because I couldn't get it zeroed with no error.

The coarse output I complained about is due to the differentiator. I wrote my own PID and I found that each time the PV changes by 1 unitt the output may change by as much as 3000 units depending on the differentiator time constant. Obviously, Rockwell must filter this as I had too. I can now see Rockwell did a pretty good job of filtering when the RG bit is NOT set. When the RG bit is set the output looks a lot smoother yet, but I think they might have gone over board on the filtering as the differentiator seems to have lost its effectiveness as shown above in the two graphs using the same gains. The only other way to solve this problem is to have more resolution on the feedback. Much more resolution.

I don't NOT like the way Rockwell implemented the integral sum. The built in PID's integrator can only unwind by overshooting the set point and if I change gains on the fly the output takes a BIG jump. This does not happen in the incremental form of PID. I also wonder how one goes from auto to manual and back without causing a the output to make a big jump. When going form manual to auto, one would needs to take the current output and used the integrator gain to calculate what the integrated sum should be so when the system is put in auto there will not be a big jump in the output. This is not necessary using the velocity or incremental form.

I wrote my own PID which I will post. It performs better than the built in PID, but I used less filtering on the differentiator so my control looks even more coarse than the builtin PID. I also made two other significant changes from the Rockwell PID. First, I used the velocity or incremental form of PID which handles saturation much better than the position or absolute form. Second, I used the I-PD form of PID where BOTH the P and D term use the PV instead of the error. This reduces the wild jumps in the output when the SP makes a step jump.

Finally, I simplified the SMC program and compared it again both my PID and the builtin PID. I would use the SMC over either PID for temperature control. SMC is simpler and more robust. Also, I don't need Mathcad to compute the ideal gains. There is just one time constant to change and it isn't that critical.

I will update the .zip file, referenced by the link above, later today after I document some of the files. I will include some trend bit maps, my SMC, PID programs. I will be out of town ( away from my ML1500 ) till friday :( I will be training people on motion control.

Now to play with the max set point
 

Similar Topics

Hi Everyone. I have been reading through the forums, and I have learned a lot! I do have a specific question that I couldn't find. I have a...
Replies
8
Views
5,047
HI - I have a tough process and have been struggling with controlling my PV using a Micrologix 1400. I uploaded the file, changed .rss to .txt...
Replies
9
Views
1,917
I have 2 no.s Micrologix PLCs used for PID control variable output to 7 no.s VFD drives.2 no.s are used as i have no spare analog cards for analog...
Replies
3
Views
1,505
I'm trying to get my PID function to go into manual mode and give the CV a value through a MOV instruction. I can set the Auto/Manual bit, and the...
Replies
3
Views
1,627
Hey guys, After spending most of a day Googling looking for the answer, I finally decided to make a thread and ask the experts. I'm trying to...
Replies
5
Views
3,508
Back
Top Bottom