LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-Case-Structure

Hello,

 

what is the best way to create an multi-case structure for checking many logic states in once? I need it for a simple state machine which is controlled by some digital sensors in the way:

 

WHEN DI0; DI2 = TRUE and DI1 and DI3 = FALSE then .........state1

WHEN DI0; DI3 = TRUE and DI2 and DI1 = FALSE then .........state2

WHEN all DI = TRUE then ........ error state

 

And so on... has someone an idea? Maybe I am a little bit slow?! 😉

 

Thanks!

 

Paul 

0 Kudos
Message 1 of 5
(3,016 Views)

You could build them into a 1D array of booleans, and then either convert to a number or to a string of 1s and 0s, such as in this thread.

 

That gives you either an integer or a string that can be input to a case structure condition and you can put in any logic states you require. Just remember to include a default state for unexpected combinations.

---
CLA
0 Kudos
Message 2 of 5
(3,007 Views)

try looking at this , once a number is connected to the case structure...right click and change "radix"

Example_VI.png

0 Kudos
Message 3 of 5
(2,968 Views)

How are you reading the DIO?  I would be tempted to just read the port (8 digital lines) as a U8 and then that value can go straight to the case selector.

 

The other option is to read the 3 lines as an array of booleans and then use Boolean Array To Number whose result can then go into the case selector.

 

If using numbers, you can set the radix of the case structure so that you can view the state case in boolean.  Might make it a little easier to understand what is happening.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 5
(2,960 Views)

Yeah, the radix set to binary is the necessary part for me to improve readability of the case structure 🙂

---
CLA
0 Kudos
Message 5 of 5
(2,950 Views)