Tag Archives: Modulation

Wireless Book

About this book

This textbook covers fundamental topics in Telecommunication including Channel Modeling, Modulation/Demodulation, Channel Coding/Decoding, Multicarrier, Capacity, Antenna Arrays, Diversity, and 4G/5G. It will also cover advanced topics such as High-Resolution Spectral Estimation, Reconfigurable Intelligent Surfaces, Index Modulation, Full-Duplex, and Millimeter Wave. This book will mainly target engineering students (both graduate and advanced undergraduate) who are new to the fields of Communication and Signal Processing and are struggling to understand the fundamental concepts. This book will help the students step by step by introducing the concepts first in their most basic form and then providing the code that the students can experiment with. It contains pedagogical elements such as chapter introductions, end-of-chapter questions and numerical problems, MATLAB/Octave/Python code, figures and tables, and a website (raymaps.com) for feedback and interaction. It will not only be helpful for undergraduate and graduate students but also for professional engineers and hobbyists.

Buy the book here.

About the author

Yasir Ahmed has more than 20 years of experience in various organizations in Pakistan, Europe, and the USA in both Engineering and Management roles. He worked as a Research Assistant in the Mobile and Portable Radio Group (MPRG) of Virginia Tech under the supervision of Dr. Jeff Reed and was one of the first researchers to propose Space Time Block Codes (STBCs) for eight transmit antennas. The collaboration with MPRG has continued over the years and has resulted in 12 research publications and a book on Wireless Communications. Yasir worked as GM SEED at Ignite National Technology Fund, a company involved in supporting the innovation and entrepreneurship ecosystem in the country. He previously worked for Qualcomm USA, leading the physical layer performance and conformance testing of GSM/UMTS modems, and for COMSATS Islamabad as an Assistant Professor, teaching various subjects in the Telecom and Networks area. He was part of the Ignite team that evaluated multi-billion-rupee NIC and DigiSkills programs and has also helped fund a number of startups that have gone on to become successful commercial ventures.

Buy the book here.

Index Modulation Explained

Wireless researchers are continuously exploring ways to increase the spectral efficiency (bits/sec/Hz) and energy efficiency (bits/Joule) of wireless communication systems [1]. Spectral efficiency can generally be improved by using larger constellations or by using multiple antennas at the transmitter and receiver, better known as MIMO. But increasing energy efficiency is not that straightforward. Let’s consider this in bit more detail.

Continue reading Index Modulation Explained

Theoretical BER of M-QAM in Rayleigh Fading

We have previously discussed the Bit Error Rate of M-QAM in Rayleigh Fading using Monte Carlo Simulation. We now turn our attention to calculation of Bit Error Rate (BER) of M-QAM in Rayleigh fading using analytical techniques. In particular we look at the method used in MATLAB function berfading.m. In this function the BER of 4-QAM, 16-QAM and 64-QAM is calculated from series expressions having 1, 3 and 5 terms respectively. These are given below (M is the constellation size and must be a power of 2).

if (M == 4)
     ber = 1/2 * ( 1 - sqrt(gamma_c/k./(1+gamma_c/k)) );
elseif (M == 16)
     ber = 3/8 * ( 1 - sqrt(2/5*gamma_c/k./(1+2/5*gamma_c/k)) ) ...
     + 1/4 * ( 1 - sqrt(18/5*gamma_c/k./(1+18/5*gamma_c/k)) ) ...
     - 1/8 * ( 1 - sqrt(10*gamma_c/k./(1+10*gamma_c/k)) );
elseif (M == 64)
     ber = 7/24 * ( 1 - sqrt(1/7*gamma_c/k./(1+1/7*gamma_c/k)) ) ...
     + 1/4 * ( 1 - sqrt(9/7*gamma_c/k./(1+9/7*gamma_c/k)) ) ...
     - 1/24 * ( 1 - sqrt(25/7*gamma_c/k./(1+25/7*gamma_c/k)) ) ...
     + 1/24 * ( 1 - sqrt(81/7*gamma_c/k./(1+81/7*gamma_c/k)) ) ...
     - 1/24 * ( 1 - sqrt(169/7*gamma_c/k./(1+169/7*gamma_c/k)) );

