Communication Lab Matlab-Zeytinoglu
Communication Lab Matlab-Zeytinoglu
ELE 045
LABORATORY MANUAL
COMMUNICATION
SYSTEMS II
ELE 045
Laboratory Manual
Copyright
ELE 045
Contents
CONTENTS ...
PREFACE . . . . . . . . . . . . . . . . . . . . . . . . . v
INTRODUCTION . . . . . . . . . . . . . . . . . . . . 1
Evaluation of the Laboratory Work . . . . . . . . . . .
How to Use This Manual . . . . . . . . . . . . . . . .
Typographical Conventions . . . . . . . . . . . . . . .
3
5
7
EXPERIMENTS . . . . . . . . . . . . . . . . . . . . .
9
11
13
27
39
51
63
77
89
Remarks . . . . . . . . . . . . . .
Experiment 1: Probability Theory . . .
Experiment 2: Stochastic Processes . .
Experiment 3: Binary Signalling Formats
Experiment 4: Detection . . . . . . .
Experiment 5: Quantization . . . . . .
Experiment 6: Digital Modulation . . .
Experiment 7: Digital Communication .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
APPENDICES . . . . . . . . . . . . . . . . . . . . . . 99
iii
iv Contents
ELE 045
ELE 045
Preface
PREFACE ...
This manual has been written as a laboratory reference for the fourth
year electrical engineering course titled ELE 045 Communication Systems
II. In the laboratory, the student will encounter seven experiments which
demonstrate principles of communication | with special emphasis on digital
communication | systems explored in the lectures.
The study of random signals and noise is essential for evaluating performance of communication systems. Therefore, the rst two experiments
present the groundwork for the description of random signals by illustrating
basic concepts from probability theory and stochastic processes. Other experiments demonstrate binary signalling formats, transmission channel characteristics, detection, quantization, and digital modulation. In the nal experiment the student will combine all elements studied in earlier experiments to
design and simulate a complete digital communication system.
All experiments described in this manual are based on computer simulations. They are performed within the MATLAB environment, which is an
interactive, matrix-based system for scienti c and engineering calculations.
Simulations can model the behaviour of real systems with remarkable degree
of precision. However, if any conclusions are to be drawn on results from
simulation studies, a few words of caution are on order. First, the simulation environment may constrain which physical phenomena can be possibly
modelled. Second, the simulated environment | or any other design |
is built on a set of fundamental assumptions. Thus, simulation results are
considered representative for the behaviour for a real system, only, if these
fundamental assumptions are not violated and if the simulation capability
is not exceeded. It is of utmost importance to be familiar with the inherent
limitations of a simulation environment. Appendix A introduces the simulation environment used in the experiments and provides an overview of the
underlying assumptions.
The MATLAB program provides the user with a rich set of functions
to manipulate and process data. In addition, there are several toolboxes consisting of high level functions for speci c applications, such as the Control
System Toolbox. The experiments described in this manual use an extensive
vi
ELE 045
Preface
set of routines performing various tasks frequently encountered in communication systems. We call this collection of routines the Communication
System Toolbox.
In designing the Communication System Toolbox, we adhered to the
principles of original MATLAB functions. Each function represents a simple
and general purpose tool. Combining these apparently simple functions in
a typical block diagram fashion, we can simulate the dynamic behaviour of
complex communication systems with extreme ease. There are other tools
based on existing MATLAB routines with their behaviour modi ed for the
present simulation environment. Yet, another set of functions are designed
as top-level blocks. They coordinate data ow between several subtasks
to achieve the desired input-to-output mapping representing a particular
system function. As the student gains an understanding of how the individual
subtasks are performed, the use of top-level functions greatly simplify the
command syntax. In most cases, only a single call has to be made to a
top-level function which will replace several lines of code. Such a building
block approach becomes a useful tool in analyzing complex systems. For
example the function a2d represents the analog-to-digital conversion process.
It consists of lower level routines that perform companding, quantization and
source coding . Finally, there are special purpose functions which simplify
speci c tasks in experiments, as such their intended use is restricted to this
course only. A complete list of functions in the Communication System
Toolbox is given in Appendix B.
In designing these experiments our intention has been to provide the
students with easy-to-use tools to study complex concepts. However, due to
limited number of hours that can be formally devoted to laboratory sessions,
not all functions in the Communication System Toolbox are used in the experiments. We encourage the student to use these functions in all aspects
of the course. Feel free to experiment with these tools extend the functionality, improve them or write your own functions to create your very own
toolbox. Share your creative ideas with others. Remember that learning is
an interactive process, and it is more gratifying if it is done collectively.
Toronto, Ontario
July, 1991
O. M. Z. and N. W. M.
INTRODUCTION
ELE 045
Introduction
Pre-Lab Assignment
For each experiment, there will be a pre-lab assignment consisting of
problems listed under the pre-lab heading. The pre-lab assignment is to be
done by all students individually and to be handed in as you come into the
laboratory.
Post-Lab Assignment
A question that appears in a box indicates a problem that must be
answered in the post-lab assignment for that particular experiment. These
questions must be answered in writing and submitted to your instructor when
you come into the laboratory for the next experiment.
Post-lab questions are placed at the end of relevant sections in the
experiment procedure. Therefore, you will have a chance to read the question
to ensure that you have performed all necessary steps and that you have not
missed taking some important data. It is also recommended if you devote a
few minutes at the end of each session to outline answers to these problems
Introduction
ELE 045
in the notes pages of your laboratory manual. This will allow you to clarify
ambiguous points by consulting your instructor.
General
Unless justi able cause for absence is shown, you are expected to be
present and on time at each laboratory session.
No late pre- or post-lab assignments are to be accepted. If you have
di culty in answering any question it is your responsibility to consult your
instructor before the due date of your assignment.
ELE 045
Introduction
Introduction
ELE 045
ELE 045
Introduction
The symbol is indicates the MATLAB prompt that you will see on
your terminal after starting the MATLAB program.
This font is used within text to show characters or words that you
type. Variables obtained from issuing MATLAB commands are represented in this font. It also indicates messages or prompts from the
system that appear on your screen. For example:
Compute the mean and variance of the random sequence
mean abc = mean(abc)
Introduction
ELE 045
EXPERIMENTS
11
ELE 045
IMPORTANT REMARK
A number of global MATLAB variables are essential for the functions in the
Communication System Toolbox to perform and to communicate properly.
The MATLAB function start initializes theses variables to their default values for each experiment. Whenever you enter the MATLAB workspace, your
very rst command line must be:
start
You will be then greeted by a welcome screen and by other informative messages. Please make sure that you initialize each MATLAB session
with the start command.
12
ELE 045
EXPERIMENT 1
PROBABILITY THEORY
OBJECTIVES
In this experiment you will study:
properties of discrete and continuous random variables
uniform and Gaussian random variables in terms of their probability
density and cumulative distribution functions
statistical measures of mean, variance and mean-square power.
REFERENCES
1. A. B. Carlson, \Communication Systems," third ed., McGraw-Hill
Inc., New York, 1986, pp. 118{147.
2. L. W. Couch II, \Digital and Analog Communication Systems," third
ed., MacMillan Publishing Co., New York, 1990, pp. 660{684.
3. S. Haykin, \An Introduction to Analog & Digital Communications,"
J. Wiley & Sons Inc., New York, 1989, pp. 404{430.
PRE-LAB ASSIGNMENT
1. Consider a 4-faced die, with the face values numbered 1 through 4.
a. Determine the sample space for the experiment where the die
is rolled once.
b. In another experiment the die is rolled 2000 times and the following outcomes were observed:
Face Value
Number of Occurrences
1
112
2
784
3
865
4
239
ELE 045
able.
ELE 045
PROCEDURE
A. Discrete Random Variables
A.1 Using the function dice , generate random samples representing the outcome of the experiment where a 4-faced, fair die is rolled 2,000 times:
x = dice( 2000, 4, 'fair')
A.2 Compute and display the sample probability density function (pdf) and
cumulative distribution function (cdf) of the sequence x:
subplot(121), pdf(x)
subplot(122), cdf(x)
Q1.1 Why are probabilities of the sample events in this experiment not equal? Is this result expected? What should be
done in step A.1, to improve this outcome?
A.3 Using the function dice generate a sequence representing the outcome
of an experiment where a 4-faced, biased die is rolled 2,000 times:
y = dice( 2000, 4, 'biased')
A.4 Clear the graphics screen and display the sample pdf of the random
sequence y:
clf
pdf(y)
Plot the sample pdf in the space provided for Graph 1.1. Compute the
sample cdf and show your result in Graph 1.2. Indicate which points
belong to the cdf at the jump points. You can verify your answer using
the MATLAB function cdf.
15
ELE 045
0.8
1
0.6
0.8
0.4
0.6
0.4
0.2
0.2
0
0
0
0
Graph 1.2
Graph 1.1
0.4
0.8
0.3
0.6
0.2
0.4
0.1
0
0
0.2
2
4
Graph 1.3
0
0
4
Graph 1.4
ELE 045
P( 0 < U 3 )
P( 3 < U 5 )
P( U = 3 )
Table 1.1
Q1.3 Why is P (U = 3) di erent than P (X = 3) in step A.4?
B.3 Let's play statistics. Generate 500 samples from a U (2 6) distribution:
u = uniform(2,6,500)
var u = var(u)
Compare these results with answers from pre-lab Question 2. Comment on any di erence. Can you predict the algorithms in MATLAB
functions mean and var ? Display their contents by using the MATLAB
command type. Use mean u and var u to determine E U2 ]. Check your
result with the MATLAB function meansq.
and
= var u from step B.3. Sketch the pdf and the cdf.
clg, subplot(121), gaus pdf(mean u,var u)
subplot(122), gaus cdf(mean u,var u)
17
ELE 045
0.5
1
0.4
0.8
0.3
0.6
0.2
0.4
0.1
0
0
0.2
2
0
0
Graph 1.5
Graph 1.6
Indicate the horizontal axis values where the pdf is at its maximum
and the cdf equals to 0.5. Compare these values with the mean value
of the Gaussian distribution.
P( 3 < G 5 )
P( G 5 )
Table 1.2
Compare these results with those in Table 1.1. The Gaussian distribution used to generate these results and the uniform distribution in step
B.2 have the same mean and variance yet, the results are di erent.
Can you explain?
..
.
gaus pdf(m,10)
ELE 045
..
.
gaus cdf(m,0.5)
gaus cdf(m,0.00001)
Where in this experiment did you observe a similar pdf? If in the last
step you had a uniformly distributed random variable with mean
and variance 0.00001, instead of a Gaussian random variable, would
the resulting pdf be di erent?
B.7 Now x the variance of the Gaussian distribution at and change the
mean value such that 2 f;4 ;1 2 5g.
2
clf
s = 1 gaus pdf(-4,s)
axis( -8 8 0 0.5] ), hold on
gaus pdf(-1,s)
..
.
gaus pdf(5,s)
What is the e ect of changing the mean value ? Let X( 2 ) represent a random variable such that X( 2 ) N ( 2 ): Compare
P (;5 < X(;4 1) < ;3) and P (4 < X(5 1) < 6): You may wish to
19
ELE 045
Using engineering terminology, you can say that mean value changes
the dc level of the waveform1.
a = gauss(0, 4,100)
b = gauss(0, 1,100)
c = gauss(0, 0.5,100)
d = gauss(0,0.01,100)
clf
subplot(221), plot(a),
subplot(222), plot(b),
subplot(223), plot(c),
subplot(224), plot(d),
axis(
axis(
axis(
axis(
1
1
1
1
100
100
100
100
-10
-10
-10
-10
10]
10]
10]
10]
)
)
)
)
Using MATLAB functions mean and var determine the mean and variance of each sequence and enter your answers in Table 1.3.
1
Displayed waveforms x, y, z are not identical as each call to the MATLAB function gauss generates a new random sequence. If you want to use the same random sequence each time you make a call to the function gauss , use it in the form
gauss(mean value,variance,n,seed) and provide the same seed value.
ELE 045
Sequence
Mean
Variance
Mean Sq.
a
b
c
d
Table 1.3
Determine the mean-square power of each waveform using the respective mean and variance values. Check your results using the MATLAB
function meansq.
D. Dart Game
D.1 To illustrate the signi cance of mean and variance, use the MATLAB
If you want to have more information about this simulation use the online help facility by typing help dart. Feel free to experiment with
various mean and variance values. In particular, it is interesting to look
at simulation results as one or both variances are set to zero. Try to
correlate your observations with other parts of this experiment.
21
ELE 045
f(x) = x
0.8
0.7
0.6
0.5
0.4
0.3
0.2
AREA = 0.5
0.1
0
0
0.2
0.4
0.6
0.8
Fig. 1.7
0,1], 20000)
ELE 045
x min,x max], N)
E.1 Integrate the pdf of the standard normal random variable numerically
over the interval ;4 4]:
integral('f(x)',
-4,4], 20000)
When the menu is displayed, select the function representing fX (x) the
pdf of the standard random variable. What does this answer con rm
about pdf's? If you were to integrate fX (x) over (;1 1) what should
be the answer?
E.2 Integrate fX (x) over the interval 0 1] and con rm the answer using a
-function table1.
E.3 You can also integrate \any" function of your choice. for example to
integrate cosh(x) over the interval ; ] enter:
integral('cosh(x)',
-pi,pi], 20000)
While this method may not be very accurate with only 20,000 points, it
is robust. The algorithm can also be easily extended to compute the ndimensional volume of a closed surface of the form f (x1 : : : x ) = K .
n
Each time you use the function integral , you will receive a slightly di erent answer
as the function uses a new set of N random points. For improved accuracy average
these results.
23
24 Experiment 1: Notes
ELE 045
ELE 045
Experiment 1: Notes
25
26 Experiment 1: Notes
ELE 045
EXPERIMENT 2
RANDOM PROCESSES
OBJECTIVES
In this experiment you will work with sample functions that will highlight
basic concepts from the theory of random processes. In particular you will:
study wide-sense stationarity and ergodicity
examine correlation as a measure of relation between random processes
investigate the relationship between a random process, its autocorrelation function and the power spectral density function.
REFERENCES
1. A. B. Carlson, \Communication Systems," third ed., McGraw-Hill
Inc., New York, 1986, pp. 152-180.
2. L. W. Couch II, \Digital and Analog Communication Systems," third
ed., MacMillan Publishing Co., New York, 1990, pp. 447-477.
3. S. Haykin, \An Introduction to Analog & Digital Communications,"
J. Wiley & Sons Inc., New York, 1989, pp. 434-464.
PRE-LAB ASSIGNMENT
1. Let the random process X( t) = cos(2 1000t+ ) be de ned in terms
of the discrete-valued random variable such that 1 = 0, 2 = =2,
and 4 = 3 =2 with equal probability.
3 =
a. Determine the mean value E X( t) ], the mean-square value
E X2 ( t) ], and the autocorrelation function RX(t + ).
b. Determine the time average values hX( t)i and hX2 ( t)i.
c. Is X( t) wide-sense stationary? Is it ergodic?
2. Determine and sketch the power spectral density of the random process
Y(t), if the autocorrelation function RY (t) is given as:
a. RY ( ) = ( )
b. RY ( ) = ( )
ELE 045
c. RY ( ) = ( =T ) where T = 10 msec
d. RY ( ) = 1.
3. Determine the mean and the mean-square value of the random process
Z(t), if:
a. the autocorrelation function RZ( ) is given as:
R ( )
Z
3.0
1.0
0.3 mV/Hz
f [kHz]
-5
ELE 045
PROCEDURE
A. Wide-Sense Stationarity and Ergodicity
A.1 Generate all 4 realizations | sample functions | of the random process
X( t) described in Question 1 of the pre-lab assignment. Display the
rst 400 samples of each realization:
x = realize(
subplot(221),
subplot(222),
subplot(223),
subplot(224),
0 pi/2 pi
waveplot(
waveplot(
waveplot(
waveplot(
3*pi/2] )
x(1,1:400)
x(2,1:400)
x(3,1:400)
x(4,1:400)
)
)
)
)
A.2 Record the value of each sample function of X( t) for t = 0, 0.5, 1.25,
2.2, 3.4 msec. For each t, evaluate the ensemble mean and the ensemble
mean-square value.
X(
t)
X(
t)
X(
t)
X(
t)
0.0
0.5
t msec]
1.25
2.2
3.4
E X( t)]
E X2( t)]
Table 2.1
A.3 Using the MATLAB function ecorr determine the autocorrelation function RX(t1 t2), for the values of t1 and t2 shown in Table 2.2.
ecorr( x, t1, t2 )
29
ELE 045
t2
0.0
t1
0.7
1.9
2.6
0.0
0.7
1.9
2.6
Table 2.2
Q2.1 Explain the symmetry in Table 2.2. Why are RX(1:9 2:6)
A.4 Determine the time average values hX( t)i and hX ( t)i for each
2
meansq(x(1,:))
meansq(x(2,:))
meansq(x(3,:))
meansq(x(4,:))
hX( t)i
]
]
]
]
hX ( t)i
2
1
2
3
4
Table 2.3
Compare the time average values from Table 2.3 with the ensemble
average values shown in Table 2.1. What does this comparison say
about the ergodicity of X( t)?
ELE 045
t).
clf
acf(x(1,:),100)
t) di erent from
such that
= 0 and
0, pi ] )
B . Correlation
Correlation measures the relationship between two sets of data in the sense
that the closer the data sets are related, the larger will be the absolute
value of the correlation measure. One of the applications of correlation is to
estimate a random quantity from observations made on a related parameter.
B.1 Generate 1,000 records, each describing the age, the height and the
weight of a person between the ages of 20 and 50.
a = person data(1000)
31
ELE 045
B.2 Using the data array a, generate scatter diagrams that display weight
vs. height , age vs. weight , and age vs. height.
B.3 Statistical relationship among age, height, and weight parameters can
The function guess will display the weight of a person and will prompt
you to guess the height. Try 10 rounds of guessing. Use the weight
vs. height diagram to assist you.
B.4 Play a second guessing game in which you are given the age of a person
and you are asked to guess the height.
guess('age','height')
Q2.4 Among the age , height and weight parameters which two
C . Autocorrelation Function
C.1 Autocorrelation is the correlation measure of samples from the same
random process. To study this concept, consider the random process
T(t) that represents average day-time temperatures between June 1
and August 31.
clf
subplot(211), temperature
ELE 045
C.2 Repeat the above step for a discrete valued, white Gaussian process
B(t) that represents the number of new born babies in the City of
Toronto between June 1 and August 31.
subplot(212), new born
C.3 Display the temperature and new-born waveforms, and the normalized
autocorrelation functions of T(t) ; E T(t) ] and B(t) ; E B(t) ].
clf, subplot(211), temperature(0)
figure(2), subplot(211), new born(0)
Q2.6 Which waveform uctuates more rapidly? Relate your answer to the results observed in parts C.1 and C.2.
RT(3) =
RB(3) =
33
ELE 045
close(2), clf
z = corr seq(0.85,4096,3,0)
waveplot(z)
D.2 Compute and display the autocorrelation function RZ( ) and the power
spectral density function SZ(f ) of the random process Z(t).
clf, subplot(211), acf(z)
subplot(212), psd(z)
D.3 Evaluate the mean and mean-square value of Z(t) using RZ( ):
E Z(t) ] =
E Z (t) ] =
D.4 Also determine the mean-square value of Z (t) using SZ(f ). The mean2
square value is equivalent to the area under the PSD function. Due
to sampling of waveforms in the Matlab simulation environment, the
mean-square value is equal to the area under the PSD function multiplied by a scaling factor. The scaling factor is the number of data
samples divided by the sampling frequency (see Appendix A). In the
present experiment, the value of the scaling factor is 0.04096.
E Z2(t) ] =
0:04096 =
E . White Noise
The PSD function of a white noise process is at over the entire system
bandwidth. A white noise process, used as an input, will excite all frequency
modes of an \unknown" system. Therefore, calibrated white noise is a useful tool in system identi cation. For example, to determine the frequency
response of an unknown system, a set-up such as shown in Fig. 2.1 can be
used.
WHITE NOISE
GENERATOR
BLACKBOX
BAND-PASS
FILTER
RMS POWER
METER
PASS-BAND ADJUST
ELE 045
E.1 Generate 1,024 samples from a zero-mean white Gaussian noise process of unit power. Use this sequence as an input to a blackbox , that
represents a lter with unknown bandwidth and order.
clf
wn = gauss(0,1,1024)
cn = blackbox(wn)
E.2 Feed the output of the blackbox to a band-pass lter with variable
pass-band.
spect est(cn)
When the function spect est is invoked, you will be asked to specify the
frequency range for the spectral estimation process and the bandwidth
of the band-pass lter. Cover the spectral range 0, 5 kHz ] and use a
lter bandwidth of 250 Hz. After the required information is entered,
the function will return the power of the output signal inside each
pass-band range and display the estimated magnitude spectrum.
-2
10
-3
Power [W]
10
-4
10
-5
10
-6
10
0.5
1.5
2
2.5
3
Frequency [kHz]
3.5
4.5
Graph 2.1
E.3 Plot the output from the function spect est in Graph 4.1. Compare the
35
ELE 045
ELE 045
Experiment 2: Notes
37
38 Experiment 2: Notes
ELE 045
EXPERIMENT 3
BINARY SIGNALLING FORMATS
OBJECTIVES
In this experiment you will investigate how binary information is serially
coded for transmission at baseband frequencies. In particular, you will study:
line coding methods which are currently used in data communication
applications
power spectral density functions associated with various line codes
causes of signal distortion in a data communications channel
e ects of intersymbol interference (ISI) and channel noise by observing
the eye pattern.
REFERENCES
1. A. B. Carlson, \Communication Systems," third ed., McGraw-Hill
Inc., New York, 1986, pp. 381{391.
2. L. W. Couch II, \Digital and Analog Communication Systems," third
ed., MacMillan Publishing Co., New York, 1990, pp. 144{165.
3. S. Haykin, \An Introduction to Analog & Digital Communications,"
J. Wiley & Sons Inc., New York, 1989, pp. 197{200 and 227{230.
PRE-LAB ASSIGNMENT
1. Given the binary sequence b = f1 0 1 0 1 1g sketch the waveforms
representing the sequence b using the following line codes:
a. unipolar NRZ
b. polar NRZ
c. unipolar RZ
d. bipolar RZ
e. manchester.
Assume unit pulse amplitude and use binary data rate R = 1 kbps:
b
2. Determine and sketch the power spectral density (PSD) functions corresponding to the above line codes. Use R = 1 kbps: Let f1 > 0 be the
b
ELE 045
location of the rst spectral null in the PSD function. If the transmission bandwidth B of a line code is determined by f1 , determine B
for the line codes in question 1 as a function of R :
T
y(t) [V]
0.5
-0.5
-1
-1.5
0
5
6
Time [xTb sec]
10
ELE 045
PROCEDURE
A. Binary Signalling Formats: Line Code Waveforms
Binary 1's and 0's such as in pulse-code modulation (PCM) systems, may be
represented in various serial bit signalling formats called line codes. In this
section you will study signalling formats and their properties.
A.1 You will use the MATLAB function wave gen to generate waveforms
representing a binary sequence:
where R is the binary data rate speci ed in bits per second (bps).
If you use the function wave gen with the rst two arguments only, it
will default to the binary data rate set by the variable binary data rate,
which is 1,000 bps. Create the following binary sequence:
b
b =
1 0 1 0 1 1 ]
Since you will compare waveforms at the same R , you can use the
function wave gen with only two arguments.
b
Q3.1 For the above set of line codes determine which will gener-
41
ELE 045
Display the PSD function of each line code used in part A.1:
psd( wave gen( b, 'line code name' ) )
Let:
R =
b
unipolar NRZ
polar NRZ
unipolar RZ
bipolar RZ
manchester
f1
p
f2
n1
n2
Table 3.1
ELE 045
B . Channel Characteristics
In this part you will simulate characteristics of a communications channel.
NOISE
INPUT
CHANNEL
OUTPUT
B.1 Create a 10 sample binary sequence b and generate a waveform representing b in polar NRZ signalling format. Use R = 1 kbps:
b
b = binary(10)
x = wave gen( b, 'polar nrz', 1000 )
B =
T
Hz.
B.2 Consider a baseband data transmission channel with unity gain and additive white Gaussian noise (AWGN) where the noise power is 10;2 W
and the channel bandwidth is 4:9 kHz: Transmit waveform x over this
channel. Display the channel input and output waveforms:
y = channel( x, 1, 0.01, 4900 )
subplot(211), waveplot(x)
subplot(212), waveplot(y)
43
ELE 045
increase the channel noise power while keeping the channel bandwidth
at 4:9 kHz and observe changes in the channel output.
subplot(212), waveplot( channel(x,1,sigma,4900) )
where sigma 2 f0:1 0:5 1 2 5g: At what noise power level, does the
channel output waveform becomes indistinguishable from noise?
B.4 You can also observe e ects of increasing channel noise power by looking at the PSD of the channel output waveform.
b = binary(1000)
x = wave gen(b, 'polar nrz', 1000)
clf, subplot(121), psd(x), a = axis
subplot(122), psd(channel(x,1,0.01,4900))
axis(a), hold on
psd(channel(x,1,1,4900))
psd(channel(x,1,5,4900))
the channel input, determine an expression that will describe the PSD of the channel output in terms of the input
and noise PSD functions.
B.5 E ects of channel bandwidth on transmitted waveform: Distortion observed in the time display of the channel output is due to
nite bandwidth of the channel and due to noise. To study distortion
due to channel bandwidth only, set noise power to zero and regenerate
the channel output waveform:
clf
b = binary(10)
x = wave gen( b, 'polar nrz', 1000 )
subplot(211), waveplot(x)
subplot(212), waveplot(channel(x,1,0,4900))
ELE 045
where bw 2 f3000 2000 1000 500g: Observe the delay in the output
waveform due to ltering characteristics of the channel. Plot the input
and output waveforms.
0
10
10
x(t)
Bandwidth
4.9 kHz
y(t)
3.0 kHz
y(t)
2.0 kHz
y(t)
1.0 kHz
y(t)
0.5 kHz
y(t)
Graph 3.1
C . Eye Diagram
E ects of channel ltering and noise can be best seen by observing the output
waveform in the form of an \eye diagram". The eye diagram is generated
with multiple sweeps where each sweep is triggered by a clock signal1 and
the sweep width is slightly larger than the binary data period T = 1=R : In
this simulation the eye diagram is based on a sweep width of 2T :
b
1 0 0 1 0 1 1 0 ]
The clock signal is either externally provided or derived from the channel output.
It is used as the external trigger input to a storage oscilloscope.
45
ELE 045
The eye diagram for the waveform x represents what you should expect
to see for an undistorted signal. To observe how the eye diagram is
generated and to observe e ects of signal distortion as the signal x is
transmitted over a nite bandwidth channel with no noise component:
y = channel( x, 1, 0, 4000 )
subplot(222), waveplot(y)
subplot(224), eye diag(y,-1)
If the second argument to the function eye diag is negative, you have
to hit the Return key for the next trace to be displayed. This will assist
you to understand how the eye diagram is generated.
C.2 Key parameters to be measured with an eye diagram are shown below.
EYE DIAGRAM
-3
1.5
x 10
0.5
B
0
slope
D
-0.5
A
-1
-1.5
0
A
B
C
D
E
t*
0.2
0.4
0.6
0.8
1
1.2
Time [sec]
1.4
1.6
1.8
2
-3
x 10
ELE 045
clf
b = binary(100)
x = wave gen( b, 'polar nrz', 1000 )
eye diag( channel( x, 1, s2, bw ) )
0.01
0.02
0.08
0.10
bw
3000
2000
1000
4000
Table 3.2
C.3 Repeat step C.2 for manchester line code and record your results in
Table 3.3.
0.01
0.02
0.08
0.10
bw
3000
2000
1000
4000
Table 3.3
47
ELE 045
Q3.4 When you compare the eye diagrams from C.2 and C.3
C.4 Generate eye diagrams as in step C.2 for polar RZ and unipolar RZ
and unipolar NRZ line codes and observe how the line code dictates
the shape and the symmetry of the eye diagram.
ELE 045
Experiment 3: Notes
49
50 Experiment 3: Notes
ELE 045
EXPERIMENT 4
DETECTION
OBJECTIVES
In this experiment you will investigate the signal detection process by studying elements of a receiver and of the decoding process. In particular you
will:
investigate the characteristics of matched lters
study performance of various receiver structures based on di erent receiver lters by measuring probability of bit error
use the eye diagram as an investigative tool to set parameters of the
detection process.
REFERENCES
1. A. B. Carlson, \Communication Systems," third ed., McGraw-Hill
Inc., New York, 1986, pp. 391{400.
2. L. W. Couch II, \Digital and Analog Communication Systems," third
ed., MacMillan Publishing Co., New York, 1990, pp. 497{504, 521{532.
3. S. Haykin, \An Introduction to Analog & Digital Communications,"
J. Wiley & Sons Inc., New York, 1989, pp. 539{573.
PRE-LAB ASSIGNMENT
1. A matched lter is to be designed to detect the rectangular pulse
r(t) = rect t ; T =2 with T = 1 msec:
T
channel. X (t) is a polar NRZ waveform with unit pulse amplitude and
52 Experiment 4: Detection
ELE 045
binary data rate R of 1 kbps. n(t) is a white noise process with PSD
function:
S (f ) = N =2 = 0:5 10;4 W=Hz:
If Y (t) is applied to a matched- lter receiver:
a. Determine the rms value of n(t) and the peak signal amplitude
at the output of the matched lter.
b. Determine E , the average energy of X (t) in a pbit period.
c. Determine the probability of bit error P = Q( 2E =N ).
b
with RC = 1=(2000 ),
a. determine the peak signal amplitude and rms value of the noise
at the lter output
b. determine the probability of bit error P , if X (t) were to be detected by a receiver based on the RC- lter.
e
ELE 045
Experiment 4: Detection
PROCEDURE
A . Characteristics of Matched Filters
A.1 Generate a rectangular pulse with unit pulse amplitude and 1 msec
pulse duration.
Determine the time when the lter output reaches its maximum value.
How is this time related to the waveform r?
Q4.1 How would you determine the peak amplitude value of the
matched lter output directly from the above plots?
A.4 Repeat parts A.1{A.3 for a triangular pulse with 10 msec pulse width
and unit peak amplitude.
r = wave gen(1,'triangle',100)
clf subplot(311), waveplot(r)
subplot(312), match('triangle')
rm = match('triangle',r)
subplot(313), waveplot(rm)
Q4.2 If the triangular pulse width is changed to 1 msec, determine the peak amplitude of the matched lter output?
A.5 Repeat parts A.1{A.3 for a manchester pulse with 10 msec pulse width
and unit peak amplitude. Predict the matched lter impulse response
53
54 Experiment 4: Detection
ELE 045
A.6 Generate a polar NRZ waveform that represents the 5-sample binary
sequence 1 0 0 1 0 ]. The binary data rate R is 1 kbps and the pulse
amplitude A is 1 V.
b
Voltage [V]
Record the waveform x5 in Graph 4.1 using the amplitude scale shown
on the left.
2
0.002
0.001
-1
-2
-1
-0.001
2
3
Time [xTb sec]
-0.002
Graph 4.1
A.7 Apply x5 to a matched lter. Record the matched lter output in Graph
4.1 using the amplitude scale shown on the right.
ELE 045
Experiment 4: Detection
B . Signal Detection
B.1 Generate a 10-sample binary sequence and a waveform that represents
this binary sequence in polar NRZ signalling format.
b10 = binary(10)
x10 = wave gen(b10,'polar nrz',1000)
clf, subplot(211), waveplot(x10)
B.2 Apply x10 to a channel with 4.9 kHz bandwidth and AWGN where the
noise power is 2 W. Display the channel output waveform y10:
y10 = channel(x10,1,2,4900)
subplot(212), waveplot(y10)
B.3 Apply y10 to a matched lter. Display the output waveform z10:
z10 = match('polar nrz',y10)
subplot(212), waveplot(z10)
Let T be the binary data period. Sample the output of the matched
lter at k T k = 1 : : : 10 and apply the following decision rule:
if z10(k T ) 0
bb = 01
if z10(k T ) > 0
b
b
b
where bb is the estimated value of the kth element of the binary sequence b10. Apply this decision rule on the matched lter output z10:
k
d
b
10
55
56 Experiment 4: Detection
ELE 045
C . Matched-Filter Receiver
C.1 Generate a 2,000-sample binary sequence b and a polar NRZ waveform
based on b:
b = binary(2000)
x = wave gen(b,'polar nrz')
Apply x to a channel with 4.9 kHz bandwidth and AWGN where the
noise power 2 is 0.5 W. Let y be the channel output waveform.
n
y = channel(x,1,0.5,4900)
C.2 Apply y to a matched lter. Display the eye diagram of the matched
lter output z.
z = match('polar nrz',y)
clf, eye diag(z)
From the eye diagram, determine the optimum sampling instants and
threshold value v th for the detector to decode the transmitted binary
sequence b. Sampling instants for the matched lter output are measured with respect to the time origin. For example, if the binary data
period is T and the sampling instant parameter is set to t , then the
detector will sample the signal at t t + T t + 2T : : : etc.
b
v th
V:
sampling instant
sec:
W]
0.5
1.0
1.5
2.0
P { empirical
e
Table 4.1
P { theoretical
e
ELE 045
57
Experiment 4: Detection
C.3 Repeat C.1{C.2 for channel noise power of 1, 1.5, and 2 W without
displaying the eye diagram of the matched lter output z. Record P
results in Table 4.1. Remark: In Experiment 3 you have observed that
e
the optimum sampling instants and the threshold value are independent
of channel noise power. Therefore, you can use the optimum sampling
instants determined in part C.2 to decode the matched lter output
for di erent channel noise power levels.
C.4 If di erent sampling instants other than the optimum values are used,
the resulting BER will be larger. You can observe this by decoding
the binary sequence using values for the sampling instant parameter
that are 0.9 and 0.5 times the optimal value used in part C.3.
S (f ) = N2 = 2 system bandwidth
o
A =
r
r lpf = rc(1000,r)
V:
D.2 Generate 2,000 samples from a zero-mean white noise sequence of 0.5 W
power. Apply the noise sequence to the RC- lter. Record the rms value
of the output noise power.
n = gauss(0,0.5,2000)
meansq(rc(1000,n))
2
W:
58 Experiment 4: Detection
ELE 045
Q4.6 From the results in parts D.1 and D.2, determine the ratio
D.3 Regenerate y from part C.1. Apply y to the RC- lter. Display the eye
diagram of the output waveform z lpf.
y = channel(x,1,0.5,4900)
z lpf = rc(1000,y)
clf, eye diag(z lpf)
D.4 From the eye diagram, determine the optimum sampling instant and
threshold value. Decode the binary sequence form z lpf.
detect(z lpf,v th,sampling instant,b)
Compare the resulting BER with the BER evaluated in step C.2.
D.5 Repeat part D.4 for the channel noise power of 1, 1.5, and 2 W. Record
results in Table 4.2.
2
W]
0.5
1.0
1.5
2.0
BW = 1.0 kHz
BW = 0.5 kHz
Table 4.2
D.6 Repeat parts D.3 { D.5 for a rst-order RC- lter with 500 Hz bandwidth. Record the resulting BER values in Table 4.2.
z lpf = rc(500,y)
eye diag(z lpf)
detect(z lpf,v th,sampling instant,b)
ELE 045
Experiment 4: Detection
S1
hold on
waveplot(5*y5)
y5
in Graph 4.2.
E.2 Repeat parts D.3 { D.4, but use the integrate-and-dump lter instead
of the low-pass lter. Compare the resulting BER with those resulting
from a low-pass lter and a matched lter.
59
60 Experiment 4: Notes
ELE 045
Voltage [V]
-1
-2
0
0.5
1.5
2.5
3
Time [xTb sec]
Graph 4.2
3.5
4.5
ELE 045
Experiment 4: Notes
61
62 Experiment 4: Notes
ELE 045
EXPERIMENT 5
QUANTIZATION
OBJECTIVES
In this experiment you will:
study uniform and non-uniform quantization characteristics
observe e ects of di erent types of quantizer distortion
measure signal to quantization error ratio for various quantizer types
as a function of the input signal power.
REFERENCES
1. A. B. Carlson, \Communication Systems," third ed., McGraw-Hill
Inc., New York, 1986, pp. 430{439.
2. L. W. Couch II, \Digital and Analog Communication Systems," third
ed., MacMillan Publishing Co., New York, 1990, pp. 130{144.
3. S. Haykin, \An Introduction to Analog & Digital Communications,"
J. Wiley & Sons Inc., New York, 1989, pp. 187{197.
PRE-LAB ASSIGNMENT
1. Consider a 2-bit uniform, mid-riser type quantizer. Assume that the
quantizer has been designed for the input range ;1 1 ]:
a. Determine all quantization levels used by the quantizer.
b. Determine the quantization interval for each quantization level.
c. Sketch the input-to-output mapping characteristic.
2. Let the quantization noise be a uniformly distributed random variable
de ned over the interval ;q=2 q=2 ] where q is the length of the
quantization interval of a N-bit uniform quantizer:
a. Determine q as a function of N .
b. Determine the variance of quantization noise.
64 Experiment 5: Quantization
ELE 045
PROCEDURE
A. Uniform Quantization
After a message has been sampled, the next step is to quantize the samples.
Because an analog signal has a continuous range of amplitudes, pulses in
the sampled signal will have an in nite number of amplitude levels. It is not
possible to assign unique, nite length code words to an in nite number of
amplitudes. Quantization consists of approximating the sampled signal by a
signal made up of discrete amplitudes.
OUTPUT
0.2
0
-0.2
-0.4
-0.6
-0.8
-1
-1
-0.75
-0.5
-0.25
0
INPUT
0.25
0.5
0.75
Graph 5.1
A.2 Let x be the analog pulse amplitude, and x be the quantizer output,
if x is the input. Assume that pulse amplitude x is normalized such
that jxj 1. From Graph 5.1 derive the quantizer mapping rule:
q
ELE 045
Experiment 5: Quantization
Quantization Interval
xq
Binary Code
Table 5.1
Observe the length of each interval that appears in the rst column
of Table 5.1. How is the quantization interval length related to the
number of quantization levels of a uniform quantizer? The entries in
the 2nd column are referred to as quantization levels only these values
appear at the quantizer output.
1
2
3
4
5
6
7
8
xq
Binary Code
Table 5.2
A.4 Devise a rule which assigns a unique 2-bit binary symbol to each quantization level. Use a natural code1 which assigns the binary symbol
There are several other coding methods such as magnitude-sign code , Gray code ,
etc. Each code has unique properties that makes it suitable in certain applications.
65
66 Experiment 5: Quantization
ELE 045
A.5 One of the most common methods of converting an analog signal into
Default sampling frequency is set to 10 kHz by the variable sampling freq. Use a 2-bit uniform quantizer and compare the quantized
waveform with the original sequence x:
clf, waveplot(x), hold on, waveplot(quantize(x,2))
ELE 045
Experiment 5: Quantization
Since the quantized sequence is only an approximation to the original, quantization produces distortion. There are two types of distortion associated
with a quantizer: overload (or clipping) distortion and quantization noise.
Overload distortion occurs when the input signal exceeds the quantizer's input range | in this experiment ;1 1 ]. Once the quantizer range has been
exceeded, quantizer output will remain at its maximum or minimum value
until the input falls within the quantizer's input range.
B.2 Set the amplitude of the sinusoid x to 0.9 and display x and its 3-bit
quantized version:
a = 0.9
clf
waveplot(a*x), hold on, waveplot(quantize(a*x,3))
Observe that, since max jxj = 0:9 < 1, no clipping occurs. Now increase
the signal amplitude and repeat the above step for a = 1:25 2 and 5.
B.3 Use samples from the sinusoid x to observe quantization error x ; xq:
clf
xq = quantize(x, N)
waveplot(xe)
xe = x - xq
Table 5.3
67
68 Experiment 5: Quantization
ELE 045
B.4 Generate the following sequence and display its PSD function:
x = sin( 2*pi*512* 1:2048]/SAMPLING FREQ )
psd(x)
Table 5.4
Under the assumption that the quantization error amplitude is uniformly distributed over ;q=2 q=2 ] where q is the quantization step
size of an N-bit uniform quantizer, noise power is given by:
2
Compare results in Table 5.4 with those obtained from the formula.
C . Non-uniform Quantization
C.1 Generate 100 samples representing voiced segment of a typical speech
signal and display the sequence:
s = speech(100)
subplot(211), waveplot(s)
ELE 045
Experiment 5: Quantization
C.2 Quantize s using a 6-bit uniform quantizer and display the quantized
waveform:
sq = quantize(s,6)
subplot(212), waveplot(sq)
xq = quantize(x,6)
subplot(211),waveplot(x),subplot(212),waveplot(xq)
C.4 Apply -law companding to sampled signals s and x and then quantize:
msq = mu inv( quantize(mu law(s), 6) )
mxq = mu inv( quantize(mu law(x), 6) )
Since quantized samples must be restored to their original values, nonuniform quantization is equivalent1 to the following sequence of operations: compand | uniform quantization | expand. Display waveforms
1
and mu inv are inverse functions of each other. They represent companding
and expansion characteristics, respectively. This you can verify by comparing any
arbitrary sequence z with mu inv(mu law(z)).
mu law
69
70 Experiment 5: Quantization
ELE 045
,
and compare with original signals s and x. It is of particular interest to compare msq with sq and mxq with xq. First, the large
amplitude signal s:
msq mxq
C.5 For a given number of quantization levels, a uniform quantizer is optimum if input sample amplitudes are uniformly distributed over the
input range ;1 1 ]. However, speech signal amplitude distribution is
best modelled by a Laplace distribution. Generate the sample pdf of
2,000 samples from a Laplace distribution with variance 0:01:
close(2), figure(1), clf
a = laplace( 2000, 0.01 )
pdf( a, 30 )
C.6 In practise, any quantizer has to operate on signals at varying amplitude levels. Therefore, to assess the quantizer performance, it must be
tested with signals at di erent power levels. One measure of quantizer
performance is the signal to quantization noise ratio SQNR. Consider
a 8-bit quantizer used in a typical voice grade A/D converter:
Algorithm:
1. Generate a sequence of 1,000 voice signal samples at a speci ed
power level and measure the signal power: 2 .
2. Quantize the sequence using an 8-bit uniform quantizer. Measure
the resulting quantization error power: 2 (uniform).
s
ELE 045
Experiment 5: Quantization
where all quantities are measured in dB. Enter results into Table 5.5.
Also plot SQNR vs. 2 for both quantizer types in Graph 5.2.
s
SQNR(uniform)
SQNR( -law)
Table 5.5
50
45
40
SQNR [dB]
35
30
25
20
15
10
5
0
-50
-45
-40
-35
-30
-25
-20
Signal Power [dBW]
Graph 5.2
-15
-10
-5
71
72 Experiment 5: Quantization
ELE 045
ELE 045
Experiment 5: Quantization
APPENDIX
WORKING WITH REAL SOUND SAMPLES
This appendix provides information on how you can work with real sound
samples and how you can play-back processed sound samples through the
built-in audio circuitry of your Sun-SPARC workstation. The Sun-SPARC
workstation family has the capability to sample and to play-back sound at
8 kHz sampling frequency using 8-bit, -law companding quantization. You
are provided with sample sound les that you can process, quantize and listen
to. Play-back of the processed sound les allows qualitative assessment of the
sound quality to be expected from di erent quantization schemes.
The sample sound le is sample speech. This le has been extracted
from a larger sound le that has been created on a di erent hardware platform by sampling a CBS news broadcast at 8 kHz and using 14-bit uniform
quantization. The original le contains 123,000 samples representing approximately 15 seconds of sound. The sample speech le contains 20,000 samples
to minimize the computational load and therefore to improve the response
time of your workstation. The 14-bit quantized samples have been converted
into oating point format and as such they will serve as \analog" samples.
They are stored in the x analog array.
You can process samples in the x analog array and listen to the results.
Since a 2.5 seconds long sound le may not convey full information about the
quantization e ects, you are also given versions of the 15 seconds long sound
le that had been pre-processed with 1{8 bit uniform and -law companding
quantization.
The sound samples are stored in the array x analog . Remember that
the samples are played back through an 8-bit DAC. Therefore 8-bit
quantization will be your sound quality reference.
73
74 Experiment 5: Quantization
ELE 045
You can control the sound level through the \audio control panel".
Start this utility by entering the command:
!gaintool &
where N 2 f1 2 : : : 8g, type is 'uniform' or 'mu law', and the optional volume level is as before an integer between 0 and 100.
Remarks
It is likely that you will not hear much di erence1 in the sound quality
of the 5{8 bit quantized samples except the background noise which is
the manifestation of the increasing quantization noise with decreasing
This observation is partly due to the quality of the sound circuit and the built-in
speaker of the workstation.
ELE 045
Experiment 5: Quantization
number of quantization levels. Also note that the quantization noise will
appear as hiss which con rms the assumption that when su ciently
large number of quantization levels are used, the quantization noise
will be uncorrelated with the input and can be accurately modeled as
a white noise process. Working with a large number of quantization
levels consumes plenty of processing power and you may have to wait
much longer to create and listen to your results. Remember that you
are doing a software emulation of a process that is usually performed in
dedicated hardware. It is therefore recommended that you only listen to
the pre-processed sound les at 5{8 bit quantization levels, and restrict
your processing to 1{4 bit quantization.
Di erent volume levels may be misleading, as the human psychology | or shall we say the teen-age ear? | has the tendency to
associate loud sound with \better quality". As a result of normalization, and companding, the sound les you generate will most likely
be at di erent sound levels. Therefore, some experimentation with the
volume control is necessary.
75
76 Experiment 5: Notes
ELE 045
EXPERIMENT 6
DIGITAL MODULATION
OBJECTIVES
In this experiment you will apply concepts of baseband digital transmission
and analog continuous wave modulation to the study of band-pass digital
transmission. You will examine:
generation of digital modulated waveforms
coherent (synchronous) and noncoherent (envelope) detection of modulated signals
system performance in the presence of corrupting noise.
REFERENCES
1. A. B. Carlson, \Communication Systems," third ed., McGraw-Hill
Inc., New York, 1986, pp. 512{542.
2. L. W. Couch II, \Digital and Analog Communication Systems," third
ed., MacMillan Publishing Co., New York, 1990, pp. 331{344 and 532{
551.
3. S. Haykin, \An Introduction to Analog & Digital Communications,"
J. Wiley & Sons Inc., New York, 1989, pp. 368{374 and 574{583.
PRE-LAB ASSIGNMENT
1. Consider the binary sequence b = 1 0 0 1 0 ]. Let the binary data
rate R be equal to 1 kbps and let the peak amplitude of all digital
modulated waveforms be set to 1 V.
a. Sketch the ASK waveform representing the binary sequence b
using a carrier frequency of 5 kHz.
b. Sketch the PSK waveform representing the binary sequence b
using a carrier frequency of 5 kHz.
c. Let the mark and space frequencies used by an FSK modulator
be set to 3 and 6 kHz, respectively. Sketch the resulting FSK
waveform representing the binary sequence b.
b
ELE 045
2. Sketch the power spectral density function for each of the modulated
signals in Question 1.
ELE 045
PROCEDURE
In this experiment, the binary data rate R is 1 kbps and peak modulated signal
amplitude is 1 V. The bit period T = 1=R is represented by 100 samples.
b
1 0 0 1 0 binary(45) ]
A.2 To generate the ASK signal sa, with a carrier frequency of 8 kHz:
generate a unipolar NRZ signal xu, from the sequence b
mix xu with the output of an oscillator operating at 8 kHz.
xu = wave gen(b,'unipolar nrz')
sa = mixer( xu, osc(8000) )
A.3 Display the rst 500 samples of the waveforms xu and sa representing
the rst 5 bits in the binary sequence b. Compare the two waveforms.
tt = 1:500]
subplot(211), waveplot(xu(tt))
subplot(212), waveplot(sa(tt))
Also display the respective PSD functions over the frequency interval
0, 20 kHz ] and record in Graph 6.1 and 6.2. To display the PSD function over a speci c frequency range you have issue the psd command
with two arguments such that psd(x,freq range) displays the PSD
of x over the frequency interval de ned by the vector freq range.
fr =
0, 20000 ]
subplot(211), psd(xu,fr)
subplot(212), psd(sa,fr)
79
ELE 045
10
10
-1
-1
10
10
-2
-2
10
Power [W]
Power [W]
10
-3
10
-4
10
-5
10
-6
-6
10
10
-7
-4
10
-5
10
10
-3
10
-7
5
10
15
Frequency [kHz]
20
10
Graph 6.1
5
10
15
Frequency [kHz]
20
Graph 6.2
A.5 Display the rst 500 samples of the waveforms xp and sp:
subplot(211), waveplot(xp(tt))
subplot(212), waveplot(sp(tt))
A.6 Display the PSD functions of xp and sp over the frequency interval 0,
20 kHz ]. Record main characteristics of each PSD function.
subplot(211), psd(xp,fr)
subplot(212), psd(sp,fr)
ELE 045
10
10
-1
-1
10
10
-2
-2
10
Power [W]
Power [W]
10
-3
10
-4
10
-5
10
-6
-6
10
10
-7
-4
10
-5
10
10
-3
10
-7
5
10
15
Frequency [kHz]
20
Graph 6.3
10
5
10
15
Frequency [kHz]
20
Graph 6.4
subplot(211), waveplot(xp(tt))
subplot(212), waveplot(sf(tt))
Display the PSD function of the FSK signal and record in Graph 6.5.
clf
psd(sf,fr)
81
ELE 045
10
-1
10
-2
Power [W]
10
-3
10
-4
10
-5
10
-6
10
-7
10
8
10
12
Frequency [kHz]
14
16
18
20
Graph 6.5
Q6.1 How can you generate an FSK signal from two ASK signals? For a system where e cient bandwidth utilization is
required, which modulation scheme would you prefer?
z(t)
MATCHED
FILTER
sa (t)
LO
S/H
^
b
sin(c t)
vTH
bit sync
ELE 045
10
-1
10
-2
Power [W]
10
-3
10
-4
10
-5
10
-6
10
-7
10
8
10
12
Frequency [kHz]
14
16
18
20
Graph 6.6
B.2 Apply ya to a matched lter and record its output for 0 < t < 5 T .
b
za = match('unipolar nrz',ya)
subplot(212), waveplot(za(tt))
1
Voltage [mV]
0.5
-0.5
-1
0
3
Time [xTb sec]
Graph 6.7
83
ELE 045
The major di culty in implementing a coherent detector is carrier synchronization. In order to achieve optimum performance, the local oscillator should
have the same phase and frequency as the incoming carrier. Phase or frequency deviation will result in degradation of detection performance.
B.3 To observe the e ect of phase error, demodulate sa using a local oscil-
PHASE ERROR
0
20
60
80
120
PEAK AMPLITUDE V]
Table 6.1
Q6.3 Recall that the BER resulting from the detection of a sig-
B.4 Demodulate sa with 60 and 120 phase errors. Decode the matched
lter output to recover the rst ve bits of the sequence b. Record each
decoded sequence and comment on the di erence.
Phase error = 60
Phase error = 120
^1;5 =
b
^1;5 =
b
ELE 045
85
of detector matched lter output is modulated by a sinusoid. Determine the frequency of this modulating signal as
a function of f and f .
c
Noncoherent Detection
Noncoherent detection of digital modulated signals does not require synchronization of the local oscillator with the carrier component. However, in the
face of corruptive noise, a system using noncoherent detection experiences
higher BER relative to coherent detection. Consider the noncoherent detector
for an ASK signal shown in Fig. 6.2.
sa (t)
y(t)
BPF
z(t)
ENVELOPE
DETECTOR
S/H
^
b
vTH
bit sync
ELE 045
The function of the band-pass lter (BPF) is to reduce the out-of-band noise
and interference. Assume the bandwidth of the BPF is appropriately chosen
such that signal distortion is negligible i.e., if the input to the BPF is s (t),
then the signal at the output of the BPF is also s (t). The envelope detector
consists of a recti er followed by a low-pass lter (LPF) with bandwidth f ,
chosen according to the rule:
a
signal bandwidth
carrier frequency:
B.6 Let the bandwidth of the LPF used in the MATLAB function envelope
be set to 4,000 Hz. Apply the ASK signal sa to the function envelope
and display its output together with the ASK signal sa:
ya = envelope(sa,4000)
clf, subplot(211), waveplot(sa(tt))
subplot(212), waveplot(ya(tt))
= 1 W, and of
su cient bandwidth such that no distortion is introduced to the signal.
Display the ASK signal sa and the channel output y for 0 < t < 5T .
2
y = channel(sa,1,1.5,49000)
subplot(211), waveplot(sa(tt))
subplot(212), waveplot(y(tt))
ELE 045
From the eye diagram, determine optimum sampling instants and the
threshold value. Apply zm to the decision circuit, and record the resulting probability of bit error.
detect(zm,vth,sampling instant,b)
Coherent detection: P =
e
Q6.6 Compute the theoretical probability of bit error for the case
considered above. Recall that the PSD function of the channel noise is
2
N
S (f ) = 2 = 2 system bandwidth :
o
C.4 Use noncoherent detection to decode the bit sequence from the channel
output y. Compare the resulting BER with the coherent case.
ze = envelope(y,4000)
detect(ze,vth,sampling instant,b)
D . Optional
D.1 Determine the BER for a PSK signal using coherent detection under
the same channel conditions as in part C.
D.2 Determine the BER for a FSK signals using noncoherent detection for
the same channel conditions as in part C.
87
88 Experiment 6: Notes
ELE 045
EXPERIMENT 7
DIGITAL COMMUNICATION
OBJECTIVES
In this experiment you will integrate blocks representing communication system elements into a larger framework that will serve as a model for digital
communication systems. In particular, you will study:
building blocks that constitute baseband and band-pass systems
inverse functional relations between A/D { D/A conversion and transmitter { receiver elements
how to encounter phase reversal by di erential encoding
how to select transmitter parameters based on empirically determined
channel characteristics.
REFERENCES
1. A. B. Carlson, \Communication Systems," third ed., McGraw-Hill
Inc., New York, 1986, pp. 430{439 and 512{532.
2. L. W. Couch II, \Digital and Analog Communication Systems," third
ed., MacMillan Publishing Co., New York, 1990, pp. 130{144 and 547.
3. S. Haykin, \An Introduction to Analog & Digital Communications,"
J. Wiley & Sons Inc., New York, 1989, pp. 177{202 and 539{580.
PRE-LAB ASSIGNMENT
1. Consider the unipolar NRZ and manchester binary signalling formats.
Let the channel noise PSD function be S (f ) = N0 =2.
a. Determine the energy per bit interval E for both line codes as a
function of signal amplitude A, and binary data period T .
b. Determine the bit error rate P for matched lter based detection
of both line codes as a function E and N0 . Sketch P for E =N0 2
0:1 10 ].
n
2. Determine the bit error rate P for coherent detection of ASK and PSK
e
ELE 045
PROCEDURE
A . Introduction
A.1 Analog Waveform to Channel Code Transformation
The block diagram depicted in Fig 7.1 represents how an analog signal
is transformed rst into a digital format and then into a form compatible with channel characteristics. The main functions are the A/D
converter and the transmitter represented by a2d and tx .
ANALOG WAVEFORM
ANTI-ALIASING
FILTER
SAMPLING
LAW
COMPANDING
MATLAB FUNCTIONS
mu_law
UNIFORM
QUANTIZATION
quantize
SOURCE
CODING
bin_enc
bin2gray
A2D
PAR to SERIAL
CONVERSION
DIFFERENTIAL
ENCODING
par2ser
diff_enc
TX
CHANNEL
CODING
wave_gen
modulate
to CHANNEL
ELE 045
The block diagram depicted in Fig 7.2 represents how the channel output is processed by the receiver to recover the transmitted binary sequence. The estimated binary sequence is subsequently converted into
an analog waveform. The two main blocks are the receiver and the D/A
converter represented by the MATLAB functions rx and d2a .
from CHANNEL
mult_car
DEMODULATION
RX
MATLAB FUNCTIONS
RECEIVER
FILTER
match
lpf
DETECTION
detect
DIFFERENTIAL
DECODING
diff_dec
SERIAL to PAR
CONVERSION
ser2par
D2A
SOURCE
DECODING
LAW
EXPANSION
gray2bin
bin_dec
mu_inv
OUTPUT
LPF
ANALOG WAVEFORM
91
ELE 045
REMARKS
The MATLAB functions a2d, d2a, tx and rx have been designed to
simplify and to automate tasks that constitute each block. Use the
on-line help facility to obtain more information about each function.
The output from the transmitter is send over the communication channel represented by channel and will serve as the input to the receiver.
Depending on the channel characteristics you have to modify the sampling instances of the waveform at the output of the receiver lter. This
information can be best extracted from the eye diagram at the lter
output. One of options of the receiver function rx is to display the eye
diagram and to prompt the user for the optimum sampling time. Type
help rx to learn how to use this function.
ELE 045
Now compare the message signal represented by the data array s and
the output from the A/D{D/A conversion, s analog:
subplot(211), waveplot(s)
subplot(212), waveplot(s analog)
Q7.1 Does the process of converting analog signals rst into dig-
C . Di erential Encoding
C.1 Generate 100 samples of a sinusoid, convert into digital domain and
prepare to resulting binary data for transmission over a baseband communication channel using manchester line code:
x = sin( 2*pi*400* 1:100]/SAMPLING FREQ )
x pcm = a2d(x,6)
xw = tx( x pcm, 'manchester', 'no diff', 1000 )
93
ELE 045
D . Baseband Communication
D.1 Generate 1,000 binary samples to evaluate the bit error rate (BER) as
b = binary(1000)
Rb = 1000
u = tx(b,'unipolar nrz',Rb)
m = tx(b,'manchester',Rb)
N0 and
ELE 045
where ch input is either the unipolar NRZ waveform u or the manchester waveform m. The value of A in the above command line will change
the waveform amplitude and therefore the transmitter power measured
in terms of E . Perform the BER computations for values of A shown
in Table 7.1.
b
(volts)
0.2
0.3
0.4
0.5
0.6
0.7
UNIPOLAR NRZ
E =N0
MANCHESTER
E =N0
Table 7.1
Compare the above empirical P values with theoretical values determined in the pre-lab assignment and plot them the same graph.
e
Determine N0 corresponding to 2 = 2 and R = 1 kbps. If the channel input is u, determine from your pre-lab assignment the required
transmitter power measured in terms of E to achieve P 10;2. For
the calculated value of transmitter power, empirically determine BER
using u. Repeat using the manchester encoded waveform m.
b
E . Band-Pass Communication
E.1 Generate 100 samples from a speech signal:
s = speech(100)
95
ELE 045
Transmitter | tx :
600000, 1400000] )
Eb
N0
fc
Pe
Table 7.2
Q7.3 Is the empirical BER di erent than the theoretical value? If
ELE 045
Experiment 7: Notes
97
98 Experiment 7: Notes
ELE 045
APPENDICES
ELE 045
APPENDIX A
SIMULATION ENVIRONMENT
If one attempts to model an analog signal on a digital computer, the simulation environment will impose certain limitations on the degree of precision
that can be achieved in representing the analog signal. This appendix delineates characteristics of analog signals simulated on a digital computer and
discusses their signi cance from a user's perspective.
In MATLAB, a function f (t) is de ned by an array of data points
that represents amplitude of the function at sampling instances. For
example, the array f (t1 ) f (t2 ) : : : f (t ) ] represents f (t) at sampling
instances t1 t2 : : : t . Irrespective of the number of sample points
included in the data array, the result still corresponds to a sampled
version of the function. To make this observation tangible, assume
that you issue the following MATLAB command:
n
x = sin(t)
1:100] * (1/fs) ]
will work just ne, but what you have created through the above set of
commands, are 100 samples of a 1 kHz sinusoid sampled at a frequency
of only 1 Hz. If you leave out the term 1=fs or modify its value,
you only change the sampling frequency, but the fact that you are
sampling remains unrevocably embedded in the very structure of the
resulting data array.
So how do you generate an analog waveform? The simple answer is
that you can not generate a true analog signal. Consequently, one can
only talk about \pseudo-analog" signals, that have been sampled at a
su ciently high rate so that the sampled signal will accurately represent the analog waveform. The MATLAB function wave gen generates
waveforms representing binary line codes exactly in this manner. For
101
ELE 045
example, if you specify a binary data rate of 5 kHz, the sampling frequency is set to 50 kHz or higher depending on the experiment. The
f = K f rule, where f is the input signal frequency or binary data
rate and K 10 is the sampling constant, is a compromisey between
the data array size and precision.
s
ELE 045
APPENDIX B
COMMUNICATION SYSTEM TOOLBOX
HOW TO GET STARTED ?
All global parameters are in the le start.m. When you rst enter the MATLAB environment, type start to initialize global parameters.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
PROBABILISTIC ANALYSIS
cdf . . .
exp cdf .
exp pdf .
gamma pdf
gaus cdf .
gaus pdf .
lapl cdf .
lapl pdf .
meansq .
pdf . . .
Q . . . .
rayl cdf .
rayl pdf .
unif cdf .
unif pdf .
var . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
103
ELE 045
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . autocorrelation function
. . autocorrelation function display
. ensemble autocorrelation function
. . . power spectral density function
power spectral density function display
QUANTIZATION
a2d . .
d2a . .
mu inv
mu law
quant ch
quant ef
quantize
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
analog-to-digital conversion
digital-to-analog conversion
. . . . . -law expansion
. . . . -law companding
. . quantizer characteristics
. . . . quantizer e ciency
. . . uniform quantization
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . binary-coded-decimal coding
. . . . . natural binary source coding
. . . . natural binary source decoding
natural binary to gray -code conversion
gray -code to natural binary conversion
. . . . binary to polar transformation
. . . binary to bipolar transformation
. . . . . . . . di erential decoding
. . . . . . . . di erential encoding
. 1's complement of a binary sequence
. . . . . parallel-to-serial conversion
. . . . polar to binary transformation
. . . . . serial-to-parallel conversion
. . . . . . . . . . . . exclusive OR
ELE 045
. . . .
. . . .
. . . .
. . .
. . . .
. . .
. . . .
. . . .
. . .
. . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . . . . . triangular pulse
. . . . . . . . . . . . Nyquist pulse
. . . . . . generate Nyquist waveform
. . . . . generate duobinary waveform
. . . . . . . modi ed duobinary pulse
digital modulated wave (ASK,BPSK,FSK)
. . . . . . . . . . sinusoidal oscillator
. . . . . . voltage controlled oscillator
. . . binary signal waveform generation
. . . . . display binary signal waveform
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
DATA TRANSMISSION
bpf . .
channel
eye diag
lpf . .
rc . . .
detect .
envelope
int dump
mixer .
match .
rx . .
tx . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . . . band-pass lter
. . . data communication channel
eye diagram generation and display
. . . . . . . . . low-pass lter
. . . . . . . 1st order RC- lter
. . . . . . binary data detection
. . . . . . . . envelope detector
. . . . integrate-and-dump lter
. . . . . . . . two input mixer
. . . . . . . . . matched lter
. . . . . . . . receiver function
. . . . . . transmitter function
UTILITY FUNCTIONS
blackbox .
convert .
exp5 c6 .
tsize . .
fx . . . .
play . . .
playback .
limiter .
normalize
rectify . .
sinc . . .
spec est .
stair . .
stat plot .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
105
ELE 045