06-10-2023 03:38 AM
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).
Solved! Go to Solution.
06-10-2023 03:46 PM
Its Bit/Byte?
(U8) has 8 bits, which means each array element has 8 bits.
User Number to Boolean array for bit conversion.
06-11-2023 04:04 AM
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.
06-12-2023 03:00 AM
@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.
06-12-2023 09:56 AM
Try something like this:
06-12-2023 11:18 AM - edited 06-12-2023 11:29 AM
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.
06-12-2023 11:49 AM
If your string exclusively contains the letters 0 and 1, here's one possibility:
If other characters can occur (e.g. linefeeds), you need a bit more code after deciding what to do with them....
06-12-2023 11:56 AM - edited 06-12-2023 12:11 PM
@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:
06-12-2023 12:18 PM - edited 06-12-2023 12:20 PM
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
06-12-2023 12:31 PM - edited 06-12-2023 12:32 PM
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?