LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to display a binary file

By far the easiest way to do this is to use the built in primitives for binary file IO, but I believe from your previous post these aren't available in the the version of LabVIEW you are using.  They look something like this, you specify the datatype to read and LabVIEW sorts out the rest.

 

BinaryIO.png

 

Otherwise, there is an option to flatten the data to a string, log as binary/ASCII (equivalent in this case), read back as a string then unflatten the data.

 

BinaryIO.png

 

Those functions, Flatten to String and Unflatten from String may not be available in LV7.x - I don't have a copy to check against here.


Regards,

Peter D

Message 11 of 17
(711 Views)

Thank you for the reply Todd. I will try to do that, but like you said, I think it may be too slow.

Peter,
I think I will try the second option, with the flattening and unflattening. In the image, I'm not quite sure what you mean by "writing and reading with normal IO". Are those functions within Labview? Thank you

0 Kudos
Message 12 of 17
(664 Views)

Hi trannh,

 

Sorry - I just meant use the Open/Create/Replace, Write Binary/ASCII, Read Binary/ASCII and Close File functions.

 

You can use either the binary IO or ASCII IO functions and the result will be the same.


Regards,

Peter D

Message 13 of 17
(646 Views)

Hello Peter,

I tried using the flatten and unflatten functions. I'm stuck though. I'm not sure how to log as binary. I've attached some code to show you what I've got. It's not much really, because I'm not sure how proceed. I want to tell the unflatten function to use the waveform(DBL) type so that it can graph the data. I'm sure I'm missing some steps however.

Would it be easier to use MATLAB for data analysis. Perhaps there is a way to call binary files into Matlab and then displaying that data into a graph? I'll look into that as well.

Thank you

0 Kudos
Message 14 of 17
(621 Views)

Hi Trannh,

 

From my understanding it sounds like you need two distinct functions.  The first one is doing this:

 

  1. Code to acquire the array of waveforms (do you have this already?)
  2. Flatten to String function with the array of waveforms as an input
  3. The resultant string being logged with Write to Binary File

The second function should be able to:

 

  1. Read from Binary File (this will return the string - read the whole file)
  2. Unflatten from string - you will need to wire a waveform array constant to the 'type' input
  3. Then a graph to display

 

The easiest way to create a waveform array constant is to right-click your waveform array wire from the first function and select Create » Constant - you can then cut and paste this across to other function.

 

- Did we discuss the reasoning behind writing the data to a file?

 

It is possible to analyse the data in Matlab, although it does not natively (to my knowledge) support the LabVIEW waveform datatype, so you would need to find a plug-in.  My guess is that it would be more difficult - what analysis do you need to perform?


Regards,

Peter D

Message 15 of 17
(613 Views)

Hello Peter,

I don't have the code to acquire the array of waveforms. I'm not quite sure how to do that. Do you mean converting the waveform data into a 2D array? Is this something I do in my data acquisition program or in a separate program like the latest attachment I showed you? I've attached pictures of both. In the first program, I tried to use the waveform data and the method you suggested, but I'm not getting anything. The program is saving the data into an external binary file. In the second image, I tried to create a program that could open any file and then use the method you suggested to display the data. I think I'm getting closer. Thank you so much for helping me with this.

Download All
0 Kudos
Message 16 of 17
(601 Views)

In the first program I was trying to make the program display all of the data acquired onto the second graph once I hit the stop button to stop recording data.

0 Kudos
Message 17 of 17
(599 Views)