annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

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

Risolto!
Vai alla soluzione

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

Scarica tutti
0 Kudos
Messaggio 1 di 13
2.452Visualizzazioni

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
Messaggio 2 di 13
2.416Visualizzazioni

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
Messaggio 3 di 13
2.387Visualizzazioni

@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
Messaggio 4 di 13
2.347Visualizzazioni

Try something like this:

 

SRWL.png

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Messaggio 5 di 13
2.331Visualizzazioni

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.

Scarica tutti
0 Kudos
Messaggio 6 di 13
2.319Visualizzazioni

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
Messaggio 7 di 13
2.311Visualizzazioni

@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
Messaggio 8 di 13
2.306Visualizzazioni

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

Scarica tutti
0 Kudos
Messaggio 9 di 13
2.295Visualizzazioni
Soluzione
Accettato da 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

 

Messaggio 10 di 13
2.286Visualizzazioni