You are on page 1of 14

ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2

Page 1 of 14




FACULTY OF ENGINEERING


LAB SHEET


ANALOG AND DIGITAL
COMMUNICATIONS

ETM 2046

TRIMESTER 1 (2012-2013)



ADC2 Digital Carrier Modulation









ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 2 of 14
ADC2 Digital Carrier Modulation with MATLAB and SIMULINK
A) OBJECTIVES
To understand digital carrier modulation such as ASK, FSK and PSK and QAM.
To use MATLAB to:
- Create ASK, PSK, FSK and 16 QAM signals by modulating a binary bit stream on a carrier.
- Examine the modulated signals in the time domain.
To illustrate Mary modulation blocks using SIMULINK.

B) SOFTWARE REQUIRED
MATLAB version 5.3 or higher
MATLAB Simulink version 5.0 or higher with Communications Blockset library

C) THEORY OF DIGITAL CARRIER MODULATION
Baseband digital signals are suitable for transmission over a pair of wires or coaxial cables due to its sizable
power at low frequencies. These signals cannot be transmitted over a radio link because this would require
impractically large antennas to efficiently radiate the low-frequency spectrum of the signal. Hence, for such
purposes, we use analog modulation techniques in which the digital signal messages are used to modulate a
high-frequency continuous-wave (CW) carrier.

In binary modulation schemes, the modulation process corresponds to switching (or keying) the amplitude,
frequency or phase of the CW carrier between either of two values corresponding to binary symbols 0 or 1.
The three types of digital modulation are amplitude-shift keying (ASK), frequency-shift keying (FSK) and
phase-shift keying (PSK).
Amplitude-Shift Keying (ASK)

In ASK, the amplitude of the carrier assumes one of the two amplitudes dependent on the logic states of the
input bit stream. This modulated signal can be expressed as:

=
"1" symbol cos
"0" symbol 0
) (
t A
t x
c
c
e


Note that the modulated signal is still an on-off signal.

Frequency-Shift Keying (FSK)

In FSK, the frequency of the carrier is changed to two different frequencies depending on the logic state of
the input bit stream. Usually, a logic high causes the centre frequency to increase to a maximum and a logic low
causes the centre frequency to decrease to minimum. The modulated signal can be expressed as:

=
"1" symbol cos
"0" symbol cos
) (
2
1
t A
t A
t x
c
e
e

(1)
(2)
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 3 of 14
Phase-Shift Keying (PSK)

In PSK, the phase of the carrier changes between different phases determined by the logic states of the input bit
stream. In two-phase shift keying, the carrier assumes one of the two phases. A logic 1 produces no phase
change and a logic 0 produces a 180
0
phase changes This modulated signal can be expressed as:

+
=
"1" symbol cos
"0" symbol ) cos(
) (
t A
t A
t x
c
c
c
e
t e


Figure 1 illustrates the above digital modulation schemes for the case in which the data bits are represented
by the polar NRZ waveform.


Figure 1 Digital Carrier Modulation

Quaternary Phase-Shift Keying (QPSK)

In 4PSK or QPSK, 2 bits are processed to produce a single-phase change. In this case, each symbol consists
of 2 bits. The actual phases that are produced by a QPSK modulated signal are shown in Table 1:
Bits Phase
00 45
0

01 135
0

10 315
0

11 225
0


(3)
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 4 of 14
Table 1 Bits and Phases for 4PSK or QPSK modulation
From Table 1, a signal space diagram or signal constellation can be drawn as shown in Figure 2. Note that
from any two closest bits sequences, there is only one bit change. This is called Gray Coded scheme. For
example, bit sequence 00 has one bit change for its closest bit sequences 01 and 10.















Figure 2 4PSK or QPSK Constellation


Eight Phase-Shift Keying (8PSK)

In this modulation, 3 bits are processed to produce a single-phase change. This means that each symbol
consists of 3 bits. Figure 3 shows the constellation and mapping of the 3-bit sequences onto appropriate phase
angles.
















Figure 3 8PSK Constellation


Higher Order Phase Shift Keying

Modulation schemes like 16 PSK, 32 PSK and higher orders can be also be designed and represented on a
signal space diagram.

00
10
01
11
0
t/2
t
3t/2
001
101
011
111
0
t/2
t
3t/2
000 010
110 100
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 5 of 14
Quadrature Amplitude Modulation (QAM)

QAM is a method for sending two separate (and uniquely different) channels of information. The carrier is
shifted to create two carriers namely the sine and cosine versions. The outputs of both modulators are
algebraically summed, the results of which is a single signal to be transmitted, containing the In-phase (I) and
Quadrature-phase (Q) information. The set of possible combinations of amplitudes (A) and phases (u), as shown
on an x-y plot, is a pattern of dots known as a QAM constellation as shown in Figure 4.


Figure 4 I-Q Constellation (Diagram)

Consider the 16 QAM modulation schemes, in which 4 bits are processed to produce a single vector. The
resultant constellation consists of four different amplitude distributed in 12 different phases as shown in Figure
5.























Figure 5 16 QAM Constellation


In-phase
Q value
I value
u
A
Quadrature-phase
1111
0100
1110
1101
1100
1011 0111
0011
0010
1010 0110
1001 0101 0001
0000
1000
Quadrant 3 Quadrant 4
Quadrant 2 Quadrant 1
AB AB
CD
CD
2V
1V
3V
1V
2V
3V
2V 3V 1V 2V 3V
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 6 of 14
D) MATLAB and SIMULINK

