LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Set an element in boolean array as the selected case for a case structure

Solved!
Go to solution

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.

Download All
Message 1 of 10
(2,428 Views)
Solution
Accepted by topic author dachal1

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 2 of 10
(2,423 Views)

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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 10
(2,420 Views)

I have 1D(true, false) array now. How can I index the 8th element? Can you explain it little bit more?

Thank you.

0 Kudos
Message 4 of 10
(2,417 Views)

@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.  🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 10
(2,385 Views)

Thank you.

0 Kudos
Message 6 of 10
(2,380 Views)
Solution
Accepted by topic author dachal1

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)

 

altenbach_0-1627431485576.png

 

0 Kudos
Message 7 of 10
(2,367 Views)
Solution
Accepted by topic author dachal1

@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)

 

altenbach_0-1627431485576.png

 


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.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 10
(2,364 Views)
Solution
Accepted by topic author dachal1

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 😉

 

altenbach_0-1627442859274.png

 

 

 

Message 9 of 10
(2,354 Views)

Thank you.

0 Kudos
Message 10 of 10
(2,328 Views)