Sahand University of Technology Electrical Engineering

Download Report

Transcript Sahand University of Technology Electrical Engineering

Sahand University of Technology
Electrical Engineering Department
Microelectronic Research Center
Simulink and code DSM D-T and C-T
With matlab
By:mostafa azadbakht
Advisor:Dr.E.Najafi aghdam
1
Tow way for simulink DSM:
m.azadbakht
1
•Simulink
block library
2
•code
2
1
Totality algorithm for build discrete _ time DSM with sumulink block library:
Y
U
m.azadbakht
SAMPLE AND
HOLD
+
H(Z)
QUNTIZRE
V
3
2
Totality algorithm for build discrete _ time DSM with sumulink code:
Step 1
Read the input & Read the transfusion NTF
Step 2
Simulink DSM with command schreier
Step 3
Give FFT of output simulink and plot…
m.azadbakht
4
All step for build discrete _ time Low pass DSM with simulink block library:
STEP1:
Read the NTF function
NTF=synthesizeNTF(order,osr,opt)
STEP 2:
Read the gain feedback:
FB=realizeNTF(NTF,’CIFB’)
STEP 3:
Read the gain forward:
FF=realizeNTF(NTF,’CIFF’)
m.azadbakht
5
constant:
Parameters for all simulinks:
Amplitude max vin=0.5 volt
Fin=0.0008*2*pi~0.005*pi
OSR=64
Opt=1
m.azadbakht
6
Order 1:
FB1=1
m.azadbakht
7
Command for draw spectrum:
Plotsp(vo,vi,k);k=1.5~4
m.azadbakht
8
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
9
Simulink DSM 1’s order Low pass with simulink code:
close all,clear all,clc
osr=64;
N=1;
Nlev=2^N;
n=2^13;
z=57;
t=[0:n-1];
H=synthesizeNTF(1,osr,1);
u=0.5*(Nlev-1)*sin(2*pi*z/n*t);
v=simulateDSM(u,H,Nlev);
spec=fft(v)/(n*(Nlev-1)/2);
snr=calculateSNR(spec(1:ceil(n/(2*osr))+1),z);
clear f
f=linspace(0,0.5,n/3);
figure,plot(f,dbv(spec(1:n/3)),'b'),grid on
m.azadbakht
10
Order 2:
FB1=1 FB2=1
m.azadbakht
11
View spectrum :
m.azadbakht
12
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
13
Simulink DSM 2’s order Low pass with simulink code:
close all,clear all,clc
osr=64;
N=1;
Nlev=2^N;
n=2^13;
z=57;
t=[0:n-1];
H=synthesizeNTF(2,osr,1);
u=0.5*(Nlev-1)*sin(2*pi*z/n*t);
v=simulateDSM(u,H,Nlev);
spec=fft(v)/(n*(Nlev-1)/2);
snr=calculateSNR(spec(1:ceil(n/(2*osr))+1),z);
clear f
f=linspace(0,0.5,n/3);
figure,plot(f,dbv(spec(1:n/3)),'b')
m.azadbakht
14
Order 3:
FB1=0.44 FB2=0.2881 FB3=0.7997
m.azadbakht
15
View spectrum :
m.azadbakht
16
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
17
Simulink DSM 3’s order Low pass with simulink code:
close all,clear all,clc
osr=64;
N=1;
Nlev=2^N;
n=2^13;
z=57;
t=[0:n-1];
H=synthesizeNTF(3,osr,1);
u=0.5*(Nlev-1)*sin(2*pi*z/n*t);
v=simulateDSM(u,H,Nlev);
spec=fft(v)/(n*(Nlev-1)/2);
snr=calculateSNR(spec(1:ceil(n/(2*osr))+1),z);
clear f
f=linspace(0,0.5,n/3);
figure,plot(f,dbv(spec(1:n/3)),'b')
m.azadbakht
18
Order 4:
FB1=0.2923 FB2=1.4212 FB3=2.7446 FB4=2.5536
FF1=2.5536 FF2=2.7446 FF3=1.4212 FF4=0.2923
m.azadbakht
19
View spectrum :
m.azadbakht
20
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
21
Simulink DSM 4’s order Low pass with simulink code:
close all,clear all,clc
osr=64;
N=1;
Nlev=2^N;
n=2^13;
z=57;
t=[0:n-1];
H=synthesizeNTF(4,osr,1);
u=0.5*(Nlev-1)*sin(2*pi*z/n*t);
v=simulateDSM(u,H,Nlev);
spec=fft(v)/(n*(Nlev-1)/2);
snr=calculateSNR(spec(1:ceil(n/(2*osr))+1),z);
clear f
f=linspace(0,0.5,n/3);
figure,plot(f,dbv(spec(1:n/3)),'b')
m.azadbakht
22
Order 5:
FB1=0.1086 FB2=0.7247 FB3=2.0551 FB4=3.1432 FB5=2.6416
FF1=2.6416 FF2=3.1432 FF3=2.0551 FF4=0.7247 FF5=0.1086
m.azadbakht
23
View spectrum :
m.azadbakht
24
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
25
Simulink DSM 5’s order Low pass with simulink code:
close all,clear all,clc
osr=64;
N=1;
Nlev=2^N;
n=2^13;
z=57;
t=[0:n-1];
H=synthesizeNTF(5,osr,1);
u=0.5*(Nlev-1)*sin(2*pi*z/n*t);
v=simulateDSM(u,H,Nlev);
spec=fft(v)/(n*(Nlev-1)/2);
snr=calculateSNR(spec(1:ceil(n/(2*osr))+1),z);
clear f
f=linspace(0,0.5,n/3);
figure,plot(f,dbv(spec(1:n/3)),'b')
m.azadbakht
26
Order 6:
FB1=0.0325 FB2=0.2855 FB3=1.1098 FB4=2.4712 FB5=3.3619 FB6=2.6850
FF1=2.6850 FF2=3.3619 FF3=2.4712 FF4=1.1098 FF5=0.2855 FF6=0.0325
m.azadbakht
27
View spectrum :
m.azadbakht
28
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
29
Simulink DSM 6’s order Low pass with simulink code:
close all,clear all,clc
osr=64;
N=1;
Nlev=2^N;
n=2^13;
z=57;
t=[0:n-1];
H=synthesizeNTF(6,osr,1);
u=0.5*(Nlev-1)*sin(2*pi*z/n*t);
v=simulateDSM(u,H,Nlev);
spec=fft(v)/(n*(Nlev-1)/2);
snr=calculateSNR(spec(1:ceil(n/(2*osr))+1),z);
clear f
f=linspace(0,0.5,n/3);
figure,plot(f,dbv(spec(1:n/3)),'b')
m.azadbakht
30
Order 7:
FB1=0.0082 FB2=0.0913 FB3=0.4664 FB4=1.4036 FB5=2.7423 FB6=3.4921 FB7=2.7096
FF1=2.7093 FF2=3.4921 FF3=2.7423 FF4=1.4036 FF5=0.4664 FF6=0.0913 FF7=0.0082
m.azadbakht
31
View spectrum :
m.azadbakht
32
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
33
Simulink DSM 7’s order Low pass with simulink code:
close all,clear all,clc
osr=64;
N=1;
Nlev=2^N;
n=2^13;
z=57;
t=[0:n-1];
H=synthesizeNTF(7,osr,1);
u=0.5*(Nlev-1)*sin(2*pi*z/n*t);
v=simulateDSM(u,H,Nlev);
spec=fft(v)/(n*(Nlev-1)/2);
snr=calculateSNR(spec(1:ceil(n/(2*osr))+1),z);
clear f
f=linspace(0,0.5,n/3);
figure,plot(f,dbv(spec(1:n/3)),'b')
m.azadbakht
34
Simulink DSM Band pass for all order with block library :
𝐻𝑙𝑜𝑤 𝑝𝑎𝑠𝑠 (Z)
-𝒁𝟐
Z
𝐻𝑏𝑎𝑛𝑑 𝑝𝑎𝑠𝑠 (Z)
CONVERT
m.azadbakht
35
Simulink DSM band pass 1’s order with block library :
m.azadbakht
36
View spectrum :
m.azadbakht
37
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
38
Simulink DSM 1’s order Band pass with analysis code:
close all;clear all;clc
amp=0.452;
n=2^15;
t=[0:n];
fin=0.24589746;
u=amp*sin(2*pi*fin*t);
y=zeros(1,n);
v=y;
for i=3:n;
y(i)=-y(i-2)-u(i-2)+v(i-2);
if y(i)>0
v(i)=1;
else
v(i)=-1;
end
end
figure(100),plotsp(u,v,2);figure(200),plot(v)
m.azadbakht
39
View spectrum :
m.azadbakht
40
Digital output:
m.azadbakht
41
Simulink DSM band pass 2’s order with block library :
m.azadbakht
42
View spectrum :
m.azadbakht
43
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
44
Simulink DSM 2’s order Band pass with analysis code:
close all;clear all;clc
amp=0.452;
n=2^15;
t=[0:n];
fin=0.24985;
u=amp*sin(2*pi*fin*t);
y=zeros(1,n);
v=y;
for i=5:n;
y(i)=-2*y(i-2)-y(i-4)-2*u(i-2)-u(i-4)+2*v(i-2)+v(i-4);
if y(i)>0
v(i)=1;
else
v(i)=-1;
end
end
figure(100),plotsp(u,v,2);figure(200),plot(v)
m.azadbakht
45
View spectrum :
m.azadbakht
46
Digital output:
m.azadbakht
47
Simulink DSM band pass 3’s order with block library :
m.azadbakht
48
View spectrum :
m.azadbakht
49
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
50
Simulink DSM 3’s order Band pass with analysis code:
close all;clear all;clc
amp=0.452;
n=2^15;t=[0:n];fin=0.24898789;
u=amp*sin(2*pi*fin*t);
y=zeros(1,n);
v=y;
for i=7:n;
y(i)=-3*y(i-2)-3*y(i-4)-y(i-6)-0.8*u(i-2)-1.32*u(i-4)-0.56*u(i-6)+0.8*v(i-2)+1.32*v(i-4)+0.56*v(i-6);
if y(i)>0
v(i)=1;
else
v(i)=-1;
end
end
figure(100),plotsp(u,v,2);figure(200),plot(v)
m.azadbakht
51
View spectrum :
m.azadbakht
52
Digital output:
m.azadbakht
53
Simulink DSM band pass 4’s order with block library :
m.azadbakht
54
View spectrum :
m.azadbakht
55
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
56
Simulink DSM 4’s order Band pass with analysis code:
close all;clear all;clc
amp=0.452;
n=2^15;t=[0:n];fin=0.24898789;
u=amp*sin(2*pi*fin*t);
y=zeros(1,n);
v=y;
for i=7:n;
y(i)=-3*y(i-2)-3*y(i-4)-y(i-6)-0.8*u(i-2)-1.32*u(i-4)-0.56*u(i-6)+0.8*v(i-2)+1.32*v(i-4)+0.56*v(i-6);
if y(i)>0
v(i)=1;
else
v(i)=-1;
end
end
figure(100),plotsp(u,v,2);figure(200),plot(v)
m.azadbakht
57
View spectrum :
m.azadbakht
58
Digital output:
m.azadbakht
59
Simulink DSM band pass 5’s order with block library :
m.azadbakht
60
View spectrum :
m.azadbakht
61
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
62
Simulink DSM 5’s order Band pass with analysis code:
close all;clear all;clc
n=2^15;t=[0:n];fin=0.25;amp=0.455;
u=amp*sin(2*pi*fin*t);
y=zeros(1,n);
v=y;
for i=11:n;
y(i)=-4.998*y(i-2)-9.996*y(i-4)-9.998*y(i-6)-4.99*y(i-8)-y(i-10)-0.80769*u(i-2)-2.9141*u(i-4)-3.97*u(i-6)-2.4186*u(i-8)0.555*u(i-10)+0.80769*v(i-2)+2.9141*v(i-4)+3.97*v(i-6)+2.4186*v(i-8)+0.555*v(i-10);
if y(i)>0
v(i)=1;
else
v(i)=-1;
end
end
figure(100),plotsp(u,v,2);figure(200),plot(v)
m.azadbakht
63
View spectrum :
m.azadbakht
64
Digital output:
m.azadbakht
65
1
Totality algorithm for build continuous _ time DSM with sumulink block library:
Y
U
m.azadbakht
+
H(Z)
SAMPLE
AND HOLD
QUNTIZRE
V
66
Order 1:
m.azadbakht
67
View spectrum :
m.azadbakht
68
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
69
Order 2:
FB1=1 FB2=1.5
m.azadbakht
70
View spectrum :
m.azadbakht
71
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
72
Order 3:
FB1=0.2316 FB2=0.7868 FB3=2.4154
Fg=1/650
m.azadbakht
73
View spectrum :
m.azadbakht
74
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
75
Order 4:
FB1=0.0889 FB2=0.1379 FB3=.2039 FB4=0.3184
Fg=0.0168
m.azadbakht
76
View spectrum :
m.azadbakht
77
View analog in put and digital out put
Analog in
Digital out
m.azadbakht
78
Calculate SNRmax
1
2
m.azadbakht
• Analytical code
just for 1;s order
and 2’s order
• Simulink code
for all order’s
79
Analytical code
1’s order:
SNRmax=6.02N+1.76db-5.17db+30log(osr)
close all
clear all
clc
SNRmax=zeros(1,256);
x=100;
for N=1:4; %degree quantizer
for osr=4:4:1024;
SNRmax(osr)=6.02*N+1.76-5.17+30*log10(osr);
end
figure(x);plot(SNRmax);
x=x+100;
end
m.azadbakht
80
N=1
Figure 100:
SNRmax=9
2.92db
m.azadbakht
81
N=2
Figure 200:
SNRmax=98.94d
b
m.azadbakht
82
N=3
Figure 300:
SNRmax=1
05db
m.azadbakht
83
N=4
Figure 400:
SNRmax=1
11db
m.azadbakht
84
Analytical code
2’s order:
SNRmax=6.02N+1.76db-12.9db+50log(osr)
close all
clear all
clc
x=100;
SNRmax=zeros(1,256);
for N=1:4;
for osr=4:4:1024;
SNRmax(osr)=6.02*N+1.76-12.9+50*log10(osr);
end
figure(x);plot(SNRmax);
x=x+100;
end
m.azadbakht
85
N=1
Figure 100:
SNRmax=1
45.4db
m.azadbakht
86
N=2
Figure 200:
SNRmax=1
51.4db
m.azadbakht
87
N=3
Figure 300:
SNRmax=1
57.4db
m.azadbakht
88
N=4
Figure 400:
SNRmax=1
63.5db
m.azadbakht
89
90
m.azadbakht
close all,clear all,clc
format long
n=2^18;
z=57;
t=[0:n-1];
u=0.452*sin(2*pi*z/n*t);
SNRmax=zeros(1,256);
x=100;
for order=1:4;
for N=1:4;
NLEV=2^N;
for osr=4:4:1024;
h=synthesizeNTF(order,osr,1);
v=simulateDSM(u,h,3);
spec=fft(v)/(n*(NLEV-1)/2);
SNRmax(osr)=calculateSNR(spec(1:ceil(n/(2*osr))+1),z);
end
figure(x);plot(SNRmax);
x=x+100;
end
end
m.azadbakht
91
THANK’S
m.azadbakht
92