LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Some binary data recoreded by labview cannot open by other program

I have got some binary data which is recorded by a labview program. When I use some other program to open it (e.g. matlab, notepad, MS excel), it become some strange character, but when I use another labview retrieval program to open it, there is no problem. What happen?

The original data is 32 bit data sets which are separated by a <CRLF>.

The recording program (HS-Acquis.llb), the retrieval program (Advanced Viewer.llb), original data file (C1010710.480245) and the data file after retrieval (C1010710.480245.txt) was attached

phy_mechanic
0 Kudos
Message 1 of 4
(3,722 Views)

Well, binary is not at all the same as plain text so notepad and Excel would not be able to interpret the contents correctly. In addition, the default binary storage in LabVIEW is big endian.

 

Since the reader program is evidently able to export the data as ASCII text, what is the problem? Are you wondering how to modify the main program to save as text? You did not include any of the file save/file read functions so I'm not sure what would be required. There might be other major changes required. Binary storage is often used when high speeds are required.

0 Kudos
Message 2 of 4
(3,712 Views)
Because I don’t want to export the data as ASCII text every time, I want to analysis the data directly by other program. I am wondering that why those data can only read by a labview program.

Other than that, what can I do to the program (HS-Acquis.llb), so that it can produce a readable data file (no matter binary or ascii) for matlab?

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

The data seems like it can only be read by LabVIEW because LabVIEW is set up to properly read the binary data and it is simple for a user to do.

 

For matlab to read the data, it will have to be properly configured.

FOPEN     -     Open a file
FREAD     -     Binary file read
FWRITE   -     Binary file write
FTELL      -     Return the current file position
FSEEK     -     Set file position indicator
FCLOSE   -     Close a file

 

An example is given from http://www.mathworks.com/support/tech-notes/1400/1403.htm:

%This m-file is a short example of how to read and write a binary file 
%in MATLAB using low level routines

%write file
fid = fopen('square_mat.bin','wb') %open file in binary write mode
fwrite(fid, 'This is a square matrix', 'char'); %insert a header
fwrite(fid, [1 2 3; 4 5 6; 7 8 9]', 'int32'); %write data to file
fclose(fid); %close file


%read in the same file
fid = fopen('square_mat.bin','rb') %open file
bintitle = fread(fid, 23, 'char'); %read in the header
title = char(bintitle')
data = fread(fid, [3 inf], 'int32') %read in the data
data_tranpose = data' %must transpose data after reading in
fclose(fid) %close file

 As you can see, the data type, size, array size, etc. has to be explicitly defined. In addition, as Dennis alluded to, LabVIEW stores binary data in Big-Endian format, wheras most windows applications use little endian. I assume matlab is one of those applications...but I am not a huge matlab developer. Google may have more information on that. You can use a typecast in matlab to convert big to little and little to big, however, so that may be a great place to start. Please see http://www.mathworks.com/access/helpdesk/help/techdoc/ref/typecast.html

 

Of course, our wonderful applications engineers at National Instruments have already done the above work for you and developed Knowledgebase 11SF83W0: How do I Transfer Data Between The MathWorks, Inc. MATLAB® Software Developm...which is easily searchable from ni.com knowledgebase category using 'matlab binary'

Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 4 of 4
(3,668 Views)