LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

bit manipulation

Hi,
I have a binary file and I need to read every 96 bits until EOF bcoz each 96 bits gives the status of 96 digital lines. Each time I read 96 bits, each bit value need to be stored separately, say like line(i) where i=0 to 95. Later on I will have to read these values and turn ON/OFF some LEDs on my front panel. Can anyone tell me how to read the bits. Right now I am able to read the file and display the data as a graph but I don't know how to manipulate the bits.
0 Kudos
Message 1 of 7
(3,104 Views)
Use a Boolean array to store the values (length = 96).

To READ a single bit, use "Index Array".

To READ each bit in sequence (and do something?), use a FOR LOOP (N = 96) either with "Index Array" (index input wired to I), or use auto-indexing.

To WRITE a bit, use "Replace Array Subset".

Does this help?
Message 2 of 7
(3,104 Views)
srini wrote:

> Hi,
> I have a binary file and I need to read every 96 bits until EOF bcoz
> each 96 bits gives the status of 96 digital lines. Each time I read 96
> bits, each bit value need to be stored separately, say like line(i)
> where i=0 to 95. Later on I will have to read these values and turn
> ON/OFF some LEDs on my front panel. Can anyone tell me how to read the
> bits. Right now I am able to read the file and display the data as a
> graph but I don't know how to manipulate the bits.

Get the 12 Byte (96 bit) in an array (of U8). You can than use the
"Number to Boolean Array" from the Boolean-Menu to convert the U8 to an
array of booleans.
If you're working with bigger amount of data, keep in mind, that
Booleans are C-Style in LabView, which m
enas, the every booleans takes
up 1 Byte! So from 12 Bytes you read in, you'll get 96 Bytes.

For reading I would read it in as text, and convert this to an Array of
U8...

Hope, this helps a bit

Marco
0 Kudos
Message 3 of 7
(3,104 Views)
Hi,
Your reply was very useful and I don't know how to thank you bcoz you have made it so easy. I have one more querry. After reading the bits corressponding to the 96 lines, I am switching ON/OFF 96 LEDs in a subpanel VI(Sub VI ia named STATUS.vi) in my front panel. The LEDs are of CONTROL type and their mechanical action is "switch when pressed". Now, I want to display some details about each line(like why it is OFF or ON) in another subpanel when I click on any one of the LEDs. I tried using event structure in the STATUS.vi, but it waits for the key down event of the 1st LED, displays the message and then only displays the status (ON/OFF) of the second LED. If I want to see the status of 3rd, then again I have to click the 1st or 2nd LED. Is there any w
ay to first display the status and then display the message upon mouse click?
I hope I have made my question clear.
0 Kudos
Message 4 of 7
(3,104 Views)
Hi Srini
You are most welcome. I'm not exactly clear about your explanation - and I'm afraid I'm stuck with LabView 6.0, so I'm not familiar with the Event Structure. However, I put a quick example together which you can look at - perhaps it helps? If you have any questions, just ask. Good luck...
0 Kudos
Message 5 of 7
(3,104 Views)
Does your file contain exactly 96 bits or do you possibly need to read multiple chunks of 96 bits until eof? In any case, you can convert your string of any length directly into an array of booleans using 4.x typecast. If there are multiples of 96, you should then reshape the array e.g. into an "n by 96" 2D array.

You apparently want to be able to click on the array to get the status. This is a bit complex because it functionally is an indicator and using it as a control would change the data. You can use an event structure to see which element has changed, then immediately reset it to what it was using a local variable write.

I have attached a simple example (LabVIEW 7.0). It takes a 12 byte string (96 bits) and converts it into a 96 bit boolean a
rray which is written to a control. Clicking on any element then displays some information on that array. Modify as required. Good luck!
0 Kudos
Message 6 of 7
(3,104 Views)
Hi,
Your previous example on displaying a message after LED click is good. I will go thru your new example and let you know about it. Actaully I need to read multiple chunks of 96 bits until EOF. As you have rightly pointed out, I have converted the data into an "n by 96" 2D array. Thank you once again for your valuable answer. Bye!
0 Kudos
Message 7 of 7
(3,104 Views)