0% found this document useful (0 votes)
13 views5 pages

Ac Exp-4

The document describes a simulation of a 16-QAM transmitter and receiver. It involves serial to parallel conversion, modulation, AWGN noise addition, demodulation, filtering, thresholding and constellation diagram plotting. Code is provided to simulate the transmission and reception of 16-QAM signals over an AWGN channel and plot the signal, constellation diagram and average probability of symbol error versus SNR.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

Ac Exp-4

The document describes a simulation of a 16-QAM transmitter and receiver. It involves serial to parallel conversion, modulation, AWGN noise addition, demodulation, filtering, thresholding and constellation diagram plotting. Code is provided to simulate the transmission and reception of 16-QAM signals over an AWGN channel and plot the signal, constellation diagram and average probability of symbol error versus SNR.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Ashish Kumar(20EEAEC003)

Experiment: 4
Simulate the transmitter and receiver for 16-QAM. Plot
the signal and signal constellation diagram. Plot the
average probability of symbol error as a function of SNR
Eb/No, where Eb is the transmitted energy per bit and
No/2 is the double sided power spectral density of
additive white Gaussian noise (AWGN) with zero mean.
SOFTWARE- ONLINE MATLAB SIMULATION.

CODE
clc;
clear;
close all;
%%%% Serial To Parallel and 2-to-4 Level Converter %%%%
o1=[]; o2=[]; for i=1:4:64
sp = dec2bin(i:i+3, 4) - '0'; % Serial to Parallel 4-bit Register
I = sp(1);
Id = sp(2);
Q = sp(3);
Qd = sp(4);

% Assigning Amplitude levels for I-channel


if I == 0
o1 = [o1 -3]; % if input is 00, output is -3
else
o1 = [o1 1]; % if input is 10, output is 1
end

% Assigning Amplitude levels for Q-channel


if Q == 0
o2 = [o2 -3]; % if input is 00, output is -3
else
o2 = [o2 1]; % if input is 10, output is 1
end end

%%%% Oscillator and Balanced Modulator %%%% fc = 500; % Carrier


Frequency fs = 20000; % Sampling Frequency t = 1:100; % Duration of
Signal s = []; for i = 1:1:16 % Modulation (multiplication with
carrier signals cos and
sin)
Ac = o1(i); As = o2(i); s1 =
Ac * cos(2 * pi * (fc / fs) * t);
s2 = As * sin(2 * pi * (fc / fs) * t);
s = [s (s1 + s2)]; end
figure(1)
plot(s) % 's' denotes the transmitted signal
title('16QAM Modulated Signal', 'FontSize', 14) xlim([0
1610]);
%%%% AWGN Addition While Passing Through The Channel %%%%
SNR_dB = 10; % Set the desired signal-to-noise ratio (SNR) in dB SNR_linear
= 10^(SNR_dB / 10); % Convert SNR from dB to linear scale noise_power =
var(s) / SNR_linear; % Calculate the noise power based on SNR noise =
Ashish Kumar(20EEAEC003)

sqrt(noise_power) * randn(size(s)); % Generate Gaussian noise r = s +


