1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
<html>
<body>
<h1> 22_custom_sym: creating a custom symbol </h1>
<h2> Scope </h2>
<p>
Create a custom diode symbol with an embedded (inline) model card.
<h2> The schematics </h2>
<p>
<center>
<a href="22_custom_sym.rs"><img src="22_custom_sym.svg" width=400px></a>
<br>Click the image to get the sch-rnd sheet</center>
<h2> Preparing for simulation </h2>
<p>
Draw the symbol the usual way, using lines, rectangles and {p t}
for placing terminals; select the objects, convert selection to symbol;
set the usual attributes (e.g. name on the symbol and on the terminals).
<p>
For spice simulation, set the following attributes:
<ul>
<li> symbol attribute <b>spice/prefix</b> to <b>D</b>: for the simulation
this is a diode; this attribute lets the sheet name the symbol U1
still show spice a D component by prefixing the name with D_.
<li> symbol attribute <b>spice/model_card</b> to
<b>.MODEL my_diode D (IS=2f RS=3.4 N=2.2)</b>:
this is how the model is specified inline, within the symbol, not
relying on external libs
<li> terminal attribute <b>spice/pinnum</b>; the positive (anode) terminal
should be 1, the negative (cathode) should be 2.
</ul>
<p>
The inline model card option is useful for one-off symbols or for an easy
and quick way of tuning model parameters in test-bench schematics.
<h3> Raw spice commands </h3>
<p>
Similar to those used in <a href="10_bjt_amp_tr.html">10_bjt_amp_tr</a>.
<h2> Export and run ngspice </h2>
<p>
Running ngspice the usual way on the export yields the following graphs:
<p>
<img src="22_custom_sym.png">
<h2> Using other implementations </h2>
<h3> gnucap </h3>
<p>
Gnucap uses a different command syntax. Modify the spice command symbol's
spice/command attribute to:
<pre>
print tran v(out) v(in)
tran 1u 4m > plot.txt
</pre>
<p>
After the export, write the single word <b>spice</b> in the first line of the
file (e.g. using a text editor), otherwise gnucap won't know that the file is
in spice syntax. Then run <i>gnucap 22_custom_sym.cir</i> and it will dump a text
table to plot.txt that can be plotted using a suitable utility, e.g. gnuplot.
<p>
The <a href="gnucap/22_custom_sym.rs">gnucap-modified schematic is also available.</a>
<h3> xyce </h3>
<p>
TODO
|