# Software PLL tracking of carrier frequency in bandlimited transmission

My understanding is that a PLL(either in hardware or software) can recover the carrier frequency(or be used to correct the frequency offset) of a system. My question is how does this work when the transmitter is sending a pulse-shaped signal?

For a an approximate sinusoid the operation of the PLL makes sense but how does tracking work for carriers transmitting data?

As an example, suppose you're receiving a raised-cosine pulse, what do you do?

• What kind of modulation are you using with the raised-cosine pulse shaping? (PSK, QAM etc) I have made several posts specific to carrier and clock recovery with raised cosine pulse shaping for QPSK and QAM modulations that would apply to general cases. You can search under my name to find them or if you have trouble, I can look them up and put a link to them here. – Dan Boschen Aug 12 '18 at 21:17
• Hi, it would be QPSk or 4QAM(same thing I guess). I will try to find them but a link would be cool(I have low confidence in my ability to find them). Am I wrong in thinking the modulation would screw it up? For non-shaped QPSK/4QAM you could do a 4th power operation(I think) but for pulse shaped signals it seems the modulation would make the carrier unrecoverable with a PLL, particularly for frequencies which overlap with the frequency of the base band pulse. – FourierFlux Aug 12 '18 at 21:29
• No it would not screw it up and yes for QPSK you could do a 4th power carrier recovery but this approach is sub-optimum. I do have a post that shows the complete implementation for QAM/QPSK carrier recovery with the tracking loop as a software PLL implementation and then other posts that discuss the trade space involved in timing recovery with raised cosine pulse shapes. I will find them later and add the links. – Dan Boschen Aug 12 '18 at 21:34
• Thanks, I will read it. I am still confused why RRC modulation wouldn't mess up the frequency tracking loop though. – FourierFlux Aug 12 '18 at 21:49
• The pulse shaping adds an envelope to the amplitude of the carrier, no different than large-carrier AM (as the envelope itself does not cause the symbol to change sign so there is still a net postive mean or DC value after pulse shaping). So while it does transfer energy to sidebands, the carrier still exists as the largest component in the frequency domain. – Dan Boschen Aug 12 '18 at 22:07

Here is a link to an example carrier tracking implementation for a QPSK and QAM system, applicable to full-response raised cosine pulse shaping. This post also has links to many other concerns with demodulating the waveform, including timing recovery and setting the parameters in the tracking loop implementation.

Recovering signal for psk

A x4 carrier recovery approach may be the simplest way to see how the pulse shaping effects the carrier recovery. For QPSK without pulse shaping you can recover the carrier by raising the waveform to the fourth power, and then dividing the resulting 4x carrier by four to complete the recovery. This is because phases add when you multiply, so if we have four possible phases in our modulated signal:

$$e^{(j\omega t + 0)}$$ $$e^{(j\omega t + \pi/2)}$$ $$e^{(j\omega t + \pi)}$$ $$e^{(j\omega t + 3\pi/2)}$$

Raising to the 4th power results in the following for all the cases above. $$e^{(j4\omega t + 0)}$$

If we observe our waveform over time and it instantly goes from one phase location to the other (no pulse shaping, infinite bandwidth), then the 4th power result will be a pure tone at 4x the carrier frequency with no other components.

However if we slowly transition from one phase to the other, we will still get a pure tone at 4x the carrier frequency, but there will be significant energy in sidebands close to this frequency as well. The 4x tone will still be the strongest in vicinity of this 4x signal and is easily tracked with a PLL to complete recovery. (This is evidenced by a positive mean in the baseband equivalent analytic signal). It is because this signal is the strongest that a PLL can track it (typically if the signal being tracked is +6 dB higher than the sidebands a PLL can lock to it), and it is because of the additional sideband energy that we need to the PLL to complete the recovery, effectively acting as narrow bandpass filter to provide a clean carrier.

I added some graphics below for the simpler case of BPSK with and without pulse-shaping that will hopefully provide an intuitive answer. Personally I find it much simpler to think and work with describing frequency using the complex exponential ($e^{j\omega t})$ rather than with cosines and sines, and for the same reason I avoid including an actual carrier but model at the baseband equivalent analytic signal. However I think in this case showing an actual sinusoidal carrier will more immediately get across the point I am trying to make. For the same reason, this is very illustrative in showing how the pulse shaping affects a tracking loop but it is not how I would typically do carrier recovery (see the link above for a typical software recovery loop I would implement).

