09-18-2013 09:50 PM
HI,
I am contiously generate data and I would like to check the bit 17 and then if it is true add 1 to an array and if not zero, then I would like to remove all zeros and just have ones out of the while loop ( when the user click on stop)
could you please help me on this. I have attached the vi
Thanks
09-18-2013 09:51 PM
Can you upload your VI in 2011
09-18-2013 11:36 PM
I attached the 2011 version to this email
09-19-2013 12:07 AM - edited 09-19-2013 12:08 AM
The VI you have attached does not have much resemblance to your question. Also, your diagram constant is empty, so we don't really know what typical data looks like.
Have you even wondered what would happen if you remove the "equal true" and wire directly to the select node? Same thing!
Please fill the diagram constant with some typical data so we can see what you have.
Counting is also typically done with integers, not floating point numbers. All you get out of the while loop is the array data from the last iteration. Is this really what you want?
tintin_99 wrote:I am contiously generate data and I would like to check the bit 17 and then if it is true add 1 to an array and if not zero, then I would like to remove all zeros and just have ones out of the while loop ( when the user click on stop)
could you please help me on this. I have attached the vi
You seem to check bits at all multiple positions of 17. If you only want to retain the ones, you seem to generate a lot of redundancy and unnecessary intermediary data. All you need is count the "ones" in a scalar shift register and at the end initialze an array of ones of that size. Right?
So please attach a VI that contains typical data. Also tell us what result you expect from it. Thanks!
09-19-2013 12:45 AM - edited 09-19-2013 12:53 AM
Hi Tintin_99,
Check the attached vi. It does pretty much what you want to do. I have briefly explained the functionality on the block diagram.
Also, if you just need the number of 1's in the array, consider implementing what Christian has mentioned above. "All you need is count the "ones" in a scalar shift register and at the end initialze an array of ones of that size."
regards,
Nitz
(Kudos are always welcome, Mark it as a Solution if your problem is Solved;))
09-19-2013 01:21 AM - edited 09-19-2013 01:25 AM
Here's what I had in mind.
It is usually much more efficient not to create green arrays, but do bitwise operations directly on the integer. If we right-shift the number by 17 placed and bitwise AND it with 1, we get a 0 or 1, depending on the original bit 17.

09-19-2013 02:05 AM
Hi Christian,
This looks really good.:) One question, what if its a 64 bit data instead of 32 bit? I believe the bit wise shift works only for 32 bits and in this case, it has to be handled with multiple shift functions after splitting the data appropriately. Would you still prefer the bitwise shift to the green arrays in such cases?
regards,
Nitz
09-19-2013 02:25 AM
09-19-2013 03:19 AM
I'm sorry Christian, I misinterpretted something and had a notion that the logical shift doesn't work for U64 shift. I just tested it now, it works perfectly fine with U64 data as well. Sorry again for the post and thank you for replying.
regards,
Nitz