SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems...

54
SYSC 4600 Digital Communications Laboratory Manual Fall 2004 Department of Systems and Computer Engineering Carleton University Copyright © 2001 by László Házy and Sébastien Roy

Transcript of SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems...

Page 1: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

SYSC 4600 Digital CommunicationsLaboratory Manual

Fall 2004

Department of Systems and Computer EngineeringCarleton University

Copyright © 2001 by László Házy and Sébastien Roy

Page 2: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer
Page 3: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

1

Table of Contents

Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Notes on the Simulation ofCommunication Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

Typographic Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Frequently Asked Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Experiment 1:Baseband Digital Transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Experiment 2:Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Experiment 3:Bandpass Digital Modulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Experiment 4:Error-Control Coding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

Page 4: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer
Page 5: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

3

Introduction

This manual describes a series of five laboratory experiments designed to complement the lecturesof the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer simulations performed with the help of the MATLAB language as well asa custom set of Matlab functions created specifically for this course.

The procedures are quite detailed and assume no prior knowledge of Matlab. For those studentswishing to practice or perform the experiments at home, every effort has been made to ensure that theexperiments are compatible with the Matlab student edition. Hence, all experiments except experi-ment 4 can be performed either on the PCs in the lab or using the Matlab student edition on a homecomputer. However, certain parts of the experiments are more difficult to perform using the studentedition. Experiment 4, Error-Control Coding, requires the full power of the professional version andcan only be performed in the lab.

Experiments make use of standard Matlab functions and the 460 custom toolbox. On laboratoryPCs, the 460 toolbox is found on the Z: drive. Students are free to copy the contents of this directoryto floppy disk for home use.

The manual is organized in two parts. The introductory section includes instructions and guide-lines on performing the experiments and writing up lab reports. The second part consists of the exper-iments themselves which are all divided up in three main sections. In the first section, which providespreparation material, a conceptual diagram is presented to give a good visual overview of the experi-ment. Objectives, references and pre-lab questions are also given. It is strongly suggested that at leastthe referenced sections in the text book be read prior to beginning lab work. The prelab questionsMUST be answered prior to attempting the experiment. They are meant to provide a good theoreticalbackground to the experiment. The second section is the experimental procedure itself while the thirdsection consists of post-lab questions.

Page 6: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

4

Acknowledgements

The authors would like to thank the following people who have contributed to the creation of thislab manual and the accompanying software toolbox:

1. Professor David D. Falconer, who initially provided the opportunity for the creation ofthis new series of experiments;

2. Professor Halim Yanikomeroglu for supporting the in-depth revision of this lab manualand accompanying software during the summers of 1999 and 2001, thereby contributingsignificantly to the quality of the whole;

3. The TAs for 94.460 in the fall of 1998 -2000 (Tao Wan, Mohamed Ahmed, FarhadZarkeshvari) who have put up with the quirks and imperfections of the early versions ofthis manual and toolbox; their comments were most helpful;

Page 7: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

5

Notes on the Simulation ofCommunication Systems

In computer simulations, continuous-time (analog) signals are represented as sequences of sam-ples of the original waveforms. This entails two forms of degradation or “approximation” with respectto the original:

1. Discretization of time: While the original analog waveform exists at all instants, thesampled waveform is only defined at the sampling instants. It is therefore crucial tochoose a sampling frequency sufficiently high to make the sampled waveform behavelike the original analog signal. The Nyquist criterion states that the sampling frequencyshould be at least double the bandwidth of the signal.

2. Quantization: The value of the signal at each sample instant is represented in the com-puter as a finite precision number while an analog waveform’s can take on an infiniterange of amplitudes.

A sequence of samples can be represented by an “array” or “vector” in Maltab or in any othersuitable language. Sequences of digital symbols, such as binary digits, which are to be transmitted ina digital communication system, can also be represented as arrays or vectors. Operations such asaddition, amplification, modulation, filtering, decisions based on threshold comparisons, etc, can allbe represented as mathematical operations on the individual samples or on the entire array.

Computer simulation is an essential tool used to design and evaluate the performance of commu-nication systems. Some simulation packages also facilitate converting the simulation programs intocode that actually implements modems on programmable digital signal processing devices. Thus,these computer simulation experiments will not only allow you to observe and visualize the systemcomponents discussed in the lectures, but will also give you a flavor of the digital communication sys-tem design process.

Page 8: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

6

Typographic Conventions

This typewriter-like font is used for commands to be entered at the computer in the Matlabenvironment and for results returned by the computer. The symbol >> stands for the Matlab inputprompt:

>> b = round(rand(1,1000));

In the body of the text, variables created in Matlab are also rendered in this font, e.g.my_variable . On the other hand, variables related to theoretical formulas or which do not directlycorrespond to a computer variable are written in italics, e.g. variable, or with Greek letters, e.g. .

In computer commands, variables within angle brackets, e.g. <variable>, are placeholdersand they are to be replaced by some fixed quantity or string by the user according to the lab instruc-tions. For example, consider the following excerpt from the procedure of experiment 1:

In this case, the first time these two commands are entered, the placeholder <data_rate> would bereplaced by 250.

The first command in the example above is cut in two lines, i.e. there is a carriage return beforethe number 10000. This is done frequently in the manual when the lines are too long to fit within thepage margins. At the computer, however, every command should be typed without any intermediatecarriage returns. If the length of the command exceeds the width of the screen, Matlab will automati-cally move the cursor to a new line where you would continue to input the command.

Framed items in the procedure indicate data that must be included in the lab report. For example:

Filled-in tables and post-lab questions must also be included in the report. See the section on Fre-quently Asked Questions for more information on lab reports. Finally, commands are sometimes pre-

W = [Hz]

Let us now examine the relationship between the PSD and the data rate Fd. UseManchester coding and produce a PSD for different values of Fd:

>> [Ss,f] = psd(modul(b,’manchester’,<data_rate>),10000);

>> plot(f,Ss);

where <data_rate> is successively taken to be 250 b/s, 500 b/s and 1000 b/s.

Page 9: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

7

sented in a shadow box like this:

This is meant to illustrate the syntax of a newly introduced command. Commands in shadowed boxesshould not be typed in as part of the procedure.

scope(<signal>,<mode>,<sweep_time>,<Fd>,<Fs>);

Page 10: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

8

Frequently Asked Questions

Question: Why a software lab?Answer: Lab experiments dedicated to the study of communication systems have traditionally beenhardware-oriented and necessitated equipment such as oscillators, modulators, spectrum analyzers,etc. While the hands-on approach is certainly positive, this type of equipment is not always reliableand difficult to adjust. This results in some confusion since it is difficult, within the alloted time, todetermine whether it is the students’ understanding or the equipment that is at fault. It is important forstudents to appreciate that software simulation allows one to concentrate on learning the conceptssince the technicalities of the hardware have been removed.

Question: When should the prelab be done?Answer: The prelab problems must be completed and presented at the beginning of the correspond-ing lab session.

Question: What should go in the lab report?Answer: The following should be included in every lab report:

• Prelab assignments (if not handed in at the beginning of the lab session);• All the boxed items in the procedure section, i.e. fill-in blanks, tables, printed plots when

requested;• Answers to the post-lab questions.

Please DO NOT print every graph produced in the course of the experiment. Only those specifi-cally requested in boxed areas are required in the report. Printing everything leads to

• thick, hard to manage reports;• congestion of printer resources and therefore lengthened lab session;• unwarranted waste of paper.

If you really want to save everything for future reference, save the graphs on disk.

Question: Who hands in the lab reports?Answer: See the course handout.

Question: When are lab reports due?Answer: See the course handout.

Page 11: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

9

Question: Who marks the lab reports?Answer: Each lab report is marked by the TAs who supervised the corresponding lab session.

Question: If we already have Matlab, can we do the labs at home?Answer: Absolutely. The experiments have been designed to be compatible with the student editionof Matlab. Because the student version limits the length of vectors to 16383 (8192 if using a versionpredating version 5.0), some parts of the experiments will require you to shorten the sequences youare working with. Also, execution of certain commands from the 460 custom toolbox takes signifi-cantly longer with the student edition, hence greatly increasing the time required to perform theexperiment. Whenever the use of the student edition of Matlab requires special attention, this hasbeen noted in the relevant sections of the lab manual. However, it is recommended that you redo theseparts in the lab with the full vector length in order to obtain higher quality results. It is usually alsopossible to redo the experiment several times with a shorter sequence length and average the results toreach the same level of statistical significance. Experiment 4, Error-Control Coding, requires the pro-fessional version of Matlab and the Communications Toolbox. It is therefore the only experiment thatcannot be conducted at home because

• it makes use of powerful coding and decoding functions from the Matlab ProfessionalCommunications Toolbox and

• it would be difficult to assess the bit error rate performance of codes within the vector sizelimit of the student edition.

IMPORTANT: You have to show up during your assigned lab sessions to get your prelabs marked.Furthermore, attendance might be recorded.

Question: The plots I’m getting on screen are different from what other teams are getting. Howcome?Answer: In most experiments, random generation of waveforms or bit streams is used as the basis forfurther processing. Random number generation is initialized when you load Matlab. If you have typedall the commands in the order indicated, the random generator will generate the same data as anyother team that followed the same procedure. If you have had to backtrack to an earlier point in theexperiment and DID NOT begin over completely (e.g. quit Matlab and run it again), the results mightbe different. This does not mean the results are wrong; they are just different. If you really want to getresults consistent with that of other teams in order to verify your work, you have to start over by exit-ing and reloading Matlab and then following precisely the order of the commands.

Page 12: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

10

Page 13: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

11

Experiment 1Baseband Digital Transmission

OBJECTIVES

