LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3 digital inputs for case structure

Solved!
Go to solution

I am in the early stages of developing a VI that will monitor 3 digital input lines. Only one digital input will be active at any one time. For each digital input, a different sub VI will run.  Currently, I am using 3 separate case structures  (attached.)

 

 

Is there a way to use one case structure ( 3 cases plus one default) to monitor the three digital input lines?  Specifically, how do I convert the Boolean data (from the digital input lines) to a data type recognized by the selector terminal?

 

 

Thanks,

 

Bill

 

0 Kudos
Message 1 of 8
(4,833 Views)

You don't need to put the boolean indicators in the case structure since you are wriing a true in the true case and a false in the false case, just wire the boolean wire directly to the indicator outside of the case structure.

 

You could build the 3 digital inputs into an array.  And use a find True to get the value.

 

You could also combine the 3 DAQmx read tasks into 1.

 

Message Edited by Ravens Fan on 11-17-2008 12:35 PM
Message 2 of 8
(4,823 Views)

Quick idea....

 

Build an array out of the booleans and convert the array into a numeric. That can be used to drive the case structure.

 

Optionaly...

 

Type cast the numeric to an enum before driving the case structure so you use plain language in the case sctructure.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 8
(4,821 Views)

Thanks Ravens Fan,  Search Array worked like a charm.

 

Ben,

 

I haven't tried the enum yet. When you say "Type cast" is that the same as "Type Def"?  I just got to tht chapter in  Labview for Everyone 8.0, so I'm not that familiar with enums yet.

 

Bill

0 Kudos
Message 4 of 8
(4,788 Views)

No a typecast is a no-op in LabVIEW.

 

Well not really, it doesn't alter data it only alter the type description of data. It tells Labview to read the data at a given memory address (wire) from type A as data from type B.

See here what differences in code this makes.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 8
(4,782 Views)
Solution
Accepted by topic author Bill_5335

Adding to my quick post from yesterday.

 

By defining an enum for every possible value with a descriptive name it is much easier to follow what the code is doing.

 

The attached VI (LV 7.1) shows how I could handle three booleans controlling a press to ensure the safety is set, and the part is in-place when the operator chooses to activate the press.

 

 

This approach lets you deal each of the 9 possible states uniquely.

 

Of course this approach is not workable for more than 5 bits (booleans) (unless you have a summer intern Smiley Wink no not me!)

 

 

Ben

 

 

Message Edited by Ben on 11-18-2008 07:22 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Download All
Message 6 of 8
(4,761 Views)

Thanks Ben,

 

Great solution! I always appreciate the help I get from this board.  Aside from taking Labview Basic 1 & 2 classes, I am learning Labview pretty much on my own.  Bill

 

Message 7 of 8
(4,745 Views)

POBA wrote:

Thanks Ben,

 

Great solution!...

You are welcome Bill. If that approach is acceptable, then I would like to ask you concidering marking that post as a solution. (I'm working on getting my solution count up. If another better answer comes up latter you can change it)

 

Take care,

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 8 of 8
(4,737 Views)