Greetings,
Thank you for your suggestions and sorry about my delay in replying, unfortunately neither suggestion solved the problem. Adding the reset of the device resulted in no change. Callbacks are not very well suited for my program since it reads only the most recent sample out of the buffer whenever the rest of the program is in position (asyncronous) and ignors all other data collected. I did modify an example code using callbacks (included below) and experienced the same issue with slower speeds unless the device test panel is opened first.
Further tests have shown that the slowdown only manifests when the ReadRelativeTo property is set to DAQmx_Val_MostRecentSamp, and also that opening any NI program that communicates to the DAQ device solves the issue.The problem has also gone away, in a few cases, after the computer has simply been in use for several hours. A possible cause may be the computer allocation of USB resources. I am using DAQmx 8.5 and am running two DAQ devices (USB-6210 and USB-6501) through a USB hub, though only the USB-6210 is operated at high speeds.
Do you have any further suggestions or are you aware of any issues with allocating computer USB resources, particularly any addressed in official NI software? The modified example code is below.
Thanks, Andrew
A modified version of ANSI C Example program: ContAcq-IntClk.c
#include <stdio.h>
#include <NIDAQmx.h>
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData);
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
int main(void)
{
int32 error=0;
TaskHandle taskHandle=0;
char errBuff[2048]={'\0'};
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"PMDet/ai0:7","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",31250.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,10));
DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,10,0,EveryNCallback,NULL));
DAQmxErrChk (DAQmxRegisterDoneEvent(taskHandle,0,DoneCallback,NULL));
DAQmxErrChk (DAQmxSetReadOverWrite(taskHandle, DAQmx_Val_OverwriteUnreadSamps));
DAQmxErrChk (DAQmxSetReadRelativeTo(taskHandle, DAQmx_Val_MostRecentSamp));
DAQmxErrChk (DAQmxSetReadOffset(taskHandle, -1));
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
printf("Acquiring samples continuously. Press Enter to interrupt\n");
getchar();
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}
int32 CVICALLBACK EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
{
int32 error=0;
char errBuff[2048]={'\0'};
static int totalRead=0;
int32 read=0;
float64 data[1000];
/*********************************************/
// DAQmx Read Code
/*********************************************/
DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,10,10.0,DAQmx_Val_GroupByScanNumber,data,80,&read,NULL));
if( read>0 ) {
printf("Acquired %d samples. Total %d\r",read,totalRead+=read);
fflush(stdout);
}
Error:
if( DAQmxFailed(error) ) {
DAQmxGetExtendedErrorInfo(errBuff,2048);
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
printf("DAQmx Error: %s\n",errBuff);
}
return 0;
}
int32 CVICALLBACK DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData)
{
int32 error=0;
char errBuff[2048]={'\0'};
// Check to see if an error stopped the task.
DAQmxErrChk (status);
Error:
if( DAQmxFailed(error) ) {
DAQmxGetExtendedErrorInfo(errBuff,2048);
DAQmxClearTask(taskHandle);
printf("DAQmx Error: %s\n",errBuff);
}
return 0;
}
Message Edited by Andrew Mac on
07-07-2008 03:10 PM