This repository has been archived by the owner on Jun 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MOS_Load_Line_Movie2.m
73 lines (61 loc) · 2.81 KB
/
MOS_Load_Line_Movie2.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
VGS = linspace(0.7,2.6); % VGS ranges from 0.7V to 2.6V, 100 data points.
VDS = 0:0.01:3.3; % VDS ranges from 0 to 3.3V in 0.01V steps; 331 points.
Vin = 0:0.01:3.3; % Used to generate voltage transfer characteristics.
VDS0 = 2; % Initial guess for VDS used by "fsolve" in finding Q-point.
% MOSFET parameter values (need for sat/triode boundary plot).
mu_n = 0.05; % Electron mobility.
Cox = 3.5e-3; % MOSFET gate oxide capacitance.
W = 4e-6; % MOSFET gate width.
L = 0.6e-6; % MOSFET gate length.
Sat = 1e3/2*mu_n*Cox*W/L*VDS.^2; % NMOS saturation/triode region boundary.
ID = zeros(1,331); % Pre-allocate ID for speed, otherwise it's re-sized
% on each iteration of loops below (slow).
IDload = zeros(1,331); % Pre-allocate IDload for speed.
options = optimset('Algorithm','levenberg-marquardt','Display','off');
VDD = 3.3; % Positive rail is 3.3V.
RD = 3.3e3; % Load resistor is 3.3k ohms.
Vout = zeros(1,331); % Pre-allocate Vout for speed.
% Generate voltage transfer characteristics and load line
% (same for all frames):
for n = 1:331 % Sweep Drain-Source voltage.
Vout(n) = fsolve(@(VDS)MOS_IV(Vin(n),VDS)*1e6 - ...
(-VDS/RD + VDD/RD)*1e6,VDS0,options); % v.t.c.
% uA scale for fsolve tolerance.
IDload(n) = (-VDS(n)/RD + VDD/RD)*1e3; % Load line (mA).
end
% This loop generates 100 movie frames, one for each VGS value.
for k = 1:100 % Step Gate-Source voltage.
% Generate I-V characteristics:
for n = 1:331 % Sweep Drain-Source voltage.
ID(n) = MOS_IV(VGS(k),VDS(n))*1e3; % I-V characteristics (mA).
end
% Calculate Q-point values:
VDSQ = fsolve(@(VDS)MOS_IV(VGS(k),VDS)*1e6-(-VDS/RD + VDD/RD)*1e6, ...
VDS0,options);% uA scale for fsolve tolerance.
IDQ = MOS_IV(VGS(k),VDSQ)*1e3;
if k >= 2
VDSQm1 = fsolve(@(VDS)MOS_IV(VGS(k-1),VDS)*1e6-(-VDS/RD + VDD/RD)*1e6, ...
VDS0,options);% uA scale for fsolve tolerance.
end
% Plot I-V characteristics, Q-point and load line:
subplot(2,1,1);
plot(VDS, ID, 'r', VDSQ, IDQ, 'ko', VDS, IDload, 'b', ...
VDS, Sat,'k:');
h = gcf; % Get current figure handle.
axis([0 3.3 0 1]);
xlabel(['{V}_{DS} (V) [{V}_{DSQ} = ', num2str(VDSQ),' (V)]']);
ylabel(['{I}_{D} (mA) [{I}_{DQ} = ', num2str(IDQ), ' (mA)]']);
title(['I-V Characeristics & Load Line: {V}_{GS} = ', num2str(VGS(k)),' (V)']);
if k >= 2
text(2,0.9,'\Delta {V}_{DS}/\Delta {V}_{GS} = ')
text(2.75,0.905,num2str((VDSQ-VDSQm1)/(VGS(k)-VGS(k-1))))
end
% Plot voltage transfer characheristics:
subplot(2,1,2);
plot(Vin, Vout, 'g', VGS(k), VDSQ, 'ko');
axis([0 3.3 0 3.3]);
xlabel(['{V}_{in} (V) [V_{in Q} = ', num2str(VGS(k)),' (V)]']);
ylabel(['{V}_{out} (V) [V_{out Q} = ', num2str(VDSQ),' (V)]']);
title('Voltage Transfer Characteristics');
M(k) = getframe(h);
end