# Determine phase and magnitude of an oscillating signal

I'm studying mechanical engineering and I would like to determine the magnitude and phase of a signal. Fourier analysis has been mentioned many times during my study and I think I know what it is about but I never had to apply it myself, which is (as usual) way more difficult than following the analysis someone else did;) I tried to find answers to my questions, but haven't been successful so far. I started to get more confused the more I read so I decided to ask somebody for help. I don't expect a final solution, like source code, but could please someone point me in the right direction?

Technical background:
I would like to analyze the bending moment of the rotor mast of a helicopter. The bending moment is calculated from the signal of a strain gauge, which rotates with the rotor. Apparently, the signal of the bending moment is overlain by the rotor revolution. What I need is the phase and the magnitude of the signal.

Approach:
I have time-discrete flight test data of the bending moment and a signal, which indicates, when rotor blade number one is located above the tailboom. I applied a fast fourier transformation to the data of one revolution and would like to determine phase and magnitude from the imaginary and real part of the fourier coefficients. The computations are done by a python script.

Questions:
As far as I understood, the first fourier coefficent equals the mean value of the signal and the next coefficients equals the coefficient of the first harmonic frequency, which would be the rotor frequency, since I analyse the data of one revolution. If I change the number of terms considered, the coefficents change. This makes perfectly sense to me, but affects phase and magnitude as well. So choosing the second coefficient returned by my fft-function can't be right. What am I missing?

Johannes

How do I choose N? Does N equal the number of measured values?

Never heard of atan2, but I found information about it...

If the frequency of the coefficient equals k/N, I know, that the coefficient with k=1 stands for the rotor rpm. I did the calculation for 36 revolutions and in 7 cases, the coefficient with k=0 has had the larges magnitude by far. So I'll increase the sampling rate. Fortunately, the raw flight test data is sampled with 25kHz and the data I used unitl now is sampled with 1kHz.

Does it affect the quality of the result, if I calculate the phase and magnitude for every revolution seperately and calculate the mean afterwards instead of calculating the phase and magnitude for the whole flight at once? I decided to calculate the phase and magnitude for each revolution to be able to calculate the standard deviation to asses the quality.

thanks alot!

Here some final notes:

• the time for the signal calculated from the fourier coefficients starts at t=0s no matter what time the actual signal starts. This is what leads to the phase shift in the diagramm ("Signals") I posted above.

• calculating the mean of all phases for each revolution leads to a tremendous standard deviation (up to 180°). This is caused by the discontinuity of arctan. It can be solved by calculating the mean of the real and imaginary part of the fourier coefficients befor calculting the phase. I'm not yet sure under which circumstances calculating the mean of the fourier coefficients is valid...

• arctan2 from python expects the arguments in a different order than posted above or as other programms like excel... I used numpy.angle(imaginary number) and numpy.abs(imaginary number) in the end anyway...

Thanks alot for your help! Johannes

• Couple of questions: 1. What do you mean when you say that the "signal of the bending moment is overlain by the rotor revolution"? 2. Are you assuming that the signal of the bending moment is sinusoidal? If not, how would you define the "beginning" of the signal? I don't think you can solve this problem without defining those things. – Adrian Keister Jul 19 '13 at 17:17
• yes, the signal is sinusoidal. In forward flight, the mast is bended about the lateral axis of the helicopter. Since the strain gauge is mounted to the rotating axis, the signal isn't equal to the magnitude of the bending moment, but a sinusoidal signal oscillating with the rpm of the rotor. I don't know, what you mean with "beginning". I know the beginning of a revolution due to a second signal. <br><br> I hope this answers your questions. It's not that easy for me to describe, since English isn't my mother tongue;) – Johannes Jul 19 '13 at 23:23

Here's the algorithm I would use:

1. Take the DFT/FFT of your sinusoidal signal. If your sinusoidal signal is $x_{n}$, then your transformed signal is $$X_{k}=\sum_{n=0}^{N-1}\left[x_{n} \cdot e^{-2\pi ikn/N}\right].$$
2. You want the basic amplitude and phase of the strongest frequency component of your signal. So, find $\displaystyle \max_{k} |X_{k}|$, call it $X_{\max}$.
3. The amplitude of the strongest component of your signal is given by $$\frac{|X_{\max}|}{N}=\frac{\sqrt{\text{Re}^{2}(X_{\max})+\text{Im}^{2}(X_{\max})}}{N},$$ and the phase is given by $$\arg(X_{\max})=\text{atan2}(\text{Im}(X_{\max}),\text{Re}(X_{\max})),$$ where you may need to offset this value by the signal that tells you when the rotor blade one is located above the tailboom. I don't know if you're familiar with the $\text{atan2}$ function, but it's basically the arctangent function without the $\pi$ ambiguity that it normally has. I'm pretty sure Python has this function natively.

If you happen to be interested in the frequency of the sinusoid represented by $X_{\max}$, it is $k/N$ cycles per sample, where $k$ is the index of this component.

Incidentally, if you find that the first component of your transformed signal is by far the strongest, that's probably an indication that you're not sampling fast enough.

• How do I choose N? Does N equal the number of measured values? Never heard of atan2, but I found information about it... If the frequency of the coefficient equals k/N, I know, that the coefficient with k=1 stands for the rotor rpm. I did the calculation for 36 revolutions and in 7 cases, the coefficient with k=0 has had the larges magnitude by far. So I'll increase the sampling rate. Fortunately, the raw flight test data is sampled with 25kHz and the data I used unitl now is sampled with 1kHz. – Johannes Jul 20 '13 at 16:04
• Does it affect the quality of the result, if I calculate the phase and magnitude for every revolution seperately and calculate the mean afterwards instead of calculating the phase and magnitude for the whole flight at once? I decided to calculate the phase and magnitude for each revolution to be able to calculate the standard deviation to asses the quality. thanks alot! – Johannes Jul 20 '13 at 16:05
• The rpm of the rotor is adapted to e.g. speed and air density. But I have the signal of the position of one blade, so I can calculate the rpm for each revolution. The rpm varies between 5.4 Hz and 6.77Hz. So the minimum sample rate equals 67.7Hz. The sample rate of the data I analyse equals 1kHz. But there are still 7 out of 36 revolutions with a way larger first component than the others... – Johannes Jul 20 '13 at 19:49
• What do you mean with "sample FFT plotted against k"? The coefficients in the complex plane? Until now, I selected the data of each revolution, without considering, that N should be a power of 2. Should I crop the interval or take values of the next revolution into account? – Johannes Jul 20 '13 at 19:56
• What do you mean with "well defined peak"? The sinusoidal character of the values of the beinding moment? Unfortunately, it is not always distinct. How ever, this hardly happens, so I could simply exclude those revolutions. Thanks for your support! What you wrote helped me way more, than pretty much everything I read in the last couple of days in various books and web pages... – Johannes Jul 20 '13 at 20:03