ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binary Detection

I am new to labView and I need help comparing integer values coming out of a 1-D array. I have so far created three for loops. Within the first for loop is a random number generator that generates a series of 1s or 0s (I used the round to nearest integer value tool) for 5 times into an array. The second loop generates a 20 1s into an array. The third loop generates a series of 5 1s or 0s like the first loop into an array as well. Each of these array I concatenate into a larger 1-D array. I need to go through this final array which would have values, for example, of (101001111111111111111111101001) I need to figure out how to detect when the 20 1s occur. I am thinking of putting the output of the array to a for loop that somehow goes until it detects 20 1s consecutively in a row. Although I am unsure how to implement this using the LabView tools as this is my very first program in LabView. Any help is greatly appreciated.
 
Thank You 
0 Kudos
Message 1 of 5
(3,301 Views)

Try this.



Message Edited by Ravens Fan on 03-03-2008 08:31 PM
0 Kudos
Message 2 of 5
(3,289 Views)
Ravens VI will run forever if there is a possibility that the array has no consecutive series of 20 ones. To make it bulletproof, it would also need to check if it runs out of elements. I would always recommend this. Currently it even runs forever if the input array is empty. 😉
 
Here's an alternative (including the array generation). It is probably slightly less efficient than Ravens solution, but if speed really is an issue you should cast the binary array into a single U64 integer and do some simple shifting and masking to find the pattern. 😉
 
See if you can make sense if it. 🙂
 
 
 
 
0 Kudos
Message 3 of 5
(3,279 Views)
Thank you this seem logically correct I just didnt know which tools to use in order to implement, Although I do get one bad wiring error "you have connected an array data type to its element data type." how should I fix this? Also what is that tool you used to display the array index of the 20th 1? and since I am going to continue going through the array after the 20 1s would I be able to do some type of thing where I use that index to "go to next index" because eventually the whole program will analyze the all integers after the 1s. Sorry so many question I am very new to this.
0 Kudos
Message 4 of 5
(3,274 Views)


LabMaster03 wrote:
Thank you this seem logically correct I just didnt know which tools to use in order to implement, Although I do get one bad wiring error "you have connected an array data type to its element data type." how should I fix this? Also what is that tool you used to display the array index of the 20th 1? and since I am going to continue going through the array after the 20 1s would I be able to do some type of thing where I use that index to "go to next index" because eventually the whole program will analyze the all integers after the 1s. Sorry so many question I am very new to this.


Right click on the tunnel at the left and select Enable Indexing.
 
You've got me again, Christian.  I guess I was going on the assumption the data was good and it add 20 1's in it somewhere.Smiley Surprised
0 Kudos
Message 5 of 5
(3,269 Views)