Dcom Experiments

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

DCOM EXPERIMENTS

1. ASK Modulation Using MATLAB

2. FSK Modulation Using MATLAB

3. PSK Modulation Using MATLAB

4. QPSK Modulation Using MATLAB

5. QAM Modulation Using MATLAB

6. MSK Modulation Using MATLAB

7. Linear Block Code Generation Using MATLAB

8. Cyclic code Generation Using MATLAB


EXPERIMENT 1
Amplitude Shift Keying (ASK Modulation)

AIM:
To plot the wave form for Binary Amplitude Shift Keying (BASK) signal using MATLAB for a
stream of bits.

THEORY:
Amplitude Shift Keying (ASK) is the digital modulation technique. In amplitude shift keying, the
amplitude of the carrier signal is varied to create signal elements. Both frequency and phase
remain constant while the amplitude changes. In ASK, the amplitude of the carrier assumes one
of the two amplitudes dependent on the logic states of the input bit stream. This modulated
signalcan be expressed as:

Amplitude shift keying (ASK) in the context of digital signal communications is a modulation

process, which imparts to a sinusoid two or more discrete amplitude levels. These are related
to the number of levels adopted by the digital message. For a binary message sequence there
are two levels, one of which is typically zero. Thus, the modulated waveform consists of bursts
of a sinusoid. Figure 1 illustrates a binary ASK signal (lower), together with the binary sequence
which initiated it (upper). Neither signal has been band limited.
Fig: an ASK signal(below)and the message(above)

There are sharp discontinuities shown at the transition points. These result in the signal
having an unnecessarily wide bandwidth. Band limiting is generally introduced before
transmission, in which case these discontinuities would be ‘rounded off’. The band limiting
may be applied to the digital message, or the modulated signal itself. The data rate is often
made a sub-multiple of the carrier frequency. This has been done in the wave form of Fig.

Block Diagram:
MATLAB PROGRAM:
clear;
clc;
b = input('Enter the Bit stream \n '); %b = [0 1 0 1 1 1 0];
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b(i);
end
end
bw = bw(100:end);
sint = sin(2*pi*t);
st = bw.*sint;
subplot(3,1,1)
plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(3,1,2)
plot(t,sint)
grid on ; axis([0 n -2 +2])
subplot(3,1,3)
plot(t,st)
grid on ; axis([0 n -2 +2]) Q
OBSERVATION:

Output waveform for the bit stream [0 1 0 0 1 1 10]

Output:
Take different binary data at input and check the result at output waveform.

Conclusion:
We get the proper result at output waveform as per the binary input data.
EXPERIMENT 2
Frequency Shift Keying

AIM:

To plot the wave form for Frequency Shift Keyingsignal using MATLAB for a stream of bits.

SOFTWARE: MATLAB

THEORY:
Frequency Shift Keying FSK. FSK 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 output of a FSK modulated wave is high in frequency for a binaryHigh input and
is low in frequency for a binary Low input. The binary 1s and 0s are called Mark and
Space frequencies.

The FSK modulator comprises of two oscillators with a clock and the input binary
sequence. The two oscillators, producing a higher and a lower frequency signal, are
connected to a switch along with an internal clock.
BLOCK DIAGRAM:

MATLAB PROGRAM:
clear;
clc;
b = input('Enter the Bit stream \n ');

%b = [0 1 0 1 1 1 0];

n = length(b);t
= 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n

if (b(i) == 0)

b_p(i) = -1;
else
b_p(i) = 1;
end

for j = i:.1:i+1 bw(x(i*100:(i+1)*100)) =


b_p(i);
end
end
bw = bw(100:end);wo
= 2*(2*pi*t);
W = 1*(2*pi*t); sinHt
= sin(wo+W); sinLt =
sin(wo-W);
st = sin(wo+(bw).*W);
subplot(4,1,1) plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(4,1,2) plot(t,sinHt)
grid on ; axis([0 n -2 +2])
subplot(4,1,3) plot(t,sinLt)
grid on ; axis([0 n -2 +2])
subplot(4,1,4)
plot(t,st)
grid on ; axis([0 n -2 +2])
Fs=1;
figure %pburg(st,10)
periodogram(st)
OBSERVATION:
Output waveform for the bit stream [0 1 0 0 1 1 1 0]
EXPERIMENT N0: 3
PHASE SHIFT KEYING MODULATION

