[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: getting started with geda simulation
On Sunday 28 October 2007, Kai-Martin Knaak wrote:
> Al Davis hinted me to gnucap. So I decided to give it a try.
> The utility gspiceui seems to be the glue between gschem and
> gnucap or ngspice. It compiled out of the box. Thanks to the
> geda CD image gnucap and ngspice were already installed.
> Unfortunately I got stuck with my first circuit --- A
> resistor and a cap that form a simple low pass. This what I
> did:
>
> 1) Draw circuit in gschem, using symbols from the standard
> lib. Named the nets that go in and out. Symbols I used are
> resistor-1.sym
> capacitor-1.sym
> gnd-1.sym
> vpulse-1.sym
>
> 2) Import gschem in gspiceui
> This seemed successful to me -- No warnings or error messages
> in the log window. The named nets appear in the list of
> nodes, the syms in the list of components.
>
> 3) When I try to create a simulation, I get the error
> message: No source component has been selected.
> However, the voltage source component V1 that corresponds to
> vpulse-1 had been selected in the components list.
>
> Did I miss something obvious? Is vpulse-1.sym not a proper
> source component? Any hints?
>
You are better off without gspiceui. It obscures what is going
on. GUI's make simple things simple and complex things
impossible.
Here's what I would do ...
First, you need to generate a netlist. Gnucap cannot yet read
gschem files, so you need to convert:
============
$$ gnetlist -g spice-sdb lowpass.sch
============
That generates a file "output.net". Look at it to see if it
makes sense.
============
$$ cat output.net
* gnetlist -g spice-sdb lowpass.sch
*********************************************************
* Spice file generated by gnetlist *
* spice-sdb version 4.28.2007 by SDB -- *
* provides advanced spice netlisting capability. *
* Documentation at http://www.brorson.com/gEDA/SPICE/ *
*********************************************************
*============== Begin SPICE netlist of main design ============
V1 in 0 pulse 0 1 1000n 1000n 10000n 100u 200u
R1 in out 1M
C1 0 out 100n
.end
============
Looks good. Assuming you want to run gnucap interactively, it's
ready. Let's go...
=========
$$ gnucap output.net
>> (signs on)
>> see what we have
gnucap> list
*********************************************************
* Spice file generated by gnetlist *
* spice-sdb version 4.28.2007 by SDB -- *
* provides advanced spice netlisting capability. *
* Documentation at http://www.brorson.com/gEDA/SPICE/ *
*********************************************************
*============== Begin SPICE netlist of main design ============
V1 ( in 0 ) PULSE iv= 0. pv= 1. delay= 1.u rise= 1.u fall= 10.u width= 100.u period= 200.u
R1 ( in out ) 0.001
C1 ( 0 out ) 100.n
gnucap>
>> looks good. Gnucap lists the parameters with names, You can
>> put it in the netlist that way too, I cannot remember the order.
>> You need to specify the "probes" .. what do you want to look at.
>> wait ... The resistor is .001 ohms?????
>> That's what you asked for. "1M" is 1 milli-ohm.
gnucap> print tran v(nodes)
gnucap>
>> You could list all the stuff you want to look at. For now,
>> I just want the voltage at all nodes.
>> Now lets run a transient analysis.
>> Spice has its own order for the arguments, different for
>> every command. I can not remember what the order is,
>> so gnucap also takes the order start, stop, step,
>> like good old Fortran. It takes the Spice order too, so'
>> you can use either.
gnucap> tran 0 400u 10u
#Time v(in) v(out)
0. 0. 0.
10.u 1. 0.99994
20.u 1. 1.0001
30.u 1. 0.99994
40.u 1. 1.0001
50.u 1. 0.99994
.....
>> Nice table, but I want a graph.
>> I recommend "gwave" as the viewer.
>> Run it again, this time save the results in a file.
gnucap> tran 0 400u 10u >z
>> Now run gwave on that file
gnucap> !gwave z &
gnucap>
>> You play with it there.
>> The time stepping is coarse, because it printed with the
>> steps I asked for. I want them all, even the internal ones.
gnucap> tran 0 400u 10u trace all >z
gnucap> !gwave z &
gnucap>
>> Now it has all the steps, so the waveform is better.
Here's a start. You can play from here.
The time stepping I specified is obviously bad, because
the pulse has a rise time of 1us, and I asked for 10us steps.
It used reasonable steps internally, but didn't print them all.
"trace all" makes it print all of the steps. If you are plotting,
this is usually what you want.
There is also some numerical jitter (.99994 .. 1.0001 ..)
hinting that you need to tighten the tolerance if you care.
You have a time constant of 100 ps.
OH!!! you really wanted 1 MEGohm!!
gnucap> modify r1=1meg
gnucap> tran 0 400u 10u trace all >z
gnucap> !gwave z &
When you specify component values in Spice, M means milli.
If you want meg, as in megohms, you need to say "meg".
Don't blame me for this. It's Spice compatible.
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user