Hi,
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];
UpdateData(false);
if(taskHandle != 0) {
// DAQmxBaseStopTask (taskHandle);
DAQmxBaseClearTask (taskHandle);
}
return;
Error:
if( DAQmxFailed(error) )
DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
if( DAQmxFailed(error) )
printf("DAQmxBase Error: %s\n",errBuff);
}