Measuring frequency of a series of pulses from analog input 
Author Message
 Measuring frequency of a series of pulses from analog input

I'm working on a program that uses a DAQ to read in a series of
pulses.  I need to somehow measure the frequency of these pulses
coming in.  I'm not sure if I can use the "Extract Single Tone
Information" vi for pulses, as it describes only being able to read it
in for sine waves.

The frequency of the pulses will range from 0 to about 120 Hz (I
measured this much on an oscillicope).  I have a while loop running
with a 100 millisecond delay in the loop.  I was thinking I could
somehow measure the number of peaks in a certain time period (ie: the
100 ms that the loop is running at).  I'm not sure how to accomplish
this, as I'm relatively new to data aquisition.

If anyone could suggest a good way to measure this frequency (i need
to measure it about every 100 ms) I would appreciate it.  Thanks.



Wed, 21 Jan 2004 03:43:50 GMT  
 Measuring frequency of a series of pulses from analog input
One method would be to run your 100 msecs worth of samples throught
the "Threshold Peak Detector.vi" and use the resulting indices and
count to figure out the frequency.  The count output tells you how
many threshold crossings you had which should equal the number of
pulses.  Then, subtract the first element of the indices array from
the last and multiply by the "delta t" (take the reciprocal of your
sample rate for that channel) to get the time period.  Now you know
how many pulses (count) per time period.  Divide the count minus one
by the calculated time period to get the frequency.  Remember to
subtract one from the count and be careful about choosing your
threshold.

I know you want to do that with AI, but the counter / timers are
really designed for that sort of thing.  If you have any on your DAQ
board, they are itching to take this measurement.

Dan Press
www.primetest.com



Wed, 21 Jan 2004 04:27:11 GMT  
 Measuring frequency of a series of pulses from analog input
You could measure it by counting the number of pulses every 100 msec.
However, you will only have an resolution of 10 Hz that way, which
probably isn't good enough.

You can greatly increase your accuracy by counting the number of
pulses and recording when each one occurs.  Subtract the time of the
first pulse from the last pulse.  Divide the number of pulses minus
one by the time interval, and you have the pulse frequency.

If the frequencies are going to be less than 20 Hz, you will need to
keep track of when the last pulse occurred in the previous block.
Otherwise, it will alternate between 0 and 10 Hz as an output.

You could also use Extract Single Tone like you suggested.  It will
output the primary frequency of a square wave just as well as a sine
wave.  You would want to set your sample rate so that each block of
data you analyze is a power of two.  This only works for frequencies
above 20 Hz, for the same reason - it requires two pulses in one block
to work properly.

Bruce



Wed, 21 Jan 2004 11:29:14 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Measuring frequency from an analog input

2. measure frequency of a digital pulse without a counter

3. Analog voltage input to frequency

4. Using analog output to trigger analog input.

5. measuring duty cycles of 4 square waves at analog input channels of E-series pci daq card

6. pulse signal of variable frequency

7. How to generate a radio-frequency pulse with PCI-MIO-16E

8. pulse train with continously changing frequency

9. Frequency each pulse on sound card

10. looking for VI to measure pulse-width on a waveform

11. Generate a delayed pulse with analog trigger

12. Generate a delayed pulse with analog trigger(2)

 

 
Powered by phpBB® Forum Software