Greetings,
I need to read out 12 bits several times during a run. The read_out versus non read_out periods are controlled by a external signal SHIFT. The READOUT_CLK is externally generated from a function generator (FGEN_CLK) and I expect it to give 12 transitions very time SHIFT goes high.
I'm using PFI0 to trigger the readins.
SHIFT is latched twice by FGEN_CLK to get SHIFT_l
READOUT_CLK = (FGEN_CLK) AND (SHIFT_l) AND (SHIFT)
PFI0 is connected to READOUT_CLK
-------------------------------------------
Basic idea is:1. SHIFT goes high in software.
2. READOUT_CLK starts out
3. Use DAQmxReadDigitalU32 to read in 12 bits. Here I expect the program control to stay in the reading in loop till PFI0 has seen 12 transitions.
4. SHIFT goes low in software.
-------------------------------------------
What I expect is:SHIFT goes high.
SHIFT_l goes high and READOUT_CLK starts.
11 full pulses of the READOUT_CLK.
Positive edge of 12th pulse of READOUT_CLK. This is seen by PFI0 as the last edge (it is configured to read in 12 samples). Program comes out of loop of step 3, SHIFT goes low -> stops READOUT_CLK.
Thus I should be getting 11 full pulses and a very short 12th pulse in the READOUT_CLK. The start of READOUT_CLK should be at least 1 FGEN_CLK pulse after SHIFT going high and simultaneous with SHIFT_l going high. Termination of READOUT_CLK should be simultaneous with SHIFT going low.
However, what I get is a seemingly random number of pulses in READOUT_CLK in the window when SHIFT is high. Sometimes less than 12, sometimes greater than 12.
What am I doing wrong ?
Thanks and regards,
Kartikeya Murari
Johns Hopkins University
-------------------------------------------
Code:#define NUM_SAMP 12
// Configure
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"/Dev1/PFI0",100000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,NUM_SAMP));//SHIFT goes high
DAQmxErrChk (DAQmxReadDigitalU32(taskHandle,NUM_SAMP,200.0,DAQmx_Val_GroupByChannel,data,NUM_SAMP,&sampsRead,NULL));
//SHIFT goes low