11-09-2006 04:48 PM
Hello
I have E6025 Card. I want to acquire 1000 sample whenever external digital trigger happens. (About 100HZ) unfortunately, I can only get the first 1000 samples. How can I do it continuously?
I am looking for the solution in C.
Here is part of code I am using
Thanks
DAQmxCreateTask("acq",&m_DAQtaskHandle);
DAQmxCreateAIVoltageChan(m_DAQtaskHandle,"Dev1/ai0","",DAQmx_Val_RSE ,-10.0,10.0,DAQmx_Val_Volts,NULL);
DAQmxCfgSampClkTiming(m_DAQtaskHandle,"",200000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps ,1000);
DAQmxCfgDigEdgeStartTrig(m_DAQtaskHandle,"/Dev1/PFI0",DAQmx_Val_Rising);
DAQmxRegisterEveryNSamplesEvent (m_DAQtaskHandle,DAQmx_Val_Acquired_Into_Buffer,m_spectrumSize,0,EveryNCallback,this);
int32 EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData)
{
..............
DAQmxReadAnalogF64(taskHandle,pDAQ->m_spectrumSize,10.0,DAQmx_Val_GroupByScanNumber, data,1000,&read,NULL);
..............
}
11-10-2006 09:50 AM
11-10-2006 12:33 PM
Hi, Garrett
Thanks for the info.
I didn't try DAQmxTaskControl() before and I found that overhead between stop and restart a task is about 30 ms. ( in another word, I can not response to the external trigger with frequency more than 30 HZ.)
I will try this DAQmxTaskControl() to see if there is any difference.
11-10-2006 12:41 PM
11-13-2006 09:52 PM
Hi Garrett,
I tried to use retriggerable counter (ctro)as my AI sample clock. I use another counter (ctr1)and routed to PFI0 to emulate the
external trigger.
but I got error like "DAQmx Error: The specified resource is reserved. The operation could not be completed as specified.
Task Name: couterOutTask "
Look like I can not use two counters at same time ?
here is what I did
// use ctr1 and routed to PFI0 as external trigger
ret = DAQmxCreateTask("trigger",&m_TriggertaskHandle);
ret = DAQmxCreateCOPulseChanFreq(m_TriggertaskHandle,"Dev1/ctr1","",DAQmx_Val_Hz,DAQmx_Val_Low,0.0,10.0,0.5);
ret = DAQmxCfgImplicitTiming(m_TriggertaskHandle,DAQmx_Val_ContSamps,1000);
// configure my ctr0 as sampling clock
char counterSource[50]="/Dev1/Ctr0InternalOutput"; //AI Sample Clock
char counterChannel[50]="/Dev1/ctr0"; //Counter used to Generate Pulses
DAQmxCreateTask ("couterOutTask", &counterTask); /* Create a task for analog input */
// create an counter output channel named coChannel
DAQmxCreateCOPulseChanFreq (counterTask, counterChannel, "", DAQmx_Val_Hz,
DAQmx_Val_Low, 0, 200000.0, // sampleing clock rate
0.5);
// create the clock for my counter output task
DAQmxCfgImplicitTiming (counterTask, DAQmx_Val_FiniteSamps, 1000);
//Configure counter output Trigger
DAQmxCfgDigEdgeStartTrig (counterTask, "/Dev1/PFI0", DAQmx_Val_Rising);
DAQmxSetTrigAttribute (counterTask, DAQmx_StartTrig_Retriggerable, TRUE);
Any ideas ?
Thanks in advamce !
11-14-2006 01:18 PM
I followed the example (http://zone.ni.com/devzone/cda/epd/p/id/2345 )
Instead of busy looping to read the data I tried to use EveryNCallback function to read the data when data is ready. But it seems that call back function only got called for the first time.
Any ideas ?
Thanks
11-15-2006 05:21 PM