05-03-2012 04:30 AM
hello everyone,
I'm noby on LabWindows, I'm working on the NI PCIe-6321, pending delivery of NI PCI 6115 for my project (data acquisition pressure sensors)
my question is how can we save the data acquired in a txt file when memory card is full and clear it after, is there a function ?
for the momemt, I work with an example of daqmx LabWindows for a voltage measurement: ContAcq-ExtClk-DigStart
thank you
05-03-2012
05:28 AM
- last edited on
11-13-2024
02:38 PM
by
Content Cleaner
Neither the 6321 nor the 6115 have a great memory on board: acquisition is routed to the PC memory via DMA channel and you must manage acquired measures inside your program.
There are several examples that you can start with: the one you mentioned shows how to configure and run a continuous acquisition but saves no data to disk.
Depending on the amount of data you want to acquire you can leave data in memory until the acquisition is closed and save to disk afterwards, or you may want to save to disk during acquisition. In both cases you can look at file I/O library functions and examples to have some guidance.
In case the acquisition rate is very fast (considering 6115 capabilities) and the volume of data to manage is huge, you may need to speed up the streaming part of the process: I have found some examples here that may give you some ideas. Another possibility is to use the TDM streaming library for which you can find here a good tutorial. Take a look also at the webcast linked at the bottom of this tutorial.
05-03-2012 08:49 AM
ok, thanks a lot
I used ArrayToFile function : ArrayToFile ("f:\\fichier.txt", data, VAL_DOUBLE,data[i], 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, VAL_CONST_WIDTH, 10, VAL_ASCII,
VAL_APPEND);
but I'm not sure about number of elements coz I want to save all the data once the memory is full
PS: now i'm working on Acq-IntClk example.
& here is part of code where i added the line, i dont know :s:s , but in the file i acquire 2000 lines of data
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,sampsPerChan,10.0,DAQmx_Val_GroupByChannel,data,sampsPerChan*numChannels,&numRead,NULL));
if( numRead>0 )
for(i=0;i<numChannels;i++)
PlotY(panel,PANEL_GRAPH,&(data[i*numRead]),numRead,VAL_DOUBLE,VAL_THIN_LINE,VAL_EMPTY_SQUARE,VAL_SOLID,1,plotColors[i%12]);
ArrayToFile ("f:\\fichier.txt", data, VAL_DOUBLE,data[i], 1, VAL_GROUPS_TOGETHER, VAL_GROUPS_AS_COLUMNS, VAL_CONST_WIDTH, 10, VAL_ASCII,
VAL_APPEND);
}
05-03-2012 10:29 AM
ArrayToFile is an easy function to use for storing measures to disk but it is the slowest of all since it opens, writes and closes the file each time it's called. That is: it is usefult to experiment with, but if you are considering a high-volume data handlong you should consider a fastest alternative.
Moreover, you are now saving data numChannels times on each iteration, and each time you save a single channel. That is to say, supposing you are acquiring 500 samples on 4 channels, you have 2000 consecutive lines in the file, no separation between data sets and you have opened/closed the file 4 times.
ArrayToFile permits you to save the whole set of data in a single pass in matrix style, in the above example 500 lines of 4 columns each, one column per channel; you could try putting this function call out of the loop:
ArrayToFile ("file", data, VAL_DOUBLE, numRead, numChannels, VAL_DATA_MULTIPLEXED, VAL_GROUPS_AS_COLUMNS, VAL_CONST_WIDTH, 10, VAL_ASCII, VAL_APPEND);
Depending on how data is organized in your array you may need to switch from "data multiplexed" to "groups together" in Array Data Order parameter.
05-04-2012 02:04 AM
hello,
Thanks for all the explanations, using the function outside the loop, she generates a file of 1000 lines, but by using it in the loop with numchannels =2 (for example) she generates two columns 500 lines, now I see clearly the difference.
for my project data acquisition with pressure sensors in your opinion it is more convenient to use a push button or a timer I opted for the 2 solution and I intend to set the timer to record such data at each interval of time, once I have all the data recorded in my file I'll do my traitememt. if you have other solutions?
thx
05-04-2012 02:14 AM - edited 05-04-2012 02:23 AM
It depends on which type of application you are developing.
If it is intended to run unattended you cannot rely on a push button and the timer approach seems more appropriate.
An alternative is to set up a contonuous acquisition process and install a callback to fire when a certain amount of samples has been acquired: in that callback you can proceed to read measures and save them to disk: see the help for DAQmxRegisterEveryNSamplesEvent () function and ContAcq-IntClk-EveryNSamplesEvent example. There are also a number of forum threads regarding this function that you may want to read.
05-04-2012 02:27 AM
I forgot to say that when using timers you cannot rely on the system being absolutely constant in responding to timer events: windows absolutely isn't a real-time system so you must consider that at some given moment your timer allback could be executed some time after it was intended so you must properly configure your buffer and code to handle irregular time intervals (i.e. irregular amount of data to acquire / handle).
05-04-2012 03:05 AM
Well I'll start by testing with a push button and then I'll switch to the timer, because now I realize just the interface.
my project is that we have bottle of 2L that will fill gas, the pressure can reach up to 300 bar
first , we will use just one sensor and save data then i'll add second one, coz the large number of data , I'll make a enregistrememt at each interval of time until complete filling of the bottle and have the complete data file for processing.
the last stage of the project is try to acquire temperature also.
i hope that now you have clear idea
for the file created , do I have to restart the operation every time because I don't want data to be indexed
05-04-2012 04:35 AM
leader06 ha scritto:
for the file created , do I have to restart the operation every time because I don't want data to be indexed
Is this a question? 'cause I cannot understand what you are asking for. Can you please clarify your doublt?
05-08-2012 01:26 AM
hi, thx a lot roberto
now, i have a another question, if we have a digital input ( push button), i found an example on CVI " Read dig channel" but for me i want to have the state of the line ( state of push button) automatically without button read in the interface
thx