LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pid heater control

Hi, I'm trying to write a PID temperature controller. The heaters are turned on and off via relays and are monitored by thermisters.

I am using one of the PID vi's supplied with the labview PID toolkit. But the value of the output from the PID vi will be a numerical value, say from 0 - 10 depending on the temperature. My question is, how do I convert this value into switching action for the relays? ie: if the value is 10, then I'd want the heater to be on, if the value is 0 I'd want the heater to be off and if the value is anywhere in between, it would be switching on and off at the appropriate rate.

Would the relay.vi help for this? Would I just set my threshold value, and if the output from the PID vi is above this value, then switch on the heater and if it's below then switch the heater off?

Thanks!

Sunny
0 Kudos
Message 1 of 7
(5,696 Views)
What you should do is to implement a PWM output (pulse width modulated). Say that if the PID output is 10, the relay is permanently on, if the output is 0, the relay is off, and for intermediate values, the relay is cyclically opened. For instance, with a PID output of 3.5, the relay will be switched on and off, remainin opened 35 % of the time. You could use the Square wave generation vi to create the pulse width modulation function (in the "Analyse > Signal generation subpalette)

CC
Chilly Charly    (aka CC)
Message 2 of 7
(5,687 Views)
Thank you. That's helpful.. I never knew about the square wave generation function...

Just out of curiousity, can I set the square wave to be output on a digital out line? (ie: will it recognize that the wave is digital or will it require me to use my analog outs?)

Thanks again!

Sunny
0 Kudos
Message 3 of 7
(5,681 Views)
1 more thing... i'm just looking at the square waveform.vi and i'm wondering:

-does the waveform goes from +(ve) amplitude to -(ve) amplitude, in which case I would have to use an offset

-for a digital output, the amplitude will just be 2.5? (this is assuming that I need to include a 2.5 offset, so that when the signal is low the output is 0 and when the signal is high the output is 5)

-is there a particular frequency for the PWM wave that you would recommend? or will it just depend on the relays?

THANKS AGAIn!
0 Kudos
Message 4 of 7
(5,679 Views)
sorry... i think i've kinda answered my first two questions...

i've attached my code, could you please tell me if i'm using the vi's correctly (i still need to adjust the values to get the right duty cycles, but i want to make sure that my output from the square waveform.vi into the analog to digital waveform.vi is the right way to do things).

How does the analog to digital waveform.vi work? is there just a threshold value so that once the analog signal is above a certain point it is converted into a 1 and when it is below a certain point it is converted into a 0?

thanks!
0 Kudos
Message 5 of 7
(5,677 Views)
sorry, forgot to attach it.. here it is
0 Kudos
Message 6 of 7
(5,675 Views)
Hello Sunny Dee,

Depending on the software installed on your system, you can probably find a few different shipping examples for implementing a PWM using your data acquisition board. In LabVIEW, go to Help->Example Finder and type "pwm" in the Search tab. There are examples for DAQmx and LabVIEW Real-Time for PWMs. In addition to understand these VIs, you might also take a look at this Example Program. Although this example is written in Traditional NI DAQ, you might see how you could modify the DAQmx examples to achieve the same effect.

I hope this helps.

Regards,

Kristi H
National Instruments
Message 7 of 7
(5,649 Views)