# QPSK modulation and Demodulation

### 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.

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

### Recommended Books

### Your Thoughts ?

#### 14 Comments Already

#### 4 pingbacks/trackbacks

- Simulation of M-PSK modulation techniques in AWGN channel | GaussianWaves
- Simulation of Symbol Error Rate Vs SNR performance curve for 16-QAM in AWGN | GaussianWaves
- Simulation of Symbol Error Rate Vs SNR performance curve for 64-QAM in AWGN | GaussianWaves
- What is the difference between 4QAM and QPSK and what is I and Q components?

i found in other reference, the equation for qpsk :

s(t)=Acos(wt+(n-1)(phi/2)

it means, the diagram constellation placed syombol on 0, 90, 180, 270..

not 45,135,225,315

is there an effect for qpsk modulation with that differennce place of symbol?

That is equation is for non-offset QPSK. PSK modulation has lot of variations like OQPSK (offset QPSK), pi/4-QPSK, DQPSK (differential QPSK),etc..,

In reality pi/4-QPSK modulation uses two constellations (dual constellations) which are shifted by 45* with respect to each other. Only either the odd or even symbol are allowed to select a point from one of the constellations while the other chooses the point from the other constellation.

This reduces the maximum phase shift from 180* to 135*. Reduction of maximum phase shift implies reduction of bandwidth and reduction of overshoot (minimized side lobes)

Hi Mathuranathan,

I am new to MATLAB and i need some help in generating MATLAB code for QPSK. I have tried to modify your code to produce the required result but no success. I need to generate/plot a polarised version of the bit stream “00 01 01 01 01 10 11 10″ for input into a QPSK modulator (odd bits = 00 00 01 11; even bits =01 11 10 10). I also need a polarised version of the odd and even bits plotted. The odd and even bits are then multiplied by +/-(sqrt2) and then modulated by carriers cos(wt) and -sin(wt). The two modulated signals are then combined to produce QPSK. plots of the modulated odd bits, modulated even bits and the QPSK signals included. The carrier frequency is 1600Hz with two cycles of carrier during each symbol (baud rate =800 symbols per sec, symbol duration =1.25mS).

At the other end, a plot of the two demodulated signals and the instantaneous waveforms of the integrators.

Hello sir,

I am trying to understand this program.I unable to understand what is the need for NRZ encoder.Can you explain me please….

Hi Naveed,

Understand that the NRZ encoder converts 0′s and 1′s into -1 and +1 respectively. In any digital modulation technique, the user input interms of 0′s and 1′s has to be converted to -1′s and +1s, each bits with a definite bit duration. For this purpose, a NRZ encoder is used.

hi

i think there is a small error in the line:

‘Modulation is achieved by varying the phase of the basis functions depending on the message symbols.’

instead of the word ‘phase’ in the above line, it should be amplitude of the basis functions depends on the message symbol. the linear combination of the basis functions in turn results in the output function whose phase depends on the message symbol.

I tried this code using unipolar and polar line coding. With polar coding, the reconstructed bit sequence was okay. but with unipolar coding, the reconstructed bit sequence always appeared same (all 1s) in almost all cases. Can anyone tell me the reason for this behaviour ?

Hi can you paste your modified main program.. I will try it out and let you know …

I mean, in the program provided by you, I changed one of the input parameter in NRZEncoder function from polar to unipolar.

Hi,

QPSK modulation is achieved using NRZ (polar) encoding method. If you use unipolar encoding the constellations in trasmitter and receiver will be different.

QPSK modulation has to be simulated with polar encoding. Simulating using unipolar, zeros out the sine/cos components. Because of that your bits are detected wrongly

In QPSK, the inphase component is multiplied by cos and quadrature component by sine. For polar encoding, inphase and quadrature phase components are either +1 and -1 . So there is no problem here.

But when you use unipolar encoding, the inphase or quadrature phase components take value 0 or 1. The value ’0′ will nullify the corresponding cos or sine component and there is no way to recover from this error.

It is not recommended to use unipolar encoding for QPSK modulation as it defeats the basic architecture of the modulation itself.

Hope this helps.