noise; % Add noise to the signal
figure(2) % Received Signal SNR is 10 dB
plot(r) % received signal is denoted by 'r'
title('Transmitted Signal With Additive Noise After Passing Through The
Channel', 'FontSize', 14);

%%%% COHERENT DEMODULATION %%%%


ss1 = []; ss2 = [];
rs1 = 2 * cos(2 * pi * (fc / fs) * t); % Sin and Cos generation by
Local Oscillator rs2 = 2 * sin(2 * pi * (fc / fs) * t); for i =
1:100:1600 % Demodulation of Received Signal ss1 = [ss1 rs1 .* r(1,
i:i+99)]; % for Ichannel ss2 = [ss2 rs2 .* r(1, i:i+99)]; % for
Q-channel end

%%%% Low-Pass Filtering %%%%


wn = 2 * (fc / fs); % Cut-off Frequency is 500 Hz
[b1, a1] = butter(1, wn, 'low'); % Butterworth filter of Order 1
[b2, a2] = butter(1, wn, 'low'); fo1 =
filter(b1, a1, ss1); % Filtering fo2 =
filter(b2, a2, ss2);
figure(3);
plot(fo1, 'linewidth', 1.5)
title('I-Channel After Passing Through Low Pass Butterworth Filter of Order
2', 'FontSize', 14);
figure(4);
plot(fo2, 'linewidth', 1.5)
title('Q-Channel After Passing Through Low Pass Butterworth Filter of Order
2', 'FontSize', 14);

%%%% Thresholding and Phase Detection %%%%


ro1 = []; ro2 = [];
for i = 1:100:1600 % Calculating Average values over an interval of 100
bits
for I-channel ff1 = fo1(1, i:i+99); l1 = length(ff1); sum1
= sum(ff1); av1 = sum1 / l1; ro1 = [ro1 av1]; end
for i = 1:100:1600 % Calculating Average values over an interval of 100
bits
for Q-channel ff2 = fo2(1, i:i+99); l2 = length(ff2); sum2
= sum(ff2); av2 = sum2 / l2; ro2 = [ro2 av2]; end

%%%% Amplitude Detection and Generation of Demodulated Data %%%%


oo1 = round(ro1); oo2 = round(ro2); op = [];

% Re-assigning bits with respect to amplitude levels


for i = 1:16 % Demodulation by Amplitude Detection
if oo1(i) == -3
op = [op 0 0]; % if amplitude of I-channel is -3, output is 00
else
op = [op 1 0]; % if amplitude of I-channel is 1, output is 10
end
if oo2(i) == -3
op = [op 0 0]; % if amplitude of Q-channel is -3, output is 00
else
op = [op 1 0]; % if amplitude of Q-channel is 1, output is 10
end end figure(5); subplot(2, 1, 1); plot(s, 'linewidth', 2)
Ashish Kumar(20EEAEC003)

title('Input Data Stream', 'FontSize', 14);


xlim([0 1610]); ylim([-4 4]);
subplot(2, 1, 2);
plot(op, 'linewidth', 2)
title('Demodulated Output Data (Same As Input)', 'FontSize', 14);
ylim([-4 4]); xlim([0 65]);

%%%% Generation of Constellation Diagram for Transmitted Data and


Received Data%%%% xo1 = o1; yo2 = o2; xoo1 = ro1; yoo2 = ro2;
figure(6);
plot(xo1, yo2, 'hk', 'linewidth', 4); % plot of original symbols hold
on;
plot(xoo1, yoo2, 'Or', 'linewidth', 4); % plot of received symbols
legend('Transmitted Data', 'Received Data');
x = line([-5 5], [-2 -2], 'linewidth', 4); % Horizontal Lines
on Constellation Diagram text(-1.9, 3.7, 'x=-2', 'FontSize', 14);
x1 = line([-5 5], [0 0], 'linewidth', 4); text(0.1, 3.7, 'x=0',
'FontSize', 14); x2 = line([-5 5], [2 2], 'linewidth', 4);
text(2.1, 3.7, 'x=2', 'FontSize', 14);
y = line([-2 -2], [-15 15], 'linewidth', 4); % Vertical Lines
on Constellation Diagram text(-3.9, -1.8, 'y=-2', 'FontSize', 14);
y1 = line([0 0], [-15 15], 'linewidth', 4); text(-3.9, 0.2, 'y=0',
'FontSize', 14); y2 = line([2 2], [-15 15], 'linewidth', 4); text(-
3.9, 2.2, 'y=2', 'FontSize', 14);
title('Constellation Diagram for Transmitted and Received Data',
'FontSize',
14); xlim([-4
4]); ylim([-4
4]); Output:
Ashish Kumar(20EEAEC003)
Ashish Kumar(20EEAEC003)

Result: Simulate the transmitter and receiver for 16-QAM. Plot the signal
and signal constellation diagram. Plot the average probability of symbol
error as a function of SNR Eb/No, where Eb is the transmitted energy per bit
and No/2 is the double sided power spectral density of additive white
Gaussian noise (AWGN) with zero mean.

You might also like