Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

USB6008, Why my program return error when I acquire for the sixth time?

I am using Usb6008 to acquire some analog signals. The code in my program is similar to acquireNScans.c
This program is just for test.I  use a start button to start one acquisition. The  problem is that when I click the start button for the sixth time, there will be a error. The code is followed.  Please help me. I am new in Visual C++.
error -200284
"Some or all of the samples requested have not yet been acquired.
To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate."

void CBTTest001Dlg::OnStart()
   // Task parameters
    int32       error = 0;
    TaskHandle  taskHandle = 0;
    char        errBuff[2048]={'\0'};
    time_t      startTime;
    bool32      done=0;
    // Channel parameters
    char        chan[] = "Dev1/ai0";
    float64     min = -10.0;
    float64     max = 10.0;
    // Timing parameters
    char        clockSource[] = "OnboardClock";
    uInt64      samplesPerChan = 2;
    float64     sampleRate = 2000.0;
    // Data read parameters
    #define     bufferSize (uInt32)1000
    float64     data[bufferSize * 5];
    int32       pointsToRead = bufferSize;
    int32       pointsRead;
    float64     timeout = 10.0;
    int32       totalRead = 0;
 m_bWorkFlag = true; 
  double a1= data[0];
  double a2= data[1];
  double a3= data[2];
  double a4= data[3];
  DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
  DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_RSE,min,max,DAQmx_Val_Volts,NULL));
  DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,samplesPerChan));
 // DAQmxErrChk (DAQmxBaseCfgInputBuffer(taskHandle,20000)); //use a 100,000 sample DMA buffer
  DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
  DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByScanNumber,data,10/*bufferSize*2*/,&pointsRead,NULL));
 //    printf("\nAcquired %d total samples.\n",totalRead);
  m_fAnalog1 = data[0];
  m_fAnalog2 = data[1];
  m_fAnalog3 = data[2];
  m_fAnalog4 = data[3];
  m_fAnalog5 = data[4];
  if(taskHandle != 0) {
//   DAQmxBaseStopTask (taskHandle);
   DAQmxBaseClearTask (taskHandle);
    if( DAQmxFailed(error) )
    if( DAQmxFailed(error) )
        printf("DAQmxBase Error: %s\n",errBuff);
0 Kudos
Message 1 of 3
By the way, the error accur when the function:
DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByScanNumber,data,10/*bufferSize*2*/,&pointsRead,NULL));
is called.
0 Kudos
Message 2 of 3


The error -200284 usually occurs when the timing parameters are not set correctly. This is thoroughly explained in the KnowledgeBase Article: Why Do I Get Error -200284 When I Set a Small Sampling Rate in DAQmx? However, when I set up and run a modified version of the acquireNScans.c example to match you parameters on a USB-6009, I do not receive any errors. Try running the attached file to see if you get the same error.

You mention that you use a button to start the acquisition. How are you handling a button press event? If the problem persists, please post a larger picture of your application to better show possible causes.

Ryan D.
District Sales Manager for Boston & Northern New England
National Instruments
0 Kudos
Message 3 of 3