Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How created a 5MHz frequency measurement at 1Hz in less 100ms ?

Hello,

I have to measure a 5Mhz frequency in less 100ms at 1Hz near. Thanks to DAQmx, we can characterize a frequency with 1 Hz near in 1s, method high frequency measurement (it's too long for my application.
I thought of another method which will use the two counters 80MHz. One counter will count a finished number of periods of my signal (which I will adapt (signal TTL)) and the second will allow me to measure the time which these X periods lasted. According to my calculations, and if I were not mistaken, 350 000 periods would be enough and thus will permit me to make a measurement in less 0.1s except for 1Hz. However, it would be necessary that the two counters starts and stops simultaneously (+/- one count for the second counter). But according to what I read, it is not possible to make. Could somebody say to me if I read well, if my idea to use 2 counters is viable or not? Or could somebody propose another solution to me in order to measure 5MHz with 1Hz near in less 100ms ?

You will find a file with 2 signals. The signal being used for this measurement is the signal in blue (channel 2): it presents a variation of tension peak at peak of approximately 1,3V for an average tension of 5V.


Thank you by advance.
0 Kudos
Message 1 of 4
(3,277 Views)
I am not certain what you mean when you say, "measure a 5Mhz frequency in less 100ms at 1Hz near". I'm supposing that you can use 100 msec maximum to collect the signal, and that you'd like your frequency measurement to be precise to within +/- 1 Hz.

You are correct that you will need to change your blue signal into TTL before you can measure frequency using the counter(s). That step alone looks like a bit of a challenge to me!

The bigger problem is the 1 Hz precision. You can use 2 counters to count cycles of your ~5 MHz signal for exactly 100 msec. You'll get 500k counts for 5 MHz. However, if you get 500001 counts, you'd have to consider that to measure 5 000 010 Hz, giving you a precision of only 10 Hz.

Does this help? Am I understanding your question? Post back as needed.


-Kevin P
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 2 of 4
(3,254 Views)
Dear Kevin,

I have a theory that (this is an hypothesis) if my first counter count exactly 350,000 periods (not one moreover not one less) I will just have an error of +/-1 count on my second counter and also the calculated frequency would be :


Fcalc = (Count of the first counter)/((1/80.10^6)*(Count of the second counter)))

For example, if I count 350,000 periods with the first count and if my theoric frequency is 5Mhz, my second count would count 5,600,000 counts (or 5,599,999 or 5,600,001) and so the frequency calculated would be :

Fcalc= 5Mhz (5,600,000 counts) or Fcalc=5000000.89Hz (5,599,999 counts) or Fcalc=4999999.11Hz (5,600,001).

The only problem with this method measurement is that the calculated frequency would not be calculated in the same interval of time with a variation of the frequency

Could you tell my if my theory is right and if it is possible to start simultaneous the 2 80MHz-counters on a PCI 6221.

Than you by advance.

Raphael Beck
0 Kudos
Message 3 of 4
(3,251 Views)
Raphael,

Very interesting... Yes, the theory sounds reasonable and it's an approach I hadn't thought of. Thanks for a new idea!

Further, yes, you should be able to set up both counters to start of a single hw trigger signal. At least that's what the help file says. I haven't verified it myself with an M-series board. The only reason I hesitate is that some of the M-series brochures and datasheets also mention a digital input capability (change detection) that isn't yet supported by NI-DAQ.

However, there's still a tricky part. Even if both counters start simultaneously, there are 2 more issues to deal with:

1. Your theory depends on counting cycles of the 80 MHz clock during *exactly* 350000 full cycles of your external signal. That's slightly different than the easier problem of counting during exactly 350000 rising edges. Depending on the phase of your external signal when you start, 350000 rising edges could mean anywhere from 349999.00001 to 350000.99999 full cycles. Combine that with the corresponding +/- 1 count from your other counter and your resolution becomes more like 15 Hz again.
So it would appear that you need to trigger your counters to start off the same edge of your external signal that you will use to count. However, this would create a race condition in the electronic circuitry. I'm not sure whether the edge that activates the trigger would also cause the count value to increment or not. And I'm also not sure if the result of the race would be consistent.

2. You also need both counters to stop at the same time. However, there are no "stop triggers" available. I started thinking of different weird ways to try to handle this, but then I had a better idea (I think)...

I think you can accomplish this with a single counter! Here's an outline:

A. Configure for continuous buffered edge counting. Use your external signal as your sample clock ("Gate") and the 80 MHz timebase clock as your source signal. You will need to make a big buffer because you'll be transferring data into it at 5 MHz. I'd suggest a size of about 1 or 2 million. Don't worry, you won't be processing this buffer.

B. Now every edge of your external signal stores a 80 MHz count value in the buffer. And you can know that values that are 350000 indices apart should have counts that differ by 5,600,000 when your signal is exactly 5 MHz.

C. I'm not 100% certain of the syntax for this part but I'll describe the idea. When you want to measure, query for the index of the "Most Recent Sample" using a DAQmx Read property node. Then use that index to actually read 2 specific values from the buffer. One can be at an offset of 0, the other would be at an offset of -350000. The difference between these values should be close to 5,600,000.

D. Two neat things -- 1. Even when the counter rolls over after ~54 seconds, the subtraction you do should still result in 5,600,000. 2. You can loop on step C as fast as you like. Essentially you'd be getting an average frequency over a sliding window of your signal.

Hope this helps. Post back as needed.

-Kevin P
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
Message 4 of 4
(3,243 Views)