- [[#Overview]]
- [[#The Time Domain]]
- [[#The Carrier Wave]]
- [[#The Data Wave]]
- [[#The BPSK Wave]]
- [[#The Frequency Domain]]
- [[#The Carrier Wave]]
- [[#The Data Wave]]
- [[#Derivation of the Fourier Series of a Square Wave]]
- [[#Plot Construction of the Fourier Series of a Square Wave]]
- [[#BPSK of a Square Wave]]
- [[#The Frequency Domain of Rectangular Waves]]
- [[#Conclusions and More Questions]]
- [[#Connections | Questions:]]
# Overview
**Binary Phase Shift Keying (BPSK) is a modulation technique used in satellite communications, Bluetooth, and other applications**. The modulation works by combining a carrier signal with a stream of digital bits to form a modulated signal. The resulting spectrum is unintuitive at first glance. The BPSK appears as a set of rolling hills (_mario hills_) with nulls at the symbol rate. We can rebuild the spectrum in Python and answer the following questions:
1. Why are there nulls at the symbol rate?
2. What does the carrier wave and data wave look like in the Time and Frequency domains?
3. If we take an arbitrary subset of the frequency span, what data are we actually looking at?
We will start by looking at both signals in the time domain and exploring how each part contributes to the BPSK signal. We will then discuss convolution and Fourier Series as we convert to the frequency domain. Finally, we will rebuild the BPSK wave and, in doing so, understand its key characteristics.
# The Time Domain
## The Carrier Wave
Modulation is the technique of combing a data wave with a carrier wave. This is beneficial in the current age because it shifts the digital signal to a unique frequency to make it discernible from all the other digital signals being transceived. Imagine if 2 people had bluetooth headphones that were set to the same frequency. They would both get eachothers music and neither source would make sense. By modulating the data to a specific frequency, those issues can be avoided.
The carrier wave is a time-independent sine wave:
$y(t) = A\sin(2\pi f t + \phi)$
$A$ is amplitude and can be set to untiy for the ideal case. This value doesn’t affect the modulation in a meaningful way for our purposes so it will be ignored for the rest of the time.
$f$ is frequency, measured in oscillations per second. Figure 1 can be inspected and the frequency is found to be 5 Hz.
$\phi$ is phase and and similar to amplitude, is not relevant for the BPSK discussion and will be set to 0 (or any integer multiple of $2\pi$ 😉).
![[4 - Attachments/image 20.png|image 20.png]]
Figure 1: An arbitrary sine wave in the time domain with frequency 5 Hz.
## The Data Wave
Data, from any digital source, is stored in a series of 1s and 0s, binary numbers. The first step in modulating this data is to apply a line-encoding. There are many types of line-encodings but we will use the Non-Return to Zero (NRZ) which maps the 0s to -1s and keeps the 1s the same. This type of encoding is used so that data is always an active signal (i.e. a powered off line will not be interpreted as a string of 0s).
We need to make two key assumptions about the binary data that we are modulating:
1. The data stream is infinitely long
2. The data stream is random
These may seem like extreme considerations but let’s break it down. Firstly, each 1 or 0 is a bit and many internet speeds are 1 Gbps which means 1,000,000,000 bits per second, and in one minute of transmission we can send 60 billion bits. With 60 billion bits a minute, the jump to infinity doesn’t seem so far away. Secondly, data is actually pseudo-randomized in practice to avoid long strings of 1s or 0s. Typically binary data can be interpreted by measuring the rising or falling edge of the data. If there is too long of one value, the receiver may miss or add an extra bit if its internal clock is slightly different than the transponder. Furthermore, with infinite numbers, we will also see patterns (even if separated by other data, represented as a dot) such as
```JavaScript
[1 . 0 . 1 . 0]
[1 . 1 . 0 . 0 . 1 . 1 . 0 . 0]
[1 . 1 . 1 . 0 . 0 . 0 . 1 . 1 . 1 . 0 . 0 . 0]
etc etc etc
```
![[4 - Attachments/image 1 8.png|image 1 8.png]]
Figure 2: An arbitrary data wave with NRZ encoding
## The BPSK Wave
The BPSK wave is the multiplication of the carrier wave and the data wave. At each point in time $t$ we multiply the corresponding amplitudes of the sine wave and the data wave. When the data is 1, the resultant wave looks the same as the sine wave. When the data is 0 (-1 for NRZ), the wave is its inverse. Another way to think about it is that the carrier is actually shifted 180 degrees, this is where the name “Binary Phase Shift Keying” comes from.
For $d(t) = 1$,
$d(t) \cdot y(t) = 1\cdot \sin(2\pi f t)=y(t)$
For $d(t) = -1$,
$d(t) \cdot y(t) = -1\cdot \sin(2\pi f t)$
Using the trigonometrc identity
$\sin(a)\cos(b)=\sin(a+b)-\cos(a)\sin(b)$
$\sin(2\pi f t)\cos(\pi)=\sin(2\pi ft+\pi)-\cos(2\pi f t)\sin(\pi)$
$d(t)\cdot y(t)=sin(2\pi ft+\pi)$
Therefore,
$d(t)\cdot y(t) = \begin{cases} \sin(2\pi ft), & \text{for } d(t) = 1 \\ \sin(2\pi ft+\pi), & \text{for } d(t) = -1\end{cases}$
![[4 - Attachments/image 2 4.png|image 2 4.png]]
Figure 3a: BPSK of all 1s
![[4 - Attachments/image 3 4.png|image 3 4.png]]
Figure 3b: BPSK of all 0s (-1 NRZ)
With this we can take a look at what happens with we use a data signal that is a combination of 1s and -1s. The resultant BPSK shifts forward and back 180°
![[4 - Attachments/image 4 4.png|image 4 4.png]]
Figure 4: BPSK of a simple wave with random data signal
There are two more aspects of the BPSK wave to discuss. We need to determine how quickly we want to be able to transition between 1 and -1, the _symbol rate_. In Figure 4 the data changes at most once per 0.1 seconds which makes our symbol rate 1 over 0.1 or 10 baud (signal changes per second). Secondly, we need to choose _when_ we synchronize our carrier and data rate. In all the previous examples, the data rate would only change at the zero-crossing of the carrier frequency but that doesn’t need to be the case. We can shift our starting carrier phase to create some interesting BPSK spectra, but the information carried is still the same.
> [!important] Some transceivers expect a specific synchronization between the data and the carrier because of real-world limitations.
![[4 - Attachments/image 5 4.png|image 5 4.png]]
Figure 5a: BPSK with shifted carrier phase
![[4 - Attachments/image 6 3.png|image 6 3.png]]
Figure 5b: BPSK with shifted carrier phase
We have successfully built a BPSK in the time domain. However, this does not look like the promised _mario hills_. To get the desired plot, we need to convert to the frequency domain. The carrier and data waves must be converted to the frequency domain using Fourier Transforms. Once we have these, they will need to be convolved together. Convolution is used rather than multiplication because of the convolution theorem, which states
> [!important] Multiplication in the time/frequency domain is convolution in the frequency/time domain
# The Frequency Domain
## The Carrier Wave
The frequency domain has amplitude on the y-axis and frequency o the x-axis, instead of time. For a continuous wave tone (a fixed frequency time wave), the plot in the frequency domain is shown in Figure 6:
![[4 - Attachments/image 7 3.png|image 7 3.png]]
Figure 6: A Fourier Transform of a Sine Wave
The plot has two peaks, one at 2.5 kHz and another at -2.5 kHz. We have proved previously that a negative sine wave is equivalent to a positive sine wave with a phase shift. The Frequency domain thus cannot tell these two apart, and thus plots them both equally. Since negative frequencies do not exist, only the positive frequencies are shown (Figure 7):
![[4 - Attachments/image 8 3.png|image 8 3.png]]
Figure 7: The positive side of the Fourier Transform of a sine wave
This is the carrier wave in the frequency domain. The frequency shown is arbitrary and any real frequency will work.
## The Data Wave
The data wave is composed of 1s and 0s (-1s). We will start with the simplest case, altering data bits which form a square wave. The frequency of the square wave in Figure 8 is 25 Hz, and a symbol rate of 50 symbols per second.
We can mathematically describe a square wave as:
$f(x) = \begin{cases} 1, & \text{for } Lm < x < L(m+1) \\ -1, & \text{otherwise}\end{cases}$
Where,
$L$ is the half period (length of 1 symbol)
$m$ is an even integer
![[4 - Attachments/image 9 3.png|image 9 3.png]]
Figure 8: A time domain representation of square NRZ data
Taking the Fourier Transform results in Figure 9.
![[4 - Attachments/image 10 3.png|image 10 3.png]]
Figure 9: Fourier Transform of a Square Wave with Symbol Frequency 25
The above plot is interesting in the fact that it looks like the square wave is actually a combination of many CW tones. We should that a sine wave of frequency $f$ will have a tone in the Frequency Domain at $f$. This means that:
$y(f) = A_1\sin(\frac{1}{L}2\pi f)+A_2\sin(\frac{3}{L}2\pi f)+A_3\sin(\frac{5}{L}2\pi f)+...$
… equals a square wave.
Where $A_n$ are some amplitude coefficients.
### Derivation of the Fourier Series of a Square Wave
To fully appreciate this concept, a square wave is just a series of sine waves, we need to derive the formula usig the Fourier Series equation. Recall that the Fourier Series is an expansion of a periodic function in terms of infinite sums of sines and cosines (I’d love to prove this but we really don’t have time…)
$f(x) = a_0 + \sum_{n=1}^{\infty} \left(a_n \cos\frac{n\pi x}{L} + b_n \sin\frac{n\pi x}{L}\right)$
Where
$n$: coefficient number (more below)
$a_0 = \frac{1}{2L}\int_{-L}^{L} f(x)\,dx$
$a_n = \frac{1}{L}\int_{-L}^{L} f(x)\cos(\frac{n\pi x}{L})\,dx$
$a_n = \frac{1}{L}\int_{-L}^{L} f(x)\sin(\frac{n\pi x}{L})\,dx$
We now need to solve this coefficients by inputting the square wave formula and solving. For all of these integrals, we will have to split them in two because our original function is piecewise.
$a_0 = \frac{1}{2L}\int_{-L}^{0} f(x)\,dx+\frac{1}{2L}\int_{0}^{L} f(x)\,dx$
Recall our piecewise function of a square wave and we can fill in the values:
$a_0 = \frac{1}{2L}\int_{-L}^{0} -1\,dx+\frac{1}{2L}\int_{0}^{L} 1\,dx$
$a_0 = -\frac{1}{2L} \Big(\, -x \Big\vert_{-L}^{0} + x \Big\vert_{0}^{L}\Big)$
$a_0 = -\frac{1}{2L} \Big(\, -0 - L + L-0\Big)$
We’ve found $a_0=0$, one coefficient down, two infinities to go. Moving onto the $a_n$ coefficients, we will split the integral the same way as before
$a_n = \frac{1}{L}\int_{-L}^{0} -\cos(\frac{n \pi x}{L})\,dx+\frac{1}{L}\int_{0}^{L} \cos(\frac{n \pi x}{L})\,dx$
$a_n = -\frac{1}{L}\frac{L}{n\pi} \sin(\frac{n \pi x}{L})\Big\vert_{-L}^{0}+\frac{1}{L}\frac{L}{n\pi} \sin(\frac{n \pi x}{L})\Big\vert_{0}^{L}$
$a_n = \frac{1}{n \pi}\Big(- \Big(\sin\Big(\frac{n \pi 0}{L}\Big)-\sin\Big(\frac{-n \pi L}{L}\Big)\Big)+ \sin\Big(\frac{n \pi L}{L}\Big)-\sin\Big(\frac{n \pi 0}{L}\Big)\Big)$
$a_n = \frac{1}{n \pi}(-(0-\sin(-n \pi))+ \sin(n \pi)-0)$
$a_n = \frac{1}{n \pi}(-\sin(n \pi)+ \sin(n \pi))$
$a_n =0$
Therefore, all $a_n$ coefficients are equal to zero and thus, there are no cosines in the Fourier Series of a square wave.
Moving onto the $b_n$ coefficients, we can follow similar steps:
$b_n = \frac{1}{L}\int_{-L}^{0} -\sin(\frac{n \pi x}{L})\,dx+\frac{1}{L}\int_{0}^{L} \sin(\frac{n \pi x}{L})\,dx$
$b_n = \frac{1}{L}\frac{L}{n\pi} \cos(\frac{n \pi x}{L})\Big\vert_{-L}^{0}-\frac{1}{L}\frac{L}{n\pi} \cos(\frac{n \pi x}{L})\Big\vert_{0}^{L}$
$b_n = \frac{1}{n \pi}\Big(\cos\Big(\frac{n \pi 0}{L}\Big)-\cos\Big(\frac{-n \pi L}{L}\Big)-\Big(\cos\Big(\frac{n \pi L}{L}\Big)-\cos\Big(\frac{n \pi 0}{L}\Big)\Big)\Big)$
$b_n = \frac{1}{n \pi}(1-\cos(n \pi)-\cos(n \pi)+1)$
$b_n = \frac{2}{n \pi}(1-\cos(n \pi))$
Something interesting happens at this step. Since $n$ is any natural number and a cosine function is periodic about $2 \pi$, we end up with just two cases for $b_n$ : when $n$ is even, and when $n$ is odd:
$b_n = \begin{cases}\frac{4}{n \pi}, & n\text{ is odd} \\ 0, & n\text{ is even}\end{cases}$
Putting this back into the Fourier Series equation:
$f(x) = \frac{4}{\pi}\sum_{n=1,3,5,..}^{\infty} \left(\frac{1}{n} \sin\frac{n\pi x}{L}\right)$
This is equivalent to the equation we deduced from the plot of the Fourier Transform of the square wave.
### Plot Construction of the Fourier Series of a Square Wave
If we start to plot the individual components of the Fourier Series, we see that as $n$ increases, the frequency of the component increases, but each sine wave continues to have a zero-crossing at $L, -L,\,2\.L,-2L, \text{etc}$.
![[4 - Attachments/image 11 2.png|image 11 2.png]]
Figure 10: Components of the Square Wave Fourier Series
As sine waves are added together, the shape of the square wave begins to form. Figure 11 shows the series for $n$ = 1, 5, 9, and 13. Two important notes from this plot:
1. The nulls of the fundamental frequency persist
2. The entire plot consists of sine waves with increasing frequency $\frac{1}{L}\,,\frac{3}{L}\,,\frac{5}{L}\,,\text{etc}$
![[4 - Attachments/image 12 2.png|image 12 2.png]]
Figure 11: Fourier Series of a square wave for increasing n
We then convert this time series of a square wave to the Frequency Domain. Since the square wave is a sum of sine waves, we expect to see tones at their frequencies listed in 2. above. Our wave has a symbol length of 0.04 so we should see tones at 25, 75, 125, etc.
![[4 - Attachments/image 13 2.png|image 13 2.png]]
Figure 12: Frequency domain of the Fourier Series of a Square Wave
# BPSK of a Square Wave
We now have our Fourier Series of the Carrier wave and of the (simple) data wave. Recall that we got the BPSK in the time domain through multiplication, however in the Frequency domain we must take the convolution. In simple terms, the convolution recenters the data wave so that it’s 0 point is now at the carrier frequency. Since the carrier is much higher than 0, the formally negative frequencies of the Fourier transform are now positive.
![[4 - Attachments/image 14 2.png|image 14 2.png]]
Figure 13: Frequency domain of a BPSK square wave
> [!important] This is an idle pattern that is used in communications to maintain a carrier lock whilst no data is being transmitted.
We see the same tones now but as an offset to the carrier frequency. Instead of ±25, ±75, ±125, we see 2500±25, 2500±75, 2500±125, or 2325, 2375, 2425, 2475, 2525, 2575, 2625, 2675. This is our BPSK signal from the thumbnail and we do see nulls at integer multiples of the symbol rate (50), but it doesn’t look complete. This is because of the assumption made about the data being strictly a square wave.
## The Frequency Domain of Rectangular Waves
A rectangle wave is the same as a square wave expect $L$ is now a multiple of any natural number $m$. We can resolve the equation, combine our square and rectangle waves to get closer to the real BPSK signal.
Figure 14 shows the Fourier Series of the superposition rectangle waves with increasing complexity along with it’s BPSK counterpart. The nulls at the integer multiples of the symbol rate persist and the “hills’ are starting to take shape.
The frequency of the square wave was shown to be $\frac{n}{2L}$and a rectangular wave is $\frac{n}{2mL}$. The nulls are still present at the symbol rate which can be proven by contracdiction. That is, we assume that the frequency _can_ equal the symbol rate and then contradict it:
$\frac{n}{2mL}=\frac{1}{L}$
$n=2m$
This fits the definition that $n$ is _even_, however we showed that $n$ must be _odd_, therefore the frequency can never be equal to the symbol rate.
![[4 - Attachments/image 15 2.png|image 15 2.png]]
Figure 14: Data waves of L 1, 2, and the BPSK signal
![[4 - Attachments/image 16 2.png|image 16 2.png]]
Figure 15: Data waves of L 1, 2, 3, and the BPSK signal
![[4 - Attachments/image 17 2.png|image 17 2.png]]
Figure 16: Data waves of L 1, 2, 3, 4 and the BPSK signal
Finally we are getting close to the thumbnail. We can compare at Figure 17 and Figure 18 and they are starting to look alike.
![[4 - Attachments/image 18 2.png|image 18 2.png]]
Figure 17: Data waves of L 1, 2, 3, 4 and the BPSK signal
![[4 - Attachments/image 19 2.png|image 19 2.png]]
Figure 18: Data wave Fourier Series and BPSK of randomly generated data
# Conclusions and More Questions
We now revisit the original questions with satisfying answers.
1. Why are there nulls at the symbol rate?
1. The nulls at the integer multiples of the symbol rate are because through the derivation of the Fourier Series of a rectangular wave, we proved that it is a summation of sine waves with odd integer multiples of the symbol length (and integer multiples thereof).
2. What does the carrier wave and data wave look like in the Time and Frequency domains?
1. Look back and explore the figures
3. If we take an arbitrary subset of the frequency span, what data are we actually looking at?
1. A section of the BPSK signal contains a set of sine waves at specific frequencies. The frequencies correspond to certain lengths of rectangular waves
Some more questions that continue from this topic:
1. Prove there will never be a sine component of the rectangle wave with a frequency of that of the symbol rate (or integer multiple therefore)
2. What do higher data modulation waves look like, QPSK, 8-PSK, etc? What conclusions can we draw from the fact that a QPSK signal with double the information rate looks identical to that of a BPSK signal?
3. What is changed about this signal in deep space applications? What is a residual carrier and how does modulation index affect the signal?
![[Connect#Connect]]