Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

thermostat control with NI9401 in cDAQ9174

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

Download All
0 Kudos
Message 1 of 4
(3,545 Views)

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.

Regards

Andrew George @ NI UK
Download All
0 Kudos
Message 2 of 4
(3,525 Views)

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

0 Kudos
Message 3 of 4
(3,498 Views)

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.

Regards

Andrew George @ NI UK
0 Kudos
Message 4 of 4
(3,426 Views)