LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Possible data loss whlie transfering from Labview 7.0 into Matlab [binary]

Greetings,

 

I am kind of confused on binary data processing from labview to matlab. I tried to follow this thread by C. Minnella:

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=211371&query.id=131675#M211371

 

And it was a great help for me to understand many of my issues. However there is something wrong with data that I am writting and retrieving in Matlab

 

Here is how signal looks in Labview

 

http://img126.imageshack.us/my.php?image=picture1va4.png

 

And its spectrum

 

http://img126.imageshack.us/my.php?image=picture3hn6.png

 

http://img146.imageshack.us/my.php?image=picture4br6.png

 

And this is what I am getting in Matlab:

 

http://img357.imageshack.us/my.php?image=picture7jq7.jpg

 

my vi:

 

http://img146.imageshack.us/my.php?image=picture2wn0.png

 

The only change I did was replacing DAQ task with Global chanel constant, since it has original scaling for the data from Load Cell (Fx Axis in particular), this is the device I am getting data from, it is in rest, sitting on the table.

 

I can't figureout what is happening, looks like it is clipped, besides the amplitude is not correct.

 

Would really appreciate any insights,

 

Oleks 

 

 

 

 

 

0 Kudos
Message 1 of 5
(2,763 Views)

Find one bug,

 

Data type was i32 and should have 4 bytes per sample instead of 2, that I had originally. However frequency differs by factor of 10 and amplitude is still not as one that I see in Labview. I am out of ideas

 

http://img123.imageshack.us/my.php?image=picture72hz6.jpg

0 Kudos
Message 2 of 5
(2,762 Views)

How do you read your data in Matlab?

LabVIEW stores data little endian, and Matlab (on an Intel processor) reads data Big endian.

 

If you do a read in Matlab, you can adjust the endianess with a switche ',b' or ',B' (I'm not sure which).

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
Message 3 of 5
(2,751 Views)

Hello Ton,

 

Thank you for the fast reply, here is a part of the code that reads from Labview data file:

 

%Read header information, return in a structure

[headerInfo,fileMark] = GetHeader(fileName,pathName, dataBytes);

 

%Open binary file Big endian format

fid=fopen([pathName fileName],'rb','ieee-be');

 

%Move file marker to begining of scans

fseek(fid,fileMark+startScan,'bof');

 

%Read number of requested scans

y=fread(fid,headerInfo.NumChannels*scans,dataType);

 

%Reshape data into a matrix [scans x channels]

y=reshape(y,headerInfo.NumChannels,[])';

 

%Close binary file

fclose(fid);

 

 

I basically followed example posted in 2006 on NI forum. I think my major concern is whether data is getting to matlab scaled correctly (it is scaled within global channel to Newtons) and looks like I am not getting the same data type in Matlab.

0 Kudos
Message 4 of 5
(2,736 Views)

TonP wrote:

How do you read your data in Matlab?

LabVIEW stores data little endian, and Matlab (on an Intel processor) reads data Big endian.

 

If you do a read in Matlab, you can adjust the endianess with a switche ',b' or ',B' (I'm not sure which).

 

Ton


 

good catch TonP, never would have thought to look at the endianess
Cory K
0 Kudos
Message 5 of 5
(2,732 Views)