100% found this document useful (1 vote)
334 views21 pages

Lab3 6

This document discusses amplitude modulation and demodulation using MATLAB. It contains 3 key points: 1) It describes how to generate an amplitude modulated wave using the ammod function, and plots the original and modulated signals as an example. 2) It shows how to generate an amplitude modulated wave without using ammod by multiplying the message and carrier signals. 3) It demonstrates demodulating an amplitude modulated wave back to the original signal using the amdemod function, and plots the original, modulated, and demodulated signals.

Uploaded by

Cool Angel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
334 views21 pages

Lab3 6

This document discusses amplitude modulation and demodulation using MATLAB. It contains 3 key points: 1) It describes how to generate an amplitude modulated wave using the ammod function, and plots the original and modulated signals as an example. 2) It shows how to generate an amplitude modulated wave without using ammod by multiplying the message and carrier signals. 3) It demonstrates demodulating an amplitude modulated wave back to the original signal using the amdemod function, and plots the original, modulated, and demodulated signals.

Uploaded by

Cool Angel
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 21

LAB # 3

An Introduction to MATLAB Communications Tool-


box
The Communications Toolbox extends the MATLAB technical computing environment
With functions, plots, and a graphical user interface for exploring, designing, analyzing, and
simulating algorithms for the physical layer of communication systems. The toolbox helps
you create algorithms for commercial and defense wireless or wire line systems.

The key features of the toolbox are


• Functions for designing the physical layer of communications links, including source
coding, channel coding, interleaving, modulation, channel models, and equalization
• Plots such as eye diagrams and constellations for visualizing communications signals
• Graphical user interface for comparing the bit error rate of your system with a wide
variety of proven analytical results

In most media for communication, only a fixed range of frequencies is available for
transmission. One way to communicate a message signal whose frequency spectrum
does not fall within that fixed frequency range, or one that is otherwise unsuitable for the
channel, is to alter a transmittable signal according to the information in your message
signal. This alteration is called modulation, and it is the modulated signal that you
transmit. The receiver then recovers the original signal through a process called
demodulation. The contents of this tool box are as follows.

• Modulation Features of the Toolbox--Overview of the modulation types and


modulation operations that the Communications Toolbox supports
• Modulation Terminology--Definitions of terms, as well as inequalities that certain
modulation quantities must satisfy
• Analog Modulation--Representing analog signals and performing analog modulation
• Digital Modulation—Representing digital signals, representing signal constellations
for digital modulation, and performing digital modulation

This section describes how to represent analog signals using vectors or matrices. It
provides examples of using the analog modulation and demodulation functions.
Representing Analog Signals To modulate an analog signal using this toolbox, start with
a real message signal and a sampling rate Fs in hertz. Represent the signal using a vector
x, the entries of which give the signal's values in time increments of 1/Fs. Alternatively,
you can use a matrix to represent a multichannel signal, where each column of the
matrix represents one channel

Analog Modulation/Demodulation function lists


• amdemod-- Amplitude demodulation
• ammod-- Amplitude modulation
• fmdemod-- Frequency demodulation
• fmmod-- Frequency modulation
• pmdemod-- Phase demodulation
• pmmod-- Phase modulation
• ssbdemod-- Single sideband amplitude demodulation
• ssbmod-- Single sideband amplitude modulation

ammod [Amplitude modulation]

Syntax
y = ammod(x,Fc,Fs)
y = ammod(x,Fc,Fs,ini_phase)
y = ammod(x,Fc,Fs,ini_phase,carramp)

Description:
y = ammod(x,Fc,Fs) uses the message signal x to modulate a carrier signal with
frequency Fc (Hz) using amplitude modulation. The carrier signal and x have sample
frequency Fs (Hz). The modulated signal has zero initial phase and zero carrier amplitude,
so the result is suppressed-carrier modulation.Note The x, Fc, and Fs input arguments must
satisfy Fs > 2(Fc + BW), where BW is the bandwidth of the modulating signal x.y =
ammod(x,Fc,Fs,ini_phase) specifies the initial phase in the modulated signal y in radians.y =
ammod(x,Fc,Fs,ini_phase,carramp) performs transsmitted-carrier modulation instead
ofsuppressed-carrier modulation. The carrier amplitude is carramp.

amdemod [Amplitude demodulation]


Syntax
z = amdemod(y,Fc,Fs)
z = amdemod(y,Fc,Fs,ini_phase)
z= amdemod(y,Fc,Fs,ini_phase,carramp)
z = amdemod(y,Fc,Fs,ini_phase,carramp,num,den)

