Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to stream data to disk with daqmx?

Hi,
 
I am sampling six AI channels for a long time at a relatively high sampling frequency, so I guess streaming data to disk is the best way to store all the data. I am using DAQmx 8.0 and I can't find any sample program about streaming data to disk, and the posts in the forum about this topic seem all in Labview instead of DAQmx. So would anyone please provide some info how to do it in DAQmx. Some sample code will be greatly appreciated.
 
Thank you very much!
David
0 Kudos
Message 1 of 9
(4,411 Views)
By the way, I am using PCI6251. Is the CallBack functions like DAQmxRegisterEveryNSamplesEvent supported for this card? How about USB6251?
0 Kudos
Message 2 of 9
(4,405 Views)

I am using DAQmx 8.0 and I can't find any sample program about streaming data to disk, and the posts in the forum about this topic seem all in Labview instead of DAQmx.

Kind of confusing statement!

DAQmx is a Device Driver version and LabVIEW is a programming Language/Tool which uses that Device Driver's functions

Do you mean to tell that using a programming language other than LabVIEW?? like CVI/ LabWINDOWS??

Kindly clarify, so that we can suggest better

Regards,

Dev

 

0 Kudos
Message 3 of 9
(4,405 Views)

Hi,

I am using the DAQmx ANSI C, not CVI, not Labview. And the search results of streaming data to disk in the forum are done by Labview. Hopefully I made myself clear this time.

Thank you very much.

David

0 Kudos
Message 4 of 9
(4,402 Views)
Any suggestion?
0 Kudos
Message 5 of 9
(4,373 Views)

David,

The most efficient way to stream data to disk is in raw binary format.  You can then do the conversion from binary into real data during post-processing, when more processor time is available.

I'm assuming that you're somewhat familiar with the DAQ ANSI C API and programming structure of an analog acquisition program.  What you would need to do is Set up your task and task timing the usual way, but instead of reading a double value, you would want to use the DAQmxReadRaw function to read the raw digital data from the card and stream it to disk.

The functions for streaming to disk are going to be specific to your programming environment.  I understand that you are using the DAQmx ANSI C API; what is your programming language and environment?

For more information on the DAQmxReadRaw function and on reading raw data, please refer to the NI-DAQmx C Reference help, which you can find on your start menu under Programs>>National Instruments>>NI-DAQ>>NI-DAQmx C Reference Help.

Let me know if there's anything else I can help you with.

Regards,

Josh W. | National Instruments | Applications Engineer

Josh W.
Certified TestStand Architect
Formerly blue
0 Kudos
Message 6 of 9
(4,360 Views)
Hi, Josh,
 
I am using VC++.NET2003. Normally I would use binary file writing to save binary data. Is it the best way for this data streaming? After I stream the data to a file, I have to read it back for display or calculation. Is there any function that I can easily convert the raw data to proper scaled double format data?
 
Thank you very much!
David
0 Kudos
Message 7 of 9
(4,336 Views)
This sounds like my setup (although I also want to stream the data over a network 🙂
I also want to sample the data as it is written to the HD.

Should I first write the stream to HD and then sample from the HD or directly sample from the stream?
0 Kudos
Message 8 of 9
(4,321 Views)
Hello Everyone,

The NI-DAQmx driver uses a polynomial equation to convert unscaled data acquired directly from the DAQ device to scaled readings in terms of voltage, temperature, strain, etc. (depending on the type of task).  The best way to manually convert the unscaled readings into scaled readings at a later time is to record the coefficients of the polynomial the DAQmx driver uses to scale those readings, and then construct your own scaling equation using those coefficients.  You can retrieve the scaling coefficients by reading the Device Scaling Coefficients property using the DAQmxGetAIDevScalingCoeff function.  This property can be found in the NI-DAQmx C Reference Help under the list of Channel Properties, under Analog Input > General Properties > Advanced > Device Scaling Coefficients.  The following Knowledgebase describes how to use those coefficients to manually scale your measurements, and although the process is described for programming with DAQmx in LabVIEW, the same concepts apply for programming with the DAQmx C API.

KB 3SKGA409: Converting Raw Values of DAQmx Read.vi to Scaled Readings


As far as whether to scale the readings as they are acquired, or after saving them to disk, this really depends on the constraints of your system and acquisition task.  The easiest method from a programming standpoint is to just read scaled data and save that scaled data to disk.  This allows you to both view and save your data at the same time.  If however your saving to disk cannot keep up with your acquisition, you will then need to read unscaled data.  Unscaled data is smaller and can be written to disk faster, but you then need to scale the data at a later time. 

If your streaming to disk still cannot keep up with your acquisition speed, there is an advanced feature of the DAQmx driver that will compact the data in either a lossy or lossless fashion.  For more information about this, take a look at the Data Compaction section in the following tutorial:

Developer Zone: NI-DAQmx Professional Tools

I hope this helps,

Travis G.
Applications Engineering
National Instruments
www.ni.com/support

0 Kudos
Message 9 of 9
(4,301 Views)