Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

continuous analog data acquisition while using matlab script

Hi Everyone,
 
I'm trying to acquire data from a boost converter output by using NI USB-6259 Multifunction DAQ and LabView 8.2.  What I need to do is acquire analog voltage continuously and save it in a form that I can process later with MATLAB.  First I've been trying to use DAQ Assistant but I wasn't able to accomplish collecting data continuously.  I've looked at the examples and found out that Cont Acq&Graph Voltage-Int Clk.vi works the way I need. 
 
But as I said, I need the data collected to be available for MATLAB.  So, I basically added a Matlab script into the example.  This is when I start to encounter some problems.  The biggest problem I face is when I add the matlab script into the while loop, the program stops working and gives Error-200279 occured at DAQmx Read (Analog Wfm 1Chan NSamp).vi:1.
 
My matlab script is simple and it's as follows:
   if(k==0)
   Y=[];
   end            %this if case runs only for once at the beginning while i of the while loop equals to 0 and opens up a matrix.
   Y=[Y y];     %this line just records the data in Y matrix.
 
k is an input of the script which is directly connected to loop iteration value (i) of the while loop.  y is also an input connected to output of DAQmx.
 
At this point I have the following questions:
1) Is it possible to continuously acquire analog data while using a matlab script?  If so, how can I do that?  Will that also be able to work with DAQ Assistant?
2) If it's not possible to use matlab script while acquiring continuous data, is there any alternative so I can record the data which can be availabe to be processed later with MATLAB?
 
Thank you for your time.
 
Best regards.
0 Kudos
Message 1 of 2
(4,805 Views)

Hi eemekdas,

Welcome to the forums! As I understand it, you are trying to acquire a voltage and are using the NI Example Cont Acq&Graph Votlage-Int Clk.vi to do so. In the while loop, you have added a MathScript node that has two inputs, k from the iteration counter and y which is connected to the output of the DAQmx read. You want to have the data written to a file that will let you process the data at a later time. However, you are receiving “Error -200279 occurred at DAQmx Read (Analog 1D Wfm NChan NSamp).vi:1.”  Is my understanding correct?

From your description of the problem I have created the attached code which works on my computer for at least a couple of minutes without the error you were seeing. I made the assumption that you meant Y=[k y] to create the array.

The error that you are receiving is a buffer overwrite error. Here is a link with a good explanation of what is causing this and some troubleshooting steps to try.

Something to make note of is that creating an array in LabVIEW does not store the data to a file. Therefore, after the program is run, you will not be able to export and process the data later. I would suggest using File I/O to store the data, as can be seen in the Cont Acq&Graph Voltage- Write Data to file (TDMS).vi example. You can visit this site for one example of File I/O with express VIs and search the page for other good examples. However, you will need to ensure that the format you save the data in can later be opened in the environment you choose to use for processing.

Please post back if this code gives you the same error or if you have further difficulties. Good Luck.

Mallori M.



Message Edited by mallorim on 12-04-2007 08:45 AM
Mallori M
National Instruments
Sr Group Manager, Education Services

ni.com/training
Download All
0 Kudos
Message 2 of 2
(4,780 Views)