Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

Department of Computer Science and Information Technology

WIRELESS AND MOBILE COMMUNICATION: CSIWZG520


Laboratory Work Sheet -III

Submitted By:
BITS ID:
Lab Exercise:

Design a Model for Amplitude Modulation and Demodulation


We need to use MATLAB Simulink tool to design Amplitude Modulation and Demodulation:
Login to LAB: https://cloudlabs.nuvepro.com/sso/saml/BITS-CSIS-VirtualLab/login/request
Open MATLAB software

Install Curve Fitting Toolbox from Add-On (Home-> Environment -> Add-On) – It will restart Matlab
application
Go to Home tab and click on Simulink:

Click on Blank Model


After clicking Blank model, it will open untitled new model to create where we have to simulate AM
modulation and Demodulation:

For AM modulation, we need Sin wave functions. Go to Library Browser, Expand first Library module
Simulink -> Sources -> and click on Sin Wave as shown below. Add two sin wave (One for message signal and
one for Carrier signal)
Add two Sin waves from the Simulink->Sources and rename as Message and Carrier Signal as shown below:
We can copy the same sign wave by press ctrl and drag that module (or simply ctrl+c and ctrl+v)
We can increase the font from Format tab, also increase the size of the blocks by dragging them from corner.
Now, sometimes Message signal may flicker, to resolve that, we will add Constant module from Simulink
->Sources and select Constant as shown below, double click or drag under message signal:

Now for combining Message signal and Constant, we need to add adder block under Simulink-> Math
operations as shown below:

Now joint the connections as shown below, click on the small arrow sign to create the node connections:
Now for preview the Message signal and Carrier signal, we need towo scope for output. Now we will add the
Scope which can be found under Simulink->Sinks->Scope as shown below. Then we will connect the scope:

Also, we will add Product block to modulate the Message and Carrier signal. Product block and modulate the
Output from Add(Message Signal and Constant) and Carrier Signal.
We can add Product block from Simulink->Math Operations-> Product as shown below:
Now we need Scope to preview the output from Product block, we can copy the same scope (use ctrl+drag or
simply copy paste)

Now Modulation has been done,


For Demodulation, we will add one Product block.
Connect one node from output of Modulation Product and another with Carrier Signal:

Now we will add two Transfer fcn from Continuos block and connect the output to one more
Scope(Demodulation). Scope can be copied or inserted under Sinks block of Simulink.
two Transfer fcn block from Simulink->Continuous->Transfer fucntion block as shown:

Now the complete design is ready. We need to input the signal frequency and observe.
Double click on Message signal and input the value as 5 (Hz) and click OK as shown below:
Double click on Carrier signal and input the value as 50 (Hz) and click OK as shown below:
Now double click on Transfer fcn1 and change the value of numerator coefficient to [15] and denominator
coefficient to [1 15], do the same values for Transfer fcn2

Now go to Simulation tab and click Run, it will take some time and progress bar will be shown 100% , then we
can check by clicking each Scope to see the output.
Double click on Scope (Message Signal) and Scope (Carrier signal), it will show the freq output waves:

Now double click on Scope (Modulated Signal)


Double click

on Demodulated Signal Scope

We can observe Message signal and Demodulated signal is exactly same.

Now we can save this module/project and close the Simulink window.

In- Lab task: Formulate and explain about the following topics
a) Plot the traces of envelope of AM signal for following conditions.

ka=0.4, Am=1 b) ka=0.4, Am=2 c) ka=0.4, Am=3

We will open New live editor and type below code on MATLAB:

%code
% Parameters
ka = 0.4;
fc = 100; % Carrier frequency in Hz
fm = 10; % Message frequency in Hz
t = 0:0.001:1; % Time vector

% Different Am values
Am_values = [1, 2, 3];

figure;
for i = 1:length(Am_values)
Am = Am_values(i);
m_t = Am * cos(2 * pi * fm * t); % Message signal
s_t = (1 + ka * m_t) .* cos(2 * pi * fc * t); % AM signal
envelope = abs(hilbert(s_t)); % Envelope of AM signal
subplot(3,1,i);
plot(t, s_t, 'b', t, envelope, 'r', 'LineWidth', 1.5);
title(['AM Signal and Envelope for A_m = ', num2str(Am)]);
xlabel('Time (s)');
ylabel('Amplitude');
legend('AM Signal', 'Envelope');
grid on;
end

After running section from Live Editor tab, we can see the modulation graph.

b) Draw the PSD of AM signal.

Now type %% and hit enter to create new section and type below code:

% Compute and plot PSD of AM signal for Am = 1


Am = 1;
m_t = Am * cos(2 * pi * fm * t); % Message signal
s_t = (1 + ka * m_t) .* cos(2 * pi * fc * t); % AM signal

figure;
[pxx, f] = periodogram(s_t, [], [], 1/(t(2)-t(1)));
plot(f, 10*log10(pxx));
title('Power Spectral Density of AM Signal');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
grid on;
We can see the output of Spectral Desnsity.

c) Draw the PSD of DSB-SC, SSB Signals.

We will type below code after creating new section and run:

% DSB-SC signal
s_t_dsb_sc = m_t .* cos(2 * pi * fc * t);

figure;
[pxx_dsb_sc, f] = periodogram(s_t_dsb_sc, [], [], 1/(t(2)-t(1)));
plot(f, 10*log10(pxx_dsb_sc));
title('Power Spectral Density of DSB-SC Signal');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
grid on;

% SSB signal (Using the upper sideband)


ssb_upper = s_t_dsb_sc - imag(hilbert(m_t)) .* sin(2 * pi * fc * t);

figure;
[pxx_ssb, f] = periodogram(ssb_upper, [], [], 1/(t(2)-t(1)));
plot(f, 10*log10(pxx_ssb));
title('Power Spectral Density of SSB Signal');
xlabel('Frequency (Hz)');
ylabel('Power/Frequency (dB/Hz)');
grid on;
d) Plot the traces of envelope of AM signal for following conditions.
 Plot the demodulated output signal for Φ=0o
Type below code after creating new section:

% Demodulation with phase Φ=0°


phi = 0;
local_oscillator = cos(2 * pi * fc * t + phi);
demodulated_signal = s_t .* local_oscillator;
[b, a] = butter(5, 2*fm/(1/(t(2)-t(1))), 'low'); % Low-pass filter
demodulated_output = filter(b, a, demodulated_signal);

figure;
plot(t, demodulated_output, 'b');
title('Demodulated Output Signal for \Phi=0°');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
e) Calculate the power of demodulated signal for Φ=0o,30o,90 o

We will type below code after creating new section:

% Function to calculate power of demodulated signal


function power = calculate_power(phi, s_t, fc, t, fm)
local_oscillator = cos(2 * pi * fc * t + phi);
demodulated_signal = s_t .* local_oscillator;
[b, a] = butter(5, 2*fm/(1/(t(2)-t(1))), 'low'); % Low-pass filter
demodulated_output = filter(b, a, demodulated_signal);
power = sum(demodulated_output.^2) / length(demodulated_output);
end

phi_values = [0, pi/6, pi/2]; % 0°, 30°, 90° in radians


power_values = zeros(size(phi_values));

for i = 1:length(phi_values)
power_values(i) = calculate_power(phi_values(i), s_t, fc, t, fm);
end

disp('Power of demodulated signal for Φ=0°, 30°, 90°:');


disp(power_values);
f) Repeat (d), (e) for DSB-SC and SSB.
We will type below code after creating new section:

% Demodulated DSB-SC for phi=0°


phi = 0;
local_oscillator_dsb_sc = cos(2 * pi * fc * t + phi);
demodulated_signal_dsb_sc = s_t_dsb_sc .* local_oscillator_dsb_sc;
demodulated_output_dsb_sc = filter(b, a, demodulated_signal_dsb_sc);

figure;
plot(t, demodulated_output_dsb_sc, 'b');
title('Demodulated DSB-SC Output Signal for \Phi=0°');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

% Power calculation for DSB-SC


for i = 1:length(phi_values)
power_values_dsb_sc(i) = calculate_power(phi_values(i), s_t_dsb_sc, fc, t, fm);
end

disp('Power of demodulated DSB-SC signal for Φ=0°, 30°, 90°:');


disp(power_values_dsb_sc);
% Demodulated SSB for phi=0°
phi = 0;
local_oscillator_ssb = cos(2 * pi * fc * t + phi);
demodulated_signal_ssb = ssb_upper .* local_oscillator_ssb;
demodulated_output_ssb = filter(b, a, demodulated_signal_ssb);

figure;
plot(t, demodulated_output_ssb, 'b');
title('Demodulated SSB Output Signal for \Phi=0°');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

% Power calculation for SSB


for i = 1:length(phi_values)
power_values_ssb(i) = calculate_power(phi_values(i), ssb_upper, fc, t, fm);
end

disp('Power of demodulated SSB signal for Φ=0°, 30°, 90°:');


disp(power_values_ssb);
Thank You !!

You might also like