MATLAB is an interactive matrix based system for scientific and engineering numeric computation and
visualization. Its strength lies in the fact that complex numerical problem can be solved easily and in a fraction
of the time required with a programming language such as Fortran or C. It is also powerful in the sense that by
using its relatively simple programming capabilities, MATLAB can be easily extended to create new commands
and functions.

SIMULINK is a software package in MATLAB used for modelling, simulating, and analyzing dynamical
systems. It supports linear and nonlinear systems, modelled in continuous time, sampled time, or a hybrid of the
two. Systems can also be multirate that has different parts that are sampled or updated at different rates. For
modeling, SIMULINK provides a graphical user interface (GUI) for building models as block diagrams, using
click-and-drag mouse operations. With this interface, you can draw the models just as you would with pencil
and paper (or as most textbooks depict them). It also includes a comprehensive block library of sinks, sources,
linear and nonlinear components, and connectors.

Models are hierarchical, so you can build models using both top-down and bottom-up approaches. You can
view the system at a high level, then double-click on blocks to go down through the levels to see increasing
levels of model detail. This approach provides insight into how a model is organized and how its parts interact.
After you define a model, you can simulate it, using a choice of integration methods, either from the
SIMULINK menus or by entering commands in MATLAB's command window. The menus are particularly
convenient for interactive work, while the command-line approach is very useful for running a batch of
simulations. Using scopes and other display blocks, you can see the simulation results while the simulation is
running. In addition, you can change parameters and immediately see what happens, for "what if" exploration.
The simulation results can be put in the MATLAB workspace for post-processing and visualization. Model
analysis tools include linearization and trimming tools, which can be accessed from the MATLAB command
line, plus the many tools in MATLAB and its application toolboxes.

All digital modulation blocks process only discrete-time signals. The data types of inputs and outputs are
depicted in the figure below:

Figure 6 Representing Signals for Digital Modulation in Simulink

ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 7 of 14
E) EXPERIMENT PROCEDURES MATLAB

1. Open and start the MATLAB program by double-clicking the MATLAB icon.

2. Type the command in the MATLAB COMMAND WINDOW or create a script file in the MATLAB
EDITOR.