Description:
z = amdemod(y,Fc,Fs) demodulates the amplitude modulated signal y from a carrier
signal with frequency Fc (Hz). The carrier signal and y have sample frequency Fs (Hz).

The modulated signal y has zero initial phase and zero carrier amplitude, so it represents
suppressed carrier modulation. The demodulation process uses the lowpass filter specified
by [num,den] = butter(5,Fc*2/Fs).Note
The Fc and Fs arguments must satisfy Fs > 2(Fc + BW) where BW is the bandwidth of the
original signal that was modulated.z = amdemod(y,Fc,Fs,ini_phase) specifies the initial phase
of the modulated signal in radians.z = amdemod(y,Fc,Fs,ini_phase,carramp)
demodulates a signal that was created via transmitted carrier modulation instead of
suppressed carrier modulation. carramp is the carrier amplitude of the modulated signal.
z = amdemod(y,Fc,Fs,ini_phase,carramp,num,den) specifies the numerator and
denominator of the lowpass filter used in the demodulation.

fmmod [Frequency modulation]


Syntax
y = fmmod(x,Fc,Fs,freqdev)
y = fmmod(x,Fc,Fs,freqdev,ini_phase)
Description:
y = fmmod(x,Fc,Fs,freqdev) modulates the message signal x using frequency modulation.
The carrier signal has frequency Fc (Hz) and sampling rate Fs (Hz), where Fs
must be at least 2*Fc. The freqdev argument is the frequency deviation (Hz) of the
modulated signal.y = fmmod(x,Fc,Fs,freqdev,ini_phase) specifies the initial phase of the
modulated signal, in radians.

Fmdemod[ Frequency demodulation]


Syntax
z = fmdemod(y,Fc,Fs,freqdev)
z = fmdemod(y,Fc,Fs,freqdev,ini_phase)
Description:
z = fmdemod(y,Fc,Fs,freqdev) demodulates the modulating signal z from the carrier signal
using frequency demodulation. The carrier signal has frequency Fc (Hz) and sampling rate
Fs (Hz), where Fs must be at least 2*Fc. The freqdev argument is the frequency deviation
(Hz) of the modulated signal y.z = fmdemod(y,Fc,Fs,freqdev,ini_phase) specifies the initial
phase of the modulated signal, in radians.

Pmmod [Phase modulation]


Syntax
y = pmmod(x,Fc,Fs,phasedev)
y = pmmod(x,Fc,Fs,phasedev,ini_phase)
Description
y = pmmod(x,Fc,Fs,phasedev) modulates the message signal x using phase modulation. The
carrier signal has frequency Fc (Hz) and sampling rate Fs (Hz), where Fs must be at least
2*Fc. The phasedev argument is the phase deviation of the modulated signal in radians.y =
pmmod(x,Fc,Fs,phasedev,ini_phase) specifies the initial phase of the modulated signal in
radians.

pmdemod [Phase demodulation]


Syntax:
z = pmmod(y,Fc,Fs,phasedev)
z = pmmod(y,Fc,Fs,phasedev,ini_phase)
Description:

z = pmmod(y,Fc,Fs,phasedev) demodulates the phase-modulated signal y at the carrier


frequency Fc (Hz). z and the carrier signal have sampling rate Fs (Hz), where Fs must be at
least 2*Fc. The phasedev argument is the phase deviation of the modulated signal, in
radians.z = pmmod(y,Fc,Fs,phasedev,ini_phase) specifies the initial phase of the
modulated signal, in radians.
LAB # 4

Amplitude Modulation and Demodulation of


a signal

INTRODUCTION
Amplitude modulation (AM) is the family of modulation schemes in which the
amplitude of a sinusoidal carrier is changed as a function of the modulating
message signal. This type of modulation schemes includes many variants,
such as double-sideband suppressed carrier (DSB-SC), single-sideband (SSB).

DSB-SC AM:
In DSB-SC AM, the amplitude of the modulated signal is proportional to the
message signal.
The time-domain representation of this scheme is given by:
y(t) A x(t)cos(2 f t) c c = π
where A cos(2 f t) c c π is the carrier signal with a carrier frequency c f , and
x(t) is the
message signal. The transmission bandwidth is twice the bandwidth of the
message signal.

BLOCK DIAGRAM:
SIMULATION in MATLAB:

To modulate an analog signal using this toolbox, start with a real


message
Signal and a sampling rate Fs in hertz. Represent the signal using a
vector x, the entries of which give the signal's values in time
increments of 1/Fs. alternatively, you can use a matrix to represent a
multichannel signal, where each column of the matrix represents one
channel.

Generating an AM-wave using Matlab in-built function


