LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency Measurement Algorithm

I'm writing a VI where I need to measure the frequency of a pulse. This frequency is proportional to a physical measurement, in this case flow rate. I know how to get the frequency measurement into my VI, and all is well as long as the frequency is higher than my VI update rate. But things become more complicated and non-trivial when the frequency drops below the VI update rate, because during some loops there will be no pulses occurring since the last loop. In this case I could just assume that the frequency is the same as last time, and for constant frequencies this works well. But there is also the case where the flow rate has suddenly stopped, and hence a zero pulse frequency. If I assume that the last known value is also the current value, my VI will be stuck reporting the last known flow rate, and will not ever report a zero rate. It must be the same as a digital frequency to analog converter, but I couldn’t find information on the algorithms used. Has anyone worked out a solution to something like this using Labview?
0 Kudos
Message 1 of 3
(2,955 Views)
Hi,
 
I have done something similar before. You mention frequency to analog conversion - that's precisely the principle I used. Basically you count your pulses (cycles, level crossings, etc.) and feed them into an integrator. Mathematically it works like this:
 
F(0) = 0;
F(i) = [ F(i-1) + N(i)/T ] exp (-t/T);
 
F(i) - frequency after the i'th iteration
N(i) - number of pulses detected during the i'th iteration
t - iteration time
T - the integrator time constant
 
For a fixed frequency the estimator output stabilizes at N/t, but if the pulses stop coming, e.g. N=0, the output will decay to 0.
 
Use smaller T for a more "responsive" frequency estimator, larger T for a more "steady" one.
 
Hope this helps!  Zador.
 
 
P.S. Here's a link to a previous discussion on pulse detection:
0 Kudos
Message 2 of 3
(2,927 Views)
Thanks, that was exactly what I was looking for. I'll try it out.
0 Kudos
Message 3 of 3
(2,891 Views)