Although using these expressions we get very accurate BER but it is not that simple to calculate (the expressions become even more complicated for higher constellation sizes such as 256-QAM). Therefore we try to simplify these expressions by using only the first term in each expression. To our surprise the results match quite well with the results using the exact formulae. There is very minor difference at low signal to noise ratios but that can be easily bargained for the ease of calculation.

So here is our program for calculating the BER using the approximate method.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FUNCTION TO CALCULATE THE BER OF M-QAM IN RAYLEIGH FADING
% M: Input, Constellation Size
% EbNo: Input, Energy Per Bit to Noise Power Spectral Density
% ber: Output, Bit Error Rate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [ber]= BER_QAM_fading (M, EbNo)

k=log2(M);
EbNoLin=10.^(EbNo/10);
gamma_c=EbNoLin*k;

if M==4
    %4-QAM
    ber = 1/2 * ( 1 - sqrt(gamma_c/k./(1+gamma_c/k)) );
elseif M==16
    %16-QAM
    ber = 3/8 * ( 1 - sqrt(2/5*gamma_c/k./(1+2/5*gamma_c/k)) );
elseif M==64
    %64-QAM
    ber = 7/24 * ( 1 - sqrt(1/7*gamma_c/k./(1+1/7*gamma_c/k)) );
else 
    %Warning
    warning('M=4,16,64')
    ber=zeros(1,length(EbNo));
end

semilogy(EbNo,ber,'o-')
xlabel('EbNo(dB)')
ylabel('BER')
axis([0 24 0.001 1])
grid on

return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

QAM BER Approximate

So we see that the results match quite well with the results previously obtained through simulation. We will next tackle the problem of simplifying the expression for higher order modulations such as 256-QAM in both Rayleigh and Ricean channels.

M-QAM Bit Error Rate in Rayleigh Fading

We have previously discussed the bit error rate (BER) performance of M-QAM in AWGN. We now discuss the BER performance of M-QAM in Rayleigh fading. The one-tap Rayleigh fading channel is generated from two orthogonal Gaussian random variables with variance of 0.5 each. The complex random channel coefficient so generated has an amplitude which is Rayleigh distributed and a phase which is uniformly distributed. As usual the fading channel introduces a multiplicative effect whereas the AWGN is additive.

The function “QAM_fading” has three inputs, ‘n_bits’, ‘M’, ‘EbNodB’ and one output ‘ber’. The inputs are the number of bits to be passed through the channel, the alphabet size and the Energy per Bit to Noise Power Spectral Density in dB respectively whereas the output is the bit error rate (BER).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FUNCTION THAT CALCULATES THE BER OF M-QAM IN RAYLEIGH FADING
% n_bits: Input, number of bits
% M: Input, constellation size
% EbNodB: Input, energy per bit to noise power spectral density
% ber: Output, bit error rate
% Copyright RAYmaps (www.raymaps.com)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[ber]= QAM_fading(n_bits, M, EbNodB)
% Transmitter
k=log2(M);
EbNo=10^(EbNodB/10);
x=transpose(round(rand(1,n_bits)));
h1=modem.qammod(M);
h1.inputtype='bit';
h1.symbolorder='gray';
y=modulate(h1,x);

% Channel
Eb=mean((abs(y)).^2)/k;
sigma=sqrt(Eb/(2*EbNo));
w=sigma*(randn(n_bits/k,1)+1i*randn(n_bits/k,1));
h=(1/sqrt(2))*(randn(n_bits/k,1)+1i*randn(n_bits/k,1));
r=h.*y+w;

