User Tools

Site Tools


geda:circuit_simulation_improvements

This is an old revision of the document!


Circuit simulation improvements in gschem

Rationale

Using gschem as a circuit simulation (ngspice or gnucap) frontend is not easy for novice users. A new user would like to do the following things inside gschem:

  • specify what kinds of simulations should be run
  • specify which voltages and currents should be plotted
  • start the simulation

The simulation runs and the postprocessing may be in an external programm that is triggered by IPC.

There are some graphical frontends around but they can't solve all of the above problems

All frontends have the problem that you can not point to the net you'd like to see. You need to know the netname of the node.

Draft

Let's assume we only want to make tiny changes to gschem and libgeda so that we can at least set some probes and ran a simulation.

The probes

Current probes can be ordinary dc voltage sources with 0V. The easy way to insert that probe would be a symbol with two pins like an normal ampere meter. If we'd like to set a current probe to an end of a pin we need a netlister that detects that current probe and replaces it with our “ampere meter”. If we use a voltage source as an ampere meter the netlister does not need to know the netnames inside the schematic. All 0V voltage sources with a special device name are current probes.

Voltage probes may be current sources with 0A. The second pin of the current source is tied to GND with a net attribute. Thus again the netlister does not need to know the netnames as it can use that net that is connected with that special current sources. Like above a voltage source could be a special (graphical) symbol that is detected by a netlister.

Voltage and current sources

Specifying the parameters of sources is not that easy. Currently they are stored inside the “value” attribute of the symbol. eg. “value=pulse 0 1 10n 10n 100n 1u 2u”. These settings needs to match the spice attributes “pulse(V1 V2 TD TR TF PW PER)”.

A dialog would be nice that prompts the user for the named attributes and not only for the value string.

A modified edit attribute (ee) command could take care of voltage and current source devices and trigger a different property dialog for that sources. Currently the multiattrib edit dialog is triggered.

The simulations

How can we store a simulation inside gschem.

To store one simulation we can use a symbol with the devicename “SIMULATION”. All options that define one simulation are stored as attributes attached to that object.

  • kind of simulation (dc, ac, tran, …)
  • simulator options
  • the simulator? (can we run the same circuit with two simulators in one step?)
  • simulation parameters (global parameters, temperature, …)
v 20061020 1
C 41500 49200 1 0 0 spice-directive-1.sym
{
device=spice_simulation_block
refdes=A1
simulation_name=random name
simulation_active=1
simulation_type=DC 0V 1V 0.1V
parametric_simulation1=V1 lin 0 5 0.1
parametric_simulation2=R1.value lin 10k 100k 10k
option_TNOM=100 Deg
option_ABSTOL=1e-3
global_param1=???
global_param2=???
}

There may be many simulation objects inside a single schematic.

To store additional libraries we can either use an include card or using a “LIBRARY” symbol that contains all libraries either as:

  • a multiline attribute
  • multiple attached library attributes to the LIBRARY symbol

There should be a distinction between global, user and local libs. global and user libs may be specified by a gafrc or a new spicerc configuration file.

Creating a simulation dialog inside gschem

Lets assume anything we need to add simulation support to gschem is a single dialog.

  • It would have a list of simulations (listview with enable/disable buttons and simulation names)
  • It would have some icons to add the probes.
  • It may have buttons for the most common symbols: resistor, capacitor, inductor, diode, … [R,C,L,D,M,E,F,G,H..]
  • It would have some dialog elements to do the spice settings
  • It would have a simulate and a close button
  • Some additional buttons like: Copy simulation, Remove simulation, general options…

When creating that dialog all simulation objects are collected into the simulation list (listview with enable/disable checkbutton)

When changing the settings the attributes of the assosiated simulation object are changed.

The option dialog

What kind of options do we need for that dialog? And Why?

The probes that we have placed can be used to tell the simulator the variables that we like to save or tell the plotting application which plots we'd like to see. This is something completely different, we need an option for that:

  • plot all marks and only save the corresponding node voltages
  • plot all marks but save all node voltages and currents (through voltage sources)
  • only save voltage nodes of the current schematic level or store subcircuit node voltages, too.

Invoking the simulation

