08-05-2010 11:37 AM
In my system, temperature is measured by thermocouples with NI9219. The heater is switched on and off by PFI0 of NI9401.
Heater is turned on when temperature drops below Tmin and turned off when temperature rises above Tmax as shown in the attachment.
To achieve the above function, I can write some C code as follows
example:
***************************************************
static int FLAG = 1;
HEATER=on;
if (y>Tmax)&&FLAG==1
{
HEATER=off;
FLAG=0; //wait until temperature returns to Tmin
}
if(y<Tmin)&&FLAG==0
{
HEATER=on;
FLAG=1; //wait until temperature rise to Tmax
}
***************************************************
I have some problem in building my VI(attached). Can anybody help me please?
Thank you.
Bing
08-06-2010 10:57 AM
Hey Bing,
I have written a bit of logic to help you with your problem. All it does is establish whether the temperature is above or below given thresholds, and also incorporates a warning. These output LED's are Boolean and therefore can be counted as a switch to control your heater. I hope this example helps. And for future reference try to keep your code as simple as possible, use logic if you can because the states are easy to determine, and the code is easy to read and understand. The code is attached below, I have also taken a print screen in case the code will not open.
08-09-2010 11:05 AM
Thank you Andrew for your quick reply.
The VI you attached is similar to the following C code
***************************************************
HEATER=on;
if (y>Tmax)
{
HEATER=off;
WARNING=on;
}
if(y<Tmin)
{
HEATER=on;
WARNING=on;
}
***************************************************
However in my initial question, I want the heater to
----maintain HEATER=off until temperature returns to Tmin
----maintain HEATER=on until temperature rise to Tmax
I think I might need to create a local variable as what I normally do in a C code. Thank you for your help.
Regards
Bing @NCL
08-19-2010 07:58 AM
Hey Bingji,
I have produced a logic machine that will allow you to implement a thermostat, whilst the temperature is in range the logic output will read True. You can use this logic to control the heaters switching times. As said before I can only use simulated data, however you can use this code as a reference to implement the control logic in your code.