# Simulating a linear voltage regulator with ngspice

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:

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:

• What is the intended output voltage? – Peter Bennett Oct 25 '14 at 0:35
• R4 will ultimately be a potentiometer which allows for a variable output voltage between 2 and 12 volts. I realize I will have to change the R3 and R5 to access the full range, but I wanted to do a quick simulation to see if the design was correct. Right now the output voltage should be about 8V. – Dylan MacKenzie Oct 25 '14 at 0:49