Here I will present the notes I made while developing the phase lock algorithm used to detect trace amounts of DNA orbiting an electrical focal point.
It took me some time to wrap my mind intimately enough around the phase lock concept to be able to code it simply into an application. I am going to lay down my thoughts here for my future self to reference.
Phase Locking allows me to hone in on a signal from a noisy source by eliminating all other components of the noisy source except for a known frequency at a known phase. I know the frequency and phase because I either generate the signal or whoever is generating it passes on this information to me. I found that what helped the most was the following mathematical presentation.
be an Encoded Signal. is composed of the carrier wave and the Signal of Interest I want to transmit across the medium. In this case the amplitude of varies and is proportional to the Signal of Interest.
be the Background Noise that accompanies the Encoded Signal. In this case the sum indicates that the profile of the Background Noise spans many frequencies at different amplitudes and phase offsets.
The signal that I receive and that I am going to apply the Phase Lock procedure on contains both the Encoded Signal and the Background Noise:
At this point I am going to delve into a bit of signal processing. My end goal is to extract the amplitude from the noisy . For this I will use my knowledge that the Encoded Signal is broadcast at a frequency with a phase offset . The procedure is the following:
1) Multiply by a reference signal . In this case has has the same frequency and phase as .
2) Convolve the result by a constant function (this can also be interpreted as integrating the result).
To understand what the two steps above do I am going to present their effects both in time and frequency domain.
Remember: CONVOLUTION in time domain is MULTIPLICATION in frequency domain. And the other way around.
The outcome of the first step (the in the time domain) in the frequency domain is to shift the frequency of my Encoded Signal to DC (0 Hz).
The second step (the convolution of the result of step 1 with a DC function in the time domain) results in all frequencies except DC being multiplied by 0 – practically leaving only the power component of the Encoded Signal.
If you manage to understand the sequence of steps above the math below will make much more sense.
Now that I have a good intuition on what I am planning on doing I’ll go through the math in time domain to make sure I get all the fine details right.
So first up is the multiplication – which is also known as “beating” with a reference signal .
Remembering from whatever is left of my trigonometry memories that:
The top term of (5) simplifies to:
Now remember from the way I chose that and that so the first becomes which is a DC (non-oscilating) term. So the top term ends up being:
The bottom term of (5) becomes:
In this case however we can’t cancel out with unless is equal to and . This happens for Background Noise frequencies that are “close” to the Encoded Signal frequency and at about the same phase offset .
Putting everything together equation (5) can then be simplified to:
Upon a slightly more careful inspection I observe that the result of beating with is a DC term and a series of oscillatory terms at different frequencies.
NOTE: Actually there’s two DC terms. The 2nd DC term is hidden in the term. This happens as mentioned before when is about the same frequency as and when is equal to .
So if I were to filter the result of with a DC filter I would remove all the oscillating terms. To filter using a DC term I convolve the multiplication by a constant term which leaves me with:
where the term is used to indicate the frequency for which and . That is the component of the Background Noise that has a frequency and phase equal (or very close to) the Encoded Signal’s frequency and phase.
If we assume the Background Noise at the frequency and offset is small. Then:
Which means that:
which brings us to the goal of finding .
Thanks to the people at tex.stackexchange for teaching me how to use Latex properly.
The biggest thanks go to The Scientist and Engineer’s Guide to Digital Signal Processing by Steven W. Smith, Ph.D for teaching me the intro knowledge on convolution.