This experiment investigates how a digital data stream can be encoded into a sequence of pulsesfor transmission through a baseband analog channel. Specifically, you will examine:

• various line coding methods used for digital baseband modulation in data communicationapplications;

• spectral properties of those lines codes, i.e. their power spectral densities;• two important causes of signal distortion in a data communication channel: additive gaus-

sian noise and filtering effects due to the bandwidth of the channel;• effects of intersymbol interference (ISI) and additive noise as observed with the help of

the eye pattern.

REFERENCES

[1] S. Haykin, Communication Systems, 4th edition, John Wiley, 2001, pp. 201-209, 259-264 (pp.378-386, 424-431 in the 3rd edition) , ISBN: 0-471-17869-1.

Binary Basebandmodulation Channeldata +

• • •

• •

b s

Additive whiteGaussian noise

(AWGN)

o O Ooo

Oscilloscope

Figure 1: Conceptual diagram.

source•x

To detector

Page 14: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

12

[2] B. Sklar, Digital Communications, 2nd edition, Englewood Cliffs: Prentice Hall, 1988, pp. 78-82, ISBN: 0-13-084788-7.

[3] R. D. Gitlin, J. F. Hayes and S. B. Weinstein, Data Communication Principles, New York: Ple-num Press, 1992, pp. 233-248, ISBN: 0-306-43777-5.

PRE-LAB QUESTIONS

Reference [3] may be useful in solving thefollowing problems.

1. Assuming unit pulse amplitude and abinary data rate , plot the

waveforms representing the binarysequence

using the following line codes:

a) unipolar NRZ1 (on-off signal-ing);

b) binary antipodal signaling(bipolar NRZ);

c) Alternate Mark Inversion(AMI)2;

d) Manchester (split-phase);e) Nyquist (bipolar transmission

where the pulse shape is a sincfunction).

2. Let us examine the spectral properties of these line codes.

a) Determine analytically and sketch the power spectral density (PSD) functions for eachof the above line codes. Use a bit rate of .

b) Let stand for the first spectral null (other than , i.e. ) in the PSD func-

tion. If the transmission bandwidth of a line code is determined by , determine

for the line codes in question 1 as a function of .

3. Let be a waveform observed at the output of a communication channel (see Figure 2). The

1. NRZ=Non-Return to Zero, RZ=Return to Zero.2. AMI is related but slightly different from differential encoding discussed in [1], p. 207 (p. 384 in the 3rd edition). See

[3] for a full description.

0 T 2T 3T 4T 5T−2

−1.5

−1

−0.5

0

0.5

1

1.5

2Received waveform.

Time

Am

plitu

de (

V)

Figure 2: The waveform at theoutput of a communication channel.

x t( )

Rb 1 kb/s=

b 0 1 0 1 0 0 0 0 1 0 0 1 1, , , , , , , , , , , ,{ }=

Fd 1 kb/s=

f 1 f 0= f 1 0>

W f 1 W

Fd

x t( )

Page 15: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

13

waveform has been encoded using a bipolar NRZ line code. To display the corresponding eye dia-gram, is fed to an oscilloscope where the horizontal sweep time is set to. Sketch the corre-sponding eye diagram.

PROCEDURE

1. Line codes for binary signaling over baseband channels

Binary digits produced by a data source can be serially encoded using a variety of signaling for-mats calledline codes for transmission over an analog baseband channel. Their structure and spectralproperties will be examined in this section. You will be using themodul custom Matlab command:

whereFd is the data rate in symbols per second (bauds) andFs is the simulation sampling frequency.Note that in this experiment we are only concerned with binary sequences and binary modulationschemes. Therefore,Fd corresponds to the binary data rate in bits per second (b/s). The action of thecommand is to take the vectorbinary_sequence and modulate it according to the specified linecode. The following codes are supported: ‘unipolar_nrz’, ‘bipolar_nrz’, ‘bipolar_rz’, ‘ami’,‘manchester’, ‘miller’ , ‘unipolar_nyquist’, ‘bipolar_nyquist’, ‘raised_cosine’ and ‘duobinary’.

Many of the custom Matlab commands (scope, modul etc.) require theFd andFs parameters.However, if they are defined as global variables before these commands are executed, thenFd andFsdo not need to be passed as parameters (see 1.1 below for an example).

1.1 First, create this binary sequence:

>> b = [1 0 1 0 0 0 1 1 1 1];

Then, generate the coded signal representingb using themodul command with a data rate ofFd = 1 kb/s, a sampling rateFs = 10 kb/s and using the unipolar NRZ line code:

>> global Fd Fs;>> Fs = 10000;>> Fd = 1000;>> T = 1/Fd;>> s = modul(b,’unipolar_nrz’);

Display the resulting signal:

>> scope(s,’one-shot’,10*T);

Repeat these steps above for the following line codes:

x t( ) T

output = modul(<binary_sequence>,<line_code_name>,<Fd>,<Fs>);

Page 16: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

14

• bipolar NRZ;• bipolar RZ;• manchester;• AMI.

Also, repeat the above for the bipolar Nyquist line code with the difference that you will use thefollowing modified display command:

>> scope(s(100:300),’one-shot’,10*T);

This modification is necessary to get rid of the very long “tails” of the Nyquist pulse shape.

Compare the resulting waveforms with your answers in the first question of the prelab.

1.2 We will now examine the power spectral densities of the line codes. Generate a random binarysequence of 1000 bits:

>> b = round(rand(1,1000));

Note: If you are using the student edition of Matlab, reduce the length of the sequence to 250bits.

Display the PSD function3 of this sequence after it has been encoded using unipolar NRZ:

>> [Ss,f] = psd(modul(b,’unipolar_nrz’),10000,Fs,’mean’);>> plot(f,Ss);

The resulting plot is what you would observe by plugging a spectrum analyzer operating in lin-ear scale at point in the conceptual diagram of Figure 1.

To locate peaks and nulls, it is sometimes helpful to also examine the PSD in logarithmic scale:

>> plot(f,10*log10(Ss));

By observing the psd plot, identify the location on the frequency axis of the first and secondspectral peaks (denoted by and ) and the first and second spectral nulls ( and ).

Please note that while the first spectral peak can be situated at , we are only interested in

spectral nulls for , i.e. a null at doesn’t count. The location of the peaks and nullsshould be entered in the table below. Repeat the operation for all the line codes studied in part1.1 and record your results in Table 1.

Note: in order to determine the spectral nulls of the Nyquist line code, you will have to displaythe PSD at linear scale.

If the minimum required channel bandwidth for a given line code is determined by the loca-

3. The number 10000 is passed as an argument to the psd command; it represents the number of samples in the sequence,i.e. 1000 bits× Fs/Fd. If you use a shorter sequence length due to the student editon limitation, adjust this parameteraccordingly.

s

f p1 f p2 f n1 f n2

f 0=

f 0> f 0=

W

Page 17: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

15

tion of the first spectral null, determine for each line code.

1.3 Let us now examine the relationship between the PSD and the data rate Fd. Use Manchester cod-ing and produce a PSD for different values of Fd:

>> [Ss,f] = psd(modul(b,’manchester’,<data_rate>),10000*Fs/<data_rate>,Fs,’mean’);

>> plot(f,Ss);

where <data_rate> is successively taken to be 250, 500 and 1000 b/s. Observe the displace-ment of the spectral nulls and peaks and relate it to the binary data rate.

2. Simulating a baseband channel with noise

You will now simulate the characteristics of an ideal baseband communication channel includingadditive white Gaussian noise. The channel is modelled as an ideal low-pass filter whose output issummed with the output of a white Gaussian noise generator (see conceptual diagram of Figure 1).This channel model is implemented as the custom Matlab function bbchannel:

Again, if the simulation sampling frequency Fs has been apriori defined as a global variable, itneed not be passed as a parameter.

A computationally efficient implementation of the low-pass filter requires the Signal ProcessingToolbox, not included with the student edition of Matlab. For users of the student edition, a simplifiedfilter design technique is employed for which you have to set the MATLAB_SE global variable4:

>> global MATLAB_SE; MATLAB_SE = 1;

4. If you use the professional edition, DO NOT type in the command.

Table 1: Spectral characteristics of line codes at 1 kb/s data rate.

line code [Hz] [Hz] [Hz] [Hz] [Hz]

unipolar NRZ

bipolar NRZ

bipolar RZ

manchester

AMI

bipolar Nyquist

W

f p1 f p2 f n1 f n2 W

out = bbchannel(<input>,<gain>,<noise_power>,<bandwidth>,<Fs>);

Page 18: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

16

2.1 Create a 10 bit binary sequence b and encode it into an analog waveform using bipolar NRZ.

>> b = [0 1 0 0 1 0 0 1 1 0];>> s = modul(b,’bipolar_nrz’);

From your observation in part 1, determine the transmission bandwidth of s:

2.2 Transmit the waveform s over a baseband channel with unity gain and additive white Gaussiannoise (AWGN) where the noise power is 0.01 W and the channel bandwidth is 4.9 kHz. Displaythe channel input and output:

>> x = bbchannel(s,1,0.01,4900);>> subplot(211), scope(s,’one-shot’,0.01);>> subplot(212), scope(x,’one-shot’,0.01);

Has the information been preserved by this channel? In other words, could you estimate visuallythe sequence that was transmitted with knowledge of the output only?

2.3 To observe the effect of noise on the transmitted signal, you will gradually increase the channelnoise power while keeping the bandwidth constant at 4.9 kHz.

>> clf; subplot(321), scope(s,’one-shot’,0.01);>> title(’Original signal’);>> subplot(32<sub_win>), scope(bbchannel(s,1,<noise_power>,

4900),’one-shot’,0.01);>> title(’noise power = <noise_power> W’);

