LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Temperature PID loop help

I have a  PID loop that is working but the temperature swing is about 10% and I need it to be tighter than that.  After reading many of the forum posts on PID loops I think the problem is a gain issue and I need to run an autotune.  But i'm really confused on how to run the autotune, setting gains and don't understand if I need plant parameters or not.  

 

What is happening is that if I set the heater fset point to 110 degrees the PID output will go down to zero (temperature will have dropped to 105.7 degrees) and it will turn on my relay to heat.  When the temperature hits the 110 degree mark the PID output is only at 55 and continues to call for heat.  The PID output does not go to zero until 10 seconds later, when the temperature has reached 118 degrees.  

 

When I tried to run autotune the PID output never changed and the temperature continued to climb and I turned it off when it went up to 150 degrees.  

 

So what am I doing wrong here?  I really feel lost after reading the NI white paper and many of the post here.  I just don't have a handle on what all the options are and how they may change things.

 

Thanks for the help.

Danny
0 Kudos
Message 1 of 4
(4,759 Views)

The Autotuning function generates the gains and plant parameters for you. You'll note they're both inputs and outputs. You should wire those outputs parameters to the right side of shift registers around the while loop, and then wire the left side of the shift registers back into the inputs. You should also track the "tuning completed" output, and when it turns true, then set the autotuning input to false to stop autotuning. You may want to save the PID parameters at that point.

 

All that said, it looks like PID might be the wrong control algorithm for you here. Is your heater simply an ON/OFF, or can you vary the heater power? If you cannot continuously vary the heater power, then no amount of PID tuning will improve your control. PID is designed for systems where you can vary the output level, not for on-off systems.

 

You can convert an on-off relay to variable power by cycling it on and off rapidly, if your heater and relay allow this. You can't do it perfectly accurately in software, but for a slow heater system you might be able to do it well enough. For a simple example of this see http://forums.ni.com/t5/LabVIEW/PID-control-of-heating-element-feedback/m-p/1464338#M557349

Message 2 of 4
(4,720 Views)

Nathand, thank you for your help.  I have been busy on other things and i'm sorry I didn't follow up with you faster.  The heater i'm controlling is an Omega CIR series cartridge heater mounted in a custom aluminum heating block.  The initial plan was to follow a post I found on this board where a poster was using an NI-9263 module and Crydom MCPC1225A solid state relay.  This SSD allows for an input of 0-5 or 0-10VDC and then has a 0-120V output.  The problem I ran into was that the NI-9263 is limited to 1mA output per channel, where the SSD I believe needs a minimum of 4 mA to operate.  After talking to Crydom, great customer support by the way, they thought might still be able to get it to work but thought there may be a better SSD for my application.

 

The second choice was to just simple order a temperature controller from Omega and communicate to it via serial commands and have the temperature controller hardware run the PID loop and just use labview to send the controller settings either by serial or ethernet.  I spoke to Omega and they recommended the Platinum series temperature controller.  I ordered the DC powered controller and Omega recommened a SSD relay as the go between from the controller to heater.  Omega assisted me in setting up the controller PID loop configuration and benchtop testing the controller was working well.  I started digging into the Omega Labview drivers to see how to fit them into my instrument Labview code.  

 

While doing this I realized that the benchtop setup was having the Platinum series temp controller telling the SSD when to turn off and on.  I wondered why can't I simple do this with my cRIO 9485 SSd module and the same Omega SSD.  The cRIO setup I was using to control my automation module had a spare channel in the NI-9485 module and wired for 24VDC to contorl solenoid valves.  I used the PID loop in initially posted and was able to control the heater but the temperature swing was larger than I wanted.   I read thought every post I could find about the PID gain settings and started playing with the settings and printing off waveform charts of the temperature over 10 minute test sessions.  By changing the proportional gain (Kc) to 500 and leaving the rest as default my results improved greatly.  With the Kc=500, and a set point of 50 degrees C the heater kicked on at 49.9 and kicked off at 50.1.  The heater temperature continued to rise to 55 degrees C, mostly do to the watts of the cartridge heater and the fact that the heater is on one side of the aluminum block and the thermocouple is on the opposite side.  When I increased the set point to 110 degrees C, the heater kicked on at 109.8 and kicked off at 110.2 and the heater tempeature rise maxed out at 112.5 degrees C.  This is all in an acceptable range for my needs.

 

I will go back at some point and take your suggestions of adding shift registers and setting up the loop to allow for an auto tune.  I want to see if an auto tune imporves things compared to my trial and error settings.  Thank you for your help.  

 

 

Danny
0 Kudos
Message 3 of 4
(4,639 Views)

Have you considered taking a basic electronics class? It would help with a lot of the misunderstandings in your post. It sounds like you bought hardware that is easily capable of accurate temperature control, then settled for poor control rather than take the time to learn what you have and how to make it work properly.


@dannyjhu wrote:

The initial plan was to follow a post I found on this board where a poster was using an NI-9263 module and Crydom MCPC1225A solid state relay.  This SSD allows for an input of 0-5 or 0-10VDC and then has a 0-120V output.  The problem I ran into was that the NI-9263 is limited to 1mA output per channel, where the SSD I believe needs a minimum of 4 mA to operate.


The Crydom unit is an SSR (Solid State Relay), not an SSD (whatever that might be). It is not a simple on-off relay; instead, it turns on and off rapidly, synchronized with the AC period, with a duty cycle (amount of time it's turned on) determined by the analog input. This lets you get much finer control of the output, for example you can run your heater at 10% of full power rather than either 0% or 100%.

 

The Crydom unit you linked has multiple options for the input signal, including 0-10V, 0-5V, and 4-20mA (a common industrial standard). The NI-9263 is a +/-10V analog output, so you could use it with the 0-10V SSR. For a voltage control signal, the current needed is negligble. The only reason you'd need 4mA is if you decided to use the current-control (rather than voltage-control) model, in which case you'd need a current analog output such as the NI 9265. Your post completely confuses the two.


dannyjhu wrote: 

While doing this I realized that the benchtop setup was having the Platinum series temp controller telling the SSD when to turn off and on.  I wondered why can't I simple do this with my cRIO 9485 SSd module and the same Omega SSD.


Because the Omega controller is pulsing your relay and heater rapidly - using a PWM (pulse-width modulation) signal, similar to the Crydom relay mentioned earlier - to get fine control over the amount of power into the heater. Your code simply turns the heater on and off.


@dannyjhu wrote:

By changing the proportional gain (Kc) to 500 and leaving the rest as default my results improved greatly.  With the Kc=500, and a set point of 50 degrees C the heater kicked on at 49.9 and kicked off at 50.1.  The heater temperature continued to rise to 55 degrees C, mostly do to the watts of the cartridge heater and the fact that the heater is on one side of the aluminum block and the thermocouple is on the opposite side.  When I increased the set point to 110 degrees C, the heater kicked on at 109.8 and kicked off at 110.2 and the heater tempeature rise maxed out at 112.5 degrees C.  This is all in an acceptable range for my needs.


Please don't believe that this is PID control, because it's not. It's an overly-complicated on-off (or "bang-bang" controller). The Kc is meaningless if all you're doing is checking that the output is greater than 0, and if you add in any integral gain it will make things worse rather than better.

 

If you want to run your control this way, take out the PID and simplify your code. Turn on the heater when the temperature is below the setpoint and turn it on when the temperature is above the setpoint. You might get acceptable control this way, but you won't get a stable temperature - you'll always get some overshoot, then some undershoot as the system cools to below the set temperature, then overshoot again as it overheats, etc.

 

Not surprisingly, the faster you cycle the heater on and off, the better your control will be. If you couple this with a properly-tuned PID, you'll be able to achieve a stable temperature because the integral component will keep the heater on at a constant low power to offset cooling, and you'll have minimal overshoot when you increase the setpoint because the power will back off as you approach the setpoint.


@dannyjhu wrote:

I will go back at some point and take your suggestions of adding shift registers and setting up the loop to allow for an auto tune.  I want to see if an auto tune imporves things compared to my trial and error settings.  Thank you for your help.  


Don't bother autotuning with the setup as you've currently described it. It will probably make things worse. PID only works when you have a variable (rather than on-off) output. First get your code to generate a proper PWM signal so you can vary the power to the heater, then attempt autotuning. Or use the Omega controller and let it handle everything.

0 Kudos
Message 4 of 4
(4,609 Views)