Exp - 9
Exp - 9
Exp - 9
No:
Date: SIMULATION OF ASK,FSK AND BPSK DETECTION
SCHEMES USING MATLAB
AIM:
To simulate of ASK,FSK and BPSK detection schemes using MATLAB.
APPARATUS REQUIRED:
MATLAB software
THEORY:
ASK
This signal has a well defined envelope. Thus it is amenable to demodulation by an envelope detector.
Some sort of decision-making circuitry is necessary for detecting the message. The signal is recovered by
using a correlator and decision making circuitry is used to recover the binary sequence.
FSK
It is the digital modulation technique in which the frequency of the carrier signal varies according to the
digital signal changes. FSK is a scheme of frequency modulation. The binary 1s and 0s are called Mark
and Space frequencies.
BPSK
It is a widely used modulation technique in digital communication systems for transmitting binary data
over a communication channel. It is known for its simplicity and effectiveness, making it a popular
choice in applications where the communication channel is susceptible to noise and interference.
ASK CODE:
fc = 10; % Carrier frequency
fs = 1000; % Sampling frequency
T = 1; % Total time duration
t = 0:1/fs:T; % Time vector
A = 1; % Amplitude of carrier signal
SNR = 10^(SNR_dB/10);
noise_power = 0.5/(SNR); % Noise power
noise = sqrt(noise_power)*randn(size(t));
OUTPUT:
% Received Signal
received_signal = modulated_signal + noise;
% Envelope Detection
envelope = abs(hilbert(received_signal));
% Thresholding to Demodulate
threshold = 0.5*A; % Example threshold
detected_data = envelope > threshold;
subplot(3,1,1);
plot(t,modulated_signal);
title('Modulated Signal');
xlabel('Time');
ylabel('Amplitude');
subplot(3,1,2);
plot(t,received_signal);
title('Received Signal with Noise');
xlabel('Time');
ylabel('Amplitude');
subplot(3,1,3);
plot(t,envelope);
hold on;
plot(t,threshold*ones(size(t)),'r--');
title('Envelope Detection');
xlabel('Time');
ylabel('Amplitude'
legend('Envelope','Threshold');
error_rate = sum(xor(data, detected_data)) /
length(data);
disp(['Bit Error Rate: ', num2str(error_rate)]);
FSK CODE
% Parameters
fc = 10; % Carrier frequency
OUTPUT:
fs = 1000; % Sampling frequency
T = 1; % Total time duration
t = 0:1/fs:T-1/fs; % Time vector
A = 1; % Amplitude of carrier signal
data = randi([0 1], 1, length(t));
% FSK Modulation
f1 = 5; % Frequency for '0'
f2 = 15; % Frequency for '1'
modulated_signal = A * cos(2*pi*f1*t + 2*pi*(f2-
f1)*cumsum(data)/fs);
% Additive White Gaussian Noise (AWGN)
SNR_dB = 10; % Signal to Noise Ratio in dB
SNR = 10^(SNR_dB/10);
noise_power = 0.5/(SNR); % Noise power
noise = sqrt(noise_power)*randn(size(t)); %
Gaussian noise
% Received Signal
received_signal = modulated_signal + noise;
% Coherent Detection
f_carrier = f1;
carrier = A * cos(2 * pi * f_carrier * t);
demod_signal = received_signal .* carrier;
[b,a] = butter(6, 2 * f_carrier / fs);
demod_signal_filtered = filter(b, a,demod_signal);
threshold = A / 2; % Decision threshold
received_data = demod_signal_filtered >threshold;
subplot(4,1,1);
plot(t, modulated_signal);
title('Modulated Signal');
xlabel('Time');
ylabel('Amplitude');
OUTPUT:
subplot(4,1,2);
plot(t, received_signal);
title('Received Signal with Noise');
xlabel('Time');
ylabel('Amplitude');
subplot(4,1,3);
plot(t, carrier);
title('Local Carrier Signal');
xlabel('Time');
ylabel('Amplitude');
subplot(4,1,4);
plot(t, received_data, 'o');
title('Demodulated Data');
xlabel('Time');
ylabel('Bit Value (0 or 1)');
ylim([-0.2 1.2]);
error_rate = sum(xor(data, received_data)) /
length(data);
disp(['Bit Error Rate: ', num2str(error_rate)]);
BPSK CODE
fc = 10; fs = 1000;
T = 1; t = 0:1/fs:T-1/fs; A = 1;
data = randi([0 1], 1, length(t)); % Random binary data
bpsk_signal = A * cos(2*pi*fc*t + pi*data);
SNR_dB = 10; SNR = 10^(SNR_dB/10); noise_power = 0.5/(SNR);
noise = sqrt(noise_power)*randn(size(t));
% Received Signal
received_signal = bpsk_signal + noise;
received_data = received_signal .* (A * cos(2*pi*fc*t)) > 0;
subplot(4,1,1:2); plot(t, [bpsk_signal; received_signal]);
title('Modulated Signal and Received Signal with Noise');
xlabel('Time'); ylabel('Amplitude'); legend('Modulated Signal', 'Received Signal with Noise');
subplot(4,1,3); plot(t, A * cos(2*pi*fc*t));
title('Local Carrier Signal'); xlabel('Time'); ylabel('Amplitude');
subplot(4,1,4); plot(t, received_data, 'o');
title('Demodulated Data'); xlabel('Time'); ylabel('Bit Value (0 or 1)'); ylim([-0.2 1.2]);
error_rate = sum(xor(data, received_data)) / length(data);
disp(['Bit Error Rate: ', num2str(error_rate)]);
AIM &
PROCEDURE
CODING VIVA
RESULT:
Thus the ASK,FSK and BPSK detection schemes was generated using MATLAB.