where you will use successively in lieu of noise_power values in the set,and you will plot each signal in a different subwindow. Therefore, <sub_win> will take on val-ues in the set .

At which noise power level does the channel output become undistiguishable from noise?

It is also possible to observe the effect of increasing the noise power by plotting the PSD of thechannel output. First, produce a plot of the PSD of the modulated signal s:

>> b = round(rand(1,1000));>> s = modul(b,’bipolar_nrz’);>> [Ss,f] = psd(s,length(s),Fs,’mean’);

W = [Hz]

YES or NO

PRINT this graph.

= [W]

W

0.1 0.5 1 2 5, , , ,{ }

2 3 4 5 6, , , ,{ }

σn2

Page 19: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

17

>> clf, subplot(221), plot(f,Ss), a = axis;>> title(’PSD of original signal’);

Then, produce a series of PSDs corresponding to the channel output with noise power levels and plot them in a separate subwindow. The<sub_win> variable will take on values in

the set .

>> [Sx,f] = psd(bbchannel(s,1,<noise_power>,4900),length(s),Fs,’mean’);

>> subplot(22<sub_win>), plot(f,Sx); axis(a);>> title(’PSD of received signal; noise power = <noise_power>

W’);

2.4 We will now look at the effects of channel bandwidth on the transmitted signal. The channel weare studying in this experiment is an ideal low-pass filter and it introduces distortion by cuttingoff the higher portion of the signal’s spectrum. To study this effect, set the noise power to zeroand generate output waveforms for channel bandwidths of :

>> clf;>> b = [0 1 0 0 1 0 0 1 1 0];>> s = modul(b,’bipolar_nrz’);>> subplot(611), scope(s,’one-shot’,10*T);>> subplot(612), scope(bbchannel(s,1,0,4900),’one-shot’,

10*T);>> subplot(613), scope(bbchannel(s,1,0,3000),’one-shot’,

10*T);

and so on for the other bandwidth values ...

You should now have a series of 6 plots with the top plot being the original transmitted wave-form and the subsequent plots showing increasing levels of distortion.

3. Eye pattern

The distortion effects introduced by the channel and noise can be visually inspected by observingthe eye pattern (also referred to as eye diagram) of the ouptut waveform. The eye pattern can beobserved with an oscilloscope where multiple sweeps are superimposed on top of one another. Thesweeps are triggered by a clock signal synchronized to the data rate which can be provided externallyor derived from the channel output itself. Because a large number of sweeps are overlaid, the eye pat-tern is a good visual aid to observe theaverage and theworst-case behavior of the output waveform.Its appearance is that of a circular or somewhat rectangular opening (the eye) between the traces. Aclosed eye indicates an error-prone channel since it shows that there is no error margin in detecting the

PRINT this graph.

PRINT this graph.

0.01 1 5, ,{ }2 3 4, ,{ }

4900 3000 2000 1000 500, , , ,{ } Hz

Page 20: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

18

transmitted symbols. Likewise, if the eye is wide open and the pattern has been observed over a longstring of symbols, this indicates a very low error probability.

3.1 Generation of eye pattern

Start by creating a short binary sequence and generating its eye pattern using the scope com-mand5

>> b = [1 0 0 1 0 1 1 0 0 1];>> s = modul(b,’bipolar_nrz’);>> clf;>> subplot(221), scope(s,’one-shot’,10*T);>> subplot(223), scope(s,’continuous’,2*T);

The eye pattern for the waveform s represents an ideal case, i.e. an undistorted waveform. Nowgenerate the eye pattern of this sequence after it has gone through a band-limited channel:

>> x = bbchannel(s,1,0,4000);>> subplot(222), scope(x,’one-shot’,10*T);>> subplot(224), scope(x,’continuous’,-2*T);

Making the sweep time argument negative causes the eye pattern to be constructed trace by trace.You have to hit the Return key for the next trace to be displayed. By hitting the Return keyrepeatedly, you can visually observe how the pattern is formed.

3.2 You will now learn how to extract meaningful, quanti-fied information from an eye pattern. The key quanti-ties that can be measured on an eye pattern wereillustrated in Figure 3:

A: sampling interval;

B: margin over noise (half of the “eye opening”);

C: distortion of zero crossings;

D: slope - indicative of sensitivity to timing error;

E: maximum distortion;

: optimum sampling instant measured with

respect to the time origin. This is the best possible time to sample the waveform at everysymbol duration to extract the transmitted message with a minimum of errors. Itshould be chosen in the middle of the eye in such a way as to maximize B (and thus min-imize errors due to noise) and maximize the distance to the nearest zero crossings (tominimize errors due to timing jitter).

5. The Matlab Communication Toolbox provides a command to create an eye pattern which can be used instead of scope:eyescat(x,Fd,Fs). Its sweep time is internally set to .T

0.4 0.6 0.8 1 1.2 1.4 1.6−1.5

−1

−0.5

0

0.5

1

1.5

time x T (s)

Am

plitu

de (

V)

Figure 3: The eye pattern.

E

B

A

CD

topt

topt

T

Page 21: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

19

A 1000-bit sequence is transmitted as a bipolar NRZ signal through a channel with bandwidthbw and noise power np. Generate this binary sequence and modulate it using the commandsyou’ve learned so far. Generate the corresponding eye pattern for all values ofbw andnp speci-fied in Table 2. Record , A and B.

3.3 Repeat the procedure in step 3.2 using Manchester line code and record the results in Table 3.

4. Pulse shaping and ISI

Channels with a bandwidth smaller than the nominal bandwidth of the signal, as well as chan-nels with non-flat spectra (e.g. a notch in the middle of the useful band) can cause significant timespreading of the signal. If the time spreading is larger than the symbol duration, it results inintersym-bol interference (denoted as ISI). If we consider one transmitted symbol (pulse) in isolation, ISI refersto the distortion caused by the fraction of energy from other pulses in its vicinity which has been pro-jected onto the desired symbol by the time spread in the channel. This section illustrates how shapingthe pulses prior to transmission via atransmit filter can affect the amount of ISI at the receiver.

The custom Matlab functionisichannel defines a type of channel which will cause a signifi-cant amount of ISI, i.e. a flat frequency response with a notch in the middle:

Table 2: Eye pattern data for bipolar NRZ line code.

np [W] bw [Hz] [s] A [s] B [V]

0.01

3000

2000

1000

0.02

40000.08

0.10

Table 3: Eye pattern data for Manchester line code.

np [W] bw [Hz] [s] A [s] B [V]

0.01

3000

2000

1000

0.02

40000.08

0.10

topt

topt

topt

W

Page 22: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

20

where the width of the notch is specified as a fraction of the total bandwidth.

4.1 First, generate a single unipolar NRZ pulse followed by a string of zeros:

>> b = [1 zeros(1,20)];>> s1 = modul(b,’unipolar_nrz’);

Transmit this sequence through an ISI channel with no noise and a bandwidth of 1500 Hz:

>> x1 = isichannel(s1,1,0,1500,0.2);

We are only concerned with the ISI energy found at the sampling instants. If we have transmitteda single pulse which is sampled at , then all energy found at , , , etc. isISI and the sum of this energy constitutes a measure of the distortion induced by a single pulsethrough the channel under study. We can calculate this quantity with the custom function com-puteisi:

where sampling_instant and origin are specified as multiples of the bit period . Theorigin is normally zero except for non-causal pulse shapes. It can easily be verified that there isno ISI before transmission:

>> computeisi(s1,0.6,0)

In reponse to this command, Matlab should return 0 (note that the trailing semicolon must beomitted in order to get the result printed to the screen). Now compute the ISI at the receiver:

>> computeisi(x1,0.7,0)

4.2 If the transmitted pulses are shaped by an ideal transmitting filter for combatting ISI, the result isthe Nyquist pulse shape which has infinite duration yet is equal to 1 at its main sampling instantand zero at all others.

>> s2 = modul(b,’unipolar_nyquist’);>> x2 = isichannel(s2,1,0,1500,0.2);>> computeisi(s2,0.6,10)>> computeisi(x2,0.7,10)

ISI with no pulse shaping =

output = isichannel(<input>,<gain>,<noise_power>,<bandwidth>,<width_of_notch>,<Fs>);

T 2⁄ 3T 2⁄ 5T 2⁄ 7T 2⁄

isi = computeisi(<signal>,<sampling_instant>,<origin>);

T

Page 23: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

21

Again, you should find that there is no ISI before transmission (the first computeisi com-mand).

POST-LAB QUESTIONS

1. Which line codes will generate a waveform with no DC component regardless of the binarysequence represented? Why is it sometimes important in practice to encode signals for transmis-sion in such a way as to have no DC component?

2. At the output of a channel, it is necessary to extract a symbol-rate clock synchronized with thereceived signal. Such a clock signal indicates when a specific symbol starts and can therefore beused to trigger sampling of each received symbol. This operation, termed timing recovery is facil-itated by some line codes. Which ones? Why? Hint: start by looking at the problem when the mes-sage to be transmitted is all ones or all zeros.

3. Given a baseband data communications channel with a usable bandwidth of 10 kHz, what is themaximum data rate sustainable for each of the line codes examined in this experiment? (Refer topart 1 in the Procedure.)

4. Keeping in mind that the channel noise is additive and uncorrelated with the channel input, derivean expression for the PSD of the channel output in terms of the input and noise PSDs.

5. In tables 2 and 3, compare the eye patterns obtained with noise power of 0.01 W and bandwidth of1000 Hz. For which line code do you observe the best eye diagram? Explain this result in terms ofthe properties of line codes and the channel.

6. Based on your observations of eye patterns, does the optimal sampling instant depend on the

power of the additive noise? Explain.

