Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Measuring frequency with NI-6221

Solved!
Go to solution

Hi

 

I would like to use the NI-6221 to measure frequencies in the range of 200Hz to 12.5Mhz. 

Is it possible? 

Can you guide me were to start?

Are there any application notes with examples?

The accuracy required is not so high  0.5% more or less...

 

Thanks

Rafi

0 Kudos
Message 1 of 20
(5,789 Views)

Hi Rafi,

 

It's possible.  You should be aware that there are tradeoffs to the various counter frequency measurement methods (accuracy vs. measurement time).  The X Series User Manual includes a chart that shows the accuracy and measurement time of these methods. 

        original.png

 

This doesn't include the accuracy of the timebase, which is 50 ppm (.005%) on the 6221 according to the specifications. The Sample Clocked method is not available on the 6221 (only the X Series and non-9172 cDAQ support this), which is a shame since this method would be my recommendation if you had that option.  Since this method is not available, you could use the Large Range or the High Frequency method.

 

 

    1 Counter: 18.51% accuracy @ 12.5 Mhz, so this is out of the question.

 

    2 Counter Large Range: N (the divisor) would have to be 32 @ 12.5 MHz to give a measurement error of .49%.  N=32 would require 160 ms to complete a sample @ 200 Hz (not bad).  Higher values of N will give better accuracy but take longer.

 

    2 Counter High Frequency:  Would take an entire second to achieve .5% accuracy @ 200 Hz, but this 1 second gating period would give a resolution of 8 ppm accuracy when measuring 12.5 MHz (remember though, the timebase is 50 ppm).

 

So, the Large Range method will give the most accuracy at 200 Hz.  The High Frequency method will give the most accuracy at 12.5 MHz.  Either could be used to achieve the .5% accuracy requirement that you have in a reasonable amount of time across the range of your input.

 

If you are interested in measuring the entire range of your signal with better accuracy, I'd suggest looking into an X Series (e.g. 6320) for the Sample Clocked method.  If .5% is sufficient then you'll probably be OK with what you have currently although either of these methods require the use of both counters.  Here is a link showing how to program a continuous counter acquisition using the High Frequency method.

 

Best Regards,

John Passiak
Message 2 of 20
(5,780 Views)

Hello John

 

Thank you so much for this excellent answer.

 

I'm looking into the possibility to use the X series 6320 as you recommended and to use the Sample Clocked method.

 

Few Questions:

1. In this fx = the measured freq. (e.g.. 12.5MHz), fs = 100Mhz, fk=100Mhz.  Is this correct?

2. Can I also use the 20Mhz time base instead of the 100MHz?   

3. Is there any other internal time base?

4. if I put the data into the equation for Max err %  ( fx=12.5, fk=100, fs=100  all in MHz)  I get  -1.78%.  IS THIS CORRECT?