AIM:
To plot the wave form for Phase Shift Keying signal (PSK) using MATLAB for a
stream of bits.
SOFTWARE: MATLAB
THEORY:
Phase shift keying (PSK) is the most efficient of the three digital modulation, i.e., ASK, FSK
and PSK. Hence, it is used for high bit rates. In PSK, phase of the sinusoidal carrier is changed
according to the data bit to be transmitted. Also, a bipolar NRZ signal is used to represent
the digital data coming from the digital source.
Mathematical Expression for PSK:
In a phase shift keying (PSK), the binary symbols ‘1’ and ‘0’ modulate the phase of the
carrier. Let us assume that the carrier is given as,

s(t) = A cos (2πfct) …(1)


Here ‘A’ represents peak value of sinusoidal carrier. For the standard 1 W load resistor, the
power dissipated would be,
1
P = 2A²

Or A = √2𝑃 …(2)
Now, when the symbol is changed, then the phase of the carrier will also be changed by an
amount of 180 degrees (i.e., π radians). Let us consider, for example,
For symbol ‘1’, we have

S1(t) =√2𝑃 cos(2πfct) …(3)


If next symbol is ‘0’, then we have

For symbol ‘0’, we have

S2(t) =√2𝑃 cos(2πfct+ π) …(4)


Now, because cos (θ + π) = – cos θ, therefore, the last equation can be written as,

S2(t)= − √2𝑃 cos (2πfct) …(5)


With the above equation, we can define PSK signal combinely as,
s(t) = b(t) √2𝑃cos (2πfct) …(6)
where,
b(t) = + 1 when binary ‘1’ is to be transmitted

– 1 when binary ‘0’ is to be transmitted


The modulation of PSK is done using a balance modulator, which multiplies the two signals
applied at the input. For a zero binary input, the phase will be 0ׄ° and for a high input, the
phase reversal is of 180°. The output sine wave of the modulator will be the direct input
carrier or the inverted 180°phaseshifted input carrier, which is a function of the data signal.

BLOCK DIAGRAM:
MATLAB PROGRAM:
clear;
clc;
b = input('Enter the Bit stream \n ');
%b = [0 1 0 1 1 1 0];
n = length(b);
t = 0:.01:n;
x = 1:1:(n+1)*100;
for i = 1:n
if (b(i) == 0)
b_p(i) = -1;
else
b_p(i) = 1;
end
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b_p(i);
end
end
bw = bw(100:end);
sint = sin(2*pi*t);
st = bw.*sint;
subplot(3,1,1)
plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(3,1,2)
plot(t,sint)
grid on ; axis([0 n -2 +2])
subplot(3,1,3)
plot(t,st)
grid on ; axis([0 n -2 +2])
OUTPUT WAVEFORM FOR THE BIT STREAM [1 0 1 1 0 0 0 1]
EXPERIMENT NO. 4
Quadrature Phase Shift Keying

AIM:
To plot the wave form for Quadrature Phase Shift Keying (QPSK) signal using MATLAB for a
stream of bits.

THEORY:
In QPSK, the data groups are divided into groups of two or more bits and each group of bits
is represented by a specific value of amplitude, frequency or phase of the carrier. QPSK
(Quadrature PSK) is an example of multilevel phase of modulation. In QPSK system, two
successive bits in a bit stream are combined together to form a message and each message
is represented by a distinct value of phase shift of the carrier. Easy symbol or message
contains two bits. Hence, the symbol duration Ts = 2 Tb. These symbols are transmitted by
transmitting the same carrier at four different phase shifts.
QPSK Waveforms Since, there are four phase shifts involved, this system is called
as quadrature PSK or 4-PSK system. If the symbol 00 is to be transmitted, then, we have to
transmit a carrier at 0° phase shift. If 01 is to be transmitted, then the same carrier is
transmitted with a phase shift of 90°. Similarly, the messages 10 and 11 are transmitted by
transmitting the carrier at 180° and 270° respectively.

Mathematical representation of QPSK:


A QPSK signal can be represented mathematically as under:

CIRCUIT DIAGRAM:
MATLAB CODE:

clear;

clc;
b = input('Enter the Bit stream \n '); %b = [1 0 0 1 1 1 0 1];
n = length(b);
t = 0:.01:n;

x = 1:1:(n+2)*100;
for i = 1:n
if (b(i) == 0)
b_p(i) = -1;
else

b_p(i) = 1;
end
for j = i:.1:i+1
bw(x(i*100:(i+1)*100)) = b_p(i);

if (mod(i,2) == 0)
bow(x(i*100:(i+1)*100)) = b_p(i);
bow(x((i+1)*100:(i+2)*100)) = b_p(i);
else

bew(x(i*100:(i+1)*100)) = b_p(i);
bew(x((i+1)*100:(i+2)*100)) = b_p(i);
end
if (mod(n,2)~= 0)
bow(x(n*100:(n+1)*100)) = -1;

bow(x((n+1)*100:(n+2)*100)) = -1;
end
end
end %be = b_p(1:2:end);
%bo = b_p(2:2:end);
bw = bw(100:end);
bew = bew(100:(n+1)*100);

bow = bow(200:(n+2)*100);
cost = cos(2*pi*t);
sint = sin(2*pi*t);
st = bew.*cost+bow.*sint;

subplot(4,1,1)
plot(t,bw)
grid on ; axis([0 n -2 +2])
subplot(4,1,2)

plot(t,bow)
grid on ; axis([0 n -2 +2])
subplot(4,1,3)
plot(t,bew)
grid on ; axis([0 n -2 +2])

subplot(4,1,4)
plot(t,st)
grid on ; axis([0 n -2 +2])

OBSERVATION:
Output waveform for the bit stream [1 0 0 1 1 1 0 1]
Output waveform for the bit stream [0 1 1 0 0 1 1 1]
EXPERIMENT NO.5
Quadrature Amplitude Modulated Signal

AIM:
To plot the waveform for 8 Quadrature Amplitude Modulated Signal (QAM)using MATLAB
for a stream of bits.

THEORY:
The ability of a receiver to distinguish between one signal vector from another in presence
of noise, depends on the distance between the vector and point.
This suggests that the noise immunity will improve its signal vector the person not only in
face but also in amplitude.
Such a system is called amplitude and phase shifting key system.
In this system the direct modulation of carrier is called rancher that is cos Omega T and Sin
Omega T is involved therefore this system is called as the quadrature amplitude phase
shifting ki that is QAPSK or simply QASK.
This is also known as for drawings are Amplitude Modulation (QAM)
BLOCK DIAGRAM:

