MPSK modulation: simulate in Matlab & Python

A generic complex baseband simulation technique, to simulate all M-ary phase shift keying (M-PSK) modulation techniques is given here. The given simulation code is very generic, and it plots both simulated and theoretical symbol error rates for all MPSK modulation techniques.

M-ary phase shift keying (M-PSK) modulation

In phase shift keying, all the information gets encoded in the phase of the carrier signal. The M-PSK modulator transmits a series of information symbols drawn from the set m∈{1,2,…,M}. Each transmitted symbol holds k bits of information (k=log2(M)). The information symbols are modulated using M-PSK mapping.

Signal space constellations for various MPSK modulations
Figure 1: Signal space constellations for various MPSK modulations

The general expression for a M-PSK signal set is given by

general equation for MPSK modulation

Here, M denotes the modulation order and it defines the number of constellation points in the reference constellation. The value of M depends on the parameter k – the number of bits we wish to squeeze in a single MPSK symbol. For example if we wish to squeeze in 3 bits (k=3) in one transmit symbol, then M = 2k = 23 = 8 and this results in 8-PSK configuration. M=2 gives binary phase shift keying (BPSK) configuration. The configuration with M=4 is referred as quadrature phase shift keying (QPSK). The parameter A is the amplitude scaling factor. Using trigonometric identity, equation (1) can be separated into cosine and sine basis functions as follows

general equation for MPSK modulation separated as cosine sine basis functions

This can be expressed as a combination of in-phase and quadrature phase components on an I-Q plane as

general equation for MPSK modulation on IQ plane

Normalizing the amplitude as A=1/\sqrt{2}, the points on the reference constellation will be placed on the unit circle. The MPSK modulator is constructed based on this equation and the ideal constellations for M=4,8 and 16 PSK modulations are shown in Figure 1.

Matlab code

Full Matlab code available in the book Digital Modulations using Matlab – build simulation models from scratch

function [s,ref]=mpsk_modulator(M,d)
%Function to MPSK modulate the vector of data symbols - d
%[s,ref]=mpsk_modulator(M,d) modulates the symbols defined by the
%vector d using MPSK modulation, where M specifies the order of
%M-PSK modulation and the vector d contains symbols whose values
%in the range 1:M. The output s is the modulated output and ref
%represents the reference constellation that can be used in demod
   ref_i= 1/sqrt(2)*cos(((1:1:M)-1)/M*2*pi);
   ref_q= 1/sqrt(2)*sin(((1:1:M)-1)/M*2*pi);
   ref = ref_i+1i*ref_q;
   s = ref(d); %M-PSK Mapping
end

Python code

Full Python code available in the book Digital Modulations using Python

modem.py: PSK modem - derived class
class PSKModem(Modem):
	# Derived class: PSKModem
	def __init__(self, M):
		#Generate reference constellation
		m = np.arange(0,M) #all information symbols m={0,1,...,M-1}
		I = 1/np.sqrt(2)*np.cos(m/M*2*np.pi)
		Q = 1/np.sqrt(2)*np.sin(m/M*2*np.pi)
		constellation = I + 1j*Q #reference constellation
		Modem.__init__(self, M, constellation, name='PSK') #set the modem attributes
.
.
.

This article is part of the following books
Digital Modulations using Matlab : Build Simulation Models from Scratch, ISBN: 978-1521493885
Digital Modulations using Python ISBN: 978-1712321638
All books available in ebook (PDF) and Paperback formats

M-PSK demodulation (coherent detection)

Generally the two main categories of detection techniques, commonly applied for detecting the digitally modulated data are coherent detection and non-coherent detection.

In the vector simulation model for the coherent detection, the transmitter and receiver agree on the same
reference constellation for modulating and demodulating the information. The modulators generate the reference constellation for the selected modulation type. The same reference constellation should be used if coherent detection is selected as the method of demodulating the received data vector.

On the other hand, in the non-coherent detection, the receiver is oblivious to the reference constellation used at the transmitter. The receiver uses methods like envelope detection to demodulate the data.

The IQ detection technique is an example of coherent detection. In the IQ detection technique, the first step is to compute the pair-wise Euclidean distance between the given two vectors – reference array and the received symbols corrupted with noise. Each symbol in the received symbol vector (represented on a p-dimensional plane) should be compared with every symbol in the reference array. Next, the symbols, from the reference array, that provide the minimum Euclidean distance are returned.