7. For bipolar NRZ at 1000 b/s, the best pulse shaping filter to combat ISI is an ideal low-pass filterwith a cutoff frequency of 1 kHz. What would be the best pulse shaping filter for the Manchesterline code at the same bit rate?

ISI with pulse shaping =

Percentage of ISI reduction achieved with pulse shaping = %

topt

Page 24: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 1 Baseband Digital Transmission

22

Page 25: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

23

Experiment 2Detection

OBJECTIVES

This experiment studies the signal detection process by examining three important parts of areceiver: the receive filter, the sampler and the slicer. Specifically, you will:

• investigate the characteristics of the optimal receive filter, the matched filter;• use the eye pattern to find the optimal sampling time and the optimal decision thresh-

old(s);• study the performance of receivers with non-optimal receive filters;• study the robustness of a communication system against ISI with various combinations of

transmit and receive filters.

Binarydata TransmitBaseband

modulation Channelfilter

Receivefilter

Datasink

+

• • •

Slicer

• •

• •

b s

xy

t = kT

Additive whiteGaussian noise

(AWGN)

o O Ooo

Oscilloscope

Figure 1: Conceptual diagram.

source

Bit errorrate counter

Page 26: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

24

REFERENCES

[1] S. Haykin,Communication Systems, 4th edition, John Wiley, 2001, pp. 248-253, 259-271 (pp.413-418, 424-440 in the 3rd edition), ISBN: 0-471-17869-1.

[2] B. Sklar, Digial Communications, 2nd edition, Englewood Cliffs: Prentice Hall, 1988, ISBN: 0-13-084788-7.

PRE-LAB QUESTIONS

1. Consider a rectangular pulse of unit amplitude and of width :

a) What is the impulse response of the matched filter of this pulse?b) Determine the output of the matched filter if is the input.c) Repeat parts a) and b) for a triangular pulse with a duration of 10 ms.

2. Let represent the waveform at the output of a distorsionless, noisy channel.

is a bipolar NRZ (antipodal) waveform with unit pulse amplitude and with a binary data rate

of 1 kb/s. The noise has a PSD . If is applied to the

input of a matched filter receiver, then:

a) Determine the average noise power at the output of the matched filter;

b) Determine the peak amplitude of the data-bearing component of the signal at the outputof the matched filter;

c) Determine the average energy of in a bit period;

d) Calculate the probability of bit error .

3. A 4-level NRZ system at a data rate of 500 symbols per second utilizes the following 4 amplitudesto transmit 2-bit symbols: . At the output of a matched filter receiver a 4-level eye pattern is observed as in Figure 2.

a) If all 4 symbols are equally likely, determine the average energy per symbol and theaverage energy per bit as a function of .

b) Consider a unit amplitude bipolar NRZ (binary) system at 1000 bits per second. Calcu-late and compare it with the average energy per bit from part a).

T 10 ms=

p t( ) t T 2⁄–T

------------------ rect=

p t( )

x t( ) s t( ) n t( )+=

s t( )

Fd Sn f( ) N0 2⁄ 1.0 104–× W/Hz= = x t( )

σn2

Eb s t( )

Pe 0.5 Eb N0⁄( )erfc⋅=

3A– A– A 3A, , ,{ } volts

A

Eb

Page 27: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

25

c) For the 4-level system, whatvalue of is required toobtain in all three eye open-ings at the matched filter out-put the same margin over noiseas the binary system in b)?

d) What basic tradeoff is involvedin moving from a binary sys-tem to a 4-level system?

PROCEDURE

Note: this experiment uses thebbchannel custom command exten-sively with long data sequences and there-fore, it will require a significantly longertime to complete if using Matlab student edition. Users of the student edition should set theMATLAB_SE global variable:

>> global MATLAB_SE; MATLAB_SE = 1;

1. Matched filters as optimal receivers

In this experiment we introduce the custom Matlab command matched

which generates the matched filter corresponding to pulse_shape, and where Fs is the simulationsampling frequency which is larger than sampling_rate.

1.1 Begin by generating a single pulse of unit amplitude and 1 ms duration:

>> global Fd Fs;>> Fd = 1000; Fs = 100000; T = 1/Fd;>> s = modul(1, ’unipolar_nrz’);

Now, produce the impulse response of a filter matched to this pulse:

>> mf = matched(’unipolar_nrz’);

Plot the original pulse and its matched filter:

>> subplot(311), scope(s, ’one-shot’, 2*T);

Figure 2:Eye diagram.

A

impulse_resp = matched(<pulse_shape>,<sampling_rate>,<Fs>);

Page 28: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

26

>> subplot(312), scope(mf, ’one-shot’, 2*T);

Now plot the output of the matched filter when s is used as input:

>> subplot(313), scope(afilter(s,mf), ’one-shot’, 2*T);

At what time is the filter output at its peak value?

1.2 You will now repeat this procedure for a Manchester pulse of 1 ms width and unit amplitude:

>> s = modul(1, ’manchester’);>> mf = matched(’manchester’);>> subplot(311), scope(s, ’one-shot’, 2*T);>> subplot(312), scope(mf, ’one-shot’, 2*T);>> subplot(313), scope(afilter(s,mf), ’one-shot’, 2*T);

According to the plots, at what time should the output waveform be sampled?

What is the bit energy of the unit amplitude Manchester pulse?

1.3 Create a bipolar RZ waveform representing the binary sequence using unitamplitude and a binary data rate of 1 kb/s:

>> s = modul([1 0 0 1 0 1 1], ’bipolar_rz’);>> clf, subplot(211), scope(s, ’one-shot’, 7*T);

Pass s through a matched filter and plot the resulting output signal:

>> y = afilter(s, matched(’bipolar_rz’));>> subplot(212), scope(y, ’one-shot’, 7*T);

Note the maximum amplitude of both signals. Use the Matlab function plotyy1 to plot bothsignals on the same graph but with different vertical scales. First, create an appropriately scaledvector (time in seconds) for the abscissa

>> clf>> t = 0:1/Fs:(7*T-1/Fs);>> plotyy(t, s, t, y(1:length(t)));>> title(’Bipolar RZ signal and matched filter output’);

1. plotyy is not available on versions predating version 5.

t = [ms]

t = [ms]

= [J]

Eb

Eb

1 0 0 1 0 1 1, , , , , ,{ }

Page 29: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

27

Add appropriate labels (see thexlabel andylabel commands - usehelp <command> tofind out the correct syntax).

2. Signal detection

2.1 Generate a 10-bit random binary sequence and modulate it into a bipolar NRZ waveform.

>> b = round(rand(1,10));>> s = modul(b, ’bipolar_nrz’);

Now transmits through a baseband channel of bandwidth 4.9 kHz and an additive noise PSD of

. Display the outputx:

>> x = bbchannel(s, 1, 2e-4, 4900);>> clf>> subplot(312), scope(x, ’one-shot’, 10*T);

Attempt to visually decode the transmitted sequenceb by looking only at the outputx:

Now process the outputx with a matched filter. Display the resulting signaly:

>> y = afilter(x,matched(’bipolar_nrz’));>> subplot(313), scope(y, ’one-shot’, 10*T);

Keeping in mind that is the bit duration, visually sample the outputy at instants

where and apply the following decision rule:

You will thus obtain an estimate of the original binary sequenceb:

Now display the original waveforms and compare the original binary sequenceb with your esti-mate:

>> subplot(311), scope(s, ’one-shot’, 10*T);

PRINT this graph.

b =

=

b =

N0 2⁄ 2 104–× W/Hz=

T 1 ms= kT

k 1, ... , 10=

b̂k0 if y kT( ) 0≤1 if y kT( ) 0>î

=

Page 30: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

28

2.2 Change the simulation sampling frequency to Fs = 10000, generate a 10000-bit2 binary sequenceand modulate it using bipolar NRZ:

>> Fs = 10000;>> b = round(rand(1,10000));>> s = modul(b, ’bipolar_nrz’);

Transmit s through a channel with 4.9 kHz bandwidth and additive white Gaussian noise

(AWGN) of PSD .

>> x = bbchannel(s, 1, 0.0e-4, 4900);

Process x using a matched filter. Plot the eye pattern of the matched filter output y for the first300 bits3:

>> y = afilter(x, matched(’bipolar_nrz’));>> clf, scope(y(1:300*Fs/Fd), ’continuous’, 2*T);

By examining the eye pattern, find the optimum sampling instant and the optimum decision

threshold . Please note that the values on the time axis of an eye pattern produced with scope

have to be multiplied by the symbol period . In this case for example, if the sampling instant is

read as 0.5, in reality it is .

Also note that determined from the eye diagram does not correspond to the values found in

Part 1 of the experiment due to the internal workings of some of the custom Matlab modules.

You will use these values as parameters in the detector which processes the matched filter output.If the sampling time and threshold have been chosen correctly, it will result in optimal detectorperformance and hence, minimum probability of error. We use the custom Matlab commanddetect in order to obtain the bit error probability (also called bit error rate or BER):

where <mf_output> is the received signal after the matched filter and <tx_data> the trans-mitted binary data sequence.

2. Matlab student edition users use 1500 bits (700 if version predates 5.0).3. We use y(1:<N_bits>*Fs/Fd) where <N_bits> is the number of bits.

= sampling time = [s]

= threshold = [V]

N0 2⁄ 0.0 104–× W/Hz=

topt

λT

0.5 103–×

topt

λ

topt

ber = detect(<mf_output>,<threshold>,<sampling_time>,<tx_data>);

Page 31: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

29

>> detect(y,<treshold>,<sampling_time>,b)

Repeat the procedure of transmittingsthrough a channel and applying the output toa matched filter followed by a detector withincreasing channel noise PSD’s of

, , , and

W/Hz. Since you have found inExperiment 1 that the optimal threshold andsampling time are independent of the channelnoise power, you can use the same parame-ters for detection for all values of the noise PSD. Record the resulting probability of bit error

