0% found this document useful (0 votes)
127 views8 pages

ME End Sem Programs

The document describes three experiments on digital communication techniques: 1) Programs to encode and decode using single parity code and Hamming code are demonstrated. 2) Linear and MLSE equalizers are implemented in MATLAB to equalize a received signal passed through a channel. BER is computed and compared with and without equalization. 3) BER performance of linear equalizer and MLSE equalizer are plotted and compared against theoretical BER curve for different SNR values.

Uploaded by

Thirumal Valavan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views8 pages

ME End Sem Programs

The document describes three experiments on digital communication techniques: 1) Programs to encode and decode using single parity code and Hamming code are demonstrated. 2) Linear and MLSE equalizers are implemented in MATLAB to equalize a received signal passed through a channel. BER is computed and compared with and without equalization. 3) BER performance of linear equalizer and MLSE equalizer are plotted and compared against theoretical BER curve for different SNR values.

Uploaded by

Thirumal Valavan
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Expt. No.

1 Date:

Single parity: Encoding and Decoding


Aim:
To write a MATLAB program to en code and decode single parity codes.

Apparatus required:
MATLAB 7 Software, Computer, Printer , Word processing software.

Basic Theory:

Program
Program 1: Generation of parity
%this program will generate single parity bit clc; clear all; %Data to be encoded in even parity x=[1 0 1 0 1 1 0 1 1]; disp('data to be encoded is') x y=length(x); z=zeros(1,y+1); %the following will be again data but with last bit as zero z(1:y)=x; a=sum(x); if rem(a,2)==1 z(y+1)=1; else z(y+1)=0; end disp('encoded data is') z Program 2: Checking of parity %this program will check parity clc; clear all; x=[1 0 1 0 1 1 0 1 1]; y=sum(x); if rem(y,2)==1 disp('odd') else disp('even') end

Observation:
Program 1 data to be encoded is x= 1 0 1 0 1 1 0 1 1

encoded data is z= 1 0 1 0 1 1 0 1 1 0

Program 2: even

Result:
A program to encode and decode using single parity code is demonstrated

Expt. No. 2 Date:

Hamming code: Encoding and Decoding


Aim:
To write a MATLAB program to en code and decode Hamming codes given the parity Matrix.

Apparatus required:
MATLAB 7 Software, Computer, Printer , Word processing software.

Basic Theory:
Data = [1 0 1 1] Code = Data * G = [1 0 0 1 0 1 1]

Decode = code * HT = [ 0 0 0] if no error in transmission

Program

% Encoding clc; % Parity matrix given p=[1 1 0;0 1 1;1 1 1;1 0 1] % I matrix constructed i=[1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1] % G matrix constructed g=[p i] % Data to be encoded x=[1 1 0 1] % Multiplication with generation matrix for j=1:7 y=x*g(:,j); z=sum(y); s=rem(z,2); if s==1 d(j)=0; else d(j)=1; end end disp('the encoded message is') d %decoding i1=eye(3,3) p1=p' h=[i1 p1] % H transpose h1 = h' % Multiplication for j1=1:3 y1=d*h1(:,j1); z1=sum(y1); s1=rem(z1,2); if s1==1 d1(j1)=1; else d1(j1)=0; end end disp('the decoded message is') d1

Observation:
p= 1 0 1 1 i= 1 1 1 0 0 1 1 1

1 0 0 0 g= 1 0 1 1 x= 1

0 1 0 0

0 0 1 0

0 0 0 1

1 1 1 0 1

0 1 1 1 0

1 0 0 0 1

0 1 0 0

0 0 1 0

0 0 0 1

The encoded message is d= 1 1 1 0 0 i1 = 1 0 0 1 1 0 1 0 0 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 1 1 1 1 1 0 1 0 1 0 1 1

p1 =

h=

1 1 1

1 0 1

h1 =

