Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding the sample at the beginning of a period of a compound periodic signal

I have a signal made up of the sum of a number of sine waves. These are spaced at 100Hz, with the lowest component frequency at 200Hz (200Hz, 300Hz...etc.) All component sine waves begin at the same point with phase = 0. In my DSP software, where I am going to multiply this signal by several other signals, I need to find a point at which all of the original signal's component signals are all again at phase = 0.

If I were only using one sine wave, I could simply look for a change in sign from negative to positive. However, if the signal has, say, components at 200Hz and 300Hz, there are three zero-crossing where the sign changes from negative to positive, but only one that represents the beginning of the period, and this increases with more component waves. I do have control over the amplitudes of each component frequency during an initial startup sequence. If these waves were strictly harmonic (200Hz, 400Hz, 800Hz, etc.), I could simply remove all but the lowest frequency, find the beginning of its period, and use this as my zero-sample. However, I don't have this bandwidth. Can anyone provide an alternative approach?

Edit:

(I have clarified and integrated this edit into body of question.)

Edit 2:

This graphic should demonstrate the issue. The frequencies two components here are n and 3n/2. Without filtering out all but the lowest frequency, or taking an FFT as proposed by @hotpaw, an algorithm that only looks for zero-crossings where the sign changes from negative positive will land on one of three, and I must find the first of those three (this is the one point at which each component signal is at phase = 0). I realise that taking an FFT will work, but I'm dealing with very limited processing power and wondering if there's a simpler approach.

Sample waveform

like image 427
GarlicFries Avatar asked Oct 10 '22 11:10

GarlicFries


2 Answers

Look at the derivative of the signal!

Your signal is a sum of sines (sorry, I'm not sure how to format formulas properly)

S = sum(a_n * sin(k_n * t)) ... over all n

a_n is the positive amplitude and k_n the positive frequency. The derivative (that you can compute easily numerically) of the signal is

dS/dt = sum(a_n * k_n * cos(k_n * t)) ... over all n

At t=0 (what you're looking for), the derivative has its maximum since all cosine terms are one at the same time.

Some addition: For the practical implementation you need to consider that the derivative may be noisy, so some kind of simple first-order filtering could be necessary.

like image 147
groovingandi Avatar answered Oct 13 '22 10:10

groovingandi


I assume that all the sine waves are exact harmonics of some fundamental frequency, all have a phase of zero with respect to the same reference point at some point in time, and that this is the point in time you wish to find.

You can use an FFT with an aperture length that is an exact multiple of the period of your fundamental frequency (100 Hz). If there is zero noise, you can use 1 period. Estimate the phase with respect to some reference point (FFT aperture start or center) of all the sinusoids using the FFT. Then use the phase of the lowest frequency sinusoid that shows up as significant in the FFT to calculate all its zero crossings in your target time range. Compare with the nearest zero crossing of all the other sinusoids (using the FFT phase to estimate their phases), and find the low frequency zero crossing with the total least squared error of offsets from all the nearest zero crossings of all the other frequencies.

You can go back to the time domain to confirm the least squares estimated crossing as an actual zero crossing and/or to remove some of the numerical noise.

like image 37
hotpaw2 Avatar answered Oct 13 '22 11:10

hotpaw2