LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to find time period in real time for a sine wave

Hi,
Can anybody tell me how I can find the time period for a sine wave in real time?..I am using a waveform chart to get the real time display of the wave. I want to know the period so that I can find the frequency of oscillation.
 
0 Kudos
Message 1 of 9
(6,897 Views)

You can find the frequency by using the Extract Single Tone Information vi found in Waveform Measurements.  If you still want the period, divide the frequncy into 1.

 

Message Edited by tbob on 08-15-2005 10:51 AM

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 9
(6,890 Views)

Hi,

I tried that. But it gave me a very large fruquency like 4.9 E6... Let me explain the situation. I have a serial input through a device. The program in labview starts recording the data from the device. the device is then subjected to oscillations. That is when I want to find the frequency. When I tried the vi you suggested, the frequency didnt change  I get data at the rate of 50 Hz. Its that at first there are no oscillation and then there are oscillations... and thats when I want to detect the frequency so that we can set the frequency to what we need.

 

0 Kudos
Message 3 of 9
(6,881 Views)
You may have a hardware problem.  The frequency detected is whatever is input into the vi.  How are you capturing the signal?  What does it look like on a scope?  In my vi, you must replace the SineWave Generator with whatever your signal is.  I used the SineWave Generator just for testing.
- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 9
(6,879 Views)
Well... the instrument is an inertial reference instrument. It has sensors which get data continuously at 50 hz and send it to the laptop thouugh serial port, Those things are working fine. Then the signal from the serial port is fed into the waveform chart to get the real-time display which is also working fine. From that real time display, I need to get the frequency of the input signal. Before it is oscillated, the instrument just gives out random noise signals which are very small.. The recorded data is atached in form of a graph from matlab. I want to get the frequency of the graph in real time.
 
 
0 Kudos
Message 5 of 9
(6,870 Views)
You will have to feed the graph's input signal into the Extract Single Tone Information vi.  During the noise period, the Extract vi will not be able to output a steady frequency.  During the oscillation period, it should.  The trick is to put this vi in a loop so that it is constantly being updated with new input, and exit the loop when a valid frequency is detected.  It must detect this frequency before the oscillations die.  If the oscillating frequency changes while it is oscillating, the vi might not be able to lock in on one frequency.  If that happens, you will need another approach, which will be more complex.  You could use the FFT vi to analyze the signal and display a graph of frequencies present, similar to a spectrum analyzer.  There is a spectrum analyzer vi that you can search for, but it is quite complex.
- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 9
(6,859 Views)
In addition to tbob's comments I will add that FFT-based analyses (such as Extract Single Tone Information VI) do not work well with only a few cycles of data. The first 2 seconds of the active signal seem to have a fairly high signal to noise ratio. In that case a simple zero-crossing detector may be the best approach. If you need finer resolution than the 50 Hz sampling rate provides, try interpolating the zero-crossings. You will not find anything like this as a pre-packaged VI, but the functions involved are simple math and array operations.

Lynn

Mr. Lynn to tbob.
0 Kudos
Message 7 of 9
(6,843 Views)

I do something similar in my belt tension tester program.  Here's what I do:

 

1)find the impulse.  I calculate the envelope of the signal.  I find the start of the signal using a threshold value that the signal exceeds.  The end of the impulse is when the envelope is lower than a pre-set lower threshold. 

2)using the impulse start and stop locations I extract a sub array of data that contains only the impulse and not the background noise before or after the impulse. 

3)FFT the sub-array

4)Find the largest peak location in the fft

5) take a sub-set of the fft data and Gaussian fit the sub array to get a peak location that is higher resolution than the number of fft bins. 

6) use the Gaussian peak location to in spectral space combined with fft length and sample rate to calculate resonant frequency.

 

Here's a screenshot of the app that does the above calculations; note how similar our impulses are:

http://www.quadesl.com/labview/belt_tension_tester_2.1.gif

 

Sheldon

 

Technical geek, engineer, research scientist, biodegradable...
0 Kudos
Message 8 of 9
(6,838 Views)
"Mr. Lynn to tbob"
 
Smiley Very HappySmiley Very HappySmiley Very Happy  I'll never live this down!
- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 9
(6,829 Views)