gEDA-user: Learning Spice: TwoStageAmp example

Daniel B. Thurman dant at cdkkt.com
Mon Jul 20 21:31:11 EDT 2009


Please bear with me as I am trying to learn
how to use gEDA tools and all of it's
nuances.

For starters, I have focused on the simple
document: ngspice.pdf which is a "tutorial"
involving a simple RC circuit.  So far, so
good.

But then I wanted to try other examples,
and started to look at the "TwoStageAmp"
provided by: Stuart Brorson from his website.

I tried to run this under ngspice, but it seems
that ngspice does not like the `file' command
and it seems to have trouble locating the 2N3904
spice model:

A snippet of TwoStageAmp.ckt file, showing
the `file=' commands:
===========================================
[...]
{
T 26600 56100 5 10 1 1 0 0
refdes=A1
T 27800 55800 5 10 1 1 0 0
model-name=2N3904
T 27000 55600 5 10 1 1 0 0
file=/usr/local/geda/share/models/spice/bjt/2N3904.mod
}
C 26500 54600 1 0 0 spice-include-1.sym
{
T 26600 55000 5 10 1 1 0 0
refdes=A2
T 27000 54700 5 10 1 1 0 0
file=/home/user/Desktop/gEDA/Projects/TwoStageAmp/Simulation.cmd
}
C 26500 53700 1 0 0 spice-directive-1.sym
{
T 26600 54100 5 10 1 1 0 0
refdes=A3
T 26600 53800 5 10 1 1 0 0
value=.TEMP 0 25 100
}
[...]
===========================================

I tried to run this under ngspice, and I tried
two different sources:
(1) source TwoStageAmp.ckt
     Uses `file='
(2) source output.net (already provided from zip file)
     Uses `.INCLUDE '
And both exhibit the same errors:
===========================================
$ ngspice
******
** ngspice-18 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please submit bug-reports to: ngspice-bugs at lists.sourceforge.net
** Creation Date: Sun Jan 11 17:45:58 EST 2009
******
ngspice 1 -> source TwoStageAmp.ckt
/home/user/Desktop/gEDA/TwoStageAmp/Simulation.cmd: No such file or 
directory

Circuit: *****************************************************

Error on line 13 : q1 vcoll1 vbase1 vem1 2n3904
     unable to find definition of model  - default assumed
Error on line 14 : q2 vcoll2 vbase2 vem2 2n3904
     unable to find definition of model  - default assumed
ngspice 2 ->
===========================================
$ more output.net
* Spice file generated by gnetlist
* spice-SDB version by SDB -- provides advanced
* spice netlisting capability.
* Documentation at http://www.brorson.com/gEDA/SPICE/
C2 2 Vbase2 2.2uF
R4 0 Vbase2 2.8K
R3 Vbase2 Vcc 28K
R8 Vcoll1 2 1
CE2 0 Vem2 1pF
RE2 0 Vem2 100
RC1 Vcoll1 Vcc 3.3K
Q2 VColl2 Vbase2 Vem2 2N3904
C1 1 Vbase1 2.2uF
.TEMP 0 25 100
.INCLUDE /home/user/Desktop/gEDA/TwoStageAmp/Simulation.cmd
.model 2N3904 NPN(IS=1E-14 VAF=100
+  Bf=300 IKF=0.4 XTB=1.5 BR=4
+  CJC=4E-12  CJE=8E-12 RB=20 RC=0.1 RE=0.1
+  TR=250E-9  TF=350E-12 ITF=1 VTF=2 XTF=3 Vceo=40 Icrating=200m 
mfg=Philips)
VCC Vcc 0 DC 15V
Vinput Vin 0 DC 1.6V AC 10MV SIN(0 1MV 1KHZ)
CE1 0 Vem1 1pF
Cout VColl2 Vout 2.2uF

$ ngspice
******
** ngspice-18 : Circuit level simulation program
** The U. C. Berkeley CAD Group
** Copyright 1985-1994, Regents of the University of California.
** Please submit bug-reports to: ngspice-bugs at lists.sourceforge.net
** Creation Date: Sun Jan 11 17:45:58 EST 2009
******
ngspice 1 -> source output.net
/home/user/Desktop/gEDA/TwoStageAmp/Simulation.cmd: No such file or 
directory

Circuit: * spice file generated by gnetlist

Error on line 12 : q2 vcoll2 vbase2 vem2 2n3904
     unable to find definition of model  - default assumed
Error on line 29 : q1 vcoll1 vbase1 vem1 2n3904
     unable to find definition of model  - default assumed
ngspice 2 -> quit
ngspice-18 done
===========================================

The next thing I tried was to run this under Gnu Spice GUI:

Gnu Spice GUI:
============================================
                    *************** PROCESS COMMAND ***************

/usr/bin/ngspice -n -b 
/home/user/Desktop/gEDA/Projects/TwoStageAmp/TwoStageAmp.ckt

                    *************** PROCESS RESPONSE **************


Circuit: *****************************************************

Error on line 13 : q1 vcoll1 vbase1 vem1 vcoll1 2n3904
     unable to find definition of model 2n3904 - default assumed
