DSPRelated.com
Blogs

Discrete-Time PLLs, Part 1: Basics

Reza AmeliDecember 1, 20159 comments

Design Files: Part1.slx


Hi everyone,

In this series of tutorials on discrete-time PLLs we will be focusing on Phase-Locked Loops that can be implemented in discrete-time signal proessors such as FPGAs, DSPs and of course, MATLAB.

This article is available in PDF format for easy printing

In the first part of the series, we will be reviewing the basics of continuous-time baseband PLLs and we will see some useful mathematics that will give us insight into the inners working of PLLs. In the second part, we will focus on the discrete-time baseband PLLs. Following the first two parts in the series you will see different examples that show the applications of PLLs in different areas of digital and analog communications.

1. The Problem of Being Out-of-Phase

An important application of PLLs is phase synchronization.

1.1 Some Basic Concepts

So, what is a PLL anyway? Many (similar) answers can be given to this question depending on the application but Wikipedia does a good job providing a starting point:

A phase-locked loop or phase lock loop (PLL) is a control system that generates an output signal whose phase is related to the phase of an input signal.

This means that when a PLL locks, we can have some knowledge about the phase of the signal that enters the PLL. This definition might be a little vague so let's break it into parts and see what each part means.

What is phase? In many applications, a signal transmitter modifies the instantaneous phase of a sinusoid to embed some information in it. You can read more about the instantaneous phase on Wikipedia however for our application, we will be focusing on signals of form

$ y(t) = \cos(\omega _0 t + \theta(t)) \tag {1} $

where $\omega _0$ is the (constant) angular frequency and the $\theta(t)$ is the (time-varying) phase.

Note that $\theta(t)$ is a time-varying function and can be of any reasonable form. For example, in BPSK modulation,  the phase can assume only two values (only $0$ or $\pi$). In FM voice transmitters, $\theta(t)$ is proportional to $\int_0^ tv(\tau)d\tau$ wheren $v(t)$ is the voice signal. So as you can see $\theta(t)$ can be quite arbitrary.

In this series of tutorials, we are interested in knowing about $\theta(t)$ when only $y(t)$ is available i.e., we like to extract $\theta(t)$ from $y(t)$. This is what happens when a PLL locks to its input.


1.2 An Example of Out-of-Phase Local Oscillators

Here is an example of two local oscillators that are out of phase:

Let's say Alice has a Double-sideband suppressed-carrier transmission (DSB-SC) transmitter and she turns it on at $t = 0$. A DSB-SC modulator multiplies the input signal $A(t)$ by the output of a local oscillator running at frequency $f_0$. $A(t)$ can be Alice's voice and the output signal of Alice's transmitter looks like this:

$ y(t) = {A(t)\cos(2\pi f_0t)} \tag {2} $

Here we are assuming that the transmitter's oscillator has an initial phase of $0$ at the moment it is turned on.

Bob, however, turns on his receiver with a time delay, at $t = t_0$. From the receiver's point of view, the output of the transmitter looks like this:

$ y(t) = {A(t)\cos(2\pi f_0t + \theta_0)} \tag {3} $

That is simply because Alice's transmitter oscillator had already started working so it has an initial phase seen from the receiver's point of view.

It should be mentioned that the receiver sees its local oscillator's output without any initial phase:

$ LO_{Receiver}(t) = \cos(2\pi f_0t) \tag {4} $

If Bob and Alice had turned on the transmitter and receiver exactly at the same time (i.e., $\theta_0 = 0$), one easy way to demodulate the transmitted signal would have been to multiply it by the local oscillator's output (at the receiver) and then pass the result through a low-pass filter. Let's write the equation while keeping the $\theta_0$ factor:

$ y(t) \times LO_{Receiver}(t) = {A(t)\cos(2\pi f_0t + \theta_0)}  \times \cos(2\pi f_0t) \tag {5} $

If we expand the above signal, it can be seen that it has a low-pass component having its energy around $0 Hz$ and a high-pass component with energy around $2f_0 Hz$. If the signal is passed through a low-pass filter the high-frequency component is removed and the resulting signal is:

$ {1 \over 2} A(t)\cos(\theta _0) \tag {6} $

We have Alice's voice there multiple by a factor $\cos(\theta_0)$ that can be zero depending on when Bob decided to turn his receiver on! So there is a serious problem with Bob's radio receiver if he doesn't turn it on at the right time. He might be getting all of the Alice's voice (from an amplitude point of view), he might be getting an attenuated version of Alice's voice or he might get nothing at all.

