LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading specific bits from an array of 160 bits to turn on/off LED

Solved!
Go to solution

Hi, I have an array of 160 bits which contains the state of push buttons. The state of the buttons is 33, 34, 35, 36 and 48th bit. How can i extract those specific bits to turn on/off the corresponding LED's. The response (attached) that i am getting gets updated with the press of buttons but the LED's won't turn on/off? Is there an alternative for creating a 160 bits array which looks quite awkward (vi and picture attached). When i tried with simple 5 bits which contained the status of buttons, that worked fine (pic attached).

0 Kudos
Message 1 of 13
(1,392 Views)

Its Bit/Byte?

(U8) has 8 bits, which means each array element has 8 bits.

User Number to Boolean array for bit conversion.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 13
(1,356 Views)

The response that I'm getting which is 160 0's or 1's, an LED needs to turn on once the 33, 34, 35, 36, and 48th 0 turn to 1.

0 Kudos
Message 3 of 13
(1,327 Views)

@AbdullahWasif wrote:

How can i extract those specific bits to turn on/off the corresponding LED's... Is there an alternative for creating a 160 bits array which looks quite awkward (vi and picture attached).


The terminals on the left side of the Index Array primitive are inputs specifying the index that you want. You can wire in constants with your values. Also, as you see, not wiring in an input makes the index increment by 1 and that applies when you wire a value, so if you specify one row to be index 33, the next rows will be 34, 35, 36, etc.


___________________
Try to take over the world!
0 Kudos
Message 4 of 13
(1,287 Views)

Try something like this:

 

SRWL.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 13
(1,271 Views)

I tried this but it's not working. I think the problem is with the string coming in from the arduino. LV is detecting the string as a whole i think (I've attached a screenshot of the block diagram), i'm not sure.

Download All
0 Kudos
Message 6 of 13
(1,259 Views)

If your string exclusively contains the letters 0 and 1, here's one possibility:

 

altenbach_0-1686588496751.png

 

If other characters can occur (e.g. linefeeds), you need a bit more code after deciding what to do with them....

 

0 Kudos
Message 7 of 13
(1,251 Views)

@altenbach wrote:

If other characters can occur (e.g. linefeeds), you need a bit more code after deciding what to do with them....

 


Here's how to get a boolean array from only the zeroes and ones in the string, skipping all other characters:

 

altenbach_0-1686589862689.png

 

 

0 Kudos
Message 8 of 13
(1,246 Views)

I can't seem to make it work. I'm not getting any other text, just 0's and 1's (I've attached a picture). What is this inverted 3 (sorry for the bad description) block? Can you kindly incorporate it into my VI? I have a demo tomorrow and really need to make it work

Download All
0 Kudos
Message 9 of 13
(1,235 Views)
Solution
Accepted by AbdullahWasif

You need to learn some of the bare basics. For example, you need to disable autoindexing on the array constant and make the output tunnel conditional. Then you also need to learn about "or array elements"

 

See if this can give you some ideas. Also please don't maximize the front panel to the screen, that's very annoying. Nobody likes to stare at huge amounts of greyspace. When attaching code, it helps us if you would have typical default data in the string indicator so we can test without having any instrument. Do you know how to do that?

 

altenbach_0-1686590981478.png

 

Message 10 of 13
(1,226 Views)