% Receiver
r=r./h;
h2=modem.qamdemod(M);
h2.outputtype='bit';
h2.symbolorder='gray';
h2.decisiontype='hard decision';
z=demodulate(h2,r);
ber=(n_bits-sum(x==z))/n_bits
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

64-QAM Constellation

M-QAM Bit Error Rate in Rayleigh Fading
M-QAM Bit Error Rate in Rayleigh Fading

The bit error rates of four modulation schemes 4-QAM, 16-QAM, 64-QAM and 256-QAM are shown in the figure above. All modulation schemes use Gray coding which gives a few dB of margin in the BER performance. As with the AWGN case each additional bit per symbol requires about 1.5-2 dB in signal to ratio to achieve the same BER.

Although not shown here similar behavior is observed for higher order modulation schemes such as 1024-QAM and 4096-QAM (the gap in the signal to noise ratio for the same BER is increased to about 5dB).

Lastly we explain some of the terms used above.

Rayleigh Fading

Rayleigh Fading is a commonly used term in simulation of Digital Communication Systems but it tends to differ in meaning in different contexts. The term Rayleigh Fading as used above means a single tap channel that varies from one symbol to the next. It has an amplitude which is Rayleigh distributed and a phase which is Uniformly distributed. A single tap channel means that it does not introduce any Inter Symbol Interference (ISI). Such a channel is also referred to as a Flat Fading Channel. The channel can also be referred to as a Fast Fading Channel since each symbol experiences a new channel state which is independent of its previous state (also termed as uncorrelated).

Gray Coding

When using QAM modulation, each QAM symbol represents 2,3,4 or higher number of bits. That means that when a symbol error occurs a number of bits are reversed. Now a good way to do the bit-to-symbol assignment is to do it in a way such that no neighboring symbols differ by more than one bit e.g. in 16-QAM, a symbol that represents a binary word 1101 is surrounded by four symbols representing 0101, 1100, 1001 and 1111. So if a symbol error is made, only one bit would be in error. However, one must note that this is true only in good signal conditions. When the SNR is low (noise has a higher magnitude) the symbol might be displaced to a location that is not adjacent and we might get higher number of bits in error.

Hard Decision

The concept of hard decision decoding is important when talking about channel coding, which we have not used in the above simulation. However, we will briefly explain it here. Hard decision is based on what is called “Hamming Distance” whereas soft decision is based on what it called “Euclidean Distance”. Hamming Distance is the distance of a code word in binary form, such as 011 differs from 010 and 001 by 1. Whereas the Euclidean distance is the distance before a decision is made that a bit is zero or one.  So if the received sequence is 0.1 0.6 0.7 we get a Euclidean distance of 0.8124 from 010 and 0.6782 from 001. So we cannot make a hard decision about which sequence was transmitted based on the received sequence of 011. But based on the soft metrics we can make a decision that 001 was the most likely sequence that was transmitted (assuming that 010 and 001 were the only possible transmitted sequences).

Bit Error Rate of QPSK

Simulating a QPSK system is equivalent to simulating two BPSK systems in parallel. So there is no difference in bit error rate(BER). Since the simulation is at baseband we multiply the in-phase and quadrature streams by 1 and j respectively (instead of cos and sin carriers). At the receiver we just use the real and imag functions to separate the two symbol streams. The BER is the average BER of the two parallel streams.

As in the case of BPSK we can show that the baseband representation (using 1 and j)  is equivalent to using the passband representation (using cosine and sine). Lets assume the following signal model for QPSK.

s(t)=a(t)*cos(2*pi*f*t)+b(t)*sin(2*pi*f*t)

where a(t) and b(t) contain the information to be transmitted over the channel. Now at the receiver we multiply this signal with cos( ) to recover a(t) and sin( ) to recover b(t).

cos(2*pi*f*t)*s(t)

=cos(2*pi*f*t) [a(t)*cos(2*pi*f*t)+b(t)*sin(2*pi*f*t)]

