11-17-2008 11:04 AM
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
Solved! Go to Solution.
11-17-2008 11:35 AM - edited 11-17-2008 11:35 AM
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.
11-17-2008 11:36 AM
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
11-17-2008 02:54 PM
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
11-17-2008 03:12 PM
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
11-18-2008 07:21 AM - edited 11-18-2008 07:22 AM
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 no not me!)
Ben
11-18-2008 09:06 AM
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
11-18-2008 09:22 AM
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