Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

slow start stop

I am trying to get a series of samples from an analog input using the following code in Visual C++ 6
 
 
float64     data[50][1280];
uInt64      samplesPerChan = 1280;
float64     sampleRate = 2500.0;
int32       pointsRead;
float64     timeout = 1.030;
 
DAQmxErrChk (DAQmxBaseCreateTask ("", &taskHandle0));
DAQmxErrChk (DAQmxBaseCreateAIVoltageChan (taskHandle0, "Dev1/ai0", NULL, DAQmx_Val_Diff, -1.0, 1.0, DAQmx_Val_Volts, NULL));
 DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle0, source, sampleRate, DAQmx_Val_Falling, DAQmx_Val_FiniteSamps, samplesPerChan));
 
 for (count = 0;count < 50; count++) {
     DAQmxBaseStartTask (taskHandle0);
    DAQmxBaseReadAnalogF64 (taskHandle0,DAQmx_Val_Auto, timeout,DAQmx_Val_GroupByChannel, data[count], 1280, &pointsRead, NULL);
  DAQmxBaseStopTask (taskHandle0);
 }
 
It takes about 20 seconds to scan these 50 times. It looks like the StartTask and StopTask functions take about 250 ms. Is that normal?
 
Thanks
0 Kudos
Message 1 of 2
(2,827 Views)

Those numbers sound correct, but there is a simple solution.  Just loop on the Read.  The Read is a very simple operation compared to the Start and Stop.  This will also maintain the hardware timing instead of stopping the acquisition between reads.  You can also change your timing mode to Continuous instead of Finite.

On another note, I'm curious why you are using NI-DAQmx Base on Windows.  I'm guessing you are using a USB-600x device, which are now supported in NI-DAQmx.  I strongly recommend switching to NI-DAQmx as it is a much more feature rich driver.  The programming will be almost exactly the same (just strip out Base from the function calls).  You'll need NI-DAQmx 8.0

 
0 Kudos
Message 2 of 2
(2,805 Views)