=a(t)*cos(2*pi*f*t)*cos(2*pi*f*t) +b(t)*sin(2*pi*f*t)*cos(2*pi*f*t)

=(a(t)/2)*(1+cos(4*pi*f*t))+(b(t)/2)*sin(4*pi*f*t)

=(a(t)/2)+(a(t)/2)*cos(4*pi*f*t)+(b(t)/2)*sin(4*pi*f*t)

After low pass filtering (LPF) we get (a(t)/2), which it the required in-phase component scaled by a constant 1/2. Similarly we can find the quadrature component b(t).

sin(2*pi*f*t)*s(t)

=sin(2*pi*f*t) [a(t)*cos(2*pi*f*t)+b(t)*sin(2*pi*f*t)]

=a(t)*sin(2*pi*f*t)*cos(2*pi*f*t)+b(t)*sin(2*pi*f*t)*sin(2*pi*f*t)

=(a(t)/2)*sin(4*pi*f*t)+(b(t)/2)*(1-cos(4*pi*f*t))

=(a(t)/2)*sin(4*pi*f*t)+(b(t)/2)-(b(t)/2)cos(4*pi*f*t)

Again after low pass filtering (LPF) we are left with the quadrature component b(t) scaled by the constant 1/2. So we can conclude that the multiplication by the carrier terms at the transmitter and receiver is not required in simulation and we can simply transmit a(t) and b(t). We just have to make sure that a(t) and b(t) are orthogonal to each other so that they do not interfere.

So the transmitted QPSK signal would have the form.

s(t)=a(t)+j*b(t)

The steps involved in the simulation are

1. Generate a random sequence of symbols for the in-phase and quadrature components (-1 corresponding to binary value of 0 and +1 corresponding to binary value of 1). Add the in-phase and quadrature components in the form a(t)+j*b(t).

2. Generate complex samples of Additive White Gaussian Noise (AWGN) with the required variance (noise power = noise variance OR noise power = square of noise standard deviation OR noise power = noise power spectral density * signal bandwidth).

3. Add AWGN samples to the QPSK signal.

4. Detection is performed at the receiver by determining the sign of the in-phase and quadrature components.

5. And finally the bit error rate (BER) is calculated for the in-phase and quadrature components. Total bit error rate is the mean of the two values.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FUNCTION TO CALCULATE BER OF QPSK IN AWGN
% l - Input, length of the symbol sequence
% EbNo - Input, energy per bit to noise power spectral density
% ber - Output, bit error rate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[ber]=err_rate2(l,EbNo)       
si=2*(round(rand(1,l))-0.5);               % In-phase component
sq=2*(round(rand(1,l))-0.5);               % Quadrature component
s=si+j*sq;                              % QPSK symbol  
n=(1/sqrt(2*10^(EbNo/10)))*(randn(1,l)+j*randn(1,l)); % AWGN Noise
r=s+n;                                  % Received signal with noise
si_=sign(real(r));                        % Detected in-phase component 
sq_=sign(imag(r));                        % Detected quadrature component 
ber1=(l-sum(si==si_))/l;                  % Bit error rate in-phase
ber2=(l-sum(sq==sq_))/l;                  % Bit error rate quadrature
ber=mean([ber1 ber2]);                    % Mean bit error rate 
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

QPSK Constellation

QPSK BER

One final comment that I want to make is that bit error rate and symbol error rate is not always the same. Taking the example of QPSK a symbol error might occur when there is an error in the in-phase stream or the quadrature stream or both. So it is not a one to one mapping!!!

Note:

1. For a QPSK constellation centered around the origin of the co-ordinate system, the decision boundaries are simply defined by the x and y axes.

2. The reason for the name QPSK is that there are four symbols in the constellation, each having one of four possible phases (45, 135, 225, 315).

Bit Error Rate of BPSK

