LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculation of the frequency of a periodic analog signal in software

Hello,
As part of a series of measurements on a Diesel engine, I am trying to measure the 
shaft's rotating speed (RPM). For the rest of my measurements I am using an Analog 
Input DAQ (current signal), so I prefer to measure the rpm using an analog current 
signal as well. For that reason I am planing to use an inductive sensor which 
generates an analog current signal for each full rotation of the shaft. My question 
is, how could I calculate in LabView the frequency (i.e. shaft's RPM) of this analog 
signal? 

 

Since I do not already have the sensor, I tried to simulate the analog signal. As I imagine, my signal will look like a square pulse with noise and a duty cycle approx. 1%, so I used the Simulate Signal.vi. The frequency range I need to be able to measure is 0-70 Hz, for that reason I need to have a sampling rate of more than 150 Hz. In order to calculate the frequency of this pulse signal, I used the Extra Single Tone information.vi, but it seems to have some problem performing the calculation...

The program works perfectly for high values of duty cycle (50%), but as the value is reduced, the frequency is not calculated correctly. The .vi seems to "loose" some of the pulses..

It also seems to have a problem calculating very low frequencies (interdependent the value of duty cycle).  

Is there a way to solve these problems? I tried using no noise, but this does not seem to be the problem..

 

I send attached to this mail the vi I am using.

 

Thank you very much

0 Kudos
Message 1 of 9
(5,194 Views)

If the real world signal you expect to deal with is pulse like, you could use digital tools to count the pulses. 

 

Look at some of the LabVIEW examples for ways to do it with counters or analog VIs. The VI called Pulse and Transition Measurements.vi should particularly interest you.

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 2 of 9
(5,190 Views)

Hi, 

 

thank you for the answer... Unfortunately, this vi does not work for low frequencies and low duty cycle values, as I have already tried it. Actually, the program crashes with the following message:

"Possible reason(s):
Analysis:  The waveform did not cross the mid reference level enough times to perform this measurement. Check the signal length, reference levels, and ref level units. "
 

 

0 Kudos
Message 3 of 9
(5,180 Views)

You have several possible complications.

 

1. You specified a frequency range of 0 to 70 Hz with a duty cycle of 1%.  The period at 70 Hz is about 14 ms.  The pulse width is 1/100 of that or 140 us. Thus your sampling rate needs to be fast enough to capture a pulse 140 us wide or greater than 700 Hz.  I suggest a sampling rate of 1 kHz as this will simplify the period calculations.

2. At a frequency of zero the period is infinite.  You can talk about zero frequency but you cannot measure it.  Instead specify some minimum frequency that you can measure, then declare that any frequency less than that is considered to be equivalent to zero.  For example if you need to update your speed measurement once per second, then you may define 1 Hz as the lowest frequency you will measure. When the period is longer than one second (less than 2 pulses in one second), then you indicate the speed as zero.

3. When you get that error, see 2. Check the error wire and when that error occurs, set the speed to zero and clear the error.  Do not pop up the error dialog.

 

Lynn

0 Kudos
Message 4 of 9
(5,174 Views)

And before you go crazy trying to work this out with simulated signals, get your hardware working and see what the signal will actually look like.  It may be easier than you think to trigger on it, OR, it may be so fast or noisy that you will need to add some signal conditioning hardware before you digitize.  Trying to clean up signals in software is often more frustrating than just building a little analog filter + edge detector + buffer and cleaning up your signal at its source.

 

EDIT:  BTW, what DAQ are you using?

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 5 of 9
(5,169 Views)

Thank you for your answers..!

I actually now have the real analog signal, so the whole issue is more clear now.. Since I still have several problems with the frequency detecting vi-s, I tried to built a vi calculating the time between two sequential pulses-->f = 1/dt. My vi works ok for frequencies less than the while loop frequency.. However, for higher frequencies the result remains the same=while loop frequency=20Hz...

 

Is there a way to raise the loop frequency of my vi??   

0 Kudos
Message 6 of 9
(5,149 Views)

Giwtis,

 

Does your while loop contain a wait function?  This will generally determine the speed at which you loop will run (unless it is attempting to run faster than the processor can handle).  If you do not have a wait function the loop will run as fast as the processor will allow it (and bog down your computer because the loop is using more resources than it needs).  One way to speed up the loop is to reduce the wait time.

 

Also, did Lynn's (johnsold) suggestions help at all?  Have you tried using the Extract Single Tone Measurement VI? I was able to take measurements below 40 Hz using this VI.

 

 

Drew T.
Camber Ridge, LLC.
0 Kudos
Message 7 of 9
(5,127 Views)

Do you have a copy of that VI? I'm trying to build one as well because the precanned functions are not working to get me a frequency.

0 Kudos
Message 8 of 9
(3,964 Views)

You replied to a 5-year old thread with a very vague question.

 

Please start a new thread. Describe in detail which "precanned" functions you have tried and what is not working. Best is if you post your VI with some typical data saved as default.

 

Lynn

0 Kudos
Message 9 of 9
(3,951 Views)