in Table 1, and observe the relationship between the eye diagram and the probability of bit error.To speed up this repetitive process, you may want to use the custom Matlab commandtrans-mit to modulate, transmit, and match filter the signal. This command also displays the eye dia-gram.

>> y = transmit(b, ’bipolar_nrz’, <noise_PSD>, 4900);>> ber = detect(y, <threshold>, <sampling_time>, b)

2.3 To observe the effect of using a non-optimal sampling time, you will produce a plot of versus

sampling time. Use a channel noise PSD of W/Hz in obtainingx.

Note: Matlab will not display the usual>> prompt while you enter the body of thefor loop.Also, there is no semicolon at the end of the line containing thefor statement.

>> y = transmit(b, ’bipolar_nrz’, 0.5e-4, 4900);>> st = 0:1/Fs:1/Fd;>> pe = zeros(1,length(st));>> for i = 1:length(st)

pe(i) = detect(y,<threshold>,st(i),b);end;

>> plot(st,pe);>> xlabel(’sampling time’);>> ylabel(’Bit error rate (BER)’);>> title(’BER vs. sampling time’);

PRINT this graph.

Table 1: BER vs. noise power.

measured theoretical

0.5

1.0

1.5

2.0

N0 2⁄ Pe Pe

0.5 104–× 1 10

4–× 1.5 104–×

2 104–×

Pe

y = transmit(<tx_data>,<line_code>,<noise_PSD>,<bandwidth>);

Pe

0.5 104–×

Page 32: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

30

2.4 We will now observe the effects of the channelbandwidth on the bit error rate. Follow the sameprocedure as in Section 2.2, transmitting through

a channel with noise PSD of W/Hzand bandwidths of 1500, 1000, 500 and 350 Hz.Record the corresponding bit error rates in Table2. Since the bandwidth is being varied, you willhave to plot an eye diagram for every channel inorder to obtain optimal thresholds and samplinginstants.

Obtaining the proper sampling instant for the smaller bandwidths (e.g. 500 Hz and 350 Hz) canbe difficult.

• If the eye is “closed”, you might need to attempt to find by plotting the eye pattern

using a shorter portion of the signal samples iny, for example:

>> clf, scope(y(1:1500),’continuous’,2*T);

While you might still obtain a “closed” eye, it will usually be easier to visually identify thelocation of the zero crossings and then find somewhere between. If that doesn’t help,

you may try to find through an iterative trial and error procedure by searching for the

minimum obtainable BER. Start with a value of 0 ms and increment it by 0.1 ms until theresulting BER stops decreasing. Since the sampling time and threshold do not depend onthe noise power, you may also want to temporarily set the noise PSD to 0 W/Hz to get aclearer view of the eye.

• If the resulting BER is close to 0.5, insert a delay of one symbol as the last parameter inthedetect command:

>> detect(y,<threshold>,<sampling_time>,b,1)

For example, if the value of<sampling_time> is 0.0001, then the above syntax willresult in an effective sampling time of 0.0011 (since the symbol period is 0.001).

3. Performance of optimal receivers against ISI

In Experiment 1 it has been demonstrated that the use of an ideal pulse shaping filter leads to asignificant improvement when transmitting through an ISI-inducing channel. The channel studied atthat point had sufficient overall bandwidth but had a large notch in the middle of its band whichcaused ISI. Here we will look at a channel whose bandwidth is too narrow - also a source of timespreading and hence, ISI. We will look at how various pairs of transmit and receive filters perform inthis environment in terms of the system bit error rate.

Table 2: BER vs. channel bandwidth.

bandwidth measured

1500 Hz

1000 Hz

500 Hz

350 Hz

Pe

0.5 104–×

topt

topt

topt

Page 33: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

31

3.1 Modulate the binary sequence b using bipolar NRZ and transmit it through a noiseless channelwith bandwidth of 550 Hz. Process the received signal with a bipolar NRZ matched filter. Dis-play the eye pattern and obtain the optimal sampling time and threshold. Remember including aone-symbol delay if the BER is close to 0.5, as well as the suggestions from Section 2.4 regard-ing “closed” eye patterns

>> y = transmit(b, ’bipolar_nrz’, 0, 550);>> detect(y, <threshold>, <sampling_time>, b, <delay>)

Repeat with a bandwidth of 350 Hz and record the probability of bit error.

3.2 We will now attempt to transmit through this channel using raised cosine pulses.

The optimum pulse shape for combatting ISI is the Nyquist pulse that we studied in Experiment1. However, this pulse presents two major difficulties for practical realizations. It is non-causaland therefore, in practice it requires the use of a delayed version; its rate of convergence to zerois slow. The tails decay at rate of which means that the smallest error in the sampling instantat the output of the matched filter receiver results in an infinite series of ISI components.

The family of raised-cosine pulses (so-called because of the shape of their spectrum) also satis-fies the Nyquist criterion but offer realizability and faster decay rates of the tails. The penalty topay is some amount of excess bandwidth controlled by the roll-off factor .

Modulate the same sequence using pulses shaped by a square root raised cosine filter with a roll-off factor of 0.2. Transmit the resulting signal through a noiseless channel with a bandwidth of550 Hz, process it with the appropriate matched filter, and view the eye diagram.

>> y = transmit(b, ’raised_cosine’, 0, 550, <roll_off>);

Determine the correct threshold and sampling time, and obtain the probability of bit error.Beause of the non-causality and the length of the raised cosine pulse, there is an additional trans-mission delay, which is set to 20 symbols for this Matlab simulation. Correspondingly, a delay of20 symbols must be introduced at the detector:

>> ber = detect(y, <threshold>, <sampling_time>, b, 20)

As before, you might have to include an additional 1 symbol delay (simply replace 20 by 21).

Repeat this experiment for channels with bandwidths of 450, 400, and 350 Hz.

bipolar NRZ, ==> =

square root raised cosine, , ==> =

==> =

==> =

==> =

W 350 Hz= Pe

1 t⁄

β

β 0.2= W 550 Hz= Pe

W 450 Hz= Pe

W 400 Hz= Pe

W 350 Hz= Pe

Page 34: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

32

3.3 For a channel with a bandwidth of 350 Hz, note the results of Parts 3.1 and 3.2 in the appropriatecells of Table 3. Repeat the steps you did in Part 3.2 with all the roll-off factors in the table.Changing the roll-off factor does not affect the sampling instant, so you don’t need to display theeye diagram again.

Repeat with a bandwidth of 400 Hz. Remember that changing the channel bandwidth couldrequire determining again.

4. Correlative-level coding (duobinary)

To respect the zero-ISI (Nyquist) criterion, the signalling rate must be lower than where

is the nominal bandwidth of the channel. While it is, in theory, possible to reach the rateusing ideal Nyquist pulses, this leads to unrealizable filters in practice. However, it is possiblewith realizable filters to reach by introducing a controlled amount of ISI in such a way thatit can be easily removed at the receiver. The duobinary pulse shape is the best known example ofthis concept: it has unit amplitude at the origin and at, and an amplitude of zero at all other

multiples of (see [1] or [2]).

4.1 We will modulate the sequenceb (generated in Section 2.2) using duobinary pulses, transmit itthrough a noiseless channel with a bandwidth of 500 Hz, processes the received signal with amatched filter, and display the resulting eye diagram.

>> y = transmit(b, ’duobinary’, 0, 500);

Because of the controlled ISI, the eye pattern shows two openings on top of one another corre-sponding to three received levels that must be decoded. Therefore, two thresholds,one negative and one positive, must be selected as the vertical midpoints of the lower and uppereye opening, respectively.

Note: pay attention to the scaling of the eye pattern when determining the thresholds.

Table 3: BER vs. raised cosine roll-off factor.

pulse shape @ 350 Hz @ 400 Hz

bipolar NRZ

rais

ed c

osin

etopt

Pe Pe

β 0=

β 0.2=

β 0.5=

β 1.0=

2W W

2W

2W

T

T

A– 0 A, ,{ }

Page 35: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

33

You will use the special detection functionduodetect to apply the decision rule:

with <mode> set to the string value ‘normal’ and a delay of 20 bits.

>> duodetect(y, <neg_threshold>, <pos_threshold>,<sampling_time>, ’normal’, b, 20)

You should have obtained a perfect bit error rate of 0. While you can obtain the same result withraised cosine pulses through a bandwidth a 500 Hz, these have excess bandwidth (as determinedby the roll-off factor) and are therefore sending energy outside the 500 Hz band which couldinterfere with other channels in some real-world systems. Duobinary enables error-free transmis-sion through systems strictly band-limited to half the data rate using filters that are realizable inpractice.

4.2 Retransmit the data sequenceb through the same channel but adding noise with PSD

W/Hz. Record the corresponding in Table 4 in the “normal” column. Repeat this procedure

for all listed noise PSD’s.

4.3 You will now precode the binary sequence before modulating and transmitting it:

>> bb = precoding(b);>> y = transmit(bb, ’duobinary’, 0, 500);

Repeat the experiment for all noise power levels. The same thresholds and sampling instantapply. Record your results in Table 4 in the “precoded” column. Use the ‘coded’ decision modeat the detector:

>> duodetect(y, <neg_threshold>, <pos_threshold>,<sampling_time>, ’coded’, b, 20)

duobinary, noiseless, ==> =

Table 4: BER in a duobinary system.

noise power -- normal -- precoded

ber = duodetect(<mf_output>,<neg_threshold>,<pos_threshold>,<sampling_time>,<mode>,<tx_data>,<delay>);

W 500 Hz= Pe

1 107–×

Pe

Pe Pe

1 107–×

5 107–×

10 107–×

50 107–×

Page 36: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 2: Detection

