AIM-Spice Introduction - University of Hartford`s Academic Web Server

advertisement
AIM-Spice for ECE361 Electronics
University of Hartford – CETA
Simulation can provide insight to students taking an introductory course in electronics. Here we will
use a package called AIM-Spice. As of this writing, we are using AIM-Spice version 5.5. Briefly
consider the strengths of AIM-Spice.
•
•
•
•
•
•
AIM-Spice package is a simple and effective simulation tool
AIM-Spice uses traditional Spice like circuit descriptions but without control records
AIM-Spice will simulate circuits that our students are likely to encounter
For more complicated circuits, AIM-Spice can use a generated circuit description
The student/evaluation version of AIM-Spice is available at no charge
Producing a Spice description of a circuit is a useful pedagogical exercise
Installing AIM-Spice at Home
You can install the Windows evaluation version of AIM-Spice on your home computer. Details of how
to install AIM-Spice are publisher website. In a nutshell, you will download and uncompress a zip file
and run the corresponding setup program.
http://www.aimspice.com/download.html
Once AIM-Spice is installed, a new entry will be in your program start menu
Using AIM-Spice and Files
AIM-Spice is relatively light in terms of accessing files. We strongly suggest that you either use the
college file server (the Z drive) or use a Flash memory stick. Using a Flash memory stick makes it
easy to work on your designs either at home or in the college. Flash memory sticks are inexpensive
and are sometimes available at no charge.
AIM-Spice Example
Use your mouse to enter the start menu
Start => Programs => AIM-Spice => AIM-Spice
Inside the AIM-Spice window is an untitled window. If you would prefer to use a different text editor,
then please read the section 'The .cir File and Using a Different Text Editor' and then return here. In
continuing, with your mouse, left click:
File => Save As
In the 'Save As' pop-up window, navigate to a folder to save the file. I am using a memory stick which
is mounted as the E: drive.
Click the 'New Folder' icon to make sub-folders as necessary. I created the following path of folders
which will contain the file divider01.cir
E:\AIM-Spice\examples\divider01.cir
Click 'Save.' Note that the title of the window has changed to the given path. Inside the window, type
in the following text, which we will discuss. To begin, an asterisk indicates a comment line and an
exclamation mark is used to start a comment in a line.
* divider01.cir - Your Name - The Date
* A simple divider example
R1 1 2 1K
R2 2 0 1K
! Node zero is ground
V1 1 0 DC 10V
* end of divider01.cir
To interpret rest, compare the text to the following schematic which describes that same circuit. As
with a schematic, the text description uses networks or wires to interconnect components.
Voltage divider circuit
With Spice the network named '0' is ground and there must always be a path for DC current to flow
from every network or node, to ground. The lines starting with 'R' describe the resistors in the circuit.
The following format is used here, for more detail refer to the AIM-Spice Reference Manual, which is
attached in the Help menu.
Rname node+ node- value
The 'R' indicates that the component is a resistor. The 'name' is a number or text that identifies this
resistor among others. The node+ and node- identify the networks that attach to the positive and
negative pins, respectively in that current flows in a positive direction from the positive pin to the
negative pin. The line starting with 'V' describes an independent voltage source, which in this case
provides ten Volts DC power.
Vname node+ node- value
Next, an important comment, for every circuit description that you perform as an assignment, as in the
above file, I require that you have a comment block that contains at least the following information.
•
•
•
•
The name of the file
Your name
The date
A description of what the file describes or what the description is for
The closing comment line at the end of the file is optional, it only indicates the end of the file.
Text Files and Schematic Capture Tools
A description like that in divider01.cir, above is also called a 'Spice deck' as early versions of Spice
actually used punched cards which were stored in a stack, like a deck of playing cards. AIM-Spice
however is quite different, besides using files, the Spice circuit description do not include simulation
control statements, hence the file above describes only the actual circuit. With AIM-Spice, the details
of the simulation and output are handled with point and click type interactive tools.
For schematic capture capability, you can use a package such as KiCad to draw a schematic to produce
a Spice circuit description text file. I have a tutorial in the supplemental notes of my web-page that
describes how to use KiCad in this way. Other packages that include schematic capture capability as
well as simulation tools include ORCad / PSPice, Multisim, and many others.
Operating Point Simulation
To simulate the divider circuit, perform what is called an operating point simulation. Either click on
the 'Operating Point' simulation button, use the mouse to select the following, or use the hot-key
combination 'Control-shift-O'.
Operating point simulation button
Analysis => DC Analysis => Operating Point
After a brief moment the 'Simulation Statistics' window appears, click 'OK' and the simulation results
appear in the form of a spreadsheet. The voltage at each node and the current through the voltage
source is listed. Given that the current for all components is assumed to flow in a positive direction
from positive pins to negative pins, the voltage source current is reported as being negative.
Operating point simulation results
Low-Pass Filter
We next consider the frequency analysis and transient analysis of a low-pass filter. The following
circuit involves a single capacitor and a single resistor. This circuit is a first order low-pass RC filter.
First order low pass RC filter
The corner frequency, rise time, and time constant are well known characteristics of the low-pass filter.
Time Constant:
Corner Frequency:
Rise Time:
= RC =0.16 ms
1
F c=
=994.72Hz≈1 kHz
2 RC
0.35
T r=
≈0.35 ms
Fc
The corresponding Spice text description follows. The description of the capacitor is similar to that of
the resistor. In some cases a simulation may call for initial conditions, that is the voltage present at
time zero. The comment shows the additional term used to give the initial Voltage for a capacitor,
otherwise the initial Voltage is assumed to be zero Volts. While AIM-Spice doesn't really know what
Ohms or Farads are, it does know that K and M mean 103 and 106, respectively, and that u, n, and p
mean 10-6, 10-9, and 10-12, respectively.
* lowpass01.cir - Your name - The date
* A first order low-pass RC filter
R1 1 2 1.6K
C1 2 0 0.1uF ! 'IC = val' for initial cond.
V1 1 0 AC 1V PULSE(0V 1V)
* end of lowpass01.cir
The behavior of the voltage of the voltage source depends on the analysis performed. With a frequency
analysis the given AC value is used. In performing a transient analysis, the given pulse value is used.
Frequency Analysis
A frequency analysis essentially assumes sinusoidal steady state conditions. To start a frequency
analysis have the window containing the corresponding .cir file in focus and either click the AC
Analysis button or select the following:
AC analysis button
Analysis => AC Analysis...
The cutoff frequency for the filter is approximately 1kHz. In the 'AC Analysis Parameters' pop-up
window, select or enter the following values:
•
•
•
•
Sweep: DEC – this will sweep the frequency by decades
Points/decade: 10 – will be plenty
Start Frequency: 1E1 – ten Hertz or two decades before the corner
End Frequency: 1E5 – one hundred kilo Hertz, or two decades after the corner
Click, 'Run' and in the 'Select Variables to Plot,' select the following
• Variables in circuit: v(2) – the output
• AC Options: Magnitude
Click, OK and the Frequency analysis plot window appears. Click the 'Perform the analsysis' button.
'Perform the analysis' button
In the 'Simulation Statistics' window click 'OK.'
AIM-Postprocessor
While AIM-Spice has facilities for plotting simulation results, the AIM-Postprocessor is much more
powerful in this regards and includes the following features:
•
•
•
•
•
•
The ability to plot the sum, difference, derivative, integral, and mathematical functions of
circuit variables
The Fast-Fourier transform (FFT)
Graphical formatting capabilities
Cursors to select values on a plot and calculate differences
The ability to import and export data
The ability to print out a plot
Double click in the center of the simulation plot window to open the AIM-Postprocessor along with the
simulation results.
• To the left of the plot, double click on the text 'Y Axis Title' and in the pop-up window enter
'Magnitude' then click OK
•
Click the Y axis to the left and set or enter the following then click OK
◦ Axis Type: Logarithmic
◦ Base: 10
◦ Minimum: 1E-002
•
Click the X axis below the plot and set or enter the following then click OK
◦ Axis Type: Logarithmic
◦ Base: 10
◦ Maximum: 1E+005
•
Either click the 'Add Text' button, press the control-T hotkey pair, or select:
'Add Text' button
◦ Graph => Add Text
Click above the plot and in the pop-up window, enter the following, then click OK
'Low-Pass Filter – Your Name- The Date'
Double click to select and position the text above the window then click left to position the text. At this
moment you can print out the plot or save the plot in a file. The post processor include cursors for
taking measurements from the plot.
Magnitude versus frequency plot
Transient Analysis
A transient analysis predicts the actual circuit values in time by repeatedly solving for all the circuit
values. Before performing such an analysis it is necessary to pick the simulation time step size and the
final simulation time. Here we consider the rise time and time constant. To measure the rise time, the
step size must be small in comparison, perhaps ten to one hundred times smaller. The value 10usec is
thirty five times smaller than the rise time. Running the simulation for five time constants of simulated
time will allow the circuit come close to settling.
Time Constant:
Rise Time:
Time Step Size:
Simulated Time:
= RC =0.16 ms
0.35
T r=
≈0.35 ms
Fc
T s=10 us
T x =5 =800 us
To perform a transient analysis, either select the following, click the transient analysis button, or press
the control-T hot key combination.
Analysis => Transient Analysis
'Transient Analysis' button
In the 'Transient Analysis Parameters' window, enter the following values then click 'Run'.
•
•
Stepsize: 10E-6
Final Time: 800E-6
In the 'Simulation Statistics' window click 'OK', click the 'Perform the analysis' button, and double click
in the simulation output window to open the AIM-Postprocessor program. As before, make the
following changes:
•
•
Change the title for the Y axis to “Output Voltage”
Insert text for a title, “Step Response – Your Name – The Date”
Place the cursors at the 10% and 90% positions and measure the corresponding rise time.
To learn more about AIM-Spice and its capabilities, be sure to examine the help materials that are
installed with AIM-Spice. Start by clicking 'Help'.
The .cir File and Using a Different Text Editor
The following considers how to use a different text editor. AIM-Spice uses the .cir file in dynamic
fashion, by inserts text before and after your circuit description and hiding that inserted text from you.
As you perform the various simulations, the corresponding simulation parameters are saved in the .cir
file. Without the inserted text, AIM-Spice will treat the .cir file as a more traditional Spice file, not
allowing you to use the point-and-click controls. In some cases such behavior is desirable, allowing
AIM-Spice to seamlessly perform more traditional Spice analysis.
But suppose that you have a favorite text editor that you want to use. Given the dynamic nature of an
AIM-Spice .cir file, is is undesirable to use another text editor to directly edit the file. Rather, you can
use an include statement to use a more traditional type Spice file. Here I use a file name with the .ckt
extension. To be able to use a different text editor, perform the following:
•
In AIM-Spice, create a blank new .cir file
File => New
•
Enter into the file the following text. The first line in the following is used as the simulation
title, so be sure to include your name and the date in this file. I will expect the file name, your
name, the date, and a description to also be at the top of your included .cir file.
* divider01_aim.cir - Your Name - The Date
.include divider01.cir
•
Save the new .cir file as 'divider01_aim.cir'
File => Save As
•
At this point, you can either use another text editor, or the AIM-Spice text editor to produce
the .ckt file. With AIM-Spice do the following:
File => New ASCII File
•
Save the new text file as divider01.aim
File => Save As
At the top of every .cir file I will expect the file to start with a comment block containing the file name,
your name, and the date. An included .cir file will also contain a brief description of the circuit, as with
the examples presented earlier in this document.
So now the divider example file will look like the following:
* divider01.cir - Your Name - The Date
* A simple divider example
R1 1 2 1K
R2 2 0 1K
! Node zero is ground
V1 1 0 DC 10V
* end of divider01.cir
It is important to note that the ‘.end’ statement found at the end of traditional SPICE files must not be
used here as the statement causes AIM-Spice to perform in an incorrect fashion. At this point, you can
continue with AIM-Spice as you did before.
References
•
AIM-Spice homepage
http://www.aimspice.com/
•
AIM-Spice tutorial – this document
http://uhaweb.hartford.edu/jmhill/suppnotes/Spice/AIM-Spice5x5-intro01.pdf
•
KiCad tutorials
http://uhaweb.hartford.edu/jmhill/suppnotes/KiCadDia/index.htm
Version and Copyright Notice:
This document corresponds to AIM-Spice version 5.5. While this document is written for students at
the University of Hartford, anyone can make copies, but only of this document as-is, for educational
use, with this copyright notice attached.
Author: Jonathan Hill ( jmhill at hartford dot edu )
Date: Mon Sep 6 22:17:05 EDT 2010
Modified: Tue Dec 14 11:31:14 EST 2010
• Added comment regarding ‘.end’ statement
• With regard to an included file, changed the .cir and .ckt file naming convention to aim.cir
and .cir naming convention.
Download