Hi,
I am a first time user.
I have an signal on Dev/ai1 1Mhz and I have digital signal on PFI0 about 800Hz (it can change in time from 760-815 HZ)
I have to read 700 samples (in continuous mode) from ai1 when signal on PFI0 is high.
I find one decision - generate pulse and use it like external clock.
Here is my code
/*PULSE*/
errorCheck (DAQmxCreateTask("",&pulseTask));
errorCheck(DAQmxCreateCOPulseChanFreq(pulseTask,"Dev1/ctr0","",DAQmx_Val_Hz,DAQmx_Val_High ,0.0,1000000.0,0.5));
errorCheck (DAQmxCfgDigEdgeStartTrig(pulseTask,"/Dev1/PFI0",DAQmx_Val_Falling));
errorCheck (DAQmxCfgImplicitTiming(pulseTask,DAQmx_Val_FiniteSamps,700));
errorCheck(DAQmxSetStartTrigRetriggerable(pulseTask, 1));
errorCheck(DAQmxStartTask(pulseTask));
/*END PULSE*/
/*READ DATA */
float64 ddd[14000];
int32 cnt;
errorCheck(DAQmxCreateTask("",&aiTask));
errorCheck(DAQmxCreateAIVoltageChan(aiTask,"Dev1/ai1","",DAQmx_Val_Diff,-5.0,5.0,DAQmx_Val_Volts,NULL));
errorCheck(DAQmxCfgSampClkTiming(aiTask,"/Dev1/PFI12",800000,DAQmx_Val_Rising,DAQmx_Val_ContSamps,7000));
errorCheck(DAQmxCfgDigEdgeStartTrig(aiTask,"/Dev1/PFI0",DAQmx_Val_Rising));
errorCheck(DAQmxStartTask(aiTask));
while(1){
errorCheck(DAQmxReadAnalogF64(aiTask,700,-1,DAQmx_Val_GroupByChannel,ddd,700,&cnt,NULL));
//code ...
}
DAQmxStopTask(aiTask);
DAQmxClearTask(aiTask);
This code works well. But my device support only one pulse gen. And I need gen. pulse in another task.
I don't know how to solve this problem. How to synchronize ai reading with pfi signal?