0% found this document useful (0 votes)
16 views23 pages

DC Exps

The document contains descriptions of 9 experiments related to digital communication concepts. Experiment 1 calculates entropy, total length, and efficiency of a set of messages with given probabilities and lengths. Experiment 2 performs transmission and reception of data using even and odd parity checks. Experiment 3 demonstrates error detection using a parity check matrix. Experiment 4 implements encoding of data using a generator polynomial in a Galois Field.

Uploaded by

305 Aditya Barai
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)
16 views23 pages

DC Exps

The document contains descriptions of 9 experiments related to digital communication concepts. Experiment 1 calculates entropy, total length, and efficiency of a set of messages with given probabilities and lengths. Experiment 2 performs transmission and reception of data using even and odd parity checks. Experiment 3 demonstrates error detection using a parity check matrix. Experiment 4 implements encoding of data using a generator polynomial in a Galois Field.

Uploaded by

305 Aditya Barai
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/ 23

Exp 1

import math

msg_list = []
len_list = []

no_of_msgs = int(input("Number of messages: "))

# Input loop for probabilities


for i in range(no_of_msgs):
msg_prob = float(input("Enter probability: "))
msg_list.append(msg_prob)

# Calculation of entropy
entropy = 0
for i in range(no_of_msgs):
entropy += msg_list[i] * (math.log((1 / msg_list[i]), 2))

# Input loop for message lengths


for i in range(no_of_msgs):
msg_len = float(input("Enter length: "))
len_list.append(msg_len)

# Calculation of total length


length = 0
for i in range(no_of_msgs):
length += msg_list[i] * len_list[i]

# Calculation of efficiency
efficiency = (entropy / length) * 100

print(f"Entropy: {entropy}")
print(f"Total Length: {length}")
print(f"Efficiency: {efficiency:.2f}%")
Exp 2

#transmission
#inputs
x1 = [1,1,0,0,0,0,1]
x2 = [1,1,1,1,0,0,1]
x3 = [1,0,1,1,0,0,1]
x4 = [0,0,0,0,1,0,1]
x5 = [0,0,1,0,1,0,1]
x6 = [0,0,1,0,1,0,1]
x7 = [1,0,1,0,0,0,1]
x8 = [0,1,0,0,1,0,1]
vrc = []
realvrc = []
x = [x1,x2,x3,x4,x5,x6,x7,x8]
for j in range (0,8):
b = sum(x[j])
if b % 2 == 0:
realvrc.append(0)
else:
realvrc.append(1)
print("VRC = ",realvrc)
for i in range (0,7):
a = x1[i]+x2[i]+x3[i]+x4[i]+x5[i]+x6[i]+x7[i]+x8[i]
if a % 2 == 0:
vrc.append(0)
else :
vrc.append(1)
print("LRC = ",vrc)

#reception
#outputs
y1 = [1,1,0,0,0,0,1,1]
y2 = [1,1,1,1,0,0,1,1]
y3 = [1,0,1,1,0,0,1,0]
y4 = [0,0,0,0,1,0,1,0]
y5 = [0,0,1,0,1,0,1,0]
y6 = [0,0,1,0,1,0,1,1]
y7 = [1,0,1,0,0,0,1,1]
y8 = [0,1,0,0,1,0,1,1]
y9 = [1,1,1,0,0,0,0,1]

for k in range(0,6):
if(vrc[k] == y9[k]):
continue

else:
c = k + 1
y = [y1[7],y2[7],y3[7],y4[7],y5[7],y6[7],y7[7],y8[7]]
for m in range(0,7):
if(realvrc[m] == y[m]):
continue
else:
print("Even Parity not satisfied at", m+1,"th column of VRC")
print("Even Parity not satisfied at", k+1,"th row of LRC")
print( 'bit',c ,'of',x[m+1])
Exp 3