The problem here is that the oscillator on Bob's receiver is not in-phase with the transmitter and it needs to lock its phase to that of the transmitter. By the locking the phase, we mean knowing the $\theta_0$ that was introduced because of the time delay. That's one of the areas where PLLs find their application.

Please note that $\theta_0$ would have been also introduced if the distance between the transmitter and the receiver was not equal to an integer number of wavelengths. Also, if either the transmitter or the receiver were moving, we would have had a phase difference too. There are many factors that can result into a phase difference between a transmitter and a receiver...

Besides what we mentioned, there is actually another problem here too: if $\theta _0 = \pi/2$, what Bob gets is initially zero and will (theoretically) stays zero forever no matter what processing is made on the (equal-to-zero) received signal. We will see later that this problem can be solved using a Quadrature Demodulator.

1.3 Another Example

The example given in this subsection is not directly related to the wireless communications but it shows another problem of out-of-phase signals.

In clock-synchronous digital electronics, bits (logical states) are transferred/received at specific moments with respect to a clock signal. So the receiver (probably a flip-flop) must either use the transmitter's clock or synchronize its own clock to that of the transmitter (actually there are many workarounds for passing data from one clock domain to another but in this article we focus on PLLs only). For example, in the physical layer of some standards of Ethernet, a sequence of bits (alternating ones and zeros) is required at the beginning of each frame so the receiver can synchronize its clock. Here too, PLLs can help!

2. Quadrature Demodulators

In the previous section we saw that one essential problem with Bob's receiver was that it could be receiving a very weak signal depending on the phase offset between the transmitter's and the receiver's local oscillators. Here, we are assuming that there is no frequency mismatch between the local oscillators, an assumption that can never be true in real world. For now, we continue with the assumption of ideally-equal frequencies at both the transmitter and the receiver and we will later see how a PLL can solve that problem too.

If the receiver uses two sinusoids, with a phase difference between them, to demodulate the air signal, the problem of receiving an all-zero signal will be solved. So the receiver should use both $\cos(2 \pi f_0 t)$ and $\sin(2 \pi f_0 t)$ to demodulated the incoming signal. 

By using two orthogonal tones, it is guaranteed that all of the air signal's energy is received properly. You can verify this by redoing equations $(4)$ to $(6)$ while assuming that $LO(t) = \sin(2\pi f_0t)$ instead of $\cos(2\pi f_0t)$. You can see that $\cos(2\pi f_0t)$ does not get any energy when $\theta_0 = \pi / 2$, but $\sin(2\pi f_0t)$ does. So using two local oscillators in parallel would be a solution.

When implemented, a quadrature demodulator (excluding the gain stages), looks like this:

Quadrature Demodulator

When both the $\sin(2\pi f_0t)$ and the $\cos(2\pi f_0t)$ are used to demodulate the signal, the air signal energy cannot escape! So the received signal energy can be further processed at baseband in order to extract useful information like voice or data bits. In SDR, usually separate A/Ds digitize the $I$ and the $Q$ signals.

We can imagine that the $I(t)$ and the $Q(t)$ form a pair that represents a complex signal. There is nothing wrong with looking at things this way! If we do so, then we can consider the quandrature demodulator as a system that multiplies its input by a complex sinusoid of form $e^{-j2\pi f_0 t}$:

In virtually all SDRs, a quadrature demodulator receives the air signals so in the rest of this blog we will assume that the received signal is demodulated using a quadrature demodulator.


3. Air Sinusoids Received by a Quadrature Demodulator

Let's say we have a transmitter sending a sinusoid having a time-varying phase $\theta(t)$. The sinusoid in the air (RF signal) looks like this:

$ x_{RF}(t) = \cos(2\pi f_0t + \theta(t)) = {0.5 \times [{e^{j(2\pi f_0t + \theta(t))} + e^{-j(2\pi f_0t + \theta(t))} ] }} \tag {7} $

When this signal is received by a quadrature modulator (having a LO frequency of $f_0$), the baseband output ($I(t) + jQ(t)$) looks like:

$ x_{BB}(t) = {1 \over 2} e^{j \theta(t)} \tag {8} $

Here are a two different ways of saying what a baseband PLL does:

- A baseband PLL would like to generate local complex sinusoid $\hat x_{BB}(t)$ that has a phase $\hat \theta(t)$ that resembles $\theta(t)$ (the phase of the received signal) as much as possible.

- A baseband PLL extracts the phase of the received signal ($\theta(t)$).

Note that in many different modulation schemes the data is fully or partially carried by the phase of the transmitted signal i.e., the transmitts modifies the phase of the carrier to send data.

