File: 12_bjt_amp_ac.html

package info (click to toggle)
sch-rnd 1.0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 17,696 kB
  • sloc: ansic: 119,120; awk: 1,502; makefile: 1,421; sh: 1,404; yacc: 905; lex: 172; xml: 160
file content (98 lines) | stat: -rw-r--r-- 2,806 bytes parent folder | download | duplicates (2)
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
<html>
<body>
<h1> 12_bjt_amp_ac: pinout with spice/portmap </h1>

<h2> Scope </h2>
<p>
In this simulation we are going to look at a single-transistor amplifier
in frequency domain to verify how it amplifies a sine waves. Compared to
the <a href="10_bjt_amp_tr.html">trans variant</a> the only difference is
how we specify the transistor pinout and what spice commands we use for the
AC simulatuin

<h2> The schematics </h2>
<p>
Largely the same as <a href="10_bjt_amp_tr.html">trans variant</a>.
<p>
<center>
<a href="12_bjt_amp_ac.rs"><img src="10_bjt_amp_tr.svg" width=600px></a>
<br>Click the image to get the sch-rnd sheet; NOTE: the actual value of V1
has been changed from SINE() to a dc/ac combo.</center>
<p>

<h2> Preparing for simulation </h2>

<h3> Q1 </h3>
<p>
This example demonstrates using spice/portmap to set the pinout: the
stock spice/pinnum attributes has been manually removed from Q1 terminals and
a portmap attribute, array type, added to the Q1 symbol. The portmap is:
<pre>
{C->spice/pinnum=1}
{B->spice/pinnum=2}
{E->spice/pinnum=3}
</pre>
<p>
Since the attribute is called spice/portmap, it does not interfere with
the normal portmap attribute (installed by devmap in our example) and it
affects the spice workflow only.

<h3> V1 </h3>
<p>
V1 is generating the input sine wave on the <i>in</I> network.
The simulator will reconfigure it while sweeping the frequency for the
ac analysis.

<h3> V2 </h3>
<p>
V2 is an 5V DC power supply for Vcc:
<pre>
dc 5
</pre>


<h3> Raw spice commands </h3>
<p>
It contains the following script:
<pre>
ac dec 10 1 1000k
settype decibel out
plot vdb(out) xlimit 1 1000k ylabel 'small signal gain'
settype phase out
plot cph(out) xlimit 1 1000k ylabel 'phase (in rad)'</pre>
<p>
This runs an ac analysis between 1 Hz and 1 MHz with 10 points in every decade,
then plot gain and phase.

<h2> Export and run ngspice </h2>
<p>
Running ngspice the usual way on the export yields the following graph:
<p>
<img src="12_bjt_amp_ac1.png">
<p>
<img src="12_bjt_amp_ac2.png">

<h2> Using other implementations </h2>
<h3> gnucap </h3>
<p>
<b>This may not work with gnucap; error message: <i>open circuit: internal node 2</i> </b>
<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 a single word <b>spice</b> in the first line of the
file (e.g. using a text editor), else gnucap won't know the file is in spice
syntax. Then run <i>gnucap 12_btj_amp_ac.cir</i> and it will dump a text
table to plot.txt that can be plotted using e.g. gnuplot. Both traces are
included in the same file.
<p>
The <a href="gnucap/12_btj_amp_ac.rs">gnucap-modified schematics is also available.</a>

<h3> xyce </h3>
<p>
TODO