Electronic – Simulating a linear voltage regulator with ngspice

linear-regulatorspicevoltage-regulator

I am trying to simulate a simple linear regulator using gschem and ngspice. However, my output voltage varies by over a volt as my input voltage goes from 10V to 20V. Can I reduce this swing in the output voltage by changing circuit parameters or is this a characteristic of linear regulators?

My circuit looks like this:

Circuit diagram

And the netlist that gets generated (witl the comments and models stripped out) is this:

V1 Vin 0 16.8
C2 0 Vout .1uF  
C1 2 0 1000uF  
D1 2 0 1N4004 
R5 q1base 0 1k  
R4 q1base 3 5k  
R3 Vout 3 1k  
R1 q2base Vin 2k  
Q1 q2base q1base 2 2N4401 
Q2 Vin q2base 1 2N4401 
Q3 Vin 1 Vout TIP29 
.end

When I perform a dc sweep on v1 by doing dc v1 5 25 .1 my output is as follows:

Simulation results

Best Answer

That's about what I would expect. You don't have a very good circuit there, that's the problem.

The only voltage reference is the series combination of the 1N4004 and the B-E junction of Q1. For an input voltage change from 10V to 20V, the current through those parts will change roughly an order of magnitude, so a 10%-ish change in output voltage is to be expected.

You could get somewhat better performance by replacing the 1N4004 with a green LED (however the output will no longer go down to 2V). You could also bootstrap some current from the regulated output to reduce the percentage change in the current. It will still be quite temperature sensitive (approximately PTAT, so it will change hundreds of mV for a 10°C change in temperature with 8V nominal out).

The best way would be to use a better reference such as an LM431 (which contains a band-gap reference and also has sufficient gain to replace the transistor). The minimum output voltage with this configuration is Vref, which is nominally 1.2495V. You do need to ensure 1mA (minimum) gets to the TL431 with minimum input voltage.

enter image description here

Related Topic