Professional Documents
Culture Documents
Lab 3 Output- Wireless Communication
Lab 3 Output- Wireless Communication
Submitted By:
BITS ID:
Lab Exercise:
Install Curve Fitting Toolbox from Add-On (Home-> Environment -> Add-On) – It will restart Matlab
application
Go to Home tab and click on Simulink:
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 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 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.
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.
Now type %% and hit enter to create new section and type below code:
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.
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;
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:
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
for i = 1:length(phi_values)
power_values(i) = calculate_power(phi_values(i), s_t, fc, t, fm);
end
figure;
plot(t, demodulated_output_dsb_sc, 'b');
title('Demodulated DSB-SC Output Signal for \Phi=0°');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;
figure;
plot(t, demodulated_output_ssb, 'b');
title('Demodulated SSB Output Signal for \Phi=0°');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;