Modulation is the process by which a binary stream (zeros and ones) is converted to a format that is suitable for transmission over a wired or wireless channel that is prone to noise and interference as well as distortion. The most basic modulation scheme is BPSK or Binary Phase Shift Keying. It transmits the information in the phase of the signal which could be one of two values (0 degrees or 180 degrees).

BPSK signal can be represented as (called the passband representation)

s(t)=a(t)*cos(2*pi*f*t)

where a(t) is a time varying parameter which can have one of two values (+1 or -1). This is equivalent to having the phase of the carrier rotated by 0 degrees or 180 degrees. In simulation of digital communications systems we usually take out the carrier and perform the simulation at baseband. The passband and baseband simulations are equivalent because the carrier signal introduced at the transmitter can be easily removed at the receiver by a process called correlation (or simply put multiplication by the carrier followed by low pass filtering) and what we are left with is the parameter a(t).

If the transmitted signal is given as

a(t)*cos(2*pi*f*t)

then by multiplication with the carrier at the receiver we get

a(t)*cos(2*pi*f*t)*cos(2*pi*f*t)

=(a(t)/2)*(1+cos(4*pi*f*t))

and after low pass filtering the cosine term at twice the carrier frequency is removed and we get the parameter a(t) scaled by the factor 1/2. Since the information is contained in the sign of the parameter a(t) we can recover our transmitted symbols.

So in simulation, instead of multiplying the parameter a(t) by the carrier at transmitter and then again at the receiver we simply transmit a(t). This is equivalent to simulation of a Pulse Amplitude Modulation (PAM) system with two levels. Following are the steps involved in the simulation of BPSK system.

Steps:

1. Generate a random sequence of symbols (+1,-1)

2. Generate samples of Additive White Gaussian Noise (AWGN) with the required variance (noise power = noise variance OR noise power = square of noise standard deviation OR noise power = noise power spectral density * signal bandwidth).

3. Add AWGN samples to the BPSK signal.

4. Detection is performed at the receiver by determining the sign of the parameter a(t).

5. And finally the bit error rate (BER) is calculated. Which is the same as symbol error rate (SER) in this case.

Given below is the MATLAB code that performs these functions. Also shown below are the signals generated at the first four steps and the bit error rate calculated in the fifth and last step.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FUNCTION TO CALCULATE BER OF BPSK IN AWGN
% l - Input, length of the symbol sequence
% EbNo - Input, energy per bit to noise power spectral density in dB
% ber - Output, bit error rate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function[ber]=err_rate(l,EbNo)
s=2*(round(rand(1,l))-0.5);             % Generate BPSK symbols 
n=(1/sqrt(2*10^(EbNo/10)))*randn(1,l);  % Generate AWGN noise
r=s+n;                                  % Add noise to signal
s_=sign(r);                             % Detect symbols
ber=(l-sum(s==s_))/l;                   % Calculate BER
return
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

The length of the symbol sequence and EbNo (a bit different than SNR) are the inputs to the function and the bit error rate (BER) is the output. The length of the sequence must be such that you can count about 25 symbol errors at each value of EbNo. This means that at an EbNo of 10dB you would need to pass a few million symbols through the channel. Try it out!!!

BPSK Modulation

BPSK BER

Note:

1. To generate the above given bit error rate plot you would have to create a piece of code which calls the above function for each value of EbNo and stores the output BER value in an array and then plot the BER vs EbNo at the end of simulation. We leave this to  you as an exercise.

2. We have generated BPSK symbols directly instead of first generating a binary sequence. This does not matter much in this simple example but for more advanced modulation schemes we would have to first generate a binary stream and then from that the symbols.

3. We have used one sample per symbol of BPSK modulation, as shown in the figure above. But sometimes we have to select higher number of samples per symbol (usually 4 to 10) to implement some other signal processing functions.

4. Most of the concepts discussed above can be extended to other digital modulation schemes. The concepts for analog modulation schemes are somewhat different and we do not use error rates to evaluate the performance of these schemes.