Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx with signal length setting

Hi,

 

I have a question regarding sampling rate. Somehow the DAQmx lags compared to DAQ in my system. The old DAQ runs fine at 50 Hz sweep rate but the coverted system with DAQmx runs at 33 Hz ~ 45 Hz.

How can I reduce lagging problem? I wonder there is a setting for signal length in DAQmx.

 

The code I'm using is like this:

 

//Start this task
				DAQmxErrChk (DAQmxStartTask(taskHandle)); // now taskHandle is no more 0 and assigned to some memory address
		
				if(taskHandle != 0){ //when a task is reserved, its address is no more 0.
					bTarget = FALSE; //these three Boolean values are for control purpose in future
					isDone = FALSE;
					bScanDone = FALSE;

					if(!bContinueAcquisition){
						if(iAvailableSample == 1){// odd buffer is called
							if(ClBufferSize > iTotalSize){ //if somehow buffer size is smaller than maximum channel case, call below
								DAQmxErrChk (DAQmxReadBinaryI16(taskHandle, fdat.trace_size, 1, DAQmx_Val_GroupByScanNumber, OddBank, ClBufferSize, &read, NULL));
							}
							else //or use iTotalSize as a bank size
								DAQmxErrChk (DAQmxReadBinaryI16(taskHandle, fdat.trace_size, 1, DAQmx_Val_GroupByScanNumber, OddBank, iTotalSize, &read, NULL));
						}
						else if(iAvailableSample == 2){// even buffer is called
							if(ClBufferSize > iTotalSize){ //if somehow buffer size is smaller than maximum channel case, call below
								DAQmxErrChk (DAQmxReadBinaryI16(taskHandle, fdat.trace_size, 1, DAQmx_Val_GroupByScanNumber, EvenBank, ClBufferSize, &read, NULL));
							}
							else //or use iTotalSize as a bank size
								DAQmxErrChk (DAQmxReadBinaryI16(taskHandle, fdat.trace_size, 1, DAQmx_Val_GroupByScanNumber, EvenBank, iTotalSize, &read, NULL));
						}
					}
					else{//ThreadAcquire mode is on
						
						if(iAvailableSample == 1){
							DAQmxErrChk (DAQmxReadBinaryI16(taskHandle, fdat.trace_size, 1, DAQmx_Val_GroupByScanNumber, OddBank, SingleSize, &read, NULL));
						}
						else if(iAvailableSample == 2)
							DAQmxErrChk (DAQmxReadBinaryI16(taskHandle, fdat.trace_size, 1, DAQmx_Val_GroupByScanNumber, EvenBank, SingleSize, &read, NULL));
					}
				}//this block is called only when task handler is reserved by DAQmxStartTask()

 

How can I speed up the scanning or acquring data?

Thanks,

0 Kudos
Message 1 of 2
(2,782 Views)

OK, I have found the solution:

 

DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"OnboardClock",fdat.trace_size/2,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,fdat.trace_size/4)); 	
//DAQmx_Val_FiniteSamps or DAQmx_Val_ContSamps //DAQmx_Val_FiniteSamps with fdat.trace_size makes 33~44 Hz sampling rate //DAQmx_Val_ContSamps with fdat.trace_size makes 25 Hz sampling rate

Buffer size is the one causing lags. And DAQmx_Val_ContSamps with a bigger buffer size will definately cause a huge lag around 50% drop.

I reduced the buffer size but wonder this buffer must be a half of double buffer in double buffer mode.

 

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