4. The Continuous-Time Baseband PLL

As we said in the previous section, the PLL generates a local copy ($\hat \theta(t)$) of the phase of the received signal ($\theta(t)$). How? By constantly comparing the two. So as the word Phase-Locked Loop suggests, the PLL is actually a feedback loop.

4.1 components of a Baseband PLL

An oversimplified block diagram of the PLL looks like this:

In practice, the Phase Difference Extraction can be implemented as complex multiplication between $e^{j \theta(t)}$ and $e^{-j \hat\theta(t)}$ followed by considering the imaginary part of the result as a measure of phase difference. If $\theta(t)$ and $\hat\theta(t)$ are identical, the result of the multiplication will be purely real.

The Update Local Phase block is actually an integrator (accumulator) having a transfer function of $1\over s$. It accumulates the phases difference (provided by the previous blocks) to generate and update a local copy of the phase of the incoming signal (when the phase difference is zero, nothing is accumulated meaning that the two phases are equal). Since we are working with baseband PLLs, this block remains an integrator otherwise it would have been a VCO (voltage-controlled oscillator).

The Loop Filter block can be a PI (Proportional-Integral) controller. This controller has the following transfer function:

$ C(s) = k_0 + {K_1\over s}  \tag {9} $

The PI controller has the property that, when used in a PLL, it can track both step and ramp changes in the phase of the baseband input signal ($\theta(t)$). The constants $k_0$ and $k_1$ determine how fast the controller responds to inputs.

Based on what we said, the overall block diagram of a PLL looks like:

Let's analyze this and we will be demodulating FM radio in the next tutorial!

4.2 Analysis

We will be forgetting about the $1 \over 2$ factor in the $x_{BB}$. The effect of this factor will be included in $k_0$ and $k_1$. Also, in order to have a linear loop, we will assume that $\theta(t) - \hat\theta(t)$ is small enough so that

$ Imag\{e^{j (\theta(t) - \hat\theta(t))}\} = \sin(\theta(t) - \hat\theta(t)) \approx \theta(t) - \hat\theta(t) \tag {10} $

Using this (valid) approximation, we can rewrite (reconsider) the whole PLL block diagram as a linear system:

This system is easy to analyze as it is a linear feedback system. Solving for $e(t)$ (the error signal) in the s-domain we see that:

$ {E(s) \over {\theta(s)}} =  {1 \over {1 + F(s)/s}} \tag {11} $

This is the relationship between $E(s)$ and $\theta(s)$ in the s-domain. We are interested in this signal as it represents the error (difference) between the phase of the input signal and the locally-generated phase. We want this error to be as zero as possible (for reasonable inputs of course).

Let's say that $\theta(t)$ represents the phase changes in a QPSK signal. In this case, $\theta(t)$ is a step signal (for each phase change).

Let's plug the $\theta(t)$ that represents the unit step into the equation and see what happens to $e(t)$. Note that we are (mostly) interested in the final state of e(t) and not the transient waveform. We would like $e(t)$ to become zero at some known time and stay that way.

Since we are interested in $e(\infty)$ (final state of $e(t)$) we would be using the final value theorem which states that:

$\lim \limits_{t \to \infty} e(t) =  \lim \limits_{s \to 0} sE(s) \tag {12} $

So

$\lim \limits_{t \to \infty} e(t) =  \lim \limits_{s \to 0} {{\theta(s) \times s^2} \over {s + F(s)}}  \tag {13} $

Also, the Laplace transform of the unit step function is ${\Delta \theta_0}\over s$. Plugging the $\theta(s) = {1 \over s}$ into the above equation yields $e(\infty) = 0$ as long as $F(0)$ is finite in the s-domain.

Now let's say that $\theta(t)$ is a ramp. This kind of phase change represents a frequency difference between the transmitter's and receiver's local oscillators. The Laplace transform of the ramp function is ${\Delta \omega_0}\over s^2$. Plugging the $\theta(s) = {1 \over s^2}$ into the above equation yields $e(\infty) = 0$ as long as $F(0)$ is infinite in the s-domain. A PI controller with a transfer function of $k_0 s + {k_1 \over s}$ provides a loop filter $F(s)$ that has infinite gain a $s = 0$.

The step and the ramp in $\theta(t)$ are two very common types of phase change in a received signal in digital and analog telecommunications. And by using the PI controller in the baseband PLL, we can see that the PLL can track the phase in both cases.

4.3 Tuning the PLL

