|
| 1 | +# MOSFET I-V Curves |
| 2 | +In this example, first we'll demonstrate the I-V curves of the NMOS transistor model. |
| 3 | +First of all, we construct a circuit using the NMOS transistor. We'll need to import ModelingToolkit and the Electrical standard library that holds the transistor models. |
| 4 | + |
| 5 | +```@example NMOS |
| 6 | +using ModelingToolkit |
| 7 | +using ModelingToolkit: t_nounits as t |
| 8 | +using ModelingToolkitStandardLibrary.Electrical |
| 9 | +using OrdinaryDiffEq |
| 10 | +using Plots |
| 11 | +``` |
| 12 | + |
| 13 | +Here we just connect the source pin to ground, the drain pin to a voltage source named `Vcc`, and the gate pin to a voltage source named `Vb`. |
| 14 | +```@example NMOS |
| 15 | +@mtkmodel SimpleNMOSCircuit begin |
| 16 | + @components begin |
| 17 | + Q1 = NMOS() |
| 18 | + Vcc = Voltage() |
| 19 | + Vb = Voltage() |
| 20 | + ground = Ground() |
| 21 | +
|
| 22 | + Vcc_const = Constant(k=V_cc) |
| 23 | + Vb_const = Constant(k=V_b) |
| 24 | + end |
| 25 | +
|
| 26 | + @parameters begin |
| 27 | + V_cc = 5.0 |
| 28 | + V_b = 3.5 |
| 29 | + end |
| 30 | + @equations begin |
| 31 | + #voltage sources |
| 32 | + connect(Vcc_const.output, Vcc.V) |
| 33 | + connect(Vb_const.output, Vb.V) |
| 34 | +
|
| 35 | + #ground connections |
| 36 | + connect(Vcc.n, Vb.n, ground.g, Q1.s) |
| 37 | +
|
| 38 | + #other stuff |
| 39 | + connect(Vcc.p, Q1.d) |
| 40 | + connect(Vb.p, Q1.g) |
| 41 | + end |
| 42 | +end |
| 43 | +
|
| 44 | +@mtkbuild sys = SimpleNMOSCircuit(V_cc = 5.0, V_b = 3.5) |
| 45 | +
|
| 46 | +prob = ODEProblem(sys, Pair[], (0.0, 10.0)) |
| 47 | +sol = solve(prob) |
| 48 | +``` |
| 49 | + |
| 50 | +Now to make sure that the transistor model is working like it's supposed to, we can examine the plots of the drain-source voltage vs. the drain current, otherwise knowns as the I-V curve of the transistor. |
| 51 | +```@example NMOS |
| 52 | +v_cc_list = collect(0.05:0.1:10.0) |
| 53 | +
|
| 54 | +I_D_list = [] |
| 55 | +I_D_lists = [] |
| 56 | +
|
| 57 | +for V_b in [1.0, 1.4, 1.8, 2.2, 2.6] |
| 58 | + I_D_list = [] |
| 59 | + for V_cc in v_cc_list |
| 60 | + @mtkbuild sys = SimpleNMOSCircuit(V_cc=V_cc, V_b=V_b) |
| 61 | + prob = ODEProblem(sys, Pair[], (0.0, 10.0)) |
| 62 | + sol = solve(prob) |
| 63 | + push!(I_D_list, sol[sys.Q1.d.i][1]) |
| 64 | + end |
| 65 | + push!(I_D_lists, I_D_list) |
| 66 | +end |
| 67 | +
|
| 68 | +reduce(hcat, I_D_lists) |
| 69 | +plot(v_cc_list, I_D_lists, title="NMOS IV Curves", label=["V_GS: 1.0 V" "V_GS: 1.4 V" "V_GS: 1.8 V" "V_GS: 2.2 V" "V_GS: 2.6 V"], xlabel = "Drain-Source Voltage (V)", ylabel = "Drain Current (A)") |
| 70 | +``` |
| 71 | + |
| 72 | +We can see that we get exactly what we would expect: as the drain-source voltage increases, the drain current increases, until the the transistor gets in to the saturation region of operation. |
| 73 | +Then the only increase in drain current is due to the channel-length modulation effect. Additionally, we can see that the maximum current reached increases as the gate voltage increases. |
0 commit comments