LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

multicase structure

Hi ,

 

i'm programming a sequence of switch,

 

i want to set a table of 16 possible position coded in 4 bits, to be able to commande a card motor. 

 

i'm thinking to connect these positions to some kind of case structure but it does not work?

 

can i use other possible loop.

 

Regards,

 

SA

 

0 Kudos
Message 1 of 12
(3,490 Views)

Hi,

 

For me this looks like You would like to make a truth table with 16 possible states.

For this using the Case Structure should work, since You can wire an U8 (8 bits, but You will use only the 4 lowest bits) value and select the case (position).

 

You wrote that it does not work for You.

What's the issue? Could You post a code snippet?

 

Regards,

CLA, CLED
0 Kudos
Message 2 of 12
(3,487 Views)

Hi,

 

 

 yes it is the case, i had tryed the code attached.

 

 the idea is to make a table of boolean values, an depending  on the selected value execute the sequence inside the structure

 

 

 

 Regards,

SA

 

  

   

0 Kudos
Message 3 of 12
(3,468 Views)

Hi SASA,

 

you cannot wire an array to a case structure selector. You need to index the selected entry before!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 12
(3,464 Views)

Instead of the case structure, just make an 2D array constant to work as your lookup table.  Then you just need to use Index Array to get the value you want.  It will be a little more efficient.

 

And you need to use the Boolean Array To Number function to convert your array of swithes into a number that you can use to index the right 4 bits from.


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 5 of 12
(3,444 Views)

@SASA1 wrote:

Hi,

 

 

 yes it is the case, i had tryed the code attached.

 

 the idea is to make a table of boolean values, an depending  on the selected value execute the sequence inside the structure

 

 

 

 Regards,

SA

 

  

   


Just insert a Bool array to number and it'll be changed to a 0-15 number, working with the case structure.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 12
(3,427 Views)

Yamaeda wrote:   

Just insert a Bool array to number and it'll be changed to a 0-15 number, working with the case structure.


If you do this I highly recommend showing the radix on the case structure and set it to binary.  This way you can see that case 0b100 is for when the third item in your array is true and the first and the reset are false.  In my opinion this is easier to read than having decimal 8.

Message 7 of 12
(3,394 Views)

Oh why oh why not use an enum instead of 4 booleans

use an enum unstead.png


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 12
(3,377 Views)

@JÞB wrote:

Oh why oh why not use an enum instead of 4 booleans

use an enum unstead.png


And how would you translate the four booleans to the 16 enum items? 😄

0 Kudos
Message 9 of 12
(3,370 Views)

@altenbach wrote:

@JÞB wrote:

Oh why oh why not use an enum instead of 4 booleans

use an enum unstead.png


And how would you translate the four booleans to the 16 enum items? 😄


Boolean array to number.

 

Or I'm guessing he is suggesting don't use the 4 booleans and instead use an enum. It is hard to say which would be better without knowing more.

0 Kudos
Message 10 of 12
(3,367 Views)