ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert digital waveform data to hex and to file

I'm sampling a digital line at about 25kHZ, 1080 samples each second (using USB-6221).  So I take data for about 40ms and have the rest of the 1 second (~960ms) to do other things the program has to do, including write that data to an open file.  I'm reading the data using the "DAQmx Read" VI, which outputs a digital waveform that includes time information that I don't need.  So I've stripped out just the 1080 values using the "Get Waveform Components" VI, to pull out the "Y" component (data).  This is a boolean array, 1080 boolean values. 

So I'm trying to write this boolean array to a binary file.  I can convert the boolean array to digital using the "Get Digital Data Component" VI, and write that with "Write to Binary File", but this is wasteful because it uses one byte in the file for each original bit of data.  Also it makes reading the file difficult.  I would rather write it directly to the binary file as a binary bit stream.  Any idea how to do this?  Thanks for the help!
0 Kudos
Message 1 of 3
(4,351 Views)
If you write U32 numbers to your binary file rather than boolean arrays it will only write one bit for each boolean value. But you will need to break your array down into chunks of 32 bit as to not overflow the boolean array-to-number function. Check out the screen grab bellow.
 
-Marshall R
Message 2 of 3
(4,310 Views)
Thanks.  I ended up writing the data as ASCII instead of binary so that it's easy to check the data with a text viewer.  I don't think the file will get too large so this will work.  See the attached for how I handled this.  It may not be the best way to do it but it works. 

0 Kudos
Message 3 of 3
(4,281 Views)