As shown in equation (13), the error signal becomes zero for the step and ramp inputs when a PI controller is used in the PLL. However, this equation does not say much about how fast the error becomes zero. Of course $k_0$ and $k_1$ have a direct impact on the response time of the PLL.

In this tutorial we will not be involved with the mathematics of finding $k_0$ and $k_1$. Instead, we will be using Simulink as a design tool to find the appropriate values for $k_0$ and $k_1$.

The following figure shows a Simulink model (available for download at the top of this page) that is used to tune the PI controller that will be used in a baseband PLL. The input to the system is a 20 KHz square wave and the PI controller is tuned to track the input signal:

You can tune the PI controller manually by double-clocking on the PI controller block. The output of the system as seen in the Scope) is:

The blue line is the 20 KHz input sqaure wave and the purple line is the output of the system.

4.4 The Continuous-Time Baseband PLL in Simulink

The following figure shows the Simulink implementation of the continuous-time baseband PLL. The phase of the input is the sum of a square wave (for which we tuned the PI controller) and a ramp (corresponding to a frequency difference of 1 KHz).

 

Again, the following figure shows how the PLL follows the phase of the input:

The blue line represents the phase of the input signal ramp plus square wave) and the purple line is the output of the PLL.

5. Summary

In this tutorial we covered the basics of baseband continuous-time PLLs. In the future tutorials we will be using these basic concepts to implement different types of discrete-time demodulator.

6. References

[1] Digital Communications: A Discrete-Time Approach, Michael Rice, 2008

[2] Wikipedia, https://en.wikipedia.org/wiki/Main_Page

[3] Digital Communications: Fundamentals and Applications (2nd Edition), Bernard Sklar, 2001


[ - ]
Comment by msoyka38January 30, 2016
A few errata.
1. The frequency factor is missing in the last factor of equation (5).
2. In the last paragraph of section 1.2 you state "if theta-0 equals zero, what Bob gets is initially zero ...". This does not follow from equation (6). Your statement would be correct if theta-0 were pi/2 (as you state in section 2).

Otherwise, a very nice article. I look forward to part 2.
[ - ]
Comment by rameliJanuary 30, 2016
Hi msoyka,

Thanks a lot for your comment. I will be check the errors immediately. Also, Part 2 is almost finished and will be published very soon.

Reza
[ - ]
Comment by fvds12August 14, 2018

Hi,

very nice article.

Any chance for the 2nd and third parts (discrete-time baseband  and applications)?


[ - ]
Comment by rameliAugust 15, 2018

Hi,


Part 2 is ready but I've been too lazy. Please stay tuned :)

[ - ]
Comment by joshuablancoNovember 25, 2016

thanks, is a really good article support material.

but i have a question in 4.1 part (9)eq, you wrote that C(s)=K0s+Ki/s, "K0s" is not a derivative control ? 

[ - ]
Comment by rameliAugust 15, 2018

Hi,


In eq.9, I don't see the derivative component i.e., the s after k0. So it is not a derivative control. 


Do you see an s in your browser?

[ - ]
Comment by sahmadimehrNovember 5, 2018

Hi Reza,

One question is that. How s-domain work for loop filter which is low frequency. but at the output total s-domain transfer function around the Carrier. where this up-conversion happens? I mean the loop filter bandwidth is 500Khz, how can this up-converted going around carrier (e.g. 1G + 500Khz). I could not differentiate in S domain.


Thanks

[ - ]
Comment by rameliNovember 6, 2018

Hi sahmadimehr,

Starting from section 4 (The Continuous-Time Baseband PLL), everything that is discussed is in the baseband.

It is assumed that the RF signal has been down-converted by a quadrature demodulator as discussed in sections 2 and 3.

So, we are not dealing with any RF carriers in section 4.

[ - ]
Comment by sahmadimehrNovember 7, 2018

Thanks for reply.

But how doses this happen inside of pll (No quadrature modulation in PLL itself). The output high frequency of oscillator (Model is 1/s) is fed back (through divider by N) to the input and compare through PFD and then filtered to create control voltage. now model of filter is (e.g, 1/(s+a)). both oscillator and filter has the s-domain model. my question is that how we can intuitively describe that when we plot the TF of output phase/input phase. it is around oscillator carrier but for filter the "s" is baseband frequency?

To post reply to a comment, click on the 'reply' button attached to each comment. To post a new comment (not a reply to a comment) check out the 'Write a Comment' tab at the top of the comments.

Please login (on the right) if you already have an account on this platform.

Otherwise, please use this form to register (free) an join one of the largest online community for Electrical/Embedded/DSP/FPGA/ML engineers: