LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PID for temperature control

Hello,

I have been trying to control the temperature through labview in stead of using a PID controller (Omega CN740). I have been collecting my temperature data from C-DAQ NI-9211. So, its dynamic data. I have been using this data as the input of my process variable.  Therefore when i start running the PID VI, the vi is supposed to continuously compare my process variable and set point using the PID gains given. And it should give me an output. I am converting the output to percentage and then simulating a PWM signal. And based on that signal, i get on/off condition to relay. and that runs my heater to heat the element. 

Whenever , i am trying to run the code, initially its overshooting a lot and then keep fluctuating. Therefore, i am never finding any steady temp. I have tried to run the autotuning option too. As the signal is never becoming stable, the auto-tuning process is not returning any PID gain out. 

I, exactly dont know what's the problem(whether the code or my trial n error PID gains input). I am attaching my VI here. It would be great if someone can give me some feedback about solving the issue. 

Thanks,

Arnab

Download All
0 Kudos
Message 1 of 10
(16,166 Views)

There is an autotuning VI for systems that have dead times (i.e. temperature).  Dead time, I assume, is the time it takes for the system to respond to a change in the setpoint.  I've never used it before so I can't offer any help in that regard but maybe you can figure it out.

 

http://zone.ni.com/reference/en-XX/help/370401J-01/lvpid/pid_autotuning_temperature/

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 10
(16,134 Views)

I have used the similar type VI from the PID and fuzzy logic kit. But, its not working the way PID is supposed to work. I have not been able to figure out the problem.

Thanks. 

0 Kudos
Message 3 of 10
(16,131 Views)

What type of relay is being fed with the PWM signal- a solid state or a mechanical contact?

How many watts is the heating element and what exactly is being heated? Where is the temperature sensing element in relation to those?

 

-AK2DM

~~~~~~~~~~~~~~~~~~~~~~~~~~
"It’s the questions that drive us.”
~~~~~~~~~~~~~~~~~~~~~~~~~~
0 Kudos
Message 4 of 10
(16,119 Views)

It is solid state relay (DC to AC). So i am sending DC voltage to the relay and the heaters are AC (5 and 10 W). I am heating a block of aluminum. I am trying to maintain the surface of the block at a constant temp. I have a thermocouple from omega (TJC36-CASS-010U-2) collecting the temp at the surface and feeding it to my C-DAQ. Please let me know if you have any other questions. 

0 Kudos
Message 5 of 10
(16,116 Views)

Hi arnab,

 

I, exactly dont know what's the problem(whether the code or my trial n error PID gains input). I am attaching my VI here. It would be great if someone can give me some feedback about solving the issue. 

Well, most often the problem is in the code… 😄

In your case: the VI is just horrible lacking nearly all rules from StyleGuide (like "left to right")…

 

Other things:

- your loop misses an exactly defined timing: do you really need to bang the hardware as fast as possible? (For a rather slow temperature control?)

- you are playing around with DDT wires: this just adds "noise" and reduces insight of your code! Why do you need to simulate your PWM signal using an ExpressVI? Why do you produce just one sample for PWM? Why do you need to check this DDT wire two times? Why do you convert the result of this comparison to two different datatypes?

- why do you need to split the signal coming from your DAQAssistent? There is only one signal in the wire!

- Your "PID EGU to Percentage" is lacking most of it's inputs!

- Why do you need to convert from EGU to percentage anyway? Why not just set the output range of the PID to [0, 100]? (Well, atleast these are the default settings for your output range: why do you need that EGU conversion in this case?)

- why don't you use a shift register for those PID gains? Why do you need a local variable here?

- do you really want to switch your SSRs at 10Hz? Why not use a slower PWM base frequency of 1 or down to 0.1Hz?

- two subVIs are missing: are they important for your task? Should we know about them?

 

- to generate a PWM output is plain simple: compare the needed duty% with a counter (who counts just the iterations of your loop)…

Example:

check.png

"Schalttakt" determines at which intervals you want to switch your relays, atleast mechanical ones don't like to switch too fast. "count" is just the loop iterator…

The shown routine could be enhanced, but in it's current state it should be used only with "verified" inputs. (FullCycle should be a multiple of Schalttakt. DutyCycle should be in the range of (0, 100).)
 

I am heating a block of aluminum. I am trying to maintain the surface of the block at a constant temp.

How big is this block?

Did you determine the delay between activation of the heaters and a temp increase at the surface of this block?

Your default PID gains only have a P gain, but no I/D gains: this surely is wrong…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 10
(16,089 Views)

Hello GerdW,

Thanks a lot for your elaborated reply.  I tried to go through your comments and changed the program based on your suggestions. I am attaching my new VI here. I changed the PWM base frequency to 0.1 Hz and tried to run the program again. The result is same like as previous. I was trying to get the PWM output the way you have mentioned instead of using the express VI. But i have not been able to do that. I build the general code for counting the loop iterations. But, I dont know how to get this "Schalttakt/ms". If you have the VI of the picture that you have attached here, can you please give it ? Then i could have a look at that VI and develop the PWM output based on that. I know I am asking a lot. But, I am like in nowhere. Your help is really appreciating. I am attaching the other VIs too. I think these were the one missing. 

I have used different P, I, D gains input. But, that has not made any significant difference. I am seeing any different PID output gain even using the auto-tuning. Please let me know if I am missing any information. 

Download All
0 Kudos
Message 7 of 10
(16,061 Views)

I'm trying to understand what your intentions are for the PWM signal.  Are you wanting to flip the power on/off at varying rates?  Are you expecting the %on time to be smaller as the temperature nears the setpoint?  If so,

  • You may want to consider putting the temperature DAQ in a separate loop.
  • Use a timer rather than the simulate signal.  The Simulate VI doesn't make sense to me in this scenario
  • Output range would work better as 0 and 1.
  • Init the DAQ hardware before the while loop, send a value inside the loop and stop the task after the loop.  Opening and closing that hardware connection over and over will slow things down.

This VI is based on my assumptions about your intentions.  I haven't tested this because I can't, but I think it is pretty close.  You may need to reverse the Select values if I have them backwards.  Also play around with the relay period if you want power to be applied for a longer time span.  I didn't mess with the PID values or auto tuning parameters, only the layout of the code. 

PID_1_BD.png

 

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 8 of 10
(16,044 Views)

Hello Aputman,

Thank you very much. I tried with your code. Using the code i tried to tune the PID. I have come up with some number which is keeping my temperature pretty stable but there is an initial fluctuation of about 10 degree celc. I have not been able to reduce that. I have tried with the autotuing VI. The autotuning feature doesnt give the parameters back to me. After clicking the autotuning option I have tried to go through the procedures that opts up. But in the end it doesnt complete and return the parameters. Most probably, I am missing something there. 

Thanks a lot. I am attaching a picture with the initial fluctuation and then the scenario of becoming stable. Please,

Let me know if you have suggestions. 

 

Thanks,

Arnab

0 Kudos
Message 9 of 10
(15,984 Views)

Hi arnab,

 

in your image/chart the setpoint plot is missing. (I like to see a comparison of sp and pv in a chart…)

 

General hint: usually you get smaller overshoots with smaller sp steps. You might also decrease the P gain a little bit…

 

What happens when you change your sp with smaller steps like 10K every 25 units of your chart x axis? Or when you ramp up the sp linearly in about 120 units of your x axis?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(15,963 Views)