04-17-2016 10:47 AM
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.
Solved! Go to Solution.
04-17-2016 11:15 AM
Why do you even need a case strcuture to compare it to other boolean arays? Can you show us some code?
04-17-2016 01:33 PM
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.
04-17-2016 08:42 PM - edited 04-17-2016 08:43 PM
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.
04-18-2016 05:10 PM
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!
04-18-2016 06:16 PM
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.
04-25-2016 05:49 PM
But at the end, before the case structures, does your code end up with the same numbers as a binary to number function would?
04-25-2016 06:47 PM
@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.
04-25-2016 06:54 PM - edited 04-25-2016 06:54 PM
@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.
04-25-2016 06:56 PM
You should be using a shift register on the initial FOR loop for the number being rotated with the new bit.