Lab3 6
Lab3 6
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.
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
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.
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.
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:
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
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
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;
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.
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:
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:
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
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.
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 )
s( t ) = Ac cos ( 2πf c t + θ ( 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.
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:
(If a 10-volt signal causes a phase shift of 20 degrees, then a 20-volt signal causes a phase
shift of 40 degrees.)
(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 .
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)?
Q3. Repeat the above problem for a square wave signal (using the
MATLAB
function m_t = 4*(pulstran(t,d,'rectpuls',0.05)-2)).