LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ Channel Constant Value Validation - NULL/Empty Check

Solved!
Go to solution

Hello all,

 

I have an setup that depending on certain values pulled from a database an array of DAQ Channel Constants is created, having in it only the channels associated with the data pulled. Most of these channels are going to be used strictly for Reading measurements but a few of them will be written to. Specifically there are two that will be sending a signal to regulators, but one of these two will not always be needed. I'm looking for a way to validate whether or not a channel constant is Null or empty (like "" in a string) depending on how LabView handles these. 

 

A case statement does not work as the output tunnel requires a wire from each case so if the value does not exist in my array then I need to output SOMETHING instead of the specific channel. Right now I have an blank channel constant but (and here is the question) I know of no way to check if it is empty or populated and I don't want to be sending information via tasks to an empty channel (if LabView would even let that happen without an error). 

Here are some images to help communicate my point:

 

DAQChannelVIFalse.PNGDAQChannelVITrue.PNG

 

If this is an incorrect or inefficient way to proceed, I'm always excited to learn ways to better program my LabView programs so any suggestions are welcome! 

Please ask questions if I have not explained anything well enough.


Thank you!

0 Kudos
Message 1 of 6
(1,342 Views)
Solution
Accepted by topic author darrenlwoodson

You can use string functions (such as "Empty String/Path") to resolve the contents of a DAQmx Channel.  You can similarly feed strings containing the same text into the DAQmx functions that expect DAQmx Channels.

 

This is one of the times you can safely ignore the coercion dot you'll see when you wire a DAQmx channel to a string input.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 2 of 6
(1,326 Views)

Awesome! I was hoping this might be the case but was uncertain. I appreciate the answer! 

0 Kudos
Message 3 of 6
(1,321 Views)

There are two ways to do this. The most direct way to do this is to just use the Equal? operator and check with an empty channel constant:

 

BertMcMahan_0-1628609618790.png

 

The second way is to use a Set instead of an Array, which handles this for you and you don't need comparisons or array searches or anything:

 

BertMcMahan_1-1628609725838.png

 

Edit: Dang, Kevin beat me to it, and I forgot about the Empty String? working here even though I'm 99% sure I've done it myself 🙂

 

Message 4 of 6
(1,318 Views)

This is a great answer too! I can't believe I overlooked simply comparing it to an empty constant!

0 Kudos
Message 5 of 6
(1,307 Views)

And I liked the clever use of the new-ish Set datatype!

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 6 of 6
(1,276 Views)