Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Experiment No: .
Date: . /. /
MATLAB EXPERIMENTS
PRE-LAB :
Experiment No: .
Date: . /. /
Aim: To analyze BER(Bit Error Rate) performance of BPSK modulation Technique using
MATLAB software.
Equipments Required:
Theory:
With Binary Phase Shift Keying (BPSK), the binary digits 1 and 0 maybe represented by the
analog levels and respectively. The system model is as shown in the Figure
below.
Channel Model
The transmitted waveform gets corrupted by noise , typically referred to as Additive
Additive : As the noise gets added (and not multiplied) to the received signal
Gaussian : The values of the noise follows the Gaussian probability distribution
With this threshold, the probability of error given S1 is transmitted is (the area in blue
region):
,
where,
EXPERIMENT PROCEDURE:
PREPARATION (PRE-LAB)
1) An analog signal carries four bits in each signal element. If 1000 signal elements are sent per
second , find the baud rate and bit rate.
2) What is a correlator?
STEPS TO FOLLOW:
(c) Demodulation of the received symbol based on the location in the constellation
(e) Repeating the same for multiple Eb/No value VS BER(Bit Error Rate)
TEST PROCEDURE :
2. MATLAB logo will appear and after few moments Command Prompt will appear.
3. Go to the File Menu and select a New M- file. (File NewM-file) or in the left hand corner a blank
white paper icon will be there. Click it once.
5. Now start typing your program. After completing, save the M- file with appropriate name. To
execute the program Press F5 or go to Debug Menu and select Run.
6. After execution output will appear in the Command window .If there is an error then with an
alarm, type of error will appear in red color.
7. Rectify the error if any and go to Debug Menu and select Run.
PROGRAM:
clc;
clear all;
close all;
num_bit=1000000;%number of bit
SNRdB=0:9; // % SNR in dB
SNR=10.^(SNRdB/10);
y=s+awgn(s,SNRdB(k));
error=0;
for(c=1:1:num_bit)
error=error+1;
end
end
m(k)=error;
end
figure(1)
%plot start
BER_th=(1/2)*erfc(sqrt(SNR));
semilogy(SNRdB,BER_th,'k','linewidth',2);
title(' curve for Bit Error Rate verses SNR for Binary PSK modulation');
xlabel(' SNR(dB)');
ylabel('BER');
legend('simulation','theorytical')
OUTPUT :
Conclusion:
Questions:
1. Write matlab program to encode the data sequence using a) RZ b) NRZ c) Manchester d)
Differential encoding.
2.Why do we make 180 degree phase shift in PSK and why not 90 or 270?comment on this.
Experiment No: .
Date: . /. /
Aim: To write a program to calculate the Bit Error Rate (BER) of QPSK in an Additive
White Gaussian Noise (AWGN) channel.
Equipments Required:
Theory:
QPSK uses four points on the constellation diagram, equispaced around a circle. With four
phases, QPSK can encode two bits per symbol, shown in the diagram with Gray coding to
minimize the bit error rate (BER) sometimes misperceived as twice the BER of BPSK.
The mathematical analysis shows that QPSK can be used either to double the data rate
compared with a BPSK system while maintaining the same bandwidth of the signal, or to maintain
the data-rate of BPSK but halving the bandwidth needed. In this latter case, the BER of QPSK is
exactly the same as the BER of BPSK and deciding differently is a common confusion when
considering or describing QPSK. The transmitted carrier can undergo numbers of phase changes.
Given that radio communication channels are allocated by agencies such as the Federal
Communication Commission giving a prescribed (maximum) bandwidth, the advantage of QPSK
over BPSK becomes evident: QPSK transmits twice the data rate in a given bandwidth compared
to BPSK - at the same BER. The engineering penalty that is paid is that QPSK transmitters and
receivers are more complicated than the ones for BPSK. However, with modern electronics
technology, the penalty in cost is very moderate.
As with BPSK, there are phase ambiguity problems at the receiving end, and differentially
encoded QPSK is often used in practice.
The implementation of QPSK is more general than that of BPSK and also indicates the
implementation of higher-order PSK. Writing the symbols in the constellation diagram in terms of
the sine and cosine waves used to transmit them:
This yields the four phases /4, 3/4, 5/4 and 7/4 as needed.
The first basis function is used as the in-phase component of the signal and the second as the
quadrature component of the signal.
The factors of 1/2 indicate that the total power is split equally between the two carriers.
Comparing these basis functions with that for BPSK shows clearly how QPSK can be viewed as
two independent BPSK signals. Note that the signal-space points for BPSK do not need to split
the symbol (bit) energy over the two carriers in the scheme shown in the BPSK constellation
diagram.
QPSK systems can be implemented in a number of ways. An illustration of the major components
of the transmitter and receiver structure are shown below.
As a result, the probability of bit-error for QPSK is the same as for BPSK:
However, in order to achieve the same bit-error probability as BPSK, QPSK uses twice the
power (since two bits are transmitted simultaneously).
If the signal-to-noise ratio is high (as is necessary for practical QPSK systems) the
probability of symbol error may be approximated:
The modulated signal is shown below for a short segment of a random binary data-stream.
The two carrier waves are a cosine wave and a sine wave, as indicated by the signal-space analysis
above. Here, the odd-numbered bits have been assigned to the in-phase component and the even-
numbered bits to the quadrature component (taking the first bit as number 1). The total signal
the sum of the two components is shown at the bottom. Jumps in phase can be seen as the PSK
changes the phase on each component at the start of each bit-period. The topmost waveform alone
matches the description given for BPSK above.
EXPERIMENT PROCEDURE:
PREPARATION (PRE-LAB)
STEPS TO FOLLOW:
(c) Demodulation of the received symbol based on the location in the constellation
(e) Repeating the same for multiple Eb/No value VS BER(Bit Error Rate)
TEST PROCEDURE :
2. MATLAB logo will appear and after few moments Command Prompt will appear.
3. Go to the File Menu and select a New M- file. (File NewM-file) or in the left hand corner a blank
white paper icon will be there. Click it once.
5. Now start typing your program. After completing, save the M- file with appropriate name. To
execute the program Press F5 or go to Debug Menu and select Run.
6. After execution output will appear in the Command window .If there is an error then with an
alarm, type of error will appear in red color.
7. Rectify the error if any and go to Debug Menu and select Run.
PROGRAM:
% BER QPSK
forSNRdb=1:1:itr % SNR in dB
counter=0;
SNR=10.^(SNRdb/10);
No=1/SNR;
v=(No/Eb)/(2*nPSK); % Noise Equation
for n=1:1:nSymbol
u1=rand(1); %random first bit generation
u2=rand(1); %random second bit generation
%Modulation Process
end
%Transmition Process
AWGN1=sqrt(v)*randn(1);
AWGN2=sqrt(v)*randn(1);
%Channel
realn=real+AWGN1;
imgn=img+AWGN2;
%RX
phin=mod(atan2d(imgn,realn)+360,360);
if((phin>=0&&phin<=45)||(phin>315))
uu1=0;
uu2=0;
elseif(phin>45&&phin<=135)
uu1=0;
uu2=1;
elseif(phin>135&&phin<=225)
uu1=1;
uu2=0;
elseif(phin>225&&phin<=315)
uu1=1;
uu2=1;
end
%Detection Process
semilogy(SNRdb,pe,'--bs','linewidth',1.5,'markersize',6);
axis([1 itr 10^(-4) 1]);
xlabel('SNRdb(dB)');
ylabel('BER');
gridon;
holdon;
legend('simulation','theoretical');
OUTPUT :
Conclusion:
Questions:
1. Write matlab program to encode the data sequence using a) RZ b) NRZ c) Manchester d)
Differential encoding.
2.Why do we make 180 degree phase shift in PSK and why not 90 or 270?comment on this.
Experiment No: .
Date: . /. /
Aim: To study Cyclic Encoding and Decoding and to calculate bit error rate using MATLAB.
Software Required:
Theory:
Cyclic codes are an important class of linear codes for which the encoding and decoding
can be efficiently implemented using shift registers. Many common linear codes, including
Hamming and Golay codes, have an equivalent cyclic representation. Cyclic code is a block code,
where the circular shifts of each code word gives another word that belongs to the code. They
are error-correcting codes that have algebraic properties that are convenient for efficient error
detection and correction. Let be a linear code over a finite field (also called Galois field) of block
length n. is called a cyclic code if, for every code word c=(c1,...,cn) from C, the word (cn,c1,...,cn-1)
in obtained by a cyclic right shift of components is again a code word. Because one cyclic right
shift is equal to n 1 cyclic left shifts, a cyclic code may also be defined via cyclic left shifts.
Therefore the linear code is cyclic precisely when it is invariant under all cyclic shifts. Cyclic
Codes have some additional structural constraint on the codes. They are based on Galois fields and
because of their structural properties they are very useful for error controls. Their structure is
strongly related to Galois fields because of which the encoding and decoding algorithms for cyclic
codes are computationally efficient. The Hamming(7,4) code may be written as a cyclic code over
GF(2) with generator .In fact, any binary Hamming code of the form Ham(r, 2) is equivalent to a
cyclic code, and any Hamming code of the form Ham(r,q) with r and q-1 relatively prime is also
equivalent to a cyclic code. Given a Hamming code of the form Ham(r,2) with the set of even code
words forms a cyclic code.
Operation :
The theory of a CRC calculation is straight forward. The data is treated by the CRC algorithm as
a binary number. This number is divided by another binary number called the polynomial. The rest
of the division is the CRC checksum, which is appended to the transmitted message. The receiver
divides the message (including the calculated CRC), by the same polynomial the transmitter used.
If the result of this division is zero, then the transmission was successful. However, if the result is
not equal to zero, an error occurred during the transmission
Experiment Procedure:
program:
clc;clear all;
close all;
n=7;k=4;num_bit=10000;
genpoly=cyclpoly(n,k,'max');
SNRdB=0:10;
SNR=10.^(SNRdB/10);
for i=1:length(SNR)
msg=randint(num_bit,k,[0,1]);
code=encode(msg,n,k,'cyclic/binary',genpoly);
[row column]=size(code);
codevec=reshape(code.',1,row*column);
noise=awgn(codevec,SNRdB(i));
y=codevec+noise;
error=0;
for j=1:length(y)
if (y(j)>1&&codevec(j)==0)||(y(j)<0&&codevec(j)==1)
error=error+1;
end
end
error=error/num_bit;
m(i)=error;
end
y(find(y>0))=1;
y(find(y<0))=0;
decode_y=decode(y,n,k,'cyclic/binary',genpoly);
decmsg=reshape(decode_y,num_bit,k)
semilogy(SNRdB,m,'r','linewidth',2),grid on;
title(' Bit Error Rate verses SNR for Cyclic Code');
xlabel(' SNR(dB)');
ylabel('BER');
MODEL GRAPH
-1
10
BER
-2
10
-3
10
0 1 2 3 4 5 6 7 8 9 10
SNR(dB)
Conclusion:
Questions:
1 Consider the n = 7 binary cyclic code generated by g(x) = 1 + x + x 3 Find code word
for any message sequence.
3. For designing of (4,1) cyclic repetition code, what would be the order of the
generator polynomial g(x)?
4. For the generation of a cyclic code, the generator polynomial should be the factor
of _____