3. Analyze the following function for creating the ASK modulated signal:
function bask(b,f)
% b is the input binary bit stream
% f is the frequency of the carrier
n = length(b); % determine the length of bit stream
t = 0:0.01:n-0.01; % time axis
for i = 1:n
bw( ((i-1)*100)+1 : i*100 ) = b(i); % loop
end
carrier = cos(2*pi*f*t); % carrier signal
modulated = bw.*carrier; % modulated signal
subplot(3,1,1)
plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(3,1,2)
plot(t,carrier)
grid on ; axis([0 n -2 +2])
subplot(3,1,3)
plot(t,modulated)
grid on ; axis([0 n -2 +2])

Note: Always use the HELP function to assist you in understanding a MATLAB function/command, e.g.
typing help cos at the command prompt will return you an explanation on the function cos( ).

Next, plot the time domain for an ASK modulated signal with a carrier signal of s
1
(t) = cos (10tt) and an
unipolar NRZ binary bit stream m
1
(t) as shown below,















Binary code 1 0 1 0 1
0V
m
1
(t)
1 2 3 4 5 t/s
1V
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 8 of 14
4. Create a new function (based on the function bask) to plot the time domain for a FSK modulated signal
with the following polar NRZ bit stream m
2
(t) as shown below,








Assume the following for the FSK modulated signal:

