I am trying to control a heater based on multiple temperature sensors and a manually set temperature level, but each time there is a NAN value recorded from one of the temperature sensors the heaters turn on. Any ideas on how to stop this from happening, here is the relavent code:
'Record's the Temperature at each multiplexer sensor
Count(1)=1
SubScan(0,uSec,Temp_Sensors)
'Switch to next Am16/32 Multiplexter channel
PulsePort(C1,10000)
'Type K Thermocouple measurements 'Temp()' on the AM16/32 Multiplexer
TCDiff(Temp(Count(1)),1,mV200,1,TypeK,PTemp_C,False,Temp_Settle,50,1,0)
Count(1)=Count(1)+1
NextSubScan
'_____________________If you are using 4 heater inputs______________________
'Use outputs ** C6 ** ** C5 ** ** C4 ** ** C3 **
Case Is = 4
Avg_Temp(4)=(Temp(5)+Temp(6))/2
Avg_Temp(3)=(Temp(3)+Temp(4)+Temp(5))/3
Avg_Temp(2)=(Temp(2)+Temp(3)+Temp(4))/3
Avg_Temp(1)=(Temp(1)+Temp(2))/2
PortSet(C6,IIF(Avg_Temp(4)>=Temp_Lvl(4),0,1))
PortSet(C5,IIF(Avg_Temp(3)>=Temp_Lvl(3),0,1))
PortSet(C4,IIF(Avg_Temp(2)>=Temp_Lvl(2),0,1))
PortSet(C3,IIF(Avg_Temp(1)>=Temp_Lvl(1),0,1))
Where Temp_Sensors and Temp_Settle are all constant values.
I am trying to make the programme as user friendly as possible so that people only have to change a few constants at the start rather than finding the exact point within the code and have to change everything depending on the situation.
Hi
IE
'Type K Thermocouple measurements 'Temp()' on the AM16/32 Multiplexer
TCDiff(Temp(Count(1)),1,mV200,1,TypeK,PTemp_C,False,Temp_Settle,50,1,0)
if Temp(Count(1)) = nan then Temp(Count(1))=999 ' or
if Temp(Count(1)) = 'nan' then Temp(Count(1))=999 ' I don't remember exactly the syntax
and for extreme limits
if Temp(Count(1)) >100 then Temp(Count(1))=999 ' for the max ie 100° (numeric or variables)
if Temp(Count(1)) < -10 then Temp(Count(1))=999 ' for the min ie -10°
Count(1)=Count(1)+1
Thanks