05-08-2012 05:13 PM
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.
05-08-2012 07:20 PM
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?
05-08-2012 08:05 PM
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.
05-08-2012 08:34 PM
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.
05-08-2012 08:41 PM - edited 05-08-2012 08:45 PM
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.
05-08-2012 09:24 PM
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.
05-08-2012 11:57 PM
@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.
05-09-2012 01:14 AM
You can explain a little more. And could you please save as it for 2009?
05-09-2012 10:04 AM - edited 05-09-2012 10:10 AM
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.
05-09-2012 01:33 PM
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: