Top Banner
CTU: EE 463 Communications 2: Lab 1: MATLAB Project Sampling 1 Colorado Technical University EE 463 Communications 2 Lab 1: MATLAB Project Sampling October 2010 Loren K. Schwappach ABSTRACT: This lab report was completed as a course requirement to obtain full course credit in EE463, Communications 2 at Colorado Technical University. This Lab investigates the concepts of sampling, aliasing, and recovery of signals after sampling. In addition this lab explores the similarities between amplitude modulated signals and sampling. All of the code mentioned in this lab report was saved as a MATLAB m-file for convenience, quick reproduction, and troubleshooting of the code. All of the code below can also be found at the end of the report as an attachment, as well as all figures. If you have any questions or concerns in regards to this laboratory assignment, this laboratory report, the process used in designing the indicated circuitry, or the final conclusions and recommendations derived, please send an email to [email protected] . All computer drawn figures and pictures used in this report are of original and authentic content. I. INTRODUCTION MATLAB is a powerful program and is helpful in the visualization of applied mathematics, physics, and practical engineering. In this lab assignment MATLAB’s Simulink tools are used to explore the generation, recovery, and aliasing of a sampled signal. II. OBJECTIVES In this communications 2 lab exercise MATLAB will be used to accomplish the following objectives: 1. Demonstrate the concepts of sampling, aliasing and the recovery of signals from a sampled signal. 2. Demonstrate the relationship between amplitude modulation and sampling. 3. Apply the concept of sampling to envelope detection. III. EQUIPMENT The following tools and or equipment were used for this lab assignment: 1. MATLAB version 2009b to 2010a. 2. Simulink (Part of MATLAB) 3. Communications Toolbox (Part of Simulink) IV. PROCEDURE / RESULTS The procedures used in this lab are illustrated by the included MATLAB code (not applicable for this lab assignment) and Simulink diagrams (applicable) in this report. This Simulink diagrams can also be found at the end of this report as attachments for easier visibility. 1. Part A Generating A Sampled Message For the first part of this lab assignment (Part A), Simulink is used to demonstrate the concept of sampling. Sampling of the frequency domain is accomplished by multiplying a message signal with a non-zero average value sampling signal (pulse) at a sampling frequency that at the very least exceeds the Nyquist frequency. For this part of the lab assignment a 10 Hertz Sine wave message and 10 Hertz Pulse message are independently sampled. The effects of biasing of a sinusoidal message are also explored as well as the effect of using a zero average sampling pulse over a non-zero average pulse, however the effects are not apparent until message recovery is completed in Part B. First this lab will examine the effects of using a 10 Hertz biased sine wave (Figure 1).
17
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 1

Colorado Technical University

EE 463 – Communications 2

Lab 1: MATLAB Project – Sampling

October 2010

Loren K. Schwappach

ABSTRACT: This lab report was completed as a course requirement to obtain full course credit in EE463,

Communications 2 at Colorado Technical University. This Lab investigates the concepts of sampling, aliasing, and recovery of

signals after sampling. In addition this lab explores the similarities between amplitude modulated signals and sampling. All of

the code mentioned in this lab report was saved as a MATLAB m-file for convenience, quick reproduction, and troubleshooting

of the code. All of the code below can also be found at the end of the report as an attachment, as well as all figures.

If you have any questions or concerns in regards to this laboratory assignment, this laboratory report, the process used in

designing the indicated circuitry, or the final conclusions and recommendations derived, please send an email to

[email protected]. All computer drawn figures and pictures used in this report are of original and authentic content.

I. INTRODUCTION

MATLAB is a powerful program and is helpful in the

visualization of applied mathematics, physics, and practical

engineering. In this lab assignment MATLAB’s Simulink

tools are used to explore the generation, recovery, and aliasing

of a sampled signal.

II. OBJECTIVES

In this communications 2 lab exercise MATLAB will

be used to accomplish the following objectives:

1. Demonstrate the concepts of sampling, aliasing and the

recovery of signals from a sampled signal.

2. Demonstrate the relationship between amplitude

modulation and sampling.

3. Apply the concept of sampling to envelope detection.

III. EQUIPMENT

The following tools and or equipment were used for

this lab assignment:

1. MATLAB version 2009b to 2010a.

2. Simulink (Part of MATLAB)

3. Communications Toolbox (Part of Simulink)

IV. PROCEDURE / RESULTS

The procedures used in this lab are illustrated by the

included MATLAB code (not applicable for this lab

assignment) and Simulink diagrams (applicable) in this report.

This Simulink diagrams can also be found at the end of this

report as attachments for easier visibility.

1. Part A – Generating A Sampled Message

For the first part of this lab assignment (Part A),

Simulink is used to demonstrate the concept of sampling.

Sampling of the frequency domain is accomplished

by multiplying a message signal with a non-zero average value

sampling signal (pulse) at a sampling frequency that at the

very least exceeds the Nyquist frequency.

For this part of the lab assignment a 10 Hertz Sine

wave message and 10 Hertz Pulse message are independently

sampled.

The effects of biasing of a sinusoidal message are

also explored as well as the effect of using a zero average

sampling pulse over a non-zero average pulse, however the

effects are not apparent until message recovery is completed in

Part B.

First this lab will examine the effects of using a 10

Hertz biased sine wave (Figure 1).

Page 2: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 2

Figure 1: Lab 1 Part A Sine Wave Input.

Figure 1 above was designed in Simulink to allow

either a 10 Hertz sine wave or 10 Hertz pulse. The 10 Hertz

sine wave is chosen first and the results displaying the correct

frequency results and DC biasing are shown by Figure 2.

Figure 2: m(t) biased message.

Figure 3 below shows the time domain results of

sampling the biased sine wave with a Sampling pulse

generator that is sampling at a frequency slightly higher than

the Nyquist frequency. In this case 20.2 Hertz is chosen as the

sampling frequency which exceeds the Nyquist theorem (A

signal must be sampled by a sampling frequency that is at least

twice as high as the highest message frequency.)

Figure 3: sampled(t).

Figure 4 below shows the biased 10 Hertz Sine wave

in the frequency domain and its corresponding frequencies (10

Hertz, -10 Hertz, and DC 0 Hertz bias.)

Figure 4: M(f) biased message.

Figure 5 below shows the sampled biased sine wave

in the frequency domain. In the frequency domain you can

see several duplicates of the message signal as well as the

original message signal. The duplicates (samples) of the

message signal are located (centered) at harmonics (multiples)

of the sampling frequency.

It can already be seen that by biasing the message

signal prior to sampling we achieve what looks to be several

amplitude modulated (AM) signals in the frequency domain.

If we were to filter out one of these sampling harmonics we

would be left with a result very similar to an AM wave. This

concept will be explored later in this lab.

Page 3: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 3

Figure 5: Sampled(f)

As observed by Figure 5 above sampling results in

frequencies at 0 Hz, +-10Hz (original signal (fm)) as well as

several clones of the sampled signal centered at the sampling

frequency (fs) and its harmonics (n*fs). So the sampled

spectrum contains n*fs+-fm.

Next an analysis of biasing the message signal is

further explored by un-biasing the 10 Hertz sine wave as

shown by Figure 6.

Figure 6: Lab 1 Part A Sine Zero Bias.

The unbiased sine wave transient analysis (time

domain) results can be observed by Figure 7. And the

corresponding sampling results can be seen in Figure 8.

Figure 7: m(t) unbiased message.

Figure 8: sampled(t).

The results of Figures 7 and 8 are as expected as well

as the spectrum (frequency domain) results shown by Figure 9

and 10.

It can already be seen that by un-biasing the message

signal prior to sampling we achieve what looks to be several

double sideband suppressed carrier (DSB-SC) signals in the

frequency domain. If we were to filter out one of these

sampling harmonics we would be left with a result very

similar to a DSB-SC wave. This concept will be explored

later in this lab.

Figure 9: M(f) unbiased.

Page 4: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 4

Figure 10: Sampled(f).

Next, our sine wave source is replaced with a 10

Hertz pulse wave as shown by Figure 11. A pulse in the time

domain results in a sinc function in the frequency domain.

Thus, in-order to accurately represent a pulse wave you need

to capture at least ten harmonic frequencies created as a result

