Terminator3
Advanced Member level 3
In complex signals negative part of spectrum can be used somehow to determine phase shift. I hope. How?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
yes, in theory. But also it can be +-pi/2 (for higher/lower freqs than LO). Actually i want other angles too, if i put there delayed signal.The phase difference between I and Q components is always pi/2 I think
This thing can be smoothed, because specL and specR is just an vector (X,Y). Again, i realized how to do that only for signals for similar amplitude.mult:=round(specA[maxi]*specB[1024-maxi]+specB[maxi]*specA[1024-maxi]);
if mult<0 then
begin
if specL[maxi]>specR[maxi] then
begin
specR[maxi]:=-specR[maxi]
end else
if specL[maxi]<specR[maxi] then
specL[maxi]:=-specL[maxi];
end;
I think I see the confusion. The terminology I and Q is usually applied to two signals that are exactly 90 degrees out of phase, and then they are usually added together to make one signal. You have two signals that are not necessarily 90 degrees out of phase, and are not added together. You just want to determine the relative phase of the two. First you have to assume that the relative phase is fairly constant over the length of sample period. If the phase is changing faster than that, you need to use shorter sample periods with fewer samples. So assuming the phase is constant, the angle between the complex numbers near the peak amplitude is the phase relationship you want. And if you want to be more accurate you could interpolate between the nearest two bins to the peak. If you know the exact frequency apriori then you can apply that information to help you interpolate between two frequency bins.I need to know relative phases of two signals (identical slowly changing frequency). BUT also i want to do smoothing of this phase difference over time.
At the moment i do complex FFT of complex input (two channels), rearrange output and get 2 real spectrums separately for each signal, calculate phases, calculate phase differences, calculate amplitudes. After that i use phase to project amplitude on X and Y plane to do time-smoothing, bacause averaging phase not taking into account amplitude gives bad result. Then, after smoothing, i take smoothed X and Y and calculate atan2 and get smoothed phase difference. So it works this way.
Why i still have this question i because while observing complex FFT output i realized, that it somehow can be directly smoothed, and with trial and error i was able to produce algorithm, that analyses scalar multiplication of complex spectrum vectors. But it works only for signals with similar amplitude:
View attachment 92327
Actually it takes complex spectrum, calculate amplitudes using sqrt for full 1024 spectrum (real 512 and "negative" frequency part from 512 to 1024).
Then i add sign to amplitude spectrum using this way:
This thing can be smoothed, because specL and specR is just an vector (X,Y). Again, i realized how to do that only for signals for similar amplitude.
So i now use the old way:
1) take real spectrums of each signal
2) calculate phases
3) calculate amplitudes
4) calculate phase differences
5) project amplitudes using phase on X,Y axis
6) smooth
7) atan of smoothed X,Y to get smoothed amplitude and phase
Another method (code above), that worked only for similar amplitude, is much more effective:
1) calculate complex spectrum
2) calculate amplitudes
3) change sign of amplitudes based on complex spectrum
4) smooth
5) make atan of smoothed data to get smoothed phase and amplitude
it would be faster and less of code.