5. I have 12 input lines with different frequencies.  Which of the 6320 inputs lines can be connected directly?  (the more I can connect directly, the less multiplexing I'll have to do)

 

Thank

Rafi

0 Kudos
Message 3 of 20
(5,748 Views)

Hi Rafi,

 

fx is indeed the measured frequency (for you, 200Hz to 12.5 MHz)

 

fk is the internal timebase (the best choice is 100 MHz, which the driver should default to.  Other options are 20 MHz or 100 kHz)

 

fs is the sample clock rate.  The board will take a sample of the count register on every tick of this clock.  The clock can be what you want, but should be slow enough to guarantee a complete period of your input signal during each period of the sample clock.  The slower the sample clock, the less measurement error is introduced.  Let's say you use one of the other counters to generate a 10 Hz sample clock signal.

 

 

Plugging in the numbers I get:

 

    0.105 ppm for fx=200 Hz

    0.100 ppm for fx=12.5 MHz

 

In short, the 50 ppm (.005%) accuracy of the counter timebase would essentially represent the entire source of error using the above parameters.

 

 

When fs is greater than fx, the measurement is actually undefined (the driver should return an error if two sample clock edges occur without any edge of your signal to be measured).  The formula will result in negative numbers in this case, like the result you obtained.

 

 

Best Regards,

John Passiak
0 Kudos
Message 4 of 20
(5,737 Views)

I just noticed that you had a few direct questions.  I think 1-4 were answered by my above post.  For question 5:

 

There are 16 PFI lines that can be routed to the 4 counters on the 6320.  You will need to restart the task to change the input lines, but no external multiplexer should be necessary.  The sample clock and timebase signals would be routed internally.

 

If you want to use all 4 counters at the same time for measuring frequency, you could generate the sample clock from something other than one of the counters (e.g. configure a dummy AI/AO/DI/DO task, or use the Frequency Generator).  

 

 

Edit:  the 6320 doesn't have AO

 

 

Best Regards,

John Passiak
0 Kudos
Message 5 of 20
(5,734 Views)

Hello Johm,

 

Thank you very much. You've been very helpful.

As a matter of fact I need both AI and Ao and also frequency out signals.  Therefore, I am looking now at the 6321 which has 2 AO signals.

 

My application includes the following:

measuring freq. 200hz-12.5mhz - 10 lines

Analog input - 4 (I may use an existing DMM for them)

Analog output - 4 (I will use a switching card to mux the 2 AO)

Freq out - 3 lines SIMULTANEOUSLY (in order to simulate a decoder)

digital I/o - many (I will use an additional card)

 

In summary, all signals, but the 3 freq out, are one at a time.

 

Questions:

1.  Do you think the 6321 is the right choice?

2.  I guess I can use the 3 counters to produce the 3 simultaneous freq. out signals in 3 PFI lines. Correct?

3.  I will use 10 freq input lines in additional 10 PFI lines, leaving 3 spares.

4. If I do want to measure AI signal (power supply voltage).  What accuracy can be achieved?  Does it require a PFI line?

 

Please advice

 

Thanks

Rafi

 

 

0 Kudos
Message 6 of 20
(5,718 Views)

Hi Rafi,

 

1.  If you need 4 AO channels you might also consider the 6323.  I mentioned the 632x boards since they are the lowest cost X Series.  If you have other Analog requirements, you could look into any of the 63xx boards which have the same counters.  Depending on your form-factor of choice, you might also consider the USB-6343.  The PCIe 63x3 boards would require 2 cables (and probably 2 terminal blocks unless you plan on making a custom PCB to cable directly to) whereas the USB variant has screw terminal connections built-in for all lines.  The latency of USB is a bit higher than PCIe.

 

2.  You could use the counters to output 3 simultaneous freq out signals.  You could also use the DO lines, but the resolution of what frequencies you could hit would be much lower.  For example, you could update the DO at 1 MHz and output [1, 0, 1, 0 ... ] to obtain 500 kHz, or [1, 0, 0, 1, 0, 0 ...] to obtain ~333.33 kHz.  The counters use a 100 MHz timebase and thus can achieve many more frequencies in between.  At low frequencies either option would probably be suitable.

 

3.  Any of the PFI lines can be routed to the counter intputs or outputs, so if you do use 3 counters to generate frequencies you would still be able to connect all 10 of your frequency signals at the same time (although you could only measure one at a time per available counter).

 

4.  Accuracy specs can be found in the specifications page for whatever hardware you are intersted in. 

 

 

Best Regards,

John Passiak
0 Kudos
Message 7 of 20
(5,699 Views)

Hi John

 

Thanks again for your helpful answers.

 

1.  I'd like to elaborate more on the DO freq. out.  What exactly does it mean to 'update the DO at 1 MHz and output [1, 0, 1, 0 ... ]....' ?  Is it a setup I do with the card driver?  Can I just specify the output pattern  and thus, achieving different frequencies  ?  Can I use other base frequecncies (1MHz in your example), or only the 1mhz?

 

2.  I'm interested to use the DO output for freq output in order to perform a Tester self test where the Do will generate the 10 freq out signals which will be tested by the 10 PFI lines which will be dedicated to measure 10 freq input signals from the UUT.   Do you see anything wrong with it?

 

Thank you and best regards

Rafi

0 Kudos
Message 8 of 20
(5,662 Views)

Hi Rafi,

 

1.  The DO lines can output any arbitrary digital waveform, so you can use this to achieve a number of frequencies by defining the appropriate signal to divide down your sample clock.  The 632x and the 634x support rates of up to 1 MHz using the internal sample clock.  The 635x and 636x support rates of up to 10 MHz.  The sample clock is a divide-down of one of the internal timebases (usually 100 MHz unless your rate is very slow).  Alternatively you could use an external sample clock.

 

The M Series boards (622x, 625x, 628x) also support clocked DO, but the clock must come from an external source (i.e. you cannot divide-down the internal timebase directly through the DO task).  You could however use a counter or the Frequency Generator to create this "external" clock source.

 

 

2.  You'll have to manually route the DO signals into the PFI lines externally since the clocked DO lines on port 0 cannot be routed to PFI internally.  Also, keep in mind that if both subsystems are using the internal timebases, you would be essentially testing the board against itself.  If you're just testing the functionality of your code (rather than the accuracy of the frequency measurement) then this would be valid setup.  If you're testing accuracy you'll want to use a clock source that is at least an order of magnitude better than the 50 ppm accuracy of the internal timebase.

 

 

Best Regards,

John Passiak
0 Kudos
Message 9 of 20
(5,637 Views)

Hi John and thanks again..

 

I did not explained myself clearly regarding the self test.  Obviously I need to route the DO to FPI externally.....this is the purpose 

 

The self test is for my Tester.  The idea is to to disconnect the UUT and instead, do some sort of loopbacks and thus, to test the Tester.

For that purpose I intend to set the DO as a clocked signal, and use the PFI to measure it...thus, testing the hardware and the software as well.

 

How bad is the inaccuracy for that purpose?  I can use and frequency I want...what do you suggest?

 

Please advice

 

Thanks

Rafi

0 Kudos
Message 10 of 20
(5,626 Views)