of the sinc function. Since our pulse is a 10 hertz we should

have an accurate representation of the pulse by grabbing

frequencies up to 11* pulse frequency. Now letting this high

frequency become the highest frequency of the pulse wave our

sampling rate should be slightly higher than twice the highest

message frequency. This ensures a sampling rate of at least

222.2 Hertz and is the frequency used by our sampling pulse

generator in Figure 11.

Figure 11: Lab 1 Part A Pulse.

Figure 12 illustrates the 10 Hertz pulse in the time

domain and Figure 13 illustrates the sampled pulse in the time

domain.

Figure 12: pulse m(t).

Figure 13: sampled(t).

Figure 14 illustrates the 10 Hertz pulse in the

frequency domain (representing the magnitude of a sinc) and

Figure 15 illustrates the sampled pulse in the frequency

domain.

As observed by Figure 15 the sampling results in

frequencies of the original signal as well as several clones of

the sampled signal centered at the sampling frequencies (fs)

and its harmonics (n*fs). So the sampled spectrum contains

n*fs+-fm.

Figure 14: M(f).

Page 5: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 5

Figure 15: Sampled(f).

For the last part of Part A, a constant (-5) DC signal

is added to our sampling pulse making the sampling pulse

have a zero-average value. This has the effect of canceling

out our DC pulse components and will cause the signal to be

unrecoverable in Part B of this lab report. This is done in

Simulink as shown by Figure 16.

Figure 16: Lab 1 Part A Pulse (Zero Avg. Sampler).

Figure 17: pulse m(t).

Figure 18: sampled(t).

The results of using the zero average sampler are

shown by Figures 17 and 18 in the time domain and by

Figures 19 and 20 in the frequency domain.

As expected and shown by Figure 20 by using a zero

average sampling function we have eliminated several critical

pieces of our message signal (effectively canceled out the DC

pulse components.) Without these components recovery of

our message signal will be impossible. Thus the sampling

function must have a non-zero average value. This concept

will gain further validity after we attempt message recovery in

Part 2.

Page 6: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 6

Figure 19: M(f).

Figure 20: Sampled(f). Sampled using Zero Average

value pulse. Notice the missing DC components.

2. Part 2 – Recovery of a Sampled Message

For the second part of this lab assignment (Part B),

Simulink is used to demonstrate the concept of message

recovery from a sampled message.

Since sampling results in the original message

frequencies as well as several clones of the original message

frequencies centered at the sampling frequency (fs) and its

harmonics (n*fs). Recovery of the message should be

possible by low pass filtering the original message from the

sampled harmonics.

This should be possible so long as the sampling

frequency is at least twice as high as the highest frequency

component of the message frequency.

Furthermore, since ideal LP filters are hard to come

by we should further increase our chances of successful

message recovery by a further boost to our sampling

frequency.

First we will attempt recovery of our original

sampled 10 Hertz sine wave using a sampling rate only

slightly higher than the Nyquist rate and a 5th order

Butterworth low-pass (LP) filter as shown by Figure 21.

Figure 21: Lab 1 Part B Sine. Nyquist Sampled.

As shown by figure 22, using a sampling rate only

slightly (1%) higher than the Nyquist is insufficient for

message recovery since an ideal LP filter is unrealistic. The

frequency components displayed by Figure 23 contain more

than the original message (although hard to observe).

Thus we need to increase our sampling rate in order

to decrease our LP filter approximation.

Figure 22: recovered(t) recovered poorly using Nyquist

Sampling Rate.

Page 7: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 7

Figure 23: Recovered(f) recovered poorly using Nyquist

sampling rate.

Next the sampling rate is adjusted to a rate much

higher than the Nyquist (fm*5 versus fm*2). This should

ensure greater probability of message recovery. This was

accomplished using the Simulink model displayed by Figure

24.

Figure 24: Lab 1 Part B Sine. Over Sampled.

Figure 25 shows that our original sine wave was

successfully recovered using the higher sampling rate of 5*fm.

This allowed the 5th order Butterworth LP filter to effectively

eliminate the harmonic sampling components created through

the sampling process. Figure 26 shows the successful

recovery of the message in the frequency domain.

Figure 25: recovered(t) recovered nicely by over sampling.

Figure 26: recovered(t) recovered nicely by over sampling.

Next our input sources are changed and an attempt at

recovering our original 10 Hertz pulse using a sampling rate

much higher than the Nyquist (fm*5 versus fm*2) is

attempted. This was accomplished using the model illustrated

by Figure 27.

Figure 27: Lab 1 Part B Pulse. Over sampled and

recovered.

It has already been shown that a pulse in the time

domain results in a sync in the frequency domain, and we can

Page 8: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 8

approximate a pulse by capturing as many harmonics in the

frequency domain as possible.

However, to reduce bandwidth we can achieve a

close approximation to our pulse by limiting the pulse to

approximately 10 harmonics. Thus, for this lab assignment fm

* 11 was chosen as the highest frequency component of the

pulse.

As Figure 28 illustrates successful recovery of the

pulse was accomplished by using a high sampling rate and

capturing LP filtering out the sampling resultant frequencies.

If the sampling had been too low aliasing could have

occurred making message recovery impossible. This concept

is explored further in Part C.

Figure 28: recovered(t) recovered nicely by over sampling.

Figure 29: Sampled(f)

Next a final proof of the effects of using a zero

average value sampling function is explored by again adding a

constant (-0.5) to our sampling pulse as shown by Figure 30.

Figure 30: Lab 1 Part B Pulse Recovery with Zero Avg.

Sampling.

As a result of using a zero average value function

versus a non-zero average value function we effectively

eliminate our DC message components when sampling and

make message recovery very improbable. The time domain

results of this concept are shown by Figure 31 which looks

nothing like our original pulse! The frequency domain results

shown by Figure 32 show the elimination of the messages DC

components.

Figure 31: recovered(t). Recovery was not successful due

to Zero Avg. Sampling frequency.

Page 9: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 9

Figure 32: Sampled(f). Message unrecovered due to Zero

Avg. value of sampling pulse.

3. Part 3 – Aliasing

Aliasing refers to an effect which causes different

signals to become indistinguishable due to sampling. The

aliasing effect can make recover of a message signal

impossible when the sampling rate is too low and effectively

causes samples to shift into the original message.

Thus, aliasing can easily be caused and observed by

sampling at a rate that is lower than the Nyquist rate.

To demonstrate aliasing we can use our original 10

Hertz sine wave message and modify the sampling rate to be

lower than the Nyquist rate. For this lab assignment

demonstration a sampling rate of 1.5 times the message was

chosen.

Mathematically aliasing will result in the following

frequency components:

M ulse

ulse M S mple

So suppose we use a 10 Hertz sine wave message. If

we sample below the Nyquist minimum frequency at say 1.5

times the message, the sampled message would be composed

of the message frequencies and the addition of the samples

centered above and below the sampling frequency and its

multiples.

If the sampling frequency (fs) is 1.5 times the

message frequency then the sampling frequency must be 15

Hertz.

The samples appear both above and below this

sampling frequency as described by equation 3:

Thus even if we were to use an ideal low pass filter

capable of capturing all of the original message frequencies

(frequencies < 10 Hertz), we would still capture an extra

frequency due to the aliasing caused by sampling lower than

the Nyquist frequency as shown by equation 4:

e t e t e t

As you can see 5 Hertz is less than our 10 Hertz

message frequency so our resultant low pass filter would

output both frequencies (5 Hertz and 10 Hertz). This is not the

recovered output we expected and thus aliasing has made

recovery of this message signal impossible.

To further explore this concept graphically the

following Simulink model was build using our previous

MATLAB concepts (10 Hertz sine message with a sampling

of 15 Hertz) as shown by Figure 33.

Figure 33: Lab 1 Part C Aliasing.

As illustrated by Figure 34 the resultant recovered

message m(t) is no longer composed of a single sine wave but

seems to be a composite sinusoidal. Figure 35 further

confirms this and shows the additional frequency (5 Hertz)

component in our frequency spectrum.

Figure 34: recovered(t). Unrecovered message caused by

aliasing. Sampling rate < Nyquist rate.

Page 10: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 10

Figure 35: Recovered(f). Unrecovered message caused by

aliasing. Sampling rate < Nyquist rate.

4. Part 4 – AM & DSB-SC Wave creation

through sampling.

An amplitude modulated wave is represented in the

time domain mathematically by:

A

Looking at this equation we can observe that a AM

wave is produced by multiplying a zero average sampling

function (like a sine or cosine) with a biased message signal

and then filtering (Band Pass) out the AM wave (remember

(Figure 36) sampling will make numerous copies each

centered at the sampling frequency) which contains a

duplicate of the message above the sampling frequency and a

duplicate of the message reflected below the message

frequency. So long as the message sinusoidal is biased

(contains a DC value) the filtered result is an AM wave. If the

message sinusoidal is unbiased the result will be a DSB-SC

wave.

Figure 36: Lab 1 Part D Amplitude Modulated Signal.

Biased Sine and Zero Avg. Sampling.

Figure 37: m(t). Biased.

Figure 38 shows the sampled message in the time

domain. However we still need to filter out the extra

frequency components adding to the pulse form of the output.

By using a band-pass filter with a lower pass-band fs-fm and

upper pass-band fs+fm we get the correct AM result as shown

by Figure 39.

Figure 38: sampled(t).

Figure 39: AM filtered(t). After filtering result is AM

wave.

Page 11: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 11

Figure 40: M(f).

Figure 44 below correctly demonstrates an AM

(DSB-LC) wave created using a biased message, zero average

sampling, and band pass filtering.

Figure 44: AM Filtered(f).

Next to demonstrate a DSB-SC wave we need to

unbias the sinusoidal message. This will remove the DC

(carrier) of the DSB-LC (AM) wave. This was accomplished

in Simulink using Figure 41.

Figure 41: Lab 1 Part D DSB-SC. Unbiased m(t).

Figure 42: m(t).

Figure 43: sampled(t).

Figure 44: AM filtered(t).

The spectrum results required by a DSB-SC wave are

correctly illustrated by Figure 47. Thus we have proved that

you can create an AM wave and a DSB-SC wave using

bandpass filtering and zero averaged sampling.

Page 12: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 12

Figure 45: M(f).

Figure 46: Sampled(f).

Figure 47 below correctly illustrates a DSB-SC

spectrum.

Figure 47: DSB-SC Filtered(f).

V. CONCLUSIONS

In conclusion this lab has demonstrated the concepts

of sampling (Part A), aliasing (Part C) and the recovery (Part

B) of signals from a sampled signal. Finally this assignment

has applied the concept of sampling to amplitude modulation

and DSB-SC modulation.

It was demonstrated that by using the Nyquist

frequency as the sampling frequency we can mathematically

avoid aliasing and sample the signal in such a way as to allow

signal recovery through low-pass filtering. However since

ideal LP filters are very improbable and a using a higher

sampling rate decreases the filter design constraints it is often

better to use a sampling rate higher than the Nyquist rate.

Finally by using a zero average sampling function

and band-pass filtering we can achieve what appears to be an

AM or DSB-SC signal in the frequency domain. Whether or

not the carrier is present (AM vs. DSB-SC) is dependent upon

the presence of a bias on the message signal.

REFERENCES

[1] ykin, S , “An log n Digit l Communi tions 2nd

Edition” John Wiley & Sons, boken, NJ, 2007.

Page 13: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 13

Figure 48: Lab 1 Part A Sine Wave Input.

Figure 49: Lab 1 Part A Sine Zero Bias.

Page 14: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 14

Figure 50: Lab 1 Part A Pulse.

Figure 51: Lab 1 Part A Pulse (Zero Avg. Sampler).

Page 15: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 15

Figure 52: Lab 1 Part B Sine. Nyquist Sampled.

Figure 53: Lab 1 Part B Pulse Recovery with Zero Avg. Sampling.

Page 16: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 16

Figure 54: Lab 1 Part C Aliasing.

Figure 55: Lab 1 Part D Amplitude Modulated Signal. Biased Sine and Zero Avg. Sampling.

Page 17: Ee463   communications 2 - lab 1 - loren schwappach

CTU: EE 463 – Communications 2: Lab 1: MATLAB Project – Sampling 17

Figure 56: Lab 1 Part D DSB-SC. Unbiased m(t).