Sunteți pe pagina 1din 3

Physics and Astronomy

PHY2028 SimSheet-01
Getting Started with Spice
Reminder
Performing simulations of circuits should be approached in the same systematic manner as the laboratory
exercises. In particular, all relevant information should be recorded in 'notebooks' at the time the exercises are
undertaken. These 'notebooks' may be electronic (e.g. PDF or Word documents) or paper-based. Source les
must be included (include print-outs or copy-and-paste), and a disk copy kept. Work must be turned-in (use
BART for paper or ELE upload for electronic submission) for marking by Monday 1430hrs and will normally
be marked and returned at the next class. Use the University ELE Server to submit e-notebooks and monitor
your marks.

Homework
Read the Quickstart Tutorial for Spice 3 and answer the following questions in your notes:
1. In a Spice source le:
a. Why is it not possible to specify a component on the rst line?
b. What is the purpose of a line starting with a '*' character?
c. How would you represent a 10Mohm resistor, shown on a circuit diagram as R6 connecting nodes
3 and 7?
d. What is the meaning of the line: L18 4 8 5.0E-3 ic=1m ?
2. Briey describe the current and voltage polarity conventions used by Spice.
3. There are no 'ammeter' components in Spice, so what is the recommended way to get it to determine the
current owing through a branch?
4. What command will cause Spice to calculate the quiescent state of a circuit?
5. Explain why you would expect to nd at least one line starting .subckt in the source le used to
analyse a circuit comprising three identical op-amps.

Getting your own version of Spice


There are many versions of Spice available, several of them free. Spice runs quite well on quite modest (by
today's standards) machines. Students taking PHY2028 and wanting a version of Spice to run on their own
personal computer should choose one that is compatible with Spice 3. There is a list of recommended versions
for common operating systems on the School's Recommended Software.

Practical Session
We will be using the MacSpice 35f 2.10 on multiuser Mac OS X machines. MacSpice is compatible with, and a
descendant of, Berkeley Spice 3f5. The original Spice built-in help command is rather primitive. The same
information (and more!) is available in the MacSpice User's Guide.
Locate MacSpice in the /Applications folder, drag its icon into your Dock. The rst time you launch MacSpice
it will create a working directory inside your Documents folder and will assume that any lename which does
not specify an absolute path refers to les in this folder. Locate TextWrangler in the /Applications folder.
Double-click its icon to start the application. If this is the rst time you have opened TextWrangler, the user
manual and registration window will open and, if so, close them.

Solving a Resistor Network


Copy the circuit diagram into your notebook. Make sure that all nodes and all components are labeled clearly.
Hand calculate the voltage at each node and the current owing in each branch of your circuit.
Milestone 1
The rst task will be to nd the voltage at node 3 of circuit 13.1 (above). This will involve creating a source-le
for Spice as follows:
1. Choose a unique lename for the circuit, in this case it will be called CW121004-02.CIR, and include it
on the diagram. (Use your initials for the rst 2 characters and the date for the next 6. e.g. the le
CW121004-02.CIR was the rst document I created on 16 November 2003.)

2. Launch MacSpice by clicking the icon you added to the dock (see above).

3. Download the le CW121004-02.CIR into the MacSpice working directory.
[Note: If you are using Safari for the Mac and have not changed its default behaviour, a mouse-down on
the link will download the le to the Downloads folder (or the desktop on older iMacs). To specify
another location, control-mouse-down on the link and select 'Download linked le' from the menu that
appears.]

4. Open CW121004-02.CIR with MacSpice and try, in order, the following interactive commands (links are
to the explanations in the Spice User's Guide):

show all
op
display
print all
print v(1)
print v(1,2)
print v(2,1)
show all

List these, and describe the effect of each command, in your notebook. The parameters listed by show
for the resistors and voltage source are explained in Appendix B of the userguide.

5. Record the values of node voltages and branch currents found by MacSpice in your notebook and check
they agree with the values you calculated above.
You can use the MacSpice edit command to edit the current source le, or to create a new one. For example, to
create a new circuit called CW061031.CIR:

MacSpice 8 -> edit CW061031.CIR

Observe how MacSpice interacts with TextWrangler, the 'helper application', when you save changes and close
the editor's document window.
Milestone 2
Draw and label the circuit (13.2) corresponding to the source le CW121004-03.CIR. Note: Spice 3 allows non-
numeric names for devices and nodes, except in the case of ground which is always '0'.
Milestone 3
Using what you have learned above, create your own Spice source le for circuit 13.3. Hence calculate the
power dissipated by the 1K resistor and the voltage at the output. Explain why the calculated power associated
with one of the voltage sources is negative.
Milestone 4

Circuit 13.4 is a cube with each side a 10K resistor. Use Spice to calculate the resistance between the diagonal
corners (A and B) of the cube. [Hint: connect one corner to ground, and the other to a voltage source.]
Milestone 5

Previous: PHY2028 Worksheets and Deadlines


Next: PHY2028 AC Circuit Analysis with Spice
See also: PHY2028 Introduction

S-ar putea să vă placă și