LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to put a boolean array into a case structure without the boolean array to number function?

Solved!
Go to solution

Hi guys! Basically in my program, my "robot" (lego mindstorms EV3) has to read a barcode and do different things depending on which barcode it reads, and so  I have a boolean array, and I need it to basically compare it to other boolean arrays. First I used the "Boolean Array to Number" function, and then just put that into a case structure, but it turns out the boolean to number function is not compatible with my Lego EV3 brick, so I have to find another way to do this. Any ideas? 

 

Help is appreciated! If you have any questions or my question is confusing, just ask!

 

Thanks.

0 Kudos
Message 1 of 17
(4,823 Views)

Why do you even need a case strcuture to compare it to other boolean arays? Can you show us some code?

Message 2 of 17
(4,809 Views)

I've attatched my code there below. Basically I have a sensor reading 32 lines (either black or white), and then seperating them into 4 seperate barcodes (8 lines each), and then seperating each barcode into the first 3 lines which gives info about color, and then the last 5 lines, which gives info about how many of each size. And when I have the barcode into the specific number of lines, then i convert it into a decimel and whichever decimel it is has it's own case in the case structure which tells it what to output.  

 

For clarification, the first 3 lines show the color, so 001 (white white black) has a decimel of 1, which corresponds to a white marble, and so on.

0 Kudos
Message 3 of 17
(4,780 Views)

Is Array Subset also not compatible?  Your code could be greatly simplified with that (eliminate a bunch of FOR loops).

 

How about Rotate Left With Carry, Logical Shift, and Slit Number?  Using these, I can greatly decrease your code.

 

Since I don't have the EV3 module installed, I used a random number generator to act as your barcode reader.


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
Message 4 of 17
(4,744 Views)

Yes, it turns out those are compatible with the EV3 module. I am still somewhat new to Labview, and programming in general, so I was unaware of these functions. Thanks so much for you answer, could you explain a little bit as to how these functions are used here, and how it eliminates the use of the binary to number function.

 

Thank you so much!

 

0 Kudos
Message 5 of 17
(4,686 Views)

The Rotate Left With Carry along with the shift register is being used to actually make the 32-bit number.  This is assuming the Most Significant Bit is the first bit read.  If that is wrong, use the Rotate Right With Carry.

 

The Split Number slits the 32-bit number into two 16-bit numbers and then the 16-bit number into two 2 8-bit numbers.  So the result is four 8-bit numbers (4 bytes).

 

The AND is being used as a mask.  0 AND X (where X is 0 or 1) will be 0.  So if you AND a 0 with the bits you do not want and AND 1 with the bits you do want, you are just left with the bits you care about.  In this case, I masked off the upper 5 bits.

 

Then the Logical Shift shifts the bits.  In this case, I did a shift right 3 times in order to be left with the upper 5 bits.


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
Message 6 of 17
(4,669 Views)

But at the end, before the case structures, does your code end up with the same numbers as a binary to number function would?

0 Kudos
Message 7 of 17
(4,583 Views)

@chasemcd1745 wrote:

But at the end, before the case structures, does your code end up with the same numbers as a binary to number function would?


The output of the FOR loop should come out to be the same as if you autoindexed the line and then used Boolean Array To Number.


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
Message 8 of 17
(4,574 Views)

@crossrulz wrote:

@chasemcd1745 wrote:

But at the end, before the case structures, does your code end up with the same numbers as a binary to number function would?


The output of the FOR loop should come out to be the same as if you autoindexed the line and then used Boolean Array To Number.


Can you tell me what I'm doing wrong here? Again, thanks so much for your help I'm still pretty new to Labview.

0 Kudos
Message 9 of 17
(4,568 Views)

You should be using a shift register on the initial FOR loop for the number being rotated with the new bit.


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
Message 10 of 17
(4,563 Views)