18
ETN3046 Analog & Digital Communications FACULTY OF ENGINEERING LAB SHEET ETN3046 ANALOG AND DIGITAL COMMUNICATIONS TRIMESTER 1 (2017/2018) ADC2 – Digital Carrier Modulation TC Chuah (2017 July) Page 1

FACULTY OF ENGINEERINGfoe.mmu.edu.my/lab/lab sheet/TRIM 1/DELTA/ETN3046 ADC1... · Web viewLAB SHEET ETN3046 ANALOG AND DIGITAL COMMUNICATIONS TRIMESTER 1 (2017/2018) ADC2 – Digital

Embed Size (px)

Citation preview

ETN3046 Analog & Digital Communications

FACULTY OF ENGINEERING

LAB SHEET

ETN3046

ANALOG AND DIGITAL COMMUNICATIONS

TRIMESTER 1 (2017/2018)

ADC2 Digital Carrier Modulation

ADC2 Digital Carrier Modulation with MATLABA) 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.

B) SOFTWARE REQUIRED

MATLAB version 5.3 or higher

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))

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:

((2))

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 1800 phase changes This modulated signal can be expressed as:

((3))

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

450

01

1350

10

3150

11

2250

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.

(001001110/23/2)

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.

(0011010111110/23/2000010110100)

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.

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 (), as shown on an x-y plot, is a pattern of dots known as a QAM constellation as shown in Figure 4.

(Quadrature-phase) (In-phaseQ valueI valueA)

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.

(1111010011101101110010110111001100101010011010010101000100001000Quadrant 3Quadrant 4Quadrant 2Quadrant 1ABABCDCD2V1V3V1V2V3V2V3V1V 2V 3V)

Figure 5 16 QAM Constellation

D) Introduction to MATLAB

MATLAB is a powerful computing system for handling the calculations involved in scientific and engineering problems. The name MATLAB stands for MATrix LABoratory, because the system was designed to make matrix computations particularly easy. One of the many things you will like about MATLAB (and which distinguishes it from many other computer programming systems, such as C++ and Java) is that you can use it interactively. This means you type some commands at the special MATLAB prompt, and get the answers immediately. The problems solved in this way can be very simple, like finding a square root, or they can be much more complicated, like finding the solution to a system of differential equations. For many technical problems you have to enter only one or two commands, and you get the answers at once. MATLAB does most of the work for you.

There are two essential requirements for successful MATLAB programming:

You need to learn the exact rules for writing MATLAB statements.

You need to develop a logical plan of attack for solving particular problems.

With MATLAB you will be able to adjust the look, modify the way you interact with MATLAB, and develop a toolbox of your own that helps you solve problems that are of interest to you. In other words, you can, with significant experience, customize your MATLAB working environment. As you learn the basics of MATLAB and, for that matter, any other computer tool, remember that computer applications do nothing randomly. Hence, as you use MATLAB, observe and study all responses from the command-line operations that you implement.

To start MATLAB from Windows, double-click the MATLAB icon on your Windows desktop. When MATLAB starts, the MATLAB desktop opens as shown in Figure 1.1. The window in the desktop that concerns us for this chapter is the Command Window, where the special prompt appears. This prompt >> means that MATLAB is waiting for a command.

Figure 6 The MATLAB desktop

MATLAB has a very useful help system, which we look at in a little more detail in the last section of this chapter. For the moment type help at the command line to see all the categories on which you can get help. For example, type help plot to learn how to use MATLABs linear plot function.

Suppose you want to draw the graph of e0.2xsin (x) over the domain 0 to 6, as shown in Figure 7. The Windows environment lends itself to nifty cut and paste editing, which you would do well to master. Proceed as follows.

From the MATLAB desktop select File -> New -> M-file, or click the new file button on the desktop toolbar (you could also type edit in the Command Window followed by Enter). This action opens an Untitled window in the Editor/Debugger. You can regard this for the time being as a scratch pad in which to write programs. Now type the following two lines in the Editor, exactly as they appear here:

x = 0 : pi/20 : 6*pi;

plot(x, exp(-0.2*x).*sin(x), 'r'), grid

Figure 7 e0.2xsin(x)

To save the contents of the Editor, select File -> Save from the Editor menubar. A Save file as: dialogue box appears. Select a directory and enter a file name, which must have the extension .m, in the File name: box, e.g. junk.m. Click on Save. Take note that you are not allowed to save your files using the names of any existing MATALB built-in functions, e.g., sin, cos, plot, etc. The Editor window now has the title junk.m. If you make subsequent changes to junk.m in the Editor, an asterisk appears next to its name at the top of the Editor until you save the changes.

