digicomlab4_210401005
digicomlab4_210401005
COMMUNICATION
LAB 2
Section : EE-20B
NAME ROLL NO
ASK Demodulation
1. Start FOR Loop
2. Compute energy of each symbol as a test statistic z (T ).
3. Make a decision by comparing with a threshold. Set the threshold in the middle of the test
statistics of the two symbols.
4. Plot the conditional probability density functions for both symbols at a low SNR value where
they have some overlap.
5. Compare the received binary message with the original message and compute probability of bit
error (PB)
6. Plot the SNR vs PB curve for several values of SNR, from 10dB to -15dB with a step of 5dB (-
15 : 5 : 10). The SNR should be varied by varying the signal amplitude. The figure below is a
representation of this plot.
CODE:
% Initialize Variables
N = 1000;
Eb = 1;
Tb = 1;
fc = 5;
fs = 1000;
SNR_dB = -35:1:30;
% BPSK Modulation
T = Tb/fs;
bit_time = 0:T:Tb-T;
carrier = sqrt(2*Eb/Tb) * cos(2*pi*fc*bit_time);
modulated_signal = [];
for i = 1:N
if bits(i) == 0
modulated_signal = [modulated_signal, -carrier];
else
modulated_signal = [modulated_signal, carrier];
end
end
time = 0:T:(N*Tb)-T;
figure;
subplot(3,1,1);
stairs(0:N-1,bits,'LineWidth',2);
title('Binary Message');
xlabel('Bit Index');
ylabel('Amplitude');
subplot(3,1,2);
plot(carrier,'LineWidth',2)
title('Carrier Signal');
xlabel('Time');
ylabel('Amplitude');
subplot(3,1,3);
plot(modulated_signal,'LineWidth',1);
title('BPSK Modulated Signal');
xlabel('Time');
ylabel('Amplitude');
% Add AWGN
snr = 20; % Moderate SNR value
y_noisy = awgn(modulated_signal, snr, 'measured');
% BPSK Demodulation
received_bits = zeros(1, N);
index = 1;
for i = 1:N
test_stat = sum(y_noisy(index:index+fs-1) .* carrier);
if test_stat > 0
received_bits(i) = 1;
else
received_bits(i) = 0;
end
index = index + fs;
end
end
Task 1:
Task 2:
Task 3:
CONCLUSION:
BPSK is a simple and robust digital modulation technique that uses two phase shifts (0° and
180°) for data transmission. It offers strong resistance to noise, making it ideal for reliable
communication in low-SNR environments. While less spectrally efficient than higher-order
schemes, BPSK is power-efficient and widely used in satellite and wireless systems. Its
simplicity and reliability make it a foundational choice in digital communications.