This first image shows a sinusoidal carrier with an example (1 0 1) data pattern. Below the data pattern is shown the result of BPSK modulation with no pulse shaping applied (infinite bandwidth available). Observe in the third plot showing the modulated signal, that the phase is changing from 0 to $\pi$ radians as the data transitions. This abrupt change back and forth of the phase would prohibit a simple phase tracking PLL from tracking the phase: if it could even lock onto one phase state (because the data doesn't transition for some time for example), once the data transition occurs the very significant phase error that would occur would cause a simple tracking loop to break lock (unless the phase detector had 0°/180° ambiguity -- hint, hint at another recovery approach!). Another way of describing this, with a random data pattern that is 50% ones and 50% zeros, the carrier would be completely suppressed and therefore does not exist, so there is no signal at that frequency for any loop to lock onto. Notice too that in the example plot I give, the data transitions are not commensurate with the carrier. I did that purposely just to show that regardless of the data rate and where transitions occur, squaring this signal will result in a pure tone (when no pulse shaping or other bandwidth limiting is used) at exactly twice the rate of the carrier.

The fourth plot is simply the waveform in the third plot squared with no other filtering applied. This waveform is completely in phase with the original carrier, at exactly twice the frequency. In this case we could simply pass this signal into a frequency divide by two function (quite simple) and we would completely recover the carrier. No PLL is needed, but if there were any other noise sources present, a PLL would help increase the SNR of our recovered carrier in the presence of noise. However our waveform itself and the recovery process, in this case, contributes no additional noise or distortion.

What is occurring by squaring the signal is we are doubling the frequency (and the phase). This is clear from the trigonometric relationship:

$$cos(\alpha)*cos(\beta) = \frac{1}{2}cos(\alpha+\beta)+ \frac{1}{2}cos(\alpha-\beta)$$

$$cos(2\pi f_c t + \phi)cos(2\pi f_c t + \phi) = \frac{1}{2}cos(4\pi f_c t + 2 \phi)+ \frac{1}{2}cos(0)$$

$$= \frac{1}{2}cos(4\pi f_c t + 2 \phi)+ \frac{1}{2}$$

So if the phase is only in two states: 0 (0°) and $\pi$ (180°), doubling this results in 0 and 2$\pi$ which is also 0.

Now observe what occurs in the same situation with pulse shaping as shown in the plot below. Here the only difference is a pulse shape has been added to each symbol. Notice that the result is to only add an amplitude variation (the pulse shape) to the squared signal but it has no effect on the phase. This is an important observation as to why a normal tracking loop could still track the phase in this situation, and also illustrates why the loop that is used should be able to "fly-wheel" in the absence of updates (as most tracking loops in both carrier and timing recovery). The phase in the doubled signal is in phase with the carrier at exactly twice the frequency but the amplitude is going up and down. This does of course impact the SNR of the recovered signal, as there are fewer phase error updates for tracking but unlike the case of the modulated signal itself, the phase does not abruptly change in a manner that would be disastrous for the loop to track. This also shows the importance of using a phase tracking loop in this case, which will ride through the amplitude variations and create a clean doubled carrier with no amplitude variation.

This is perhaps clearer by comparing the two final cases of the multiplied outputs directly as shown below. Here we clearly see that the pulse shaping only affects the amplitude and not the phase, hence a phase tracking loop should be able to track and recreate a cleaner replica of the doubled carrier signal, which we would then follow with a divide by two to completely recover the carrier.

The plots above should provide a satisfactory intuitive explanation in the effects of pulse shaping on carrier tracking loops, but not to suggest the favored approach to doing carrier recovery. In a digital or software implementation instead of squaring, PLL and divider, I would suggest decision directed and other similar digital Costas-Loop approaches as I have shown in the link above.

Another intuitive explanation is given by observing the above signals in the frequency domain, and noting how the carrier is suppressed prior to squaring and then recreated at twice the carrier frequency after squaring (or raising to the fourth power for QPSK, to the eight power for 8-PSK etc).

• Thanks, this is really great. I'm still wondering, in the case that the carrier frequency is very low, how would the PLL know to track the carrier? It seems the system works under the idea that the oscillations of the carrier are essentially more abrupt/stronger than what is produced in the pulse shaper. As a second question(needs a separate thread I guess) - how would pilot tone based carrier synchronization work? – FourierFlux Aug 13 '18 at 20:38
• Please read the response I gave here dsp.stackexchange.com/questions/31355/… and then I think you will see that it does not matter what frequency the carrier can be at (DC is no different than any other frequency tone when we work with complex frequencies). Again read that post and I think it will become a lot clearer. Yes your second question is quite broad, I recommend researching it further and then post specific questions after you have dug into it based on points that still confuse you. – Dan Boschen Aug 14 '18 at 1:05

I assume that you are asking about phase synchronization in a linearly modulated (PSK, QAM, etc.) system and not particularly concerned about moderate to large frequency locking. A Frequency Locked Loop (FLL) is what you need if that is the case.

For implementing your phase synchronization system, you will find Dan's answer very helpful. He has written some of the very best posts I have read here.

Coming to your question of how the phase is recovered even when the modulation is present in a pulse shaped scenario, I call this the fundamental problem of synchronization. Usually, a PLL expects a continuous wave at its input, the phase of which can easily be locked onto. See a locking example of a PLL input and output below.

Imagine a QPSK signal input directly into a PLL designed to estimate and compensate for the phase and frequency of a sinusoid. Instead of the rectangular IQ expression you see for linear modulations, we can write a passband QAM waveform in polar form as $$s(t) = \sum _m \sqrt{a_I^2[m] + a_Q^2[m]} \cdot p(t-mT_M) \cdot \sqrt{2} \cos \left(2\pi F_C t+ \tan^{-1} \frac{a_Q[m]}{a_I[m]}\right)$$

In this polar form, we have a single sinusoid whose amplitude is fixed for PSK modulation and phase is determined by symbols $a_I[m]$ and $a_Q[m]$. The modulated signal arriving at the Rx consists of two different phase components.

1. Unknown phase shifts arising due to modulating data occurring at symbol rate. For example, in BPSK modulation, phase changes by $0^\circ$ or $180^\circ$ at the boundary of each symbol interval. For QPSK, there are four different phase shift possibilities, i.e., $45^\circ$, $135^\circ$, $-135^\circ$, or $-45^\circ$. A similar argument holds for QAM as well.
2. Unknown phase difference between Tx and Rx local oscillator, $\theta$.

Depending on its design parameters, the PLL will try to lock onto the incoming phase within a specific time duration. However, instead of being a regular sinusoid, its phase is jumping around by $0^\circ$, $\pm 90^\circ$ or $180^\circ$ at every symbol boundary due to the modulating data, never allowing our PLL to converge. This is the fundamental problem every synchronization system needs to address and is illustrated in figure below.

Now we go to your question of finding the pulse shape in this phase recovery process. First, the carrier does not need to be involved in this process. With the expansion of unique digital processing solutions and shrinking of the analog side in the wireless communication systems, the signal is downconverted by a free running oscillator at a fixed frequency (leading to low phase jitter) and the phase offset can be compensated in the $IQ$ modulated data right there and then.

Most timing synchronization algorithms operate independent of the phase information. Therefore, almost all the DSP based carrier phase synchronization algorithms are timing-aided which means that the symbol boundaries in the Rx sampled waveform are established before the phase recovery block. Knowing the exact symbol boundaries is the same as identifying the optimal sampling instants where the eye opening is maximum and Inter-Symbol Interference (ISI) from the neighbouring symbols is zero. An example of a matched filter $IQ$ output is drawn in Figure below.

You can see the Raised Cosine pulse shape in the background as a red line. From here, a phase error detector removes the modulation such that the input to the loop filter is a track-able signal.

Many SDR enthusiasts outside of the core wireless area find it strange when they encounter a carrier phase synchronization block of code (e.g., a PLL or a Costas loop in GNU Radio) in which there is no `carrier' to be compensated for! Instead, they only find a phase de-rotation of the $IQ$ samples going into the symbol detector as shown above.

• Nice answer @QasimChaudhari! To be clear the "phase de-rotation of the IQ samples going into the symbol detector" is the recovered carrier (at baseband)! If the carrier was off by 1 Hz for example, this phase rotator would be spinning at a 1 Hz rate. I think what confuses many SDR enthusiasts is the complex baseband (I and Q) equivalence to the waveform at the actual carrier frequency. Once you cross that bridge, many things become so much clearer. So in the case the carrier is still very much involved, it is just not of the form $cos(\omega t)$ but directly at baseband as $e^{j\omega t}$. – Dan Boschen Aug 13 '18 at 12:14
• (making note that $e^{j\phi} = I + j Q$ hence our phase rotations at baseband as our recovered carrier). – Dan Boschen Aug 13 '18 at 12:16
• Is there a difference between a PLL and FLL? It seems most PLLs are designed to track carrier frequency. – FourierFlux Aug 13 '18 at 21:41
• @FourierFlux yes, there is. As the name suggests, the PLL measures the phase error, the FLL measures the frequency error. – Marcus Müller Aug 18 '18 at 2:00
• @FourierFlux: A PLL can handle a frequency offset but only a very small one due to its narrow bandwidth. An FLL is designed to lock onto a large frequency offset, on the order of the symbol rate. – Qasim Chaudhari Aug 18 '18 at 8:18