Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter timebase vs accuracy

Hi,
 
I am trying a simple frequency measurement based on the Dig Freq-Low Freq 1 Ctr sample program. I use PCI6251 ctr0 and DAQmx 8.1 ANSI C. Here is my code.
 
 DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
 DAQmxErrChk (DAQmxCreateCIFreqChan(taskHandle,"Dev2/ctr0","",6,10000.0,DAQmx_Val_Hz,DAQmx_Val_Rising,DAQmx_Val_LowFreq1Ctr,1,4,""));
 DAQmxErrChk (DAQmxSetCICtrTimebaseSrc(taskHandle,"Dev2/ctr0","/Dev2/20MHzTimebase"));
 DAQmxErrChk (DAQmxGetCICtrTimebaseSrc(taskHandle,"Dev2/ctr0",buff,100));
 DAQmxErrChk (DAQmxStartTask(taskHandle));

 while(!kbhit())
 {
  DAQmxErrChk (DAQmxReadCounterF64(taskHandle,nSampNum,10.0,data,nSampNum,&read,0));
  printf("Frequency: %.9f Hz\n",data[0]);
 }

  DAQmxStopTask(taskHandle);
  DAQmxClearTask(taskHandle);
I tried several different timebase, the 80M, 20M and 100K to measure a 2KHz signal. I supposed the higher frequency the timebase, the more accurate the measured freq. But in fact, when using 100K, the display is exactly 2000.000000000; when using 20M, there were a few 20000.20002000, and when using 80M, there are much more results different from 2000.00000. Would anyone explain why this could happen?
Thanks a lot.
David
0 Kudos
Message 1 of 10
(8,365 Views)
Hello David,

From the numbers you have given it looks like you are getting exactly 1 extra pulse on the higher frequency.  This would seem to indicate that the frequency you are generating is not exactly 2KHz.  When operating at a lower frequency your source terminal pulses are too large to fit in any extra pulses, however the faster source clocks (20MHz and 80MHz) are fast enough to fit in extra pulses.

This might be accounted for by the accuracy of the clocks on the used to generate the 2KHz signal and the clock accuracy of the source terminal clock (20MHz or 80MHz).  For the counter system on your 6251 the clock accuracy is 50 ppm.

I hope this clarifies things,

Jesse O.
Applications Engineering
National Instruments
Jesse O. | National Instruments R&D
0 Kudos
Message 2 of 10
(8,347 Views)

Hi Jess, we are using the 6251 for sampling some analog signals. We would like to time stamp the samples with an accuracy of 10 ppm. From your post it seems like 6251 clok is 50 ppm. If we were to use an external clock of 10 ppm would it be possible to run the counter using the external clock. Could you give an example code.

 

Thanks

 

-Charles

0 Kudos
Message 3 of 10
(8,136 Views)
 Hi Charles,

 The accuracy gain in your timestamp would come from the fact that the sample clock itself would be more accurate. The sample clock in the 6251, for example, is 50ppm. If you could provide a sample clock that was more stable, then the time between samples would be more stable.

The PXI-6608 counter board has a 75ppb (parts per billion)  timebase stability compared to the 50ppm (parts per million) timebase on the PCI-6251.

The waveform data type has three elements:
  t0  - timestamp from Windows when the acquisition started
  dt  - time between samples, calculated as the reciprocal of the sampling rate
  Y - amplitude of the sampled signal

If you are using a PXI chassis then by placing a precision time source like the 6608 in Slot 2 you can override the 10Mhz PXI backplane clock. The M series (6251) can PLL it's 80Mhz timebase to the PXI backplane clock, inheriting it's stability.

I hope this helps!

Have a great afternoon.

Best regards,

MatthewW
Applications Engineer
National Instruments
0 Kudos
Message 4 of 10
(8,115 Views)

We are planning on using an external clock derived from a GPS source. We are planning on using a 10Mhz clock to run the 32 bit counter and read the counter value after sampling. Reading the documentation I see that the counter has a source as well as data. If we do not provide a data would the counter keep incrementing. Is there a good example in Labwindows for a counter using an external clock and not using the data input.

 

Thanks

 

-Charles

0 Kudos
Message 5 of 10
(8,112 Views)
 
 Hi Charles,

 Here is what I understand your application to be:
    1. Provide a external clock to Source.
    2. On active edge of Data to the Gate then Count will be latched into PC memory
 
This is called Event Counting Buffered, used when you want to measure elapsed time between sequential events occuring on the gate. The difference between this and
a non buffered event count is that the count is stored on the counter card at a hardware timed instant, as opposed to the computer sending a request to the counter card to
take a count reading. With a known Source clock frequency we can then calculate the time between each gate edge.

A example showing a buffered event count in LabWindows can be found here:
  C:\Program Files\National Instruments\CVI81\samples\DAQmx\Counter\Count Digital Events\Cnt-Buf-Cont-ExtClk

Incidentally, the PXI-6608 can synchronize to a GPS IRIG-B or PPS signal. Here's a KB that talks about this.

I hope this helps!

Have a great afternoon,

Best regards,

MatthewW
Applications Engineer
National Instruments

0 Kudos
Message 6 of 10
(8,093 Views)

Hi Jesse,

 

When you mean 50ppm of stability I am not sure on what clock this proportion shuld be applied:

 

a- on the fastest clock of the 6251, i.e. 80Mhz

b- on the time base that you use in your application i.e. either 0.1Mhz, 80 MHz or 20 MHz.

 

I do not see this clear in the 6251 manuals, it says:

 

Base clock accuracy: 50 ppm
Internal base clocks: 80 MHz, 20 MHz, 0.1 MHz

 

I am also doing a timing application!

 

0 Kudos
Message 7 of 10
(7,096 Views)
Since all the three base clocks (80MHz, 20MHz and 0.1MHz) are derived from an 80MHz Oscillator, I would assume that the 50ppm value applies to all the three clocks and not just the 80MHz one.
------

"A VI inside a Class is worth hundreds in the bush"
യവന്‍ പുലിയാണു കേട്ടാ!!!
0 Kudos
Message 8 of 10
(7,070 Views)

Yes I think you are right

 

I made some calculations (you can see them here http://forums.ni.com/ni/board/message?board.id=40&message.id=7560#M7560)

 

So all in all derived clocks inherit the stability of the main oscillator

 

I am not sure yet how these errors propagate when I do a frequency estimation. Anyway that is a little bit off topic in this thread (however, any idea, you can post it here http://forums.ni.com/ni/board/message?board.id=40&message.id=7560#M7560 )

Cheers
0 Kudos
Message 9 of 10
(7,064 Views)

Hello again ....

 

I just noticed that it is not clear in the specifications (of 6602, for instance) if the clock accuracy includes:

 

- Temperature drift

- Power supply drift

 

I think this must be clarified in the manuals

0 Kudos
Message 10 of 10
(6,944 Views)