Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxCfgSampClkTiming external clock

Solved!
Go to solution

Hi,

 

I would like to how to use a external clock in the function DAQmxCfgSampClkTiming ?
I have a NI USB-6251.
First, I was using the internal clock with the line

DAQmxCfgSampClkTiming(MyTask, "" , MySampFrequency, DAQmx_Val_Rising, DAQmx_Val_ContSamps, NumberOfSamp);

DAQmxRegisterEveryNSamplesEvent (MyTask, DAQmx_Val_Acquired_Into_Buffer, NumberOfSamp, 0, EveryNSamplesCallback, NULL);

 

With a sampling frequency of MySampFrequency = 160kHz ;

 

Next,  I tried to use  an external clock :

 

DAQmxCfgSampClkTiming(MyTask, "/dev1/PFI0" , MySampFrequency, DAQmx_Val_Rising, DAQmx_Val_ContSamps, NumberOfSamp);

DAQmxRegisterEveryNSamplesEvent (MyTask, DAQmx_Val_Acquired_Into_Buffer, NumberOfSamp, 0, EveryNSamplesCallback, NULL);

 

With a 500kHz clock on PFI0

So just changing from internal clock to external clock. Then I was testing the number of acquired samples to choose if I stop or continue. I was expecting that the needed time to acquire the samples would not change but it was much shorter. So I concluded that my sampling frequency was the parameter I entered in the first case. What should MySampFrequency be to get a sampling frequency of 160 kHz ?

 

Is it possible to use an external clock as a stability reference clock, to fix the drift of the internal clock ?

 

Thank you

 

Regards

0 Kudos
Message 1 of 5
(3,612 Views)
Solution
Accepted by topic author banchilu

Hi,

 

If you use an external source for the Sample Clock, set MySampFrequency to the maximum expected rate of that external clock. So if you use a 500kHz clock on PFI0, set 500kHz to MySampFrequency .

 

I was wondering what do you mean by telling "So I concluded that my sampling frequency was the parameter I entered in the first case" ?

 

The internal clock has a drift but this is enough accurate. However you can still use an external clock with a frequency that is perfeclty known.

 

Regards

0 Kudos
Message 2 of 5
(3,594 Views)

I just mean that when I use a internal clock, the sample rate is the sampling frequency but when I use an external clock, it is not. What happens if I put as sample rate parameter a smaller frequency than my external clock one ?

0 Kudos
Message 3 of 5
(3,587 Views)

Hi banchilu,

 

DAQmx uses the sample rate to determine the default AI convert clock rate and input buffer size. If your program sets the sample clock rate to be smaller than the external clock frequency, you may run into ADC overrun errors or FIFO overflow errors.

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 4 of 5
(3,580 Views)

Ok.Thank you

0 Kudos
Message 5 of 5
(3,578 Views)