Sign in to follow this  

Recommended Posts

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this