34

POST-LAB QUESTIONS

1. Construct the waveform at the output of a matched filter if the input is a unipolar NRZ waveformrepresenting the sequence .

2. Refer to Section 2 of the experiment. Is it easier to decode the output of the channel beforematched filtering or after? Why? If a sampling instant other than the optimum (as observed on theeye diagram) is chosen, the is larger. Why?

3. Calculate the theoretical probability of bit error for all cases considered in Table 1. Record youranswers in the table.

4. Observe in Table 3 the relationship between the roll-off factor and the BER when the bandwidth is350 Hz. Can you explain it in terms of the properties of raised cosine pulses?

5. Did you observe in Table 4 better performance with precoding? Explain your result using theory(see [1] or [2]).

1 0 0 1 0, , , ,{ }

Pe

Page 37: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

35

Experiment 3Bandpass Digital Modulation

OBJECTIVES

This experiment extends the concepts learned in experiment 1 and 2 to the context of bandpassdigital transmission. Specifically, we will look at:

• the main forms of bandpass digital modulation and their relationship to baseband linecodes;

• the difference between coherent and noncoherent detection;• the effects of phase error and frequency drift on coherent demodulation;• the system bit error rate in the presence of additive gaussian noise.

Binarydata TransmitBandpass

modulation Channelfilter

Receivefilter

Datasink

+

• • •

Slicer

• •

• •

b s

xy

t = kT

Additive whiteGaussian noise

(AWGN)

o O Ooo

Oscilloscope

Figure 1: Conceptual diagram.

source

Bit errorrate counter

Bandpassdemodulation

Baseband

Local

Upconverter

modulation(line coding)

oscillator

Page 38: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

36

REFERENCES

[1] S. Haykin, Communication Systems, 4th edition, John Wiley, 2001, pp. 344-420 (pp. 473-563 inthe 3rd edition), ISBN: 0-471-17869-1.

[2] B. Sklar, Digital Communications, 2nd edition, Englewood Cliffs: Prentice Hall, 1988, ISBN: 0-13-084788-7.

PRE-LAB QUESTIONS

1. The binary sequence is to be transmitted through a bandpass channel at abit rate of 1 kb/s and a peak signal amplitude of 1 V.

a) Draw the ASK waveform representing the sequence if the carrier frequency is 5 kHz.

b) Draw the PSK waveform representing the sequence if the carrier frequency is 10 kHz.c) An FSK modulator uses mark and space frequencies of 4 and 6 kHz, respectively. Draw

the corresponding FSK waveform representing the sequence .

2. Draw the power spectral densities of each of the modulated signals considered in question 1 andjustify their shape.

3. If an ASK signal is applied to the input of a coherent detector as shown in Figure 2, draw thewaveform at the output of each block if the bit sequence from question 1. is transmitted.

4. Repeat question 3 for the noncoherent detector shown in Figure 3.

PROCEDURE

1. Generation of bandpass modulated signals

1.1 Amplitude-Shift Keying. Generate a binary sequence with the first 6 bits , andset the binary data rate Fd to 1 kb/s and the the simulation sampling rate Fs to 50 kHz:

>> global Fd Fs;>> Fd = 1000;>> Fs = 50000;>> b = [1 0 1 0 0 1 round(rand(1,994))];

If using the student edition of Matlab, limit the bit sequence to 250 bits. However, this will resultin hard to identify power spectra.

Modulate this sequence into an ASK signal with a carrier frequency of 5 kHz by first generatinga unipolar NRZ signal s from the sequence b, then mixing this sequence with a local oscillator

b 1 0 1 0 0 1, , , , ,{ }=

b

b

b

1 0 1 0 0 1, , , , ,{ }

Page 39: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

37

with a frequency of 5 kHz.

>> s = modul(b,’unipolar_nrz’);>> sa = mix_lo(s,5000,0);

Display the first 6 ms of the signals s and sa corresponding to the first 6 bits of the binarysequence b. Examine the relationship between the two signals.

>> clf, subplot(211), scope(s,’one-shot’,0.006);>> subplot(212), scope(sa,’one-shot’,0.006);

1.2 Plot the PSD functions of s and sa between 0 and 10 kHz:

>> [Ss,f] = psd(s,2500,Fs,’mean’);>> clf, subplot(211), plot(f(1:500),Ss(1:500));>> title(’Graph 1-a: PSD of unipolar NRZ’);>> [Ssa,f] = psd(sa,2500,Fs,’mean’);>> subplot(212), plot(f(1:500),Ssa(1:500));>> title(’Graph 1-b: PSD of ASK’);

1.3 Phase-Shift Keying. Generate a PSK signal by first modulating b into a bipolar NRZ signal sand then mixing s with a 5 kHz local oscillator:

>> s = modul(b,’bipolar_nrz’);>> sp = mix_lo(s,5000,0);

Display the first 6 ms of the waveforms s and sp:

>> clf, subplot(211), scope(s,’one-shot’,0.006);>> subplot(212), scope(sp,’one-shot’,0.006);

What is the phase difference between sp and the carrier during the first and second bit periods?

1.4 Now plot the PSD functions of s and sp:

>> [Ss,f] = psd(s,2500,Fs,’mean’);>> clf, subplot(211), plot(f(1:500),Ss(1:500));>> [Ssp,f] = psd(sp,2500,Fs,’mean’);>> subplot(212), plot(f(1:500),Ssp(1:500));

Do you observe any relationship between the PSD of s and that of sp?

PRINT this graph.

Answer =

Answer:

Page 40: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

38

1.5 We now compare the power spectrum of ASK with that of PSK.

>> clf, subplot(211), plot(f(1:500),Ssa(1:500));>> title(’Graph 2-a: PSD of ASK’);>> subplot(212), plot(f(1:500),Ssp(1:500));>> title(’Graph 2-b: PSD of PSK’);

Zoom in on the two power spectra so as to have ’enough’ detail and about the same scaling forboth. What differences and/or similarities do you notice?

1.6 Frequency-Shift Keying. Generation of a FSK signal also starts with a bipolar NRZ signal (sfrom the previous section) which is applied to the input of a voltage-controlled oscillator (VCO)with a free-running frequency of 5 kHz and a sensitivity of 2 kHz/V.

>> sf = vco(s,5000);

Display the first 6 ms of the waveforms s and sf:

>> clf, subplot(211), scope(s,’one-shot’,0.006);>> subplot(212), scope(sf,’one-shot’,0.006);

1.7 Display the PSD function of sf:

>> [Ssf,f] = psd(sf,2500,Fs,’mean’);>> clf, plot(f(1:500),Ssf(1:500));>> title(’Graph 3: PSD of FSK’);

Explain the shape of the obtained power spectrum.

2. Coherent detection of bandpass modulated digital signals

Figure 2 illustrates the structure of a coherent detector applicable to ASK and PSK signals.

2.1 To demodulate the ASK signal sa, start by mixing it with a carrier produced by a local oscillatorwith the same frequency and phase as the original LO. Display the resulting waveform xa for thefirst six bit periods (6 ms). Also, produce and display the PSD function of xa over the interval

.

>> xa = mix_lo(sa,5000,0);>> clf, subplot(211), scope(xa,’one-shot’,0.006);

Answer:

PRINT this graph.

PRINT this graph.

0 15 kHz,[ ]

Page 41: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

39

>> [Sxa,f] = psd(xa,2500,Fs,’mean’);>> subplot(212), plot(f(1:750),Sxa(1:750));

Identify this graph as Graph 4 and explain the result.

Apply xa to the input of a unipolar NRZ matched filter and display the output waveform overthe first 6 bit periods.

>> ya = afilter(xa,matched(’unipolar_nrz’));>> subplot(212), scope(ya,’one-shot’,0.006);

2.2 We will now examine the performance of coherent detection in the presence of noise. Users ofMatlab student edition should set the MATLAB_SE global variable:

>> global MATLAB_SE; MATLAB_SE = 1;

First, generate a 10000-bit1 binary sequence and modulate it as an ASK waveform:

>> Fs = 20000;>> b = round(rand(1,10000));>> s = mix_lo(modul(b,’unipolar_nrz’),5000,0);

Transmit sa through a channel with additive noise of power of 0.5 W:

>> x = bbchannel(s,1,0.5,8000);

Using coherent detection principles, demodulate x and display the eye pattern over the durationof 200 bits2 3.

>> y = afilter(mix_lo(x,5000,0),matched(’unipolar_nrz’));

1. With Matlab student edition use 800 bits (400 if version predates 5.0).2. We use y(1:<N_bits>*Fs/Fd) where <N_bits> is the number of bits.

PRINT this graph.

Figure 2: Coherent detection of ASK and PSK signals.

Integrator ormatched filter

Sampleand hold

x(t) y(t)

synchronizedbit rate clock

thresholdb̂k{ }

Localoscillator

Carrierrecovery

Page 42: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

40

>> clf, scope(y(1:4000),’continuous’,0.002);

Find the optimal sampling instant and threshold level and proceed to compute the BER:

>> detect(y,<threshold>,<sampling_time>,b)

Record your result in Table 1 then repeat the above for a noise power of 1 W.

Repeat the experiment using a PSK waveform. To generate and demodulate a PSK waveform,use the same procedure as for ASK but substitute ’bipolar_nrz’ instead of’unipolar_nrz’ as the argument of modul and matched. Display the eye pattern again tofind the optimum sampling time and threshold for the PSK case.

The main difficulty in implementing coherent detection lies in the need to have perfectly syn-chronized local oscillators at both the transmitter and the receiver. Unless side information issent about the phase and frequency of the transmitting L.O. (a waste of bandwidth), it is neces-sary to “extract” the carrier phase from the received signal. Various methods can be used for thispurpose that will not be explained here. The result, however, is that no practical system usingcoherent detection is completely free of the impediments called phase jitter and frequency drift.