=
"1" symbol ) 5 10 cos(
"0" symbol ) 5 10 cos(
) (
t t
t t
t x
c
t t
t t

where the carrier frequency, e
c
= 10tt and frequency deviation, Ae= 5tt.

5. Based on the same polar NRZ bit stream used in the above procedure create a new function that plot the
PSK signal in time domain with the following expression:

+
=
"1" symbol ) 10 cos(
"0" symbol ) 10 cos(
) (
t A
t A
t x
c
t
t t



6. Consider the following 16 QAM transmission through an Additive White Gaussian Noise (AWGN)
channel.






The randint function is use to generate the random binary data stream by creating a column vector that lists
the successive values of a binary data stream. Set the length of the binary data stream to 1,000. The code
below creates a stem plot of a portion of the data stream, showing the binary values.

%% Definition
% Random binary bit stream generation.
Fd=1; Fs=1; % Input and output message sampling frequency.
nsamp=1; % Oversampling rate.
M = 16; % Size of signal constellation.
k = log2(M); % Number of bits per symbol.
n = 8e4; % Number of bits to process.
Binary code 1 0 1 0 1
1V
m
2
(t)
1 2 3 4 5 t/s
+1V
Random Bit
Generator
Symbol
Mapping
16 QAM
Modulator

AWGN
16 QAM
Demodulator
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 9 of 14
x = randint(n,1); % Random binary data stream

% Plot the first 20 bits in a stem plot.
stem(x(1:20),'filled');
title('Random Bits');
xlabel('Bit Index'); ylabel('Binary Value');

Next, use the following script to convert the random generated bit stream into symbol. In this script, each 4-
tuple of values from x is arranged across a row of a matrix, using the reshape function in MATLAB, and
then the bi2de function is applied to convert each 4-tuple to a corresponding integer. (The .' characters after
the reshape command form the unconjugated array transpose operator in MATLAB.)

%% Bit-to-Symbol Mapping
% Convert the bits in x into k-bit symbols.
xsym = bi2de(reshape(x,k,length(x)/k).');

% Plot the first 10 symbols in a stem plot.
figure; % Create new figure window.
stem(xsym(1:10));
title('Random Symbols');
xlabel('Symbol Index'); ylabel('Integer Value');

The dmodce function implements a 16 QAM modulator. xsym from above is a column vector containing
integers between 0 and 15. The dmodce function can now be used to modulate xsym using the baseband
representation. Note that M is 16, the alphabet size. The result is a complex column vector whose values are
in the 16-point QAM signal constellation.

%% Modulation
% Modulate using 16-QAM.
y = dmodce(xsym,Fd,Fs, 'qask',M);

Next, we add white Gaussian noise to the modulated signal. The ratio of bit energy to noise power spectral
density, Eb/N0, is arbitrarily set at 10 dB. The expression to convert this value to the corresponding signal-
to-noise ratio (SNR) involves k, the number of bits per symbol (which is 4 for 16-QAM), and nsamp, the
oversampling factor (which is 1 in this example). The factor k is used to convert Eb/N0 to an equivalent
Es/N0, which is the ratio of symbol energy to noise power spectral density. The factor nsamp is used to
convert Es/N0 in the symbol rate bandwidth to an SNR in the sampling bandwidth.

%% Transmitted Signal
ytx = y;
%% Channel
% Send signal over an AWGN channel.
EbNo = 10; % In dB
snr = EbNo + 10*log10(k) - 10*log10(nsamp);
pinput = std(ytx);
noise = (randn(1,n/k)+sqrt(-1)*randn(1,n/k))*(1/sqrt(2));
Noisestd = (pinput*10^(-snr/20));
ynoisy = ytx + (Noisestd*noise).;
%% Received Signal
yrx = ynoisy;
Then, generate the scatter plot of the transmitted and received signals. This shows how the signal
constellation looks like and how the noise distorts the signal. In the plot, the horizontal axis is the In-phase
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 10 of 14
(I) component of the signal and the vertical axis is the Quadrature (Q) component. The code below also uses
the title, legend, and axis functions in MATLAB to customize the plot.

%% Scatter Plot
% Create scatter plot of noisy signal and transmitted signal on the
same axes.
figure;
plot(real(yrx(1:5e3)),imag(yrx(1:5e3)),b*);
hold on;
plot(real(ytx(1:5e3)),imag(ytx(1:5e3)),g.);
title(Signal Constellation);
legend(Received Signal,Transmitted Signal);
axis([-5 5 -5 5]); % Set axis ranges.
hold off;
Demodulation of the received 16-QAM signal is done by using the ddemodce function. The result is a
column vector containing integers between 0 and 15.

%% Demodulation
% Demodulate signal using 16-QAM.
zsym = ddemodce(yrx,Fd,Fs, 'qask', M);

The previous step produced zsym, a vector of integers. To obtain an equivalent binary signal, use the de2bi
function to convert each integer to a corresponding binary 4-tuple along a row of a matrix. Then use the
reshape function to arrange all the bits in a single column vector rather than a four-column matrix.

%% Symbol-to-Bit Mapping
% Undo the bit-to-symbol mapping performed earlier.
z = de2bi(zsym); % Convert integers to bits.
% Convert z from a matrix to a vector.
z = reshape(z.',prod(size(z)),1);
The biterr function is now applied to the original binary vector and to the binary vector from the
demodulation step above. This yields the number of bit errors and the bit error rate.

%% BER Computation
% Compare x and z to obtain the number of errors and
% the bit error rate.
[number_of_errors,bit_error_rate] = biterr(x,z)

7. Evaluate the impact of the E
b
/N
0
parameter on the Bit Error Rates (BER). You can vary the E
b
/N
0
(e.g. 20,
30 and 40), compute the respective BER and comment on the changes observed. Explain the differences if
any.
8. OPTIONAL: Interested students can try similar simulation in SIMULINK, as documented in the Appendix.


F) MARKING SCHEME
Evaluation of this lab experiment is through report writing. The lab report should be handwritten (except for
computer generated programming codes, graphs and results) and follow the standard report format, i.e. begin
with Introduction and end with Conclusion. Students should answer all questions and discuss their observations.
Marks will be given in the scale of 0 to 100, based on the following marking scheme:

ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 11 of 14
i) Lab experiment overview (10 marks)
- Introduction to the experiment
- Summary of the lab experiment
- Maximum 1 page
ii) Results and observation (50 marks)
- Explain the results gathered from the experiment
- Answer all questions listed in the experiment
iii) Conclusion and discussion (10 marks)
- Conclusive remarks on the experiment
iv) Written communication skill (30 marks)
G) REFERENCES
[1] Hwei P. Hsu, Schaum's Series of Analog & Digital Communications, 2nd Edition, McGraw Hill
International Series, 2001
[2] S. Haykin, Digital Communications, John Wiley & Sons, 2001
[3] The MathWorks, Inc.: www.mathworks.com