clc ;
clear all ;
P = input ( "enter the parity matrix " )
disp ( P )
k = input ( "enter the value of k " )
n = input ( "enter the value of n " )
I = eye ( 3 , 3 ) ;
disp ( I )
G=[IP]
disp ( G )
M = input ( "enter the message matrix " )
C=M*G
c1 = modulo ( C, 2 )
disp ( c1 )
disp ( P ' )
H = [ P'I ] ;
disp ( H ' )
disp ( "enter the vector to be checked " )
X = input ( "enter the code for error detection " )
E = modulo ( X * H ' , 2 )
disp ( "error = " ) ;
disp ( E ) ;
if E == [ 0 , 0 , 0 ] then
disp ( "the code vector does not have any error" ) ;
else
disp ( "the code vector has an error" )
end
for t = 1 : k
if H ( : ,t ) == E ' then
disp ( "error bit of code vector=" ) ;
disp ( t ) ;
X ( 1 ,t ) = bitcmp ( X ( 1 ,t ) , 1 ) ;
disp ( "corrected code vector is " ) ;
disp ( X ) ;
end
end
Exp 4

clc;
clear all;
n=input("Enter the value of n:");
k=input("Enter the value of k:") ;
for i = 1 : n - k + 1
x(i)=input("Enter the coefficients of Generator Polynomial:");
end

x1=poly(x,"p","coeff");
X=pol2str(x1);
disp("The Generator Polynomial is ");
disp("x(p)");
disp(X);
for j = 1 : k
m(j)=input("Enter the coefficients of message polynomial:");
end

ml = poly(m,"p","coeff");
M = pol2str(ml);
disp("The message Polynomial:");
disp("m(p)");
disp(M);
ul=x1*ml;
u=coeff(ul);
u2 = modulo(u,2);
u3=poly(u2,"p","coeff");
U=pol2str(u3);
disp("The Codeword polynomial is: ");
disp("u(p)");
disp(U);
l=length(u2);
if l<n then
for r = (l + 1) : n
u2(r) = 0;
end
end
disp("The Non-systematic Codeword");
disp("U(Non-systematic)");
z=n;
for t = 1 : n
g(t) = u2(z);
z = z - 1;
end
disp(g');
p=poly(0,"p");
p2=(p ^(n-k));
p3=pol2str(p2);
disp("Multiplication Polynomial");
disp(p3);
q=p2*ml;
q2=pol2str(q);
disp("Shifted Message=") ;
disp(q2);
[rem,quo]=pdiv(q,x1);
reml=coeff(abs(rem));
disp("Remainder Code: ");
disp(reml);
rem2=modulo(reml,2);
R=poly(rem2,"p","coeff");
P=pol2str(R);
disp("Remainder Polynomial =");
disp(P);
Q=q+R;
Q1=coeff(Q);
Q2=modulo(Q1,2);
Q3=poly(Q2,"p","coeff");
Q4=pol2str(Q3);
disp("The Systematic Polynomial:");
disp(Q4)

l1 =length(Q2);
if l1<n then
for v=(l1+1):n
Q2(v)=0;
end
end

disp("The Systematic Codeword:");


disp("Q(Systematic)");
disp(Q2);
Exp 5

NRZ L

NRZ M
NRZ S

BI PHASE L
BI PHASE M

BI Phase S
AMI Encoding
Decoding NRZ L

Decoding NRZ M
Decoding NRZ S

Decoding BI L
Line Encoding

Jumper 1 : Sdata --> IN 16


Jumper 2: Clk2 --> TxClk

Probe1: Sdata and ground


Probe2 : Out 10 and ground

Settings:
GP4
128Khz
Even

Click S3 for various Waveforms

Line Decoding:
Change IN 16 to IN 17

AMI :
Change Out 10 to Out 11
Exp 6
ASK mod:

Probe 1: Digital Data Generator ( NRZ ) and Ground


Probe 2: Balance Modulator ( 1 or 2 for ASK 1 or 2 ) and Ground
Probe 3 (Optional) : FSK modulator output and Ground
Exp 8

BPSK Mod
BPSK Demod
Exp 9

Channel 1: Data Generator ( Data )


Channel 2: Dibit Encoder ( Even_out )
Channel 3: Dibit Encoder
( Odd_out)
Channel 4: QPSK modulator ( Mod_out)
Jumper 1: Dibit Encoder(even) --> QPSK modulator
Jumper 2: Dibit Encoder(odd) --> QPSK modulator
Jumper 3: Data Generator (Pcs22) --> Dibit Encoder (Pcs1)

Channel 1,3 and 2 and 4 --> QPSK Modulator (Psc21)

You might also like