# QPSK modulation and Demodulation

This post is a part of the ebook : Simulation of digital communication systems using Matlab – available in both PDF and EPUB format.

### QPSK Modulation:

In digital modulation techniques a set of basis functions are chosen for a particular modulation scheme.Generally the basis functions are orthogonal to each other. Basis functions can be derived using ‘Gram Schmidt orthogonalization’ procedure.Once the basis function are chosen, any vector in the signal space can be represented as a linear combination of the basis functions.

In Quadrature Phase Shift Keying (QPSK) two sinusoids (sin and cos) are taken as basis functions for modulation. Modulation is achieved by varying the phase of the basis functions depending on the message symbols. In QPSK, modulation is symbol based,where one symbol contains 2 bits. The following equation outlines QPSK modulation technique.

$$ s_i(t)=\sqrt{\frac{2E_s}{T}}cos(2 \pi f_c t + (2n-1) \frac{\pi}{4})\;\; \mbox{,n=1,2,3,4}$$

When \(n=1\), the phase shift is 45 degrees. This is called pi/4 QPSK.The constellation diagram of QPSK will show the constellation points lying on both x and y axes.This means that the QPSK modulated signal will have an in-phase component (I) and also a quadrature component (Q). This is because it has only two basis functions.

A QPSK modulator can be implemented as follows. A demultiplexer (or serial to parallel converter) is used to separate odd and even bits from the generated information bits. Each of the odd bits (quadrature arm) and even bits (in-phase arm) are converted to NRZ format in a parallel manner. The signal on the in-phase arm is multiplied by cosine component and the signal on the quadrature arm is multiplied by sine component. QPSK modulated signal is obtained by adding the signal from both in-phase and quadrature arm.

### QPSK Demodulation:

For QPSK demodulator , a coherent demodulator is taken as an example. In coherent detection technique the knowledge of the carrier frequency and phase must be known to the receiver. This can be achieved by using a PLL (phase lock loop) at the receiver. A PLL essentially locks to the incoming carrier frequency and tracks the variations in frequency and phase. For the following simulation , a PLL is not used but instead we simple use the output of the PLL. For demonstration purposes we simply assume that the carrier phase recovery is done and simply use the generated reference frequencies at the receiver (cos(ωt)) and (sin(ωt)).

In the demodulator the received signal is multiplied by a reference frequency generators (cos(ωt)) and (sin(ωt)) on separate arms (in-phase and quadrature arms). The multiplied output on each arm is integrated over one bit period using an integrator. A threshold detector makes a decision on each integrated bit based on a threshold. Finally the bits on the in-phase arm (even bits) and on the quadrature arm (odd bits) are remapped to form detected information stream. Detector for in-phase arm is shown below. For quadrature arm the below architecture remains same but sin(ωt) basis function must be used instead.

### Matlab Code:

### File1: QPSK.m

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
% Demonstration of QPSK Modulation and Demodulation % % Author: Mathuranathan for http://www.gaussianwaves.com) % License : creative commons : Attribution-NonCommercial-ShareAlike 3.0 % Unported clear; %clear all stored variables N=100; %number of data bits noiseVariance = 0.1; %Noise variance of AWGN channel data=randn(1,N)>=0; %Generate uniformly distributed random data Rb=1e3; %bit rate amplitude=1; % Amplitude of NRZ data oddBits = data(1:2:end); evenBits= data(2:2:end); [evenTime,evenNrzData,Fs]=NRZ_Encoder(evenBits,Rb,amplitude,'Polar'); [oddTime,oddNrzData]=NRZ_Encoder(oddBits,Rb,amplitude,'Polar'); |

Check this book for full Matlab code.

Simulation of Digital Communication Systems Using Matlab – by Mathuranathan Viswanathan

### File2: NRZ_Encoder.m

Check this book for full Matlab code.

Simulation of Digital Communication Systems Using Matlab – by Mathuranathan Viswanathan

The output of the Matlab code provides more insight into the QPSK modulation technique. Apart from plotting the modulated and demodulated signal it also shows the constellation at transmitter/receiver. This Matlab code is written without using any of the inbuilt functions from communication toolbox.

### Simulation Result:

### See also:

[1] BER Vs Eb/N0 for 8-PSK modulation over AWGN

[2] BER Vs Eb/N0 for M-PSK modulation over AWGN

[3] BER Vs Eb/N0 for QPSK modulation over AWGN

[4] Simulation of BER Vs Eb/N0 for BPSK modulation over AWGN in Matlab

[5] Intuitive derivation of Performance of an optimum BPSK receiver in AWGN channel

Pingback: Simulation of M-PSK modulation techniques in AWGN channel | GaussianWaves()

Pingback: Simulation of Symbol Error Rate Vs SNR performance curve for 16-QAM in AWGN | GaussianWaves()

Pingback: Simulation of Symbol Error Rate Vs SNR performance curve for 64-QAM in AWGN | GaussianWaves()

Pingback: What is the difference between 4QAM and QPSK and what is I and Q components?()

Pingback: Constructing a rectangular constellation for 16-QAM | GaussianWaves()

Pingback: Performance comparison of Digital Modulation techniques | GaussianWaves()