1 0 0 0 1 0 0 0 1 1 1 0 0 1 1 1 1 1 1 0 1 The decoded message is d1 = 0 0 0

Result:
A program to encode and decode using Hamming code is demonstrated

Expt. No. 3 Date:

Equalization
Aim:
To write a MATLAB program to demonstrate Linear and MLSE equalizers

Apparatus required:
MATLAB 7 Software, Computer, Printer , Word processing software.
%This program is written by SPK.Babu for the M.E. Students. %This program demonstrates the equalization by Linear adaptive equalizer %using LMS algorithm and MLSE equalizer. The BER of the above is compared %with AWGN channel. The modulation used is BPSK %Since AWGN is used don't go for without equalization!!!! %DFE with RLS algorithm is yet to be developed in this program. clc; clear all; close all; % Set up parameters and signals. M = 2; % Alphabet size for modulation d = 1; d1 =1; for snr = 5:1:15 msg = randint(100000,1,M); % Random message modmsg = pskmod(msg,M); % Modulate using QPSK. trainlen = 500; % Length of training sequence chan = [.986; .845; .237; .123+.31i]; % Channel coefficients filtmsg1 = filter(chan,1,modmsg); % Introduce channel distortion. filtmsg = awgn(filtmsg1, snr, 'measured'); % Equalize the received signal. eq1 = lineareq(8, lms(0.01)); % Create an equalizer object. [symbolest,yd] = equalize(eq1,filtmsg,modmsg(1:trainlen)); % Equalize. % Compute error rates with and without equalization. demodmsg = pskdemod(yd,M); % Demodulate detected signal from equalizer. [neq,req(d)] = biterr(demodmsg(trainlen+1:end),msg(trainlen+1:end)); d d = d+1; end berlinear = req; const = pskmod([0:M-1],M) for SNR = 5:1:15 %Generation of data bits x = randint(1000000,1,M); msg = pskmod(x,M); % Modulated message chcoeffs = [.986; .845; .237; .12345+.31i]; % Channel coefficients filtmsg1 = filter(chcoeffs,1,msg); % Introduce channel distortion. filtmsg = awgn(filtmsg1,SNR, 'measured'); % Introduce Noise tblen = 10; % Traceback depth for equalizer chanest = chcoeffs; % Assume the channel is known exactly (No channel estimation performed).

msgEq = mlseeq(filtmsg,chanest,const,tblen,'rst'); % Equalize. msgeq1 = pskdemod(msgEq, M); % Demodulation into bits [a b(d1)]= biterr(x,msgeq1); % Calculate BER for each SNR d1 d1 = d1+1; end bermlse = b; %---------Plotting the BER values---------semilogy(5:1:15, berlinear, 'r-o') hold on semilogy(5:1:15, bermlse, 'g-*') bertheory = berawgn(5:1:15, 'psk', M, 'nondiff'); semilogy(5:1:15, bertheory, 'b-^') axis([5 15 1E-6 1]); grid on; xlabel('SNR in dB'); ylabel('BER'); legend('BER of Linear Equalizer', ' BER of MLSE Equalizer', 'BER of theoritical BER under AWGN')

10

10

-1

10

-2

BER

10

-3

10

-4

BER of Linear Equalizer BER of MLSE Equalizer BER of theoritical BER under AWGN

10

-5

10

-6

10
SNR in dB

11

12

13

14

15

Mini project titles 1. Simulate the Channel Model B: IEEE P802.11n Wireless LANs, "TGn Channel Models", IEEE 802.11-03/940r4, 2004-05-10. 2. Simulation of Eye Diagram 3. SC-FDMA physical layer SISO 4. Simulink: FSK VS MSK Vs GMSK BER 5. Simulink: BPSK Vs QPSK BER 6. Simulate the following channel

7. Demonstrate any one of the error correcting coding performance on BER of QPSK with AWGN and Rayleigh channel. 8. Write a simple program to demonstrate precoding used along with equalizers to attain good BER

You might also like