09-16-2014 04:32 AM
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
09-16-2014 04:49 AM
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,
09-16-2014 05:45 AM
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
09-16-2014 05:50 AM
09-16-2014 06:59 AM
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.
09-16-2014 08:06 AM
@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
09-16-2014 12:26 PM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
09-16-2014 01:21 PM
Oh why oh why not use an enum instead of 4 booleans
09-16-2014 01:39 PM
@JÞB wrote:
Oh why oh why not use an enum instead of 4 booleans
And how would you translate the four booleans to the 16 enum items? 😄
09-16-2014 01:47 PM
@altenbach wrote:
@JÞB wrote:
Oh why oh why not use an enum instead of 4 booleans
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord