LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert digital waveform to array

Hello,

 

I posted a problem before Christmas regarding data acquisition and accessing the hardware buffer on a 6562 card. I managed to figure out that problem but now I'm stuck when I try manipulating the data I obtain. (The original problem can be seen here: http://forums.ni.com/ni/board/message?board.id=70&thread.id=7926)

 

Briefly, my application is clocking and synchronising an ADC board and then looking at the raw ADC data that comes back from the board. To provide synchronisation I am sending a sync pattern on one data line and using a second line to send a "start of frame" indicator, a '1' bit when I know that the board is synchronised. This line otherwise only sends ‘0’s. This cable is wired back into the NI card and LabView. All data sent uses the NI-SHDIO Generation Express VI and I'm using the Acquisition Express VI in parallel with the Generation VI to capture the raw ADC data when it comes off the ADC board. Since I am acquiring both the ADC data and the frame indication data (which I am looping by connecting that output DIO to an input DIO), the digital waveform essentially contains 2 arrays and I can view these from a graph indicator within LabView.

 

No problems so far. In order to manipulate the data and look at individual frames I am writing the ADC data to file. To extract the digital data from the digital waveform I am using the following VIs:

 

-Get Waveform Components

-Get Digital Data Components

-Write to Binary File

 

To view and manipulate the data I read it into Matlab and this is where I can tell that something's not right. When I read the file into a variable in Matlab, the variable becomes a 1D double array of 40,008 elements. This seems very odd, considering the Acquisition VI only takes 20,000 samples. When I look at the 1D array more closely it looks like the two arrays have been cross added in some fashion. The 1D array certainly doesn't match either of the two arrays visible in the graph indicator inside LabView. I can understand if the file is reading one array after the other (20,000 + 20,000 almost equals 40,008 after all) but that doesn't appear to be the case.

 

I would greatly appreciate some help on how I can extract the two data lines either using Matlab or LabView. Currently it looks like LabView is making a hash of things whenever I try to manipulate or extract the two arrays from the digital waveform. I have tried a multitude of different VIs and ideas but nothing appears to work.

 

 

The most straight forward way would be using the "Converting Digital Waveform to Binary VI" but it can't handle two arrays within the same waveform. (The result looks like the two arrays exclusively OR’d together). To combat this I tried running two Acquisition Express VIs in parallel (one for ADC data, the other for the frame info) but got an error message referring to invalid handles. I presumed this meant that I can't run two acquisition VIs simultaneously, judging from forum posts of users facing the same error message.

 

 

Sorry for the long post but I feel that I needed to fully explain the problem. I'm attaching my LabView code.

Thank you for reading,

 

Christian

 

 

PS. GenAcq2.vi is my code. Waveform_GenAcq2_Cfg.hws is sent by the first Generation VI; Waveform_GenAcq2_shorter_frame_indicators.hws by the second Generation VI.

 

 

Download All
0 Kudos
Message 1 of 11
(13,696 Views)
I forgot to add that I was able to verify that sending just one array from LabView into Matlab worked fine. Since I know the shape of the data coming off the frame indicator line I used this to verify it. If I change the Acquisition VI to only acquire the frame indicator line, everything's fine.
 
Strangely(?) LabView has no problem extracting one 1D array from a digital waveform and writing it to file. When the waveform contains two 1D arrays, the problems appear.
 
Many thanks,
Christian
0 Kudos
Message 2 of 11
(13,694 Views)
The extra "8" is being caused by the fact that the "Write to Binary File" VI has a "prepend array or string size" input. Its default is true, and in your case you have it unwired, so you get the array size prepended. As for the rest of your issue, what are your Matlab commands to read a file? The following example VI, which generates a digital waveform and saves it to file,



can be correctly read into Matlab using the following commands:
fid = fopen('c:\temp\digData.bin','r');
F=fread(fid, [256,8], 'uchar');


Message Edited by smercurio_fc on 01-18-2008 05:26 PM
0 Kudos
Message 3 of 11
(13,669 Views)
Nix that. I just noticed a problem. Checking...
0 Kudos
Message 4 of 11
(13,666 Views)
OK. The issue was with the Matlab commands, in that fread fills in by columns. The correct Matlab commands are:
fid = fopen('c:\temp\digData.bin','r');
F=fread(fid, [8,256], 'uchar');
A=F';

The array "A" should then look the same as the 2D array in LabVIEW.
Message 5 of 11
(13,664 Views)
Hello,

I managed to solve my problem(s), using your LabView and Matlab help.
Thank you very much!
0 Kudos
Message 6 of 11
(13,586 Views)

Could anyone tell me how to convert 1D array of waveform(DBL) to digital data?

 

0 Kudos
Message 7 of 11
(11,752 Views)
0 Kudos
Message 8 of 11
(11,729 Views)

@raki wrote:

Could anyone tell me how to convert 1D array of waveform(DBL) to digital data?

 



@raki wrote:

Could anyone tell me how to convert 1D array of waveform(DBL) to digital data?

 




0 Kudos
Message 9 of 11
(9,468 Views)

I dont know how to convert "1-D array digital waveform" can some one help?

0 Kudos
Message 10 of 11
(8,772 Views)