LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

matching binaries pattern

I'm not very confident that I'm doing this right.  Could someone please give me some contructive feedbacks to see if it can be done any better?  It appears to be working but not 100% of the time.  Every now and then it would misses a search pattern.

0 Kudos
Message 1 of 10
(4,461 Views)

Can you explain what you want to do, and provide some sample inputs?  Are the values in the array only 1 or 0 - individual bits - or can they be larger numbers?

Message 2 of 10
(4,444 Views)

I would like to search only binaries pattern because they're much harder to search than standard number given little uniqueness about 1s and 0s.  Any size, small or big.  It doesn't seems like I have covered all the combinations.  So occassionally, it will miss and not work as warranted.

0 Kudos
Message 3 of 10
(4,440 Views)

So just to clearify, you're trying to find a sync pattern within a raw bit stream that has been read in 16 bit chunks.  So for instance, you want to find 0xEB90 inside an array of 0xAD720.  If this is the case, I have some code at work that I did recently to perform this task.

 

Or are the inputs going to be 0 or 1 only?  If that's the case, I would use booleans to make it more obvious.


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 10
(4,431 Views)

Ideally, I would like to accommodately any U16/I16 numbers.  At worst case senario, it should sync to binaries stream 100% of the time.  Binaries are much harder to work with because they're much harder to sync. It seems to work with all the test cases that I've thought off but once I put it to test in real time with new different possibilities, that's when reality checks in and I'm starting to lose confidence that it's working 100% accurately.

0 Kudos
Message 5 of 10
(4,428 Views)

I'm confused by your code because your comments says 30 bits but the code is processing 30 words.  Are you trying to find a sync pattern directly from an array?  Is each word supposed to represent a single bit?  Or are you trying to accommodate bit shifting to find the sync?

 

I guess I need an example to figure out exactly what your goal is.


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 6 of 10
(4,415 Views)

@lavalava wrote:

Ideally, I would like to accommodately any U16/I16 numbers.  At worst case senario, it should sync to binaries stream 100% of the time.  Binaries are much harder to work with because they're much harder to sync. It seems to work with all the test cases that I've thought off but once I put it to test in real time with new different possibilities, that's when reality checks in and I'm starting to lose confidence that it's working 100% accurately.


Again, you're going to have to explain better what you are trying to achieve.  What does "sync to binaries stream" mean?  What is a typical input to this VI?  What should the output be?  It sounds like you're asking us to tell you whether your VI ever generates bad output, and how to fix it, without explaining what constitutes good and bad output.  Also, you seem confused about binary.  Are you using all of the bits in the U16 array, or just one bit of each element?

 

If all you are trying to do is determine if a particular bit pattern is found somewhere within a sequence of bits, and your arrays aren't huge, there's a much easier solution: use the "Search/Split String" function.  If, in your existing code, the values in the U16 arrays are all either 1 or 0, then you can use "Byte Array to String" on each array (it would make sense for those arrays to be U8 instead), then connect them to Search/Split String.  If the search string is found within the other string, you'll get the offset at which the match occurs.  If you're actually using more bits than one bit per value, then it becomes more complicated.  A simple but inefficient method would convert each value to an array of booleans, concatenate the boolean arrays, and typecast to a string.

0 Kudos
Message 7 of 10
(4,406 Views)

You can explain a little more. And could you please save as it for 2009?


Yasemin Barutçu
Electrical And Electronics Engineer
0 Kudos
Message 8 of 10
(4,401 Views)

here are some random data generated, i just grouped everything into one VI.  It appears to be working 99.99% accurately but not complely.  Please take a look, thx.

0 Kudos
Message 9 of 10
(4,383 Views)

Well, I'm still not clear exactly what you're trying to do, but the code below produces identical results in your test and is both simpler and faster:

Match Pattern within Array.png

0 Kudos
Message 10 of 10
(4,365 Views)