For example, if t measures time in seconds, then the vector x below is
the result of sampling a sine wave 8000 times per second for 0.1
seconds.
The vector y represents the modulated signal.

Example 4.1:
Fs = 8000; % Sampling rate is 8000 samples per second.
Fc = 300; % Carrier frequency in Hz
t = [0:.1*Fs]'/Fs; % Sampling times for .1 second
x = sin(20*pi*t); % Representation of the signal
y = ammod(x,Fc,Fs); % Modulate x to produce y.
figure;
subplot(2,1,1); plot(t,x); % Plot x on top.
subplot(2,1,2); plot(t,y)% Plot y below.

Result:
1

0.5

-0.5

-1
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1

0.5

-0.5

-1
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1

Generating an AM-wave without using Matlab in-built function

Example 4.2:

clear all
T = 1/100;
fm = 0.25;
fc = 10;
mt = sin(2*pi*fm*[0:T:10]);
subplot (3,1,1);
plot(mt)
ct = sin(2*pi*fc*[0:T:10]);
subplot(3,1,2);
plot(ct)
yt = mt.*ct; % (array operator)
subplot(3,1,3)
plot(yt)
Result:

-1
0 200 400 600 800 1000 1200
1

-1
0 200 400 600 800 1000 1200
1

-1
0 200 400 600 800 1000 1200

To demodulate AM waveform using matlab inbuilt function

Example 4.3 :

t = .01;
Fc = 10000; Fs = 80000;
t = [0:1/Fs:0.01]';
s = sin(2*pi*300*t)+2*sin(2*pi*600*t); % Original signal
subplot (3,1,1);
plot(s)
[num,den] = butter(10,Fc*2/Fs); % Lowpass filter

y1 = ammod(s,Fc,Fs); % Modulate.
subplot (3,1,2);
plot(y1);
s1 = amdemod(y1,Fc,Fs,0,0,num,den); % Demodulate.
subplot (3,1,3);
plot(s1)

Result:

-2

-4
0 100 200 300 400 500 600 700 800 900

-2

-4
0 100 200 300 400 500 600 700 800 900

-2

-4
0 100 200 300 400 500 600 700 800 900

EXERCISE

Q1.
Q2. Using MATLAB, create a time axis between [0, 0.1] seconds with a
sampling
interval of ∆ t = 1×10-5 seconds, as follows: t = 0 : 1/1e5 :
0.1; Now sketch the following signals in time domain:
Modulating signal (low-frequency sinusoidal): m_t =
cos(2*pi*25*t);
Carrier signal (high-frequency sinusoidal): c_t =
cos(2*pi*210*t);
DSB-SC Modulated signal: phi_t = m_t .*
c_t;

Q3. Now change the message signal to m_t = sawtooth(2*pi*25*t),


or a
repeated half-triangular pulse train: d = 0 : 1/50 : 0.1; m_t =
pulstran(t,d,'tripuls',0.01,-1) - 0.5;.
Plot the modulating, carrier and modulated signals again. Did you
notice the
abrupt changes in phase?

Q4. Using MATLAB, sketch the following signals in time domain in the
interval
[0, 0.1] seconds:
DSB-SC Modulated signal: phi_t = m_t .* c_t;
After multiplication at the receiver: x_t = phi_t .* c_t;
Recovered signal: The above signal x(t) passed through a LPF.
This can be
done in MATLAB as follows1:
y_t = filtfilt([1 2 1],[1 -1.99688998444418
0.996894813039884], x_t)*1.20714892591976e-12;

For the above digital filter to work correctly, you need to make
sure you use a sampling frequency of 100 kHz. In other words,
successive samples of your signals should be 1×10-5 seconds
apart.

Q5. What does the recovered signal look like?


LAB # 5

Frequency Modulation and Demodulation of a


signal
The main objectives of this experiment are:
1) To gain a good understanding of Frequency Modulation.
2) To learn how to implement FM modulation & demodulation in software.
3) To demodulate an FM signal using the Differentiation (or Slope) technique.

INTRODUCTION
Angle modulation includes both Frequency and Phase modulation schemes
(FM and PM), which are characterized by their superior performance
(compared to AM) in the presence of noise at the expense of higher
bandwidth requirements. As you studied in class, FM and PM are very similar.
In fact, an FM signal can be interpreted as PM signal and vice-versa (refer to
your textbooks). As such, our focus in this lab will be on FM modulation
exclusively.
An FM-modulated signal has its instantaneous frequency that varies linearly
with the
amplitude the message signal. For example, a message signal x(t) causes the
frequency of the FM signal y(t) to vary linearly around a central carrier
frequency fc. The following
formula describes this relationship:

