07-27-2021 03:41 PM
Hi,
I am quite new to LabVIEW. I am trying to get the Internal state change status register(INR) of the oscilloscope, which is in decimal format and convert it into a boolean array. When the 8th element of the array is "true" I want to read the signal area. I already have extracted the INR as a boolean array and I have set the case structure to read the area. How can I set the 8 th element as the case selected?
Thank you.
Solved! Go to Solution.
07-27-2021 03:46 PM
Index the 8th element of the array and wire that to the case selector. If you want the case structure to trigger on the results of the 8th element of the array, that is.
07-27-2021 03:48 PM
I'm surprised you're stuck on this and not the conversion to the array of Boolean values. To me, that would be an advanced topic, so kudos to you for figuring that part out.
07-27-2021 03:54 PM
I have 1D(true, false) array now. How can I index the 8th element? Can you explain it little bit more?
Thank you.
07-27-2021 04:55 PM
@dachal1 wrote:
I have 1D(true, false) array now. How can I index the 8th element? Can you explain it little bit more?
Thank you.
Look in the array palette to find the "Index Array" node. Part of programming efficiently with LabVIEW is knowing where to look for things. I was hoping you could take my lead, but here, I've given you a better hint. 🙂
07-27-2021 04:57 PM
Thank you.
07-27-2021 07:19 PM - edited 07-28-2021 09:15 AM
Also be aware that array indices are zero based, so the 8th element will have index seven.
Unless you needs that boolean array elsewhere, it is wasteful to inflate you data structures to use 8x more memory. You can check the bit #8 equally well directly in the numeric by doing some cheap bitwise operations. (In fact, you can wire the masked numeric directly to the case structure and name the case 128 and the other default)
07-27-2021 07:27 PM
@altenbach wrote:
Also be aware that array indices are zero based, so the 8th element will have index zero.
Unless you needs that boolean array elsewhere, it is wasteful to inflate you data structures to use 8x more memory. You can check the bit #8 equally well directly in the numeric by doing some cheap bitwise operations. (In fact, you can wire the masked numeric directly to the case structure and name the case 128 and the other default)
On the other hand, at least IMO, the first method is more self-documenting and easier to understand at a glance. Also, you can't avoid converting if you want to display it as either an array or converted into a typedef'd cluster.
07-27-2021 10:19 PM - edited 07-27-2021 10:27 PM
Yes, of course sometimes you want to display the boolean array. Often you even want to reverse it so the LSB is on the right and it looks similar to the number displayed in binary.
My "blue" method is easier to read if you display the constant in binary.
You can even make it scalable to set the bit to be tested at run time 😉
07-28-2021 09:13 AM
Thank you.