Hi,
I'm seeing a strange "buffering" behavior from a PCI-6132. It is strange since the 6132 is not pipelined.
The scenario is as follows: an TTL signal is used to to trigger an ADC measurement; this signal is used as the sampling clock; the signal is not periodic but random.
The strange behavior is the following: when reading the ADC samples, I only get them in multiples of 8 (0,8,16,24, ...). In comparison, if I use a counter on the TTL signal, I get the correct number of edges and not multiples of 8.
I include two sets of code below: the first is the one using a counter and the second is using the ADC. In both cases, I am also using an internal hardware timer.
Additional info:
I've tried changing the ADC acquisition from continuous to finite but got the same strange behavior. Also, changing the DataXferMech from DMA to interrupt did not make a difference. I also confirmed that the DataXferReqCond is set to transfer whenever there is data on the board.
Code: (Counter)
/* CO: set to use 100kHz clock */
DAQmxErrChk(DAQmxCreateTask("Counter timer", &pciDAQ[CO]));
DAQmxErrChk(DAQmxCreateCOPulseChanTime
(pciDAQ[CO], "/Dev1/ctr1", "ctr1", DAQmx_Val_Seconds, DAQmx_Val_Low,
0.0,
COUNTER1_MIN_PULSE_WIDTH /* pulse OFF duration (s) */,
COUNTER1_MIN_PULSE_WIDTH /* pulse ON duration (s) */));
DAQmxErrChk(DAQmxCfgImplicitTiming(pciDAQ[CO], DAQmx_Val_FiniteSamps, 1));
DAQmxErrChk(DAQmxSetCOCtrTimebaseMasterTimebaseDiv
(pciDAQ[CO], "ctr1", COUNTER1_TIME_BASE_DIV));
/* CI */
DAQmxErrChk(DAQmxCreateTask("Counter input", &pciDAQ[CI]));
DAQmxErrChk(DAQmxCreateCICountEdgesChan
(pciDAQ[CI], "/Dev1/ctr0", "ctr0", DAQmx_Val_Rising, 0,
DAQmx_Val_CountUp));
DAQmxErrChk(DAQmxSetCICountEdgesTerm(pciDAQ[CI], "ctr0", "/Dev1/PFI0"));
DAQmxErrChk(DAQmxSetPauseTrigType(pciDAQ[CI], DAQmx_Val_DigLvl));
DAQmxErrChk(DAQmxSetDigLvlPauseTrigSrc(pciDAQ[CI], "/Dev1/Ctr1InternalOutput"));
DAQmxErrChk(DAQmxSetDigLvlPauseTrigWhen(pciDAQ[CI], DAQmx_Val_Low));
/* set time duration */
DAQmxErrChk(DAQmxSetCOPulseHighTime
(pciDAQ[CO], "ctr1", time /* pulse ON duration (s) */));
DAQmxErrChk(DAQmxStartTask(pciDAQ[CI]));
/* acquire count */
DAQmxErrChk(DAQmxStartTask(pciDAQ[CO]));
DAQmxErrChk(DAQmxWaitUntilTaskDone(pciDAQ[CO], DAQmx_Val_WaitInfinitely));
DAQmxErrChk(DAQmxStopTask(pciDAQ[CO]));
DAQmxErrChk(DAQmxReadCounterScalarU32
(pciDAQ[CI], 1.0 /* timeout (s) */, count, NULL));
DAQmxErrChk(DAQmxStopTask(pciDAQ[CI]));
Code: (ADC)
/* CO: set to use 100kHz clock */
DAQmxErrChk(DAQmxCreateTask("ADC timer", &pciDAQ[CO]));
DAQmxErrChk(DAQmxCreateCOPulseChanTime
(pciDAQ[CO], "/Dev1/ctr1", "ctr1",
DAQmx_Val_Seconds, DAQmx_Val_Low, 0.0,
COUNTER1_MIN_PULSE_WIDTH /* pulse OFF duration (s) */,
COUNTER1_MIN_PULSE_WIDTH /* pulse ON duration (s) */));
DAQmxErrChk(DAQmxCfgImplicitTiming(pciDAQ[CO], DAQmx_Val_FiniteSamps, 1));
DAQmxErrChk(DAQmxSetCOCtrTimebaseMasterTimebaseDiv
(pciDAQ[CO], "ctr1", COUNTER1_TIME_BASE_DIV));
/* ADC (x and y) */
DAQmxErrChk(DAQmxCreateTask("ADC input", &pciDAQ[ADC]));
DAQmxErrChk(DAQmxCreateAIVoltageChan
(pciDAQ[ADC], "/Dev1/ai1", "adc_x",
DAQmx_Val_Cfg_Default,0.0,5.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk(DAQmxCreateAIVoltageChan
(pciDAQ[ADC], "/Dev1/ai2", "adc_y",
DAQmx_Val_Cfg_Default,0.0,5.0,DAQmx_Val_Volts,NULL));
DAQmxErrChk(DAQmxCfgSampClkTiming
(pciDAQ[ADC],"/Dev1/PFI0",500000.0,
DAQmx_Val_Rising,DAQmx_Val_ContSamps,0));
DAQmxErrChk(DAQmxSetPauseTrigType(pciDAQ[ADC], DAQmx_Val_DigLvl));
DAQmxErrChk(DAQmxSetDigLvlPauseTrigSrc(pciDAQ[ADC],
"/Dev1/Ctr1InternalOutput"));
DAQmxErrChk(DAQmxSetDigLvlPauseTrigWhen(pciDAQ[ADC], DAQmx_Val_Low));
/* set time duration */
DAQmxErrChk(DAQmxSetCOPulseHighTime
(pciDAQ[CO], "ctr1", time /* pulse ON duration (s) */));
/* acquire samples */
DAQmxErrChk(DAQmxStartTask(pciDAQ[ADC]));
DAQmxErrChk(DAQmxStartTask(pciDAQ[CO]));
DAQmxErrChk(DAQmxWaitUntilTaskDone(pciDAQ[CO], DAQmx_Val_WaitInfinitely));
DAQmxErrChk(DAQmxStopTask(pciDAQ[CO]));
DAQmxErrChk(DAQmxReadAnalogF64
(pciDAQ[ADC],-1,0,
DAQmx_Val_GroupByScanNumber,
valueBuffer,numValues*2,numReturned,NULL));
DAQmxErrChk(DAQmxStopTask(pciDAQ[ADC]));