A MATLAB program saved from the Editor (or any ASCII text editor) with the extension .m is called a script file, or simply a script. (MATLAB function files also have the extension .m. MATLAB therefore refers to both script and function files generally as M-files.) The special significance of a script file is that, if you enter its name at the command-line prompt, MATLAB carries out each statement in the script file as if it were entered at the prompt. The rules for script file names are the same as those for MATLAB variable

Names.

When you run a script, you have to make sure that MATLABs current directory (indicated in the Current Directory field on the right of the desktop toolbar) is set to the directory in which the script is saved. To change the current directory type the path for the new current directory in the Current Directory field, or select a directory from the drop-down list of previous working directories, or click on the browse button (...) to select a new directory. The current directory may also be changed in this way from the Current Directory browser in the desktop.

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 bask function for creating BASK modulated signals:

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 built-in function/command, e.g. typing help cos at the command prompt will return you an explanation on the built-in function cos( ).

Next, using the above bask function with appropriate input values for b and f to plot: 1) the time domain waveforms of an unipolar NRZ binary bit stream m1(t) as shown below, 2) a carrier signal of s1(t) = cos (10t), and 3) the BASK modulated signal.

(Binary code 1 0 1 0 10V m1(t)1 2 3 4 5 t/s1V )

4. Create a new function bfsk by modifying the bask function to plot: 1) the polar NRZ bit stream m2(t) as shown below, 2) a carrier with frequency c = 10t, 3) a BFSK modulated signal xc(t) with frequency deviation, = 5t. Mathematically, the BFSK modulated signal is given by:

(Binary code 1 0 1 0 11V m2(t)1 2 3 4 5 t/s+1V )

Hint: You may need to use the if function; typing help if in the command window to find out more.

5. Based on the same polar NRZ bit stream used in the above procedure create a new function bpsk that plots 1) the polar NRZ bit stream m2(t) as shown above, 2) a carrier with frequency c = 10t, 3) the BPSK signal with the following expression:

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

(Random Bit GeneratorSymbol Mapping16 QAM ModulatorAWGN16 QAM Demodulator)

The randint function is used 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.

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 randomly generated bit stream into symbols. 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 8 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 = 8; % 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 (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 Eb/N0 parameter on the Bit Error Rates (BER). You can vary the Eb/N0 (e.g. 10, 12 and 14), compute the respective BER and comment on the changes observed. Explain the differences if any.

F) Guidelines for Report Writing

A written report should be prepared based on the above experiment using the following guidelines:

1. Lab Experiment Overview

Introduction to the experiment

Summary of the lab experiment

Maximum 1 page

2. Results and Observation

Explain the results gathered from the experiment

Answer all questions listed in the experiment

3. Conclusion and Discussion

Conclusive remarks on the experiment

4. Appendices

Any attachment if available

Please prepare individual lab report using the following cover page.

FACULTY OF ENGINEERING

LAB REPORT FOR EXPERIMENT ADC2

ETN3046

ANALOG AND DIGITAL COMMUNICATIONS

TRIMESTER 1 SESSION 2017/2018

(Student Name: ..Student ID: Lab Group No.: Degree Major:EE / CE / NE / LE / ME / OPEDeclaration of originality:I declare that all sentences, results and data mentioned in this report are from my own work. All work derived from other authors have been listed in the references. I understand that failure to do this is considered plagiarism. I agree that this report will be given 0 marks if any words/photos in this report are copied from others.Student signature: )

TC Chuah (2017 July)Page 12

=

"1"

symbol

cos

"0"

symbol

cos

)

(

2

1

t

A

t

A

t

x

c

w

w

+

=

"1"

symbol

cos

"0"

symbol

)

cos(

)

(

t

A

t

A

t

x

c

c

c

w

p

w

02468101214161820

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

+

-

=

"1"

symbol

)

5

10

cos(

"0"

symbol

)

5

10

cos(

)

(

t

t

t

t

t

x

c

p

p

p

p

+

=

"1"

symbol

)

10

cos(

"0"

symbol

)

10

cos(

)

(

t

A

t

A

t

x

c

p

p

p

Criteria0 (Need a lot of Improvement)1 (Need Improvement)2 (Satisfactory)3 (Good)

1

Read through the lab sheet and

understand the objective of the

experiment. Able to run the

MATLAB programs successfully.

2

Demonstrate ASK, FSK, and PSK

signals

3

Demonstrate the scatter plots for 16-

QAM and calculate BER for different

SNR values

4

Present results clearly, discuss

them, and summarise the findings.

5

Write a good report in a logical

manner and in a presentable format

Conclusions

Rating Awarded by

Assessor

Preparation

Conducting the Experiment

=

"1"

symbol

cos

"0"

symbol

0

)

(

t

A

t

x

c

c

w