first order gscehm schematic and spice

Hi,

I have recently started to learn spice (using gEDA and gschem and ngspice). Just to get feel of things, I am trying out this little problem whose netlist file is:

  • gnetlist -v -g spice-sdb -o eg.net eg.sch
*********************************************************
  • Spice file generated by gnetlist *
  • spice-sdb version 10.9.2004 by SDB -- *
  • provides advanced spice netlisting capability. *
  • Documentation at
    formatting link
    *
********************************************************* V1 1 0 5 R4 0 4 10 R3 3 4 40 Iswt 5 2 0 R2 0 2 50 G1 3 4 4 0 0.375 R1 1 2 75 C1 5 0 .025 ic=2V Vswt 3 5 0 .END *--------------------------------------------------------

(gschem file is given in the PS below). I am using this example to practice two main things:

  1. The simulated switch (using a current source and a voltage source). In the given circuit, Iswt=0 means the 'switch' between the two nodes is open and Vswt=0 means that switch is closed.
  2. Using initial conditions on stogare elements.

If I do the simulation on this circuit and plot v(4), is comes out to be negative exponentially increasing voltage value. However, if I do this analytically, I obtain a relationship of v(at node 4) = 0.4 e^(0.4t) which is exponentially increasing. I am not sure where my mistake is. Could anybody confirm either way.

Here are the commands I use in ngspice: ngspice 330 -> source eg.net ngspice 331 -> tran .01 1 uic ngspice 332 -> plot v(4)

The gschem file is give in the PS.

thanks,

->HS

PS: eg.sch is the gschem file I made in gEDA. $> cat eg.sch v 20050313 1 C 51200 58900 1 0 0 resistor-1.sym { T 51500 59200 5 10 1 1 0 0 1 refdes=R1 T 51500 58700 5 10 1 1 0 0 1 value=75 } C 53800 59700 1 0 0 resistor-1.sym { T 53900 59900 5 10 1 1 0 0 1 refdes=R3 T 54400 59900 5 10 1 1 0 0 1 value=40 } C 55500 57500 1 90 0 resistor-1.sym { T 55200 58200 5 10 1 1 180 0 1 refdes=R4 T 55000 57800 5 10 1 1 0 0 1 value=10 } C 52400 57200 1 90 0 resistor-1.sym { T 52200 57900 5 10 1 1 180 0 1 refdes=R2 T 52000 57400 5 10 1 1 0 0 1 value=50 } C 52900 58100 1 270 0 capacitor-3.sym { T 53400 57700 5 10 1 1 0 0 1 refdes=C1 T 53200 57300 5 10 1 1 0 0 1 value=.025 ic=2V } C 53700 58800 1 0 0 hs-vccs-1.sym { T 53850 59075 5 10 1 1 0 0 1 refdes=G1 T 53900 58700 5 10 1 1 0 0 1 value=4 0 0.375 } C 50800 58100 1 270 0 voltage-3.sym { T 50700 57900 5 10 1 1 0 0 1 refdes=V1 T 50800 57300 5 10 1 1 0 0 1 value=5 } N 51000 57200 51000 56800 4 { T 51000 57200 5 10 0 1 0 0 1 netname=0 } N 51000 56800 55400 56800 4 N 55400 56800 55400 57500 4 N 51000 58100 51000 59000 4 { T 51000 58100 5 10 0 1 0 0 1 netname=1 } N 51000 59000 51200 59000 4 N 52100 59000 52700 59000 4 { T 52100 59000 5 10 0 1 0 0 1 netname=2 } N 53500 59000 53700 59000 4 { T 53300 59000 5 10 0 1 0 0 1 netname=3 } N 53700 59000 53700 59800 4 N 53700 59800 53800 59800 4 N 54700 59800 55400 59800 4 { T 54700 59800 5 10 0 1 0 0 1 netname=4 } N 55400 59800 55400 58400 4 N 52300 58100 52300 59000 4 N 52300 57200 52300 56800 4 N 53100 57200 53100 56800 4 C 52200 56500 1 0 0 gnd-1.sym N 54600 59000 55400 59000 4 C 53300 59000 1 270 0 voltage-3.sym { T 53600 58200 5 10 1 1 0 0 1 refdes=Vswt T 53200 58300 5 10 1 1 0 0 1 value=0 } C 52900 58100 1 90 0 current-1.sym { T 53100 59000 5 10 1 1 180 0 1 refdes=Iswt T 52800 58200 5 10 1 1 0 0 1 value=0 } N 52700 58100 53500 58100 4 { T 53100 58100 5 10 0 1 0 0 1 netname=5 }

In the above file, hs-vccs-1.sym symbols is: $> cat ~/gaf/my-gschem-symbols/hs-vccs-1.sym v 20050313 1 P 0 200 200 200 1 0 0 { T 100 250 5 8 0 1 0 0 1 pinnumber=1 T 100 250 5 8 0 0 0 0 1 pinseq=1 } P 925 200 725 200 1 0 0 { T 725 250 5 8 0 1 0 0 1 pinnumber=2 T 725 250 5 8 0 0 0 0 1 pinseq=2 } T 600 1000 5 10 0 0 0 0 1 device=CURRENT_SOURCE L 200 200 250 200 3 0 0 0 -1 -1 L 675 200 725 200 3 0 0 0 -1 -1 L 350 200 550 200 3 0 0 0 -1 -1 L 550 200 500 250 3 0 0 0 -1 -1 L 550 200 500 150 3 0 0 0 -1 -1 T 150 275 8 10 1 1 0 0 1 refdes=G? L 250 200 460 340 3 0 0 0 -1 -1 L 460 340 675 200 3 0 0 0 -1 -1 L 250 200 460 60 3 0 0 0 -1 -1 L 460 60 675 200 3 0 0 0 -1 -1

Reply to
H.S.
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.