From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
02-23-2010 06:36 AM
Hello,
Sorry for my English, I'm french...
I've got a data file which represent a "many-periodic" signal (voltage on Y-axis and time on X-axis) composed of nearly 10 "peaks". I mean it's a waveform signal where the period evolves in time. Moreover, my signal is not symetric and not "zero-centered".
I would like to display the frequency for each moment of my signal, a kind of "instanteous frequency".
Until now, I detect all the peaks and calculate the time between two consecutive peaks in order to estimate only 9 periods, then 9 frequencies...
I'm looking for a better solution which can give me more frequencies in order to plot it as a fonction of the time.
Any idea?
Thank you.
02-23-2010 07:05 AM
02-23-2010 07:30 AM
Wikipedia wrote:
Frequency is the number of occurrences of a repeating event per unit time. It is also referred to as temporal frequency. The period is the duration of one cycle in a repeating event, so the period is the reciprocal of the frequency
http://en.wikipedia.org/wiki/Frequency
So, from this point of view.......you do not have a frequency, so how do you want to get any information about this?
I think, what you want to see is the time difference between the peaks.....and your approach seems to solve that already.
Norbert
02-23-2010 09:35 AM
Ok, It wasn't clear...
First, here is my data chart, voltage as a fonction of time:
the period (then the frequency) looks like constant but it doesn't!! i would like to estimate the variation of the frequency, ploting it as a fonction of time.
For example, we can fit the signal with a function as A(x) + B(x)sin(C(x)) where A(x), B(x) and C(x) may be polynomials.
C(x) should represent the frequency as a fonction of time (Known up to a 2pi factor of proportionality). But I'm not sure, and I don't know how to do...
Is it clearer?
Any ideas?
Thank you
02-23-2010 09:41 AM
The problem in your task is that you have not really sufficient periods for a single frequency analysis. You could try to simplify it like you are more or less already doing: Determine the time it takes from one maximum to the next (or minimum, regarding your task) and take this is "one period(s)". So the frequency is 1/period(s).
I think the biggest issue occurs in the clear identification of those maxima/minima. Given your screenshot, you have to either introduce "deadbands" or appropriate hysteresis for the determination of those points......
Please note, that this approach is a guess of the frequency at best because without proper continuity, the determination of a frequency is (mathematically spoken) not possible.
Norbert
02-23-2010 10:21 AM
As Norbert pointed out "frequency" is not well defined for signals which vary non-periodically. You can define "instantaneous frequency" any way you chose for your signal, but you should be very clear about what assumptions you make in doing so.
Since your signal appears to be fairly clean (high signal to noise ratio), finding successive maxima and minima and the spacing between them is probably the best way.
The Lev-Mar curve fitting routines work well to fit the frequency of a sine wave if you use less than one complete cycle of the wave. It works poorly for three or more cycles. Fourier transform techniques work best when you have about 10 or more cycles at the same frequency. Fitting to your equation " A(x) + B(x)sin(C(x)) " will probably not work very well. If you want to use fitting techniques, split the array of data at each maximum and minimum and fit the approximate half cycles to sin(omega*x). I have had some success with fitting segments of a cycle to a sine curve.
If you wish to use a zero crossing technique, find the maxima and minima as above. Then locate the midpoint (amplitude) between each maximum, minimum and minimum, maximum pair. Use the timing of those midpoints as the "zero-crossings." There will be some error, but due to the nature of your signal any frequency estimate will contain some error. For the image you posted the first midpoint would be at about 1.65 (y-axis) and 450 (x-axis). The second one would be at about 1.2 and 800. The estimate for the period of the half cycle containing the first minimum would be 800-450 = 350. The estimated frequency for a full period based on that half period is 1/(2*350) = 0.00143.
Lynn
02-23-2010 10:45 AM
Is there some reason you are not taking the Fourier Transform (FFT) of the data and using the outputs as the coefficients? There will be some DC term...for the average offset, there will be some harmonics off the step changes in the DC term ... and there will be a very large peak (or two depending on how the frequencies fall between samples) for the sinusodial looking part of the signal...
Hummer1
02-23-2010 11:45 AM
Hummer1,
The original poster indicated that the frequency is changing over the duration of the signal and that a cycle by cycle measurement is desired. At least that is the way I read it. Fourier transform methods do not work well with rapidly changing frequencies. The FFT need about 10 cycles at constant frequency for good results.
Lynn
02-23-2010 01:47 PM
I would have thought that you could take the FFT of the signal every 500 samples or so and that would give you good enough resolution for one cycle of the sinusoid.
That would divide the frequency domain up into 1/250 of the sample frequency as an increment in frequency. Then, move the window...
The signal can be windowed as well....
Sorry,
Guess I don't understand the problem.
Hummer1
02-23-2010 03:18 PM
Mathematically the Fourier transform is defined by an integral over all time. This has the effect of taking a long term average over the component at a particular frequency. If the signal only has a component at that frequency for a very short time, the magnitude of that component in the output of the transform is small. If the signal segment is not exactly an integral number of cycles, the truncation introduces additional components which look like harmonics and may also contribute a DC component.
The joys of using sampled and truncated data to represent a signal which is modeled as infinitely continuous!
Lynn