Error on line 14 : q2 vcoll2 vbase2 vem2 vcoll2 2n3904
     unable to find definition of model 2n3904 - default assumed
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000


Initial Transient Solution
--------------------------

Node                                   Voltage
----                                   -------
1                                            0
vbase1                                0.967069
2                                      9.17832
vbase2                                 1.25265
vem1                                  0.178179
vem2                                  0.440361
vcoll2                                   10.64
vout                                         0
vcoll1                                 9.17832
vcc                                         15
vin                                          0
vinput#branch                                0
vcc#branch                         -0.00711631


No. of Data Rows : 53

             *****************************************************
             Transient Analysis  Mon Jul 20 18:08:26  2009
--------------------------------------------------------------------------------
Index   time            v(vcc)          v(vin)         
--------------------------------------------------------------------------------
0    1.600000e-05    1.500000e+01    0.000000e+00   
1    3.200000e-05    1.500000e+01    0.000000e+00   
2    6.400000e-05    1.500000e+01    0.000000e+00   
3    1.280000e-04    1.500000e+01    0.000000e+00   
4    2.278000e-04    1.500000e+01    0.000000e+00   
5    3.276000e-04    1.500000e+01    0.000000e+00   
6    4.274000e-04    1.500000e+01    0.000000e+00   
7    5.272000e-04    1.500000e+01    0.000000e+00   
8    6.270000e-04    1.500000e+01    0.000000e+00   
9    7.268000e-04    1.500000e+01    0.000000e+00   
10    8.266000e-04    1.500000e+01    0.000000e+00   
11    9.264000e-04    1.500000e+01    0.000000e+00   
12    1.026200e-03    1.500000e+01    0.000000e+00   
13    1.126000e-03    1.500000e+01    0.000000e+00   
14    1.225800e-03    1.500000e+01    0.000000e+00   
15    1.325600e-03    1.500000e+01    0.000000e+00   
16    1.425400e-03    1.500000e+01    0.000000e+00   
17    1.525200e-03    1.500000e+01    0.000000e+00   
18    1.625000e-03    1.500000e+01    0.000000e+00   
19    1.724800e-03    1.500000e+01    0.000000e+00   
20    1.824600e-03    1.500000e+01    0.000000e+00   
21    1.924400e-03    1.500000e+01    0.000000e+00   
22    2.024200e-03    1.500000e+01    0.000000e+00   
23    2.124000e-03    1.500000e+01    0.000000e+00   
24    2.223800e-03    1.500000e+01    0.000000e+00   
25    2.323600e-03    1.500000e+01    0.000000e+00   
26    2.423400e-03    1.500000e+01    0.000000e+00   
27    2.523200e-03    1.500000e+01    0.000000e+00   
28    2.623000e-03    1.500000e+01    0.000000e+00   
29    2.722800e-03    1.500000e+01    0.000000e+00   
30    2.822600e-03    1.500000e+01    0.000000e+00   
31    2.922400e-03    1.500000e+01    0.000000e+00   
32    3.022200e-03    1.500000e+01    0.000000e+00   
33    3.122000e-03    1.500000e+01    0.000000e+00   
34    3.221800e-03    1.500000e+01    0.000000e+00   
35    3.321600e-03    1.500000e+01    0.000000e+00   
36    3.421400e-03    1.500000e+01    0.000000e+00   
37    3.521200e-03    1.500000e+01    0.000000e+00   
38    3.621000e-03    1.500000e+01    0.000000e+00   
39    3.720800e-03    1.500000e+01    0.000000e+00   
40    3.820600e-03    1.500000e+01    0.000000e+00   
41    3.920400e-03    1.500000e+01    0.000000e+00   
42    4.020200e-03    1.500000e+01    0.000000e+00   
43    4.120000e-03    1.500000e+01    0.000000e+00   
44    4.219800e-03    1.500000e+01    0.000000e+00   
45    4.319600e-03    1.500000e+01    0.000000e+00   
46    4.419400e-03    1.500000e+01    0.000000e+00   
47    4.519200e-03    1.500000e+01    0.000000e+00   
48    4.619000e-03    1.500000e+01    0.000000e+00   
49    4.718800e-03    1.500000e+01    0.000000e+00   
50    4.818600e-03    1.500000e+01    0.000000e+00   
51    4.918400e-03    1.500000e+01    0.000000e+00   
52    5.000000e-03    1.500000e+01    0.000000e+00   

CPU time since last call: 0.023 seconds.

Total CPU time: 0.023 seconds.

Total DRAM available = 2017.695312 MB.
DRAM currently available = 48.625000 MB.
Total ngspice program size = 8.011719 MB.
Resident set size = 3.016602 MB.
Shared ngspice pages = 503.000 kB.
Text (code) pages = 1.448242 MB.
Stack = 0 bytes.
Library pages = 5.442383 MB.


/home/user/Desktop/gEDA/TwoStageAmp/Simulation.cmd: No such file or 
directory
Warning: can't parse '0': ignored
===========================================

Can someone give me some guidance as to
what is going on?

Also, I would appreciate it if someone could point
me to a tutorial or sample project that shows how
one can do spice simulation!

Kind regards,
Dan



More information about the geda-user mailing list