MATLAB CODE:
clc
close all
m = 8;
k = log2(m);
n = 9e3;
nsamp = 1;
x = randi((0:1),n,1);
stem(x(1:20),'filled');
title('bit sequence');
xlabel('bit index');
ylabel('bit amplitude');
xsym = bi2de(reshape(x,k,length(x)/k).','left-msb');
figure;
stem(xsym(1:10));
title('symbol plot');
xlabel('symbol index');
ylabel('symbol amplitude');
y = qammod(xsym,m);
ytx = y;
scatterplot(y);
ebno = 10;
snr = ebno+10*log10(k)-10*log10(nsamp);
yn = awgn(ytx,snr);
yrx = yn;
scatterplot(yrx,30);
OBSERVATION:
EXPERIMENT NO: 07
LINEAR BLOCK CODES GENERATION USING MATLAB

AIM:
To generate linear block codes using MATLAB.
SOFTWARE:
MATLAB.

THEORY:
Linear codes are utilized in forward mistake adjustment and are applied in methods for
techniques for sending symbols (e.g., bits) on a communications channel so that, if mistakes
occur in the communication, some mistakes can be amended or recognized by the
beneficiary of a message block. The code words in a linear block code are blocks of symbols
that are encoded utilizing a greater number of symbols than the first incentive to be sent.
1. We consider an (n, k) linear block code in which k number of bits are identical to the
message sequence which is to be transmitted.
2. The remaining (n – k) number of bits are called as the generalized parity check bits
or simply parity bits.
3. These parity bits are computed from the message bits, according to the prescribed
encoding rule which decides the mathematical structure of the code.
4. Let us consider figure 9.18, which shows the structure of a code word.

Fig.1.1. Structure of the code word for a linear block code


5. A code word consists of k message bits which are denoted by m0, m1, ..., mk – 1 and
(n – k) parity bits denoted by c0, c1, ..., cn – k – 1.
6. The sequence of message bits is applied to a linear block encoder to produce an n-bit
code word. The elements of this code word are x0, x1, ..., xn – 1.
7. As shown in figure 1.1, the first k-bits of the code word are identical to the
corresponding parity bits (c0, c1....). We can express this mathematically as under:

......(1.1)
8. . The (n– k) parity bits are linear sums of the k message bits.
9. The code vector represented by equation (1.1) can be mathematically represented
as:
X = [M: C] …... (1.2)

where M = k-message vectors


and C = (n – k), parity vectors
10. A block code generator generates the parity vectors (or parity bits) required to be
added to the message bits to generate the code words. The code vector X can also
be represented as under:
X = MG ….... (1.3)
where X = Code vector of 1 × n size
M = Message vector of 1 × k size

and G = Generator matrix of k × n size


Equation (1.3) can be represented in the matrix form as under:

......(1.4)

11. The generator matrix is dependent on the type of linear block code used. The
generator matrix is generally represented as under:

...... (1.5)

where Ik = k × k identity matrix


and P = k × (n – k) coefficient matrix.
Therefore,

And

.........(1.6)
12. The parity vector can be obtained as under:
C = MP ….... (1.7)
Substituting the matrix form, we obtain,

........(1.8)
By solving the above matrix equation, we get the parity vectors as under:

........(1.9)

Similarly, we can obtain the expressions for the remaining parity bits.
BLOCK DIAGRAM:

MATLAB PROGRAM:
clc;
clear all;

k = input('Enter the length of Msg Word: ');


n = input('Enter the length of codeword: ');
P = input('Enter the Parity Matrix: ')

G = [eye(k) P]
% C=encode(m,n,k,'linear',G)
H=[P' eye(n-k)]
dtable=syndtable(H)
[n,k]=size(transpose(G))

for i=1:2^k
for j=k:-1:1
if rem(i-1,2^(-j+k+1))>=2^(-j+k)
u(i,j)=1;

else
u(i,j)=0;
end
end

end
u;
disp('the possible codewords are:')
c=rem(u*G,2)
disp('the minimum hamming distance dmin for given block code=')

d_min=min(sum((c(2:2^k,:))'))
R=input('Enter the received codeword: ');
S_B=rem(R*H',2)
S_D=bi2de(S_B, 'left-msb')

if (S_D==0)
disp('The received codeword is zero')
else

disp('The received codeword is Invalid')


E=dtable(S_D+1,:)
disp('The corrected codeword is: ')
CC=rem(R+E,2)

msg=CC(1:k)
end
%D=decode(C,n,k,'linear',G)

OUTPUT:
Enter the length of Msg Word: 3
Enter the length of codeword: 6
Enter the Parity Matrix: [1 1 1;1 1 0;1 0 1]

P=
1 1 1
1 1 0

1 0 1

G=
1 0 0 1 1 1
0 1 0 1 1 0

0 0 1 1 0 1

H=
1 1 1 1 0 0

1 1 0 0 1 0
1 0 1 0 0 1

dtable =

0 0 0 0 0 0
0 0 0 0 0 1
0 0 0 0 1 0
1 0 0 1 0 0

0 0 0 1 0 0
0 0 1 0 0 0
0 1 0 0 0 0
1 0 0 0 0 0

n=6
k =3
the possible codewords are:

c=
0 0 0 0 0 0
0 0 1 1 0 1
0 1 0 1 1 0

0 1 1 0 1 1
1 0 0 1 1 1
1 0 1 0 1 0
1 1 0 0 0 1
1 1 1 1 0 0

the minimum hamming distance dmin for given block code=


d_min = 3
Enter the received codeword: [0 0 0 1 1 0]

S_B =
1 1 0

S_D =6

The received codeword is Invalid


E=0 1 0 0 0 0
The corrected codeword is:
CC =0 1 0 1 1 0

msg =0 1 0
CONCLUSION:
Thus, we have successfully learned and implemented the linear block codes generation
using MATLAB.

You might also like