01-09-2014 07:42 AM
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?
01-10-2014 08:34 AM
01-10-2014 08:06 PM
NI USB-6251
01-13-2014 08:51 AM
01-13-2014 11:31 PM
Hi, Nathan!
Thank you for answer.
I generate one pulse using ctr0 and another one using ctr1. I have no error if I use countiniouse mode, but if I use finite mode and DAQmxSetStartTrigRetriggerable(pulseTask, 1) I have the error "NI Platform Services: The specified resource is reserved. The operation could not be completed as specified."
I want get only 700 samples of AI1 after PFI0 is Rising.
In countinious mode.
P.S. Sorry for my English. Please ask additional question if my explanation is not enough
01-14-2014 03:06 AM
I added some details to the picture to make task more clear
01-15-2014 09:57 AM
I understand what you are doing now, thank you for those pictures.
Unfortunately, as you've already discovered, the method that you are currently taking needs three counters to function. A way around this limitation would be to configure the task as a continuous input and only read 700 samples. After you've read the needed samples, you'll have to stop and start the task to ensure that the data you read on the next iteration is new data.
See this forum post for more details: http://forums.ni.com/t5/LabWindows-CVI/Flushing-of-all-channel-buffer-in-M-series-DAQ-card/td-p/6512...
01-16-2014 10:14 PM
Hi, Nathan!
Thank you for your help! But I have to solve this problem (stop and start task is not acceptable for me). If I find a solution I will post it.