Let x=(x1,x2,…,xp) and y=(y1,y2,…,yp) be two points in p-dimensional space. The Euclidean distance between them is given by

Pairwise Euclidean distance equation

The pair-wise Euclidean distance between two sets of vectors, say x and y, on a p-dimensional space, can be computed using the vectorized code. The vectorized code returns the ideal signaling points from matrix y that provides the minimum Euclidean distance. Since the vectorized implementation is devoid of nested for-loops, the program executes significantly faster for larger input matrices. The given code is very generic in the sense that it can be easily reused to implement optimum coherent receivers for any N-dimensional digital modulation technique (Please refer the books Digital Modulations using Matlab and Digital Modulations using Python for complete simulation code) .

Matlab code

Full Matlab code available in the book Digital Modulations using Matlab

function [dCap]= mpsk_detector(M,r)
%Function to detect MPSK modulated symbols
%[dCap]= mpsk_detector(M,r) detects the received MPSK signal points
%points - 'r'. M is the modulation level of MPSK
   ref_i= 1/sqrt(2)*cos(((1:1:M)-1)/M*2*pi);
   ref_q= 1/sqrt(2)*sin(((1:1:M)-1)/M*2*pi);
   ref = ref_i+1i*ref_q; %reference constellation for MPSK
   [˜,dCap]= iqOptDetector(r,ref); %IQ detection
end

Python code

Full Python code available in the book Digital Modulations using Python

Performance simulation results

The simulation results for error rate performance of M-PSK modulations over AWGN channel and Rayleigh flat-fading channel is given in the following figures.

Error rate performance of MPSK modulations in AWGN channel
Figure 2: Error rate performance of MPSK modulations in AWGN channel
Error rate performance of MPSK modulations in Rayleigh flat-fading channel
Figure 3: Error rate performance of MPSK modulations in Rayleigh flat-fading channel

Rate this article: PoorBelow averageAverageGoodExcellent (4 votes, average: 3.25 out of 5)

Reference

[1] John G. Proakis, “Digital Communciations”, McGraw-Hill; 5th edition.↗

Related Topics

Digital Modulators and Demodulators - Complex Baseband Equivalent Models
Introduction
Complex baseband representation of modulated signal
Complex baseband representation of channel response
● Modulators for amplitude and phase modulations
 □ Pulse Amplitude Modulation (M-PAM)
 □ Phase Shift Keying Modulation (M-PSK)
 □ Quadrature Amplitude Modulation (M-QAM)
● Demodulators for amplitude and phase modulations
 □ M-PAM detection
 □ M-PSK detection
 □ M-QAM detection
 □ Optimum detector on IQ plane using minimum Euclidean distance
● M-ary FSK modulation and detection
 □ Modulator for M orthogonal signals
 □ M-FSK detection

Books by the author

Wireless Communication Systems in Matlab
Wireless Communication Systems in Matlab
Second Edition(PDF)

PoorBelow averageAverageGoodExcellent (159 votes, average: 3.81 out of 5)

Digital modulations using Python
Digital Modulations using Python
(PDF ebook)

PoorBelow averageAverageGoodExcellent (122 votes, average: 3.60 out of 5)

digital_modulations_using_matlab_book_cover
Digital Modulations using Matlab
(PDF ebook)

PoorBelow averageAverageGoodExcellent (125 votes, average: 3.69 out of 5)

Hand-picked Best books on Communication Engineering
Best books on Signal Processing

13 thoughts on “MPSK modulation: simulate in Matlab & Python”

  1. How come SOQPSK-TG is not addressed in your tutorial. Telemetry Group Standard 106-20.does not explain that very well. perhaps you can write tutorial how OQPSK , SOQPSK-TG and CPM are related/

    Reply
  2. Hi, don’t you think that class is something bigger just one method. No need to use a class for every modulation type, just use functions. class is for more complex problems.

    Reply
    • Complete code is not given in this page. Please understand, the full code is available only in the ebook.

      I have used classes in such a way that the code is generic, optimized and reusable. Moreover, it is easier to build on to these generic classes to implement complex systems.

      Reply
    • AWGN model is a fundamental and the simplest mathematical model. Other propagation models exist that are suitable for modeling the radio channels encountered in LTE downlinks. Examples include

      Stanford University Interim (SUI) model
      Okumura model
      Hata COST 231 model
      COST Walfisch-Ikegami
      Ericsson 9999 model

      Reply

Post your valuable comments !!!