Wednesday, 9 November 2022

Communication System - QPSK

 clear ;

clc ;
close ;
M =4;
i = 1:M;
t = 0:0.001:1;
for i = 1:M
s1(i ,:) = cos (2* %pi *2* t)*cos ((2*i -1) *%pi /4) ;
s2(i ,:) = -sin (2* %pi *2* t)*sin ((2*i -1) *%pi /4) ;
end
S1 =[];
S2 = [];
S = [];
Input_Sequence=[0 ,1 ,1 ,0 ,1 ,0 ,0 ,0];
m = [3 ,1 ,1 ,2];
for i =1: length (m)
S1 = [S1 s1(m(i) ,:) ];
S2 = [S2 s2(m(i) ,:) ];
end
S = S1+S2;
figure
subplot (3 ,1 ,1)
a = gca ();
a.x_location = "origin";
plot (S1)
title ('Binary PSK wave o f Odd-numbered bits of input sequence')
subplot (3 ,1 ,2)
a = gca ();
a.x_location = "origin";
plot (S2)
title ('Binary PSK wave o f Even-numbered bits of input sequence')
subplot (3 ,1 ,3)
a = gca ();
a.x_location = "origin";
plot (S)
title ('QPSK waveform ')

Communication Systems - Hamming Code

 clc ;

clear all;

code1 = input ('Enter the 1st Code Word ') ;
code2 = input ('Enter the 2nd Code Word ') ;
Hamming_Distance = 0;
for i = 1:length (code1)
 Hamming_Distance = Hamming_Distance + bitxor(code1(i),code2(i)) ;
end
disp (Hamming_Distance, 'Hamming Distance')

Communication Systems - DPSK

 clc ;

bk = [1 ,0 ,0 ,1 ,0 ,0 ,1 ,1]; // input digital sequence
for i = 1: length (bk)
if(bk(i) ==1)
bk_not (i) =~1;
else
bk_not (i)= 1;
end
end
dk_1 (1) = bool2s ( 1&bk (1) ); // initial value of differential encoded sequence
dk_1_not (1) = bool2s (0&bk_not(1));
dk (1) = bitxor ( dk_1 (1) ,dk_1_not (1)) // f i r s t b i t o f dpsk encoder
for i =2: length (bk)
dk_1 (i) = dk(i -1);
dk_1_not (i) = ~dk(i -1);
dk(i) = bitxor ( bool2s ( dk_1 (i)&bk(i)),bool2s (dk_1_not (i)&bk_not (i)));
end
for i =1: length (dk)
if(dk(i) ==1)
dk_radians (i)=0;
elseif (dk(i) ==0)
dk_radians (i)=%pi;
end
end
disp (' Table 7.3 Illustrating the Generation of DPSK Signal')
disp ( '' )
disp (bk , '( bk )')
bk_not = bk_not ';
disp (bk_not , ' (bk not)')
dk = dk ';
disp (dk , 'Differentially encoded sequence (dk)')
dk_radians = dk_radians ';
disp (dk_radians, 'Transmitted phase in radians')

Communication Systems - PSK

 clc;clear all;clf;

t=[0:0.01:5*%pi];
A=5;
fc=2;

Vm=A.*squarewave(t);
Vc=A.*sin(fc.*t);
Vp= Vm.*Vc;

subplot(3,1,1);
plot(t,Vm, 'red');
xlabel("Time")
ylabel("Amplitude of Message Signal")

subplot(3,1,2);
plot(t,Vc, 'green');
xlabel("Time")
ylabel("Amplitude of Carrier Signal")

subplot(3,1,3);
plot(t,Vp, 'blue');
xlabel("Time")
ylabel("Amplitude of PSK Signal")

Communication Systems - ASK

 

clc;clear all;clf;
t=[0:0.02:5*%pi];
fc=10;
A=1;

Vm=squarewave(t,40);

Vc=A/2.*cos(fc.*t);
Va=(1+Vm).*(Vc);

subplot(3,1,1);
plot(t,Vm,'red');
xlabel("Time")
ylabel("Amplitude of Message Signal")

subplot(3,1,2);
plot(t,Vc, 'green');
xlabel("Time")
ylabel("Amplitude of Carrier Signal")

subplot(3,1,3);
plot(t,Va, 'blue');
xlabel("Time")
ylabel("Amplitude of ASK Signal")

Communication Systems - FSK

clc; clear all; clf;
t=[0:0.01:4.4*%pi];
A=5;
wc=5;

Vm=A.*squarewave(t);
Vc=A.*cos(wc.*t);
fc=wc/(2*%pi);

subplot(3,1,1);
plot(t,Vm, 'red');
xlabel("Time")
ylabel("Amplitude of Message Signal")

subplot(3,1,2);
plot(t,Vc, 'green');
xlabel("Time")
ylabel("Amplitude of Carrier Signal")

fd=0.5; //frequency deviation
subplot(3,1,3);
Vf=A.*cos(2.*%pi.*(fc+Vm.*fd).*t);
plot(t,Vf, 'blue');
xlabel("Time")
ylabel("Amplitude of FSK Signal")

Verilog Code for Universal Shift Register

  Universal Shift Register module universalshift (clr,clk,sel,in,out); input clr,clk; input [1:0]sel; input [3:0]parin; output reg[3:0]out; ...