The simulation button of the dialog should lead to the following actions:

  • save the schematic (ask the user or use a temporary file?)
  • create a netlist using gnetlist
  • create simulation files and include the netlist (can this be done with gnetlist too?)
  • execute the simulation startup script (guile, sh, …)

That startup script may even call a scheduler that can take lots of large simulations.

Appendix

A current probe symbol (draft)

v 20061020 1
P 0 0 200 200 1 0 0
{
T 100 0 5 10 0 1 0 0 1
pintype=pas
T 0 100 5 10 0 1 0 0 1
pinseq=1
T 0 100 5 10 0 1 0 0 1
pinnumber=1
T 0 100 5 10 0 1 0 0 1
pinlabel=1
}
V 300 300 150 3 10 0 0 -1 -1 0 -1 -1 -1 -1 -1
L 300 200 240 360 3 10 0 0 -1 -1
L 300 200 360 360 3 10 0 0 -1 -1
T 0 500 9 10 0 0 0 0 1
device=VOLTAGE_PROBE
T 200 50 9 6 1 1 0 0 1
refdes=I_VP?
T 0 700 9 10 0 0 0 0 1
net=GND:2
T 0 900 9 10 0 0 0 0 1
value=DC 0A

A voltage probe symbol (draft)

v 20061020 1
P 0 200 150 200 1 0 0
{
T -150 50 5 10 0 1 0 0 1
pintype=pas
T 50 250 5 10 0 1 0 0 1
pinseq=1
T 50 250 5 10 0 1 0 0 1
pinnumber=1
T 50 250 5 10 0 1 0 0 1
pinlabel=1
}
V 300 200 150 3 10 0 0 -1 -1 0 -1 -1 -1 -1 -1
L 300 300 380 140 3 10 0 0 -1 -1
L 300 300 220 140 3 10 0 0 -1 -1
T 0 500 9 10 0 0 0 0 1
device=CURRENT_PROBE
T 200 370 9 6 1 1 0 0 1
refdes=V_IP?
P 600 200 450 200 1 0 0
{
T 500 50 5 10 0 1 0 0 1
pintype=pas
T 500 250 5 10 0 1 0 0 1
pinseq=2
T 500 250 5 10 0 1 0 0 1
pinnumber=2
T 500 250 5 10 0 1 0 0 1
pinlabel=2
}
L 240 180 360 180 3 10 0 0 -1 -1
T 0 700 9 10 0 0 0 0 1
value=DC 0V

Another current probe symbol used by Kurt Peters

v 20061020 1
T 700 650 8 10 1 1 0 0 1
refdes=VAM?
T 700 850 5 10 1 1 0 0 1
device=Ammeter
T 700 1050 5 10 0 0 0 0 1
footprint=none
T 700 1250 5 10 0 0 0 0 1
numslots=0
T 700 1450 5 10 0 0 0 0 1
description=ammeter for spice
P 300 1200 300 900 1 0 0
{
T 350 1000 5 8 1 1 0 0 1
pinnumber=1
T 350 1000 5 8 0 1 0 2 1
pinseq=1
T 400 850 9 8 1 1 0 5 1
pinlabel=+
T 300 700 5 8 0 1 0 5 1
pintype=pwr
}
P 300 0 300 300 1 0 0
{
T 350 100 5 8 1 1 0 0 1
pinnumber=2
T 350 100 5 8 0 1 0 2 1
pinseq=2
T 300 500 5 8 0 1 0 3 1
pintype=pwr
T 300 300 5 10 1 1 0 0 1
pinlabel=-
}
L 300 400 400 500 3 0 0 0 -1 -1
L 200 500 300 400 3 0 0 0 -1 -1
T 700 450 5 10 0 1 0 0 1
value=DC 0V
L 300 400 300 800 3 0 0 0 -1 -1
L 100 800 500 400 3 0 0 0 -1 -1
B 0 300 600 600 3 0 0 0 -1 -1 0 -1 -1 -1 -1 -1
L 200 800 100 800 3 0 0 0 -1 -1
L 100 700 100 800 3 0 0 0 -1 -1
geda/circuit_simulation_improvements.1329768896.txt.gz · Last modified: 2014/04/18 10:59 (external edit)