APPENDIX: SIMULINK for MATLAB 7 (for reference only)

EXPERIMENT PROCEDURES
1. Type simulink at the MATLAB COMMAND prompt.
* The Simulink Library Browser window is opened.
2. Create a new model window by clicking the Create a new model button on the Library Browser
toolbar or click File >> New >> Model.
* A new empty workspace window is opened.
3. Double-click to expand the Simulink folder at the Library Browser window.
4. Go to Communications Blockset -> Comm Sources -> Random Data Sources sub-folder. Drag and drop
Random Integer Generator module into the workspace window. Double-click this module and make the
following settings:
- Mary number to 16
- Initial seed to 37
- Sample time to 0.1
- Ouput Data Type to double
5. Go to Communications Blockset -> Modulation -> Digital Baseband Modulation -> AM sub-folder.
Drag and drop Rectangular QAM Modulator Baseband module into the workspace window. Double-
click this module and make the following settings:
- Mary number to 16
- Input type to Integer
- Constellation ordering to Binary
- Normalization method to Peak Power
- Peak power (watts): to 1
- Phase offset (rad) to 0
- Output Data Type to double
6. Go to Communications Blockset -> Channels sub-folder. Drag and drop AWGN Channel Baseband
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 12 of 14
module into the workspace window. Double-click this module and make the following settings:
- Initial seed to 37
- Mode to Signal-to-noise ratio (Eb/No)
- Eb/No (dB) to 10
- Number of bits per symbol to 4
- Input signal power (watts): to 1
- Symbol period to 0.1
7. Go to Communications Blockset -> Modulation -> Digital Baseband Modulation -> AM sub-folder.
Drag and drop Rectangular QAM Demodulator Baseband module into the workspace window. Double-
click this module and make the following settings:
- Mary number to 16
- Output type to Integer
- Constellation ordering to Binary
- Normalization method to Peak Power
- Peak power (watts): to 1
- Phase offset (rad) to 0
- Output Data Type to double
8. Go to Communications Blockset -> Comm Sinks sub-folder. Drag and drop Error Rate Calculation
module into the workspace window. Double-click this module and make the following settings:
- Receive delay to 0
- Computation delay to 1
- Computation mode to Entire frame
- Output data to Port
9. Go to Simulink -> Sinks sub-folder. Drag and drop the Display module into the workspace window. Drag
the bottom edge of this inserted (Display module) icon to make the display big enough for three entries.
10. Go to Communications Blockset -> Comm Sinks sub-folder. Drag and drop TWO Discrete-Time Eye
and Scatter Diagram modules into the workspace window. Double-click these TWO module and make the
following settings:
- Trace period to 0.1
- Decision point to 0.07
- Sample per symbol to 1
11. Go to Simulink -> Math Operations sub-folder. Drag and drop TWO Complex to RealImag modules
into the workspace window.
12. Go to Simulink -> Sinks sub-folder. Drag and drop TWO XY Graph modules into the workspace window.
13. Go to Simulink -> Sinks sub-folder. Drag and drop TWO Scope modules into the workspace window.
14. Go to Simulink Extra -> Additional Sinks sub-folder. Drag and drop TWO Power Spectral Density
modules into the workspace window.
15. Connect all the inserted modules as shown in Figure 7.
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 13 of 14

Figure 7 Simulink model for 16 QAM transmission
ETM2046 Analog & Digital Communications, Trimester 1 2012/13 ADC2
Page 14 of 14
16. Set the simulation parameters (Simulation >> Parameters) as follows:

17. Save your file as recqam.mdl by clicking File >> Save As.
18. Run (Simulation >> Start) the simulation and observe all plots and BER display.

You might also like