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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
<html>
<body>
<h1> 06_passive_ac: freqency domain simulation: ac </h1>
<h2> Scope </h2>
<p>
In this simulation we are going to look at how a multi-stage RC filter behaves
when stimulated with sine waves of various frequencies.
<h2> The schematics </h2>
<p>
The single-sheet schematic contains the filter, the voltage source and
the spice command symbol.
<p>
<center>
<a href="06_passive_ac.rs"><img src="06_passive_ac.svg" width=400px></a>
<br>Click the image to get the sch-rnd sheet</center>
<p>
<h2> SPICE: what an ac simulation is </h2>
<p>
In the ac analysis simulation a DC solution is calculated first
and then a small signal sinusoidal stimulus is applied over a range of
frequencies. The result is typically a graph with frequency on the X axis
and gain or phase on the Y axis. The AC analysis is often used to get
a transfer function.
<h2> Preparing for simulation </h2>
<h3> V1 </h3>
<p>
In our example, V1 specifies a 1V AC signal with a DC component of 0V
on the <i>in</I> network. The syntax for this is (see in V1's spice/params):
<pre>
dc 0 ac 1
</pre>
<p>
The frequency of the ac component is not specified because that will be
varied over a range by the analysis command.
<h3> Raw spice commands </h3>
<p>
It contains the following script:
<pre>
ac dec 10 1 100k
settype decibel out
plot vdb(out) xlimit 1 100k ylabel 'small signal gain'
settype phase out
plot cph(out) xlimit 1 100k ylabel 'phase (in rad)'
let outd = 180/PI*cph(out)
settype phase outd
plot outd xlimit 1 100k ylabel 'phase (in deg)'
</pre>
<p>
The first line instructs spice to do the "ac analysis" in decade variation
mode (dec 10), to get a decade logarithmic output with 10 points in each
decade. It then specifies the range of interest for the frequencies:
anything between 1 Hz and 100 kHz.
<p>
Then come three plots. The first is the output voltage in decibels, on
a logarithmic Y scale, then the phase shift of the circuit, both in radians
and in degrees.
<h2> Export and run ngspice </h2>
<p>
Because of the plot commands the output is a set of drawings (if ngspice is run
on X): three graphs with one curve each.
<p>
<img src="06_passive_ac1.png">
<p>
<img src="06_passive_ac2.png">
<p>
<img src="06_passive_ac3.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 ac vdb(out) zp(out)
op
ac dec 10 1 1000k > 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 the file is in spice
syntax. Then run <i>gnucap 06_passive_ac.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/06_passive_ac.rs">gnucap-modified schematic is also available.</a>
<h3> xyce </h3>
<p>
TODO
|