LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab and LabView 6i (High speed data logger)

Hello all!

Labview 6i has an example "High Speed Data Logger" which logs data from a NI
DaqCard 6024E card and writes the data to a binary file. How can I read that
file in Matlab(6.5.0... R13)? Does anyone have a solution for this?

Best regards,
Antti Ryhänen
0 Kudos
Message 1 of 4
(2,950 Views)
The example will save the data as a binary file of I16 numbers.

Try the following in Matlab to read it.

[fname, pname]=uigetfile('c:\*.bin', 'Select file to open');
filename=[pname fname];
fid=fopen(filename,'r','b'); % Open the file for reading 'r' big endian 'b' values
[y,count]=fread(fid,[3,inf],'int16'); % Read the contents of the file, a 3 x n array of 32 bit floats
fclose(fid);

The above reads 3 columns of data. It reads inf number of rows (reads to the end of the file).

Tim
0 Kudos
Message 2 of 4
(2,950 Views)
Hello!

Thanks for advice. I still don't get it though... after running the m-file I
get a matrix y with 3 rows and n columns. How is the data arranged in that
matrix? It can't be channel(n) = row(n+1), because the data makes no sense
that way. I measured voltages around 1 V, and the matrix contains numbers in
the range -3E4...+4E4. How do the matrix elements correspond to the voltage
measured?

Best regards,
Antti Ryhänen

"Shan" wrote in message
news:506500000005000000F8BB0000-1031838699000@exchange.ni.com...
> The example will save the data as a binary file of I16 numbers.
>
> Try the following in Matlab to read it.
>
> [fname, pname]=uigetfile('c:\*.bin', 'Select file to open');
> filename=[pname fname];
> fid=fopen(filename,'r','b');
% Open
> the file for reading 'r' big endian 'b' values
> [y,count]=fread(fid,[3,inf],'int16'); % Read the contents of the
> file, a 3 x n array of 32 bit floats
> fclose(fid);
>
> The above reads 3 columns of data. It reads inf number of rows (reads
> to the end of the file).
>
> Tim
0 Kudos
Message 3 of 4
(2,950 Views)
Post your binary file (or a small version of it) and I'll take a look. I just noticed that a header is written into the binary file. You may have to ignore the header lines or read them differently.

Remember, this vi is built for speed, so you'll be saving raw binary counts at the A/D. The range will be -32768 to 32767. You'll have to scale it to volts yourself. Alternatively, you could configure the AI read to return a scaled array and save it in volts.

Attached is a modification of the Labview example to do just this. It will not be quite as fast, but may work for you.

~Tim
0 Kudos
Message 4 of 4
(2,950 Views)