2.3 Phase error. Repeat the experiment above with a PSK waveform for 1 W of noise power andwith the addition of a phase error in the demodulation process, e.g.:

>> y = afilter(mix_lo(x,5000,<phase_error>),matched(’bipolar_nrz’));

where the phase error is specified in degrees. Since the case has already been treated in theprevious section, try the remaining values of phase error listed in Table 2. Observe the resulting

and record your results.

2.4 Frequency drift. Generate a 500-bit binary sequence and modulate it to produce an ASK wave-form:

>> b = round(rand(1,500));

3. This particular eye pattern might be closed and difficult to interpret. Try plotting it for a shorter portion of the sequence,say of 100 bits. You can estimate where the opening should be by the shape of the signal lines. Locate the threshold asbeing in the middle of the pattern, i.e. take the average of the maximum and minimum observable voltage levels.Remember that for bipolar schemes, the optimal threshold should always be zero. In order to find you may need to

resort to an iterative trial and error procedure by searching for the minimum obtainable BER. Start with a value of 0 msand increment it by 0.1 ms until the resulting BER stops decreasing.

Table 1: ASK and PSK bit error rates.

noise power - ASK - PSK

0.5 W

1.0 W

topt

Pe Pe

Pe

Page 43: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

41

>> s = mix_lo(modul(b,’unipolar_nrz’),5000,0);

Demodulate this signal using a perfectly frequency-locked L.O. (5 kHz) and using a L.O. suffer-ing a slight frequency drift (4.975 kHz):

>> y = afilter(mix_lo(s,5000,0),matched(’unipolar_nrz’));>> yd = afilter(mix_lo(s,4975,0),matched(’unipolar_nrz’));

Observe and compare the two waveforms over the first 50 bit periods:

>> clf, subplot(211), scope(y,’one-shot’,0.05);>> subplot(212), scope(yd,’one-shot’,0.05);

Identify this graph as Graph 5.

Visually determine the frequency of the envelope of the matched filter output yd.

2.5 You will now modulate the sequence b you generated above to produce a PSK waveform:

>> s = mix_lo(modul(b,’bipolar_nrz’),5000,0);

Demodulate s as you did above for the ASK case using the following local oscillator frequen-cies: {4999.5, 4999.4, 4999.3, 4999.2, 4999.1, 4999.0} Hz. Remember to use a matched filtercorresponding to the bipolar NRZ pulse. Find the bit error rate for each case. You may want

to use the eye pattern to determine the optimum sampling instant and threshold. Record yourresults in Table 3.

3. Noncoherent detection of bandpass modulated digital signals

Figure 3 illustrates the structure of a noncoherent receiver4 for ASK signals. Noncoherent detec-tion does not require a local oscillator synchronized with the carrier. However, the obtained with a

Table 2: PSK BER vs. phase error.

phase error

PRINT this graph.

Envelope frequency = [Hz}

Table 3: PSK BER vs. frequency error.

LO frequency [Hz] 4999.5 4999.4 4999.3 4999.2 4999.1 4999.0

0° 5° 10° 25° 50° 75°

Pe

Pe

Pe

Pe

Page 44: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

42

noncoherent receiver is generally higher than that obtained with a coherent receiver with good oscilla-tor lock.

The bandpass filter typically has a bandwidth of and serves to limit the out-of-band noiseand interference in the system. The envelope detector consists of a rectifier followed by a low-pass fil-ter with appropriate cut-off frequency . It is important that be chosen somewhere in the interval

, where is the bandwidth of the signal and the carrier frequency, since its role is to pre-

serve signal information while eliminating the rapid fluctuations due to the carrier.

3.1 To illustrate, create an ASK waveform and demodulate it using a noncoherent receiver whoseenvelope detector has a cut-off frequency of 3500 Hz.

>> b = [1 0 1 0 0 1 1 0 round(rand(1,12))];>> sa = mix_lo(modul(b,’unipolar_nrz’),5000,0);>> ya = envelope(sa,3500);

Display the first 8 bit periods of both the modulated waveform and the output of the envelopedetector. Identify this graph as Graph 6.

Can threshold decoding be applied at the output of the envelope detector?

3.2 Repeat the ASK portion of section 2.2 with a noise power of 0.05 W for both coherent and non-coherent detection. For noncoherent detection you have to replace the demodulation andmatched filtering with envelope detection, as in part 3.1. Use a 10000 bit sequence as your start-ing point:

>> b = round(rand(1,10000));

4. Note that this is not the optimum noncoherent receiver but only a simplified implementation. As such, this receiverstructure does not optimize the signal to noise ratio.

PRINT this graph.

Figure 3: Noncoherent detection of ASK signals using an envelope detector.

Bandpassfilter

Envelopedetector

Sampleand hold

x(t) y(t)

synchronizedbit rate clock

thresholdb̂k{ }

1 T⁄

f o f o

W f c,[ ] W f c

Page 45: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

43

For coherent detection use the threshold and value determined in part 2.2, while for nonco-

herent detection you will have to display the corresponding eye pattern.

POST-LAB QUESTIONS

1. How would it be possible to produce an FSK signal using two ASK modulators?

2. If efficient bandwidth utilization and good bit error rate performance are the most importantdesign criteria for a communication system, which modulation scheme (ASK, PSK or FSK)would you choose?

3. In coherent demodulation, the matched filter used is the same as for unipolar NRZ. Why? Howdoes it operate?

4. An ASK signal with carrier frequency is demodulated by mixing it with the output of a local

oscillator whose frequency is slightly off (i.e. ). This causes the envelope of the

matched filter output to be modulated by a low-frequency sinusoid. Determine analytically thefrequency of this parasitic modulation as a function of and .

5. From your results in Table 3 comment on how precise the frequency of the local oscillator at thereceiver has to be for reliable performance. You obtained those results over an observation periodof 0.5 s (i.e. 500 bits at 1 kb/s). Would the bit error rates change significantly if we increased theobservation period to 1 s? Explain. Hint: start from the equation of the demodulated signal whichincludes the effect of the frequency error.

6. For the two cases (ASK and PSK) considered in section 2.2, calculate the theoretical bit error rate.Keep in mind that:

where the system bandwidth in this case is 8 kHz. Hint: to find you will have to calculate the

energy of the actual RF pulse.

7. Draw the structure of a non-coherent detector for FSK.

coherent ASK, = 0.05 W ==> =

noncoherent ASK, = 0.05 W ==> =

topt

σn2 Pe

σn2 Pe

f c

f o f 0 f c≠

f c f o

Sn f( )N0

2-------

σn2

2 system bandwidth×----------------------------------------------------= =

Eb

Page 46: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 3: Bandpass Digital Modulation

44

Page 47: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

45

Experiment 4Error-Control Coding

OBJECTIVES

This experiment examines channel coding as a means to improve the bit error rate through hostilechannels. Specifically, we will look at:

• Block codes and their performance against random errors;• Reed-Solomon block codes and their performance against bursty errors;• Convolutional codes and Viterbi decoding;• Differences between hard decisions and soft decisions.

Binarydata

BinaryCoding

Soft-decision

symmetric

Receivefilter

Datasink

Slicer• •

b d

y

t = kT

Figure 1: Conceptual diagram.

source

Bit errorrate counter

Bandpassdemodulation

channel

decoder

Slicer

Hard-decisiondecoder

•c e

TransmitBandpassmodulation Channelfilter +•

s

Additive whiteGaussian noise

(AWGN)

•x

Physical channel

Page 48: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 4: Error-Control Coding

46

REFERENCES

[1] S. Haykin, Communication Systems, 4th edition, John Wiley, 2001, pp. 626-668 (pp. 670-715 inthe 3rd edition), ISBN: 0-471-17869-1.

[2] W. Wand, Communications Toolbox User’s Guide, Natick: The Mathworks Inc., 1996.

[3] B. Sklar, Digital Communications, 2nd edition, Englewood Cliffs: Prentice Hall, 1988, ISBN: 0-13-084788-7.

PRE-LAB QUESTIONS

1. Consider the following code:

a) Is this a linear code? Explain.b) Is it a systematic code? If not, how can it be made

systematic?c) What is the generator matrix of the code?

d) Construct the parity check matrix .

e) What is the minimum distance ?

f) What is the error-correcting capability?g) What is the error-detecting capability?h) Compute the syndrome corresponding to the

received word .

2. Data is transmitted using coherently-detected BPSKthrough a memoryless channel with additive gaussian

noise power density . The infor-

mation (uncoded) rate is 1 kb/s and the amplitude of thereceived BPSK signal is 0.02 V. A (24,12) linear blockcode is under consideration for this communication link:it is capable of correcting all 1-bit and 2-bit errors but cancorrect no error patterns of more than 2 bits.

a) Calculate the uncoded probability of bit error.b) Calculate the uncoded message error probability.c) Calculate the coded message error probability.

3. Consider the convolutional encoder depicted in Figure 2.

a) What is the constraint length of this code?b) What are the generator polynomials?c) Draw the corresponding state diagram.d) What is the minimum free distance?

message codeword

000 000000

001 100100

010 010010

011 110110

100 001001

101 101101

110 011011

111 111111

GH

dmin

100111

input output

Figure 2: Convolutional encoder.

N0 28 109–

W/Hz×=

Page 49: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 4: Error-Control Coding

47

e) What is the error-correcting capability?

PROCEDURE

Note: this experiment requires the full professional version of Matlab and the Communications Tool-box. It is not compatible with the Matlab student edition.

1. Linear block codes

1.1 Hamming codes. Hamming codes constitute a family of linear block codes covering a widerange of message and code word lengths ( and ). First, generate a sufficiently long bitsequence for encoding:

>> b = round(rand(20000,1));

Encode this sequence using a Hamming (7,4) code.

>> c = encode(b,7,4);

You will now transmit this sequence through a binary symmetric channel with a probability ofbit error of 0.01. This is an abstract channel model that is often used in studying codes because ofits simplicity. It includes the effect of modulation and demodulation, the radio channel, additivenoise and pulse shaping. Its sole characteristic parameter is the probability of bit error, which isthe same whether a 1 or a 0 has been transmitted (hence the designation: “symmetric”). See also[1] pp. 583-584.

>> d = bsc(c,0.01);

Decode the signal at the output of the channel.

>> e = decode(d,7,4);

Finally, compute the coded and uncoded bit error rates, pc and pu and record them in Table 1.

>> [n_err,pc] = biterr(b,e(1:20000))>> [n_err,pu] = biterr(c,d)

Repeat this experiment for a Hamming (15,11) code and a Hamming (31,26).

Table 1: Binary symmetric channels: Hamming codes.

code channel BER uncoded BER coded BER

(7,4) 0.01

(15,11) 0.01

(31,26) 0.01

n k

Page 50: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 4: Error-Control Coding

48

1.2 BCH coding and the coding threshold. We will now experiment with a more powerful familyof codes, the Bose-Chandhuri-Hocquenghem (BCH) codes.

In order to perform a “fair” comparison between coded and uncoded communication links, onemust take into account the amount of overhead required by the code. Consider a BPSK systemwith a binary data rate of 1 kb/s. Suppose that at the receiver. Hence:

If we now want to introduce a (127,36) BCH code into this system while maintaining the same

useful information rate, it will be necessary to boost the raw bit rate by a factor of . Since the

amplitude of the received waveform is fixed, this will decrease by a factor of . Using this

new value of , an “adjusted” channel bit error rate (prior to decoding) can be computed taking

into account the increased bit rate required by the code.

Compute the channel bit error rates with and without coding for all cases listed in Table 2. Usethe erfc command to compute values of the function. Record your results.

Now, encode b using a (127,36) BCH code:

>> c = encode(b,127,36,’bch’);

Assuming that in the uncoded case, transmit the coded sequence through a

binary symmetric channel with appropriately adjusted bit error rate. Decode the receivedsequence and compute the coded bit error rate; record it in Table 2. For this purpose, use

>> e = decode(d,127,36,’bch’);

Repeat this sequence of operations for all values of listed in the table.

Table 2: Binary symmetric channels: BCH codes.

uncodedchannel(no code)

channel(with code)

coded

4 dB 0.0125

5 dB

6 dB

7 dB

8 dB

Eb N0⁄ 4 dB=

Pe12---

Eb

N0-------

erfc 0.0125= =

12736---------

Eb36127---------

Eb

•( )erfc

Eb N0⁄ 4 dB=

Eb N0⁄

Eb N0⁄ Pe Pe Pe

Page 51: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 4: Error-Control Coding

49

1.3 Performance of coding in bursty error channels. Up to now, the channels considered werecharacterized by random individual errors since additive white gaussian noise was assumed.However, many channels of practical importance are characterized by bursts of errors where alarge number of consecutive symbols are affected. Sources of bursty errors include impulse noiseand multipath fading. Most codes are better equipped to handle random individual errors thanlarge error bursts. This section studies the performance of different coding systems againstbursty error channels.

First, encode the sequence b using a (127,85) BCH code, which has an error correction capabil-ity of 5 bits per block. Then, pass it through a binary symmetric channel with bit error rate 0.04(i.e. on the average approximately 5 errors per block). Decode the output, compute the codedBER and record the result in Table 3.

Now transmit the same coded sequence through a bursty error channel with a bit error rate of0.04 and an average burst length of 5 bits:

>> d = bebsc(c,0.04,5);

Decode the output, compute and record the BER. Transmit the coded sequence c again through abursty error channel, this time with an average burst length of 10 bits.

Now encode b with a (127,85) Reed-Solomon code:

>> c = encode(b,127,85,’rs’);

Retry all three channels described above with the Reed-Solomon coded sequence. Record yourresults in the table. Make sure that you do specify Reed-Solomon decoding.

1.4 Coding gain. Consider a BPSK communication system characterized by a bit error rate of 0.01.Compute at the receiver for this system.

To simulate such a system using a binary symmetric channel with coding, we will base our cal-culations on the above channel . This will enable us to see the improvement due to coding

without having to simulate in detail the modulation and demodulation process. We will employ a(127,85) BCH code.

First, compute the adjusted channel bit error rate to account for the introduction of coding over-

Table 3: Bursty error channels: BCH vs. Reed-Solomon codes.

channel type channel BER coded BER - BCH coded BER - RS

non-bursty 0.04

burst lenght = 5 0.04

burst lenght = 10 0.04

Uncoded = [dB]

Eb N0⁄

Eb N0⁄

Pe

Page 52: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 4: Error-Control Coding

50

head (refer to section 1.2).

Encode the sequence b using a (127,85) BCH code. Transmit it through a binary symmetricchannel using the adjusted bit error rate as parameter. Decode the sequence and compute theresulting bit error rate.

Analytically determine the which would be required to obtain the same bit error rate

without coding.

Now compute the coding gain according to this formula:

Coding Gain = Coded equivalent - Uncoded

2. Convolutional codes

A convolutional code is defined by three parameters . The number of parallel shift regis-

ters used in the encoder is while is the number of bits being output every time the shift registers

are rotated by one. Hence, the rate of the code is defined as with linear codes, being . Parameter

is the length in bits of the longest shift register, and it is called the constraint length. Since it indi-cates the amount of memory intrinsic to the code, it is an important measure of the code’s power.

The convolutional encoder depicted in the prelab (Figure 2) has the binary transfer function

It is easy to see the correspondence between the branches linking the shift register to the top and bot-tom adders and the bits in the transfer function. Quite simply, a “0” denotes the absence of a branch atthe corresponding position. See [3] for a list of optimum short constraint length convolutional codes.

Matlab does not accept binary transfer functions (or at least not in a simple format as explainedabove), but it does accept an equivalent octal format according to which the above transfer functionwould be .

Adjusted channel bit error rate =

Coded bit error rate =

Coded equivalent = [dB]

Coding gain = [dB]

Eb N0⁄

Eb N0⁄

Eb N0⁄ Eb N0⁄

n k K, ,( )n k

k n⁄K

1 1 1 1

1 0 1 1

17 13,[ ]

Page 53: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 4: Error-Control Coding

51

2.1 First, generate a shorter bit sequence:

>> b = round(rand(2000,1));

Define the octal transfer function of an optimal (2,1,3) convolutional code and use it to encode b.

>> tf = [7 5];>> c = encode(b,2,1,’convol’,tf);

To demonstrate the power of even a simple convolutional code, we will use the most hostilechannel yet: a binary symmetric channel with a bit error rate of 0.1.

>> d = bsc(c,0.1);

To decode the received sequence, the Matlab decode command uses the Viterbi algorithm formaximum-likelihood estimation of the transmitted sequence. The Viterbi algorithm finds theshortest path through the trellis (see [1] pp. 661-663) since the start of the transmission. In prac-tice, however, it is necessary to truncate the path history to some finite length to save memoryand to obtain a finite, reasonable decoding delay. It is generally accepted that a truncation lengthof 5 times the constraint length of the code is enough to ensure minimal degradation in perfor-

mance. The truncation length is the optional 6th parameter of the Matlab decode command.However, we will use instead a variant of the decode command that provides a timing facilityto measure the decoding delay:

>> [e,t] = timedecode(d,2,1,’convol’,tf,15);

Compute the bit error rate as usual1. Record your results in Table 4. Repeat this procedure for thelisted code in the table; remember to always use as the truncation length.

POST-LAB QUESTIONS

1. In Table 1 you recorded the results of your experiment with Hamming codes. According to yourobservations, do larger Hamming codes (e.g. (31,26)) perform better than smaller ones (e.g.(7,4))? If not, what is the point of using the larger, more complex codes?

2. Consider your experiment with the Hamming (7,4) code. bits were transmitted, of

1. Since the length of the bit sequence has changed, use e(1:2000) instead of e(1:20000) when computing the biterror rate.

Table 4: Convolutional codes.

transfer function channel BER coded BER decoding time [s]

3 [7,5]

4 [17,13]

K 4= 5K

K

20000 7 4⁄×

Page 54: SYSC 4600 Digital Communications Laboratory Manual Fall 2004 · of the fourth year systems engineering course SYSC 4600 - Digital Communications. The experi-ments consist of computer

Experiment 4: Error-Control Coding

52

which 1% was in error prior to decoding.

a) Calculate the probability that a given 7-bit block had one or more bits in error.b) Of all possible error patterns, what percentage are single errors?c) Of all possible error patterns, what percentage are double errors?d) Based on your answers and observations, estimate the error-correction capability of the

Hamming (7,4) code.

3. Based on your results in Table 2, estimate the coding threshold for the BCH code under consider-ation, i.e. the point at which the code performance becomes good enough to compensate for theadded overhead bits.

4. In Table 2 you might have found for high a coded bit error rate of 0. Assuming that you

did indeed get this result, does it mean that the code is able to correct all errors through this chan-nel? Would you expect a different result with a longer bit sequence?

5. Based on your results in Table 3, comparing a Reed-Solomon code and a BCH code, would yousay one code is better than the other? Which one would you choose to combat bursty errors?

6. Consider the decoding times you recorded in Table 4. What kind of relationship do you observebetween the constraint length and the decoding time? Make a plot of the decoding time versus theconstraint length. Estimate the decoding time necessary for and justify your answer.

Eb N0⁄

K 5=