Aro Posted August 1, 2014 Share Posted August 1, 2014 I'm a little new to DAQFactory and programming in general so forgive me if this is simple. I have a device with a number of thermocouple jacks for plugging in thermocouple probes, but not all of them are used for some operations. When no probe is connected, the value displayed (after the conversion is applied) is around -170,000 oC. My question is what is the easiest way to get the display to read "OPEN" or "NO TC" when no thermocouple is attached to the jack, but display the temperature as normal when there is a thermocouple connected? Is there a way to do this without having to run a sequence for every reading? Thanks for the help. Link to comment Share on other sites More sharing options...
AzeoTech Posted August 1, 2014 Share Posted August 1, 2014 Sure, let's assume that your channel is simply "temp". Instead of doing Temp[0], do: iif(temp[0] < -300, "OPEN", temp[0]) iif() is an inline if. If temp[0] is less than -300, it will choose the first option, "OPEN", otherwise it will use the second one, the current reading. Link to comment Share on other sites More sharing options...
Aro Posted August 1, 2014 Author Share Posted August 1, 2014 Thanks, that was simple. I didn't realize you could put if statements directly into the component expression. One more thing though, the unit (oC) is still added to the end of "OPEN". Is there a way to get rid of this when temp[0] < -300? Link to comment Share on other sites More sharing options...
AzeoTech Posted August 1, 2014 Share Posted August 1, 2014 Its a special type of if. To remove the units, put it in the expression: iif(temp[0] < -300, "OPEN", format("%.1f", temp[0]) + "oC")) format() with %.1f just gives you one digit past the decimal. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.