Here, Kf is known as the sensitivity factor, and represents the frequency


deviation rate as a result of message amplitude change.

SIMULATION:
y = fmmod(x,Fc,Fs,freqdev) modulates the message signal x using frequency
modulation. The carrier signal has frequency Fc (Hz) and sampling rate Fs
(Hz),
where Fs must be at least 2*Fc. The freqdev argument is the frequency
deviation constant (Hz) of the modulated signal.
y = fmmod(x,Fc,Fs,freqdev,ini_phase) specifies the initial phase of the
modulated signal, in radians.

Example 5.1 :
To simulate frequency modulation.

Code:
AM=input('enter message signal amplitude:');
Ac=input('enter carrier signal amplitude:');
fm=input('enter message signal frequency:');
fc=input('enter carrier signal frequency:');
kf=input('enter frequency sensitivity:');
T=1/fm;
t=0:T/200:2*T;
m=AM*sin(2*pi*fm*t);
c=Ac*cos(2*pi*fc*t);
subplot(311);
plot(m);
xlabel('time');
ylabel('amplitude');
title('message signal');
subplot(312);
plot(c);
fi=kf*AM;
b=fi/fm;
s=Ac*cos(2*pi*fc*t-(b*cos(2*pi*fm*t)));
subplot(313);
plot(s);
xlabel('time');
ylabel('amplitude');
title('frequencymodulated signal');

RESULTS:
message signal
5

amplitude
0

-5
0 50 100 150 200 250 300 350 400 450
time

-5
0 50 100 150 200 250 300 350 400 450

frequencymodulated signal
5
amplitude

-5
0 50 100 150 200 250 300 350 400 450
time

Example 5.2 :
To simulate frequency modulation and demodulation using inbuilt
function

Code:

Fs = 5000; % Sampling rate of signal


Fc = 50; % Carrier frequency
t = [0:Fs]'/Fs; % Sampling times
x = sin(2*pi*10*t);
subplot(311); plot(t,x)
dev = 25; % Frequency deviation in modulated signal
y = fmmod(x,Fc,Fs,dev); % Modulation.
subplot(312); plot(t,y)
z = fmdemod(y,Fc,Fs,dev); % Demodulation
subplot(313); plot(t,z)
RESULTS:

0 .5

-0 .5

-1
0 0 .1 0 .2 0 .3 0 .4 0 .5 0 .6 0 .7 0 .8 0 .9 1

0 .5

-0 .5

-1
0 0 .1 0 .2 0 .3 0 .4 0 .5 0 .6 0 .7 0 .8 0 .9 1

0 .5

-0 .5

-1
0 0 .1 0 .2 0 .3 0 .4 0 .5 0 .6 0 .7 0 .8 0 .9 1

EXERCISE
Q3. Simulate the above code with following characteristics and
analyze the
difference.
1)
AM= 3V
Ac= 3V
fm= 200
fc= 2000
kf= 100

2)
AM= 5V
Ac= 5V
fm= 200
fc= 2000
kf= 300
3)
AM= 5V
Ac= 5V
fm= 200
fc= 1000
kf= 1000

4)
AM= 5V
Ac= 5V
fm= 200
fc= 1000
kf= 2000
LAB # 6

Phase Modulation and Demodulation of a


signal

The main objectives of this experiment are:


1) To gain a good understanding of Phase Modulation.
2) To learn how to implement PM modulation & demodulation in software.

INTRODUCTION
Angle modulation includes both Frequency and Phase modulation schemes
(FM and PM), which are characterized by their superior performance
(compared to AM) in the presence of noise at the expense of higher
bandwidth requirements. As you studied in class, FM and PM are very similar.
As such, our focus in this lab will be on PM modulation exclusively.

Phase modulation (PM) is a form of modulation that represents information as


variations in the instantaneous phase of a carrier wave.

PM changes the phase angle of the complex envelope in direct proportion to the message
signal.

Suppose that the signal to be sent (called the modulating or message signal) is m(t) and
the carrier onto which the signal is to be modulated is

m( t ) = cos( 2πf m t )

Annotated:carrier(time) = (carrier amplitude)*sin(carrier frequency*time + phase shift)

This makes the modulated signal

s( t ) = Ac cos ( 2πf c t + θ ( t ) )

For phase modulation θ ( t ) = Dp ∗ m( t )

This shows how m(t) modulates the phase - the greater m(t) is at a point in time, the
greater the phase shift of the modulated signal at that point. It can also be viewed as a
change of the frequency of the carrier signal, and phase modulation can thus be
considered a special case of FM in which the carrier frequency modulation is given by
the time derivative of the phase modulation.
Frequency modulation requires the oscillator frequency to deviate both above and below
the carrier frequency. During the process of frequency modulation, the peaks of each
successive cycle in the modulated waveform occur at times other than they would if the
carrier were unmodulated. This is actually an incidental phase shift that takes place along
with the frequency shift in fm. Just the opposite action takes place in phase modulation.
The af signal is applied to a PHASE MODULATOR in pm. The resultant wave from the
phase modulator shifts in phase, as illustrated in figure 2-17. Notice that the time period
of each successive cycle varies in the modulated wave according to the audio-wave
variation. Since frequency is a function of time period per cycle, we can see that such a
phase shift in the carrier will cause its frequency to change. The frequency change in fm
is vital, but in pm it is merely incidental. The amount of frequency change has nothing to
do with the resultant modulated wave shape in pm. At this point the comparison of fm to
pm may seem a little hazy, but it will clear up as we progress.

Now that you have seen the phase and frequency shifts in both fm and pm, let's find out
exactly how they differ. First, only the phase shift is important in pm. It is proportional to
the af modulating signal. To visualize this relationship, refer to the wave shapes shown in
figure 2-20. Study the composition of the fm and pm waves carefully as they are
modulated with the modulating wave shape. Notice that in fm, the carrier frequency
deviates when the modulating wave changes polarity. With each alternation of the
modulating wave, the carrier advances or retards in frequency and remains at the new
frequency for the duration of that cycle. In pm you can see that between one alternation
and the next, the carrier phase must change, and the frequency shift that occurs does so
only during the transition time; the frequency then returns to its normal rate. Note in the
pm wave that the frequency shift occurs only when the modulating wave is changing
polarity. The frequency during the constant amplitude portion of each alternation is the
REST FREQUENCY.

Figure 2-20. - Pm versus fm.

The relationship, in pm, of the modulating af to the change in the phase shift is easy to
see once you understand AM and fm principles. Again, we can establish two clear-cut
rules of phase modulation:

AMOUNT OF PHASE SHIFT IS PROPORTIONAL TO THE AMPLITUDE OF THE


MODULATING SIGNAL.

(If a 10-volt signal causes a phase shift of 20 degrees, then a 20-volt signal causes a phase
shift of 40 degrees.)

RATE OF PHASE SHIFT IS PROPORTIONAL TO THE FREQUENCY OF THE


MODULATING SIGNAL.

(If the carrier were modulated with a 1-kilohertz tone, the carrier would advance and
retard in phase 1,000 times each second.)
Example 6.1 :
To simulate phase modulation.

d=0.004;
fs = 1000000;
ns=d*fs;
t=(1:ns)/fs;
Ac=2;
fc=10000;
fm=1000;
Dp=5;
m_t= cos ( 2*pi* fm*t);
s_t= Ac* cos( 2*pi*fc*t + ( Dp*m_t));
subplot(211); plot(m_t);
subplot(212); plot(s_t);
RESULTS:

0.5

-0.5

-1
0 500 1000 1500 2000 2500 3000 3500 4000

-1

-2
0 500 1000 1500 2000 2500 3000 3500 4000

Example 6.2 :
To simulate phase modulation and demodulation using MATLAB’s
inbuilt command .

t = 0 : 1/1e5 : 0.1; % Time points for sampling


Fs= 1e5;
Fc = 210; % Carrier frequency in modulation
phasedev = pi; % Phase deviation for phase modulation
x = cos(2*pi*25*t);
subplot(311); plot(x);
y = pmmod(x,Fc,Fs,phasedev); % Modulate.
subplot(312); plot(y);

z= pmdemod(y,Fc,Fs,phasedev);
subplot(313); plot(z);

RESULTS:

0 .5

-0 .5

-1
0 2000 4000 6000 8000 10000 12000

0 .5

-0 .5

-1
0 2000 4000 6000 8000 10000 12000

0 .5

-0 .5

-1
0 2000 4000 6000 8000 10000 12000
EXERCISE

Q1. What happen when you change phase sensitivity Dp (take values 2,5,10)?

Q2. Again for a baseband message signal

and an unmodulated carrier


,
use MATLAB to sketch the PM modulated signal in time domain in
the interval [0, 0.1] seconds. Use the MATLAB function pmmod()
with phase deviation of
(a) kp = π /2, (b) kp = π /4.

Q3. Repeat the above problem for a square wave signal (using the
MATLAB
function m_t = 4*(pulstran(t,d,'rectpuls',0.05)-2)).

You might also like