-
Analyze the circuit below.
-
Label each node in the circuit.
-
Determine the Req for the circuit.
-
Find the current through the circuit.
-
Find the voltage at each node.
-
Starting at the left and moving to the right across the circuit shown below,
label nodes 1, 2 and 3 in the circuit. (The ground plane will be node 0).
Write a PSPICE netlist for the circuit (by hand, not using the software).
Use your class notes as an example. Be sure to include the netlist along
with a labeled picture (label the nodes and elements) of the schematic
in your lab notebook.
(end of pre-lab)
EE 101
Lab Exercise 2: Introduction to PSPICE and MATLAB
Part I: In this lab you will learn how to use PSPICE to analyze resistive
networks containing a DC voltage source.
Log on to the computer (NT mode). It is a good idea to keep all of your
computer work for this class in a separate directory structure. "ee101"
would be a logical name for the parent directory, and each lab number for
the separate lab exercises. For example, you may wish to keep the work
for this lab in U:\ee101\lab2. If you are not familiar with creating directories
ask someone to assist you.
-
Once you are logged in, to call up PSPICE, go down to the taskbar and click
on the Start button. Go to the Programs menu
and bring up the DesignLab Eval 8 menu and select Schematics.
Or, select the MSIM Schematics icon from the desktop.
-
You will now enter and analyze the circuit below.
Here is how you would draw this schematic in PSPICE:
-
With the mouse, choose the Draw menu bar. Under that, select Get
New Part. Then click on the Libraries button.
-
A parts name window will appear. Below, windows listing the libraries and
the parts contained within them appear.
-
First, let's place two resistors on the PSPICE desktop. Resistors
are located in the analog.slb library. Select this library and select
R (for resistor). Select Place & Close.
-
An image of a resistor appears on the desktop. Click the left mouse button
to place the resistor. Note that a permanent resistor has been added to
the desktop, and that you still have a floating image of a resistor. Since
you need two resistors for this circuit, go ahead and click the mouse to
place the second one also. Click the right mouse button to deselect the
resistor (so you don't add any more to your desktop). If you ever add components
to your desktop that do not belong there, you can select them with the
left mouse button and hit the del key to erase them.
-
Rotate your two resistors so they line up with the way the schematic is
drawn. Do this by selecting a resistor with the mouse (one at a time, it
should turn red) and then going to the Edit menu and choosing Rotate.
Do this for both resistors. Then, line upthe resistors by selecting
one and using the mouse to drag it so that it touches the end of the other.
Note: If you attempt to select a part and it gets a box placed
around it, but it does not turn red, then you have not selected it, but
the text around it. This is fine for moving text, but for moving the part,
you must align the mouse on the part itself and click the left mouse button.
If you select text by accident, click the right mouse button to deselect
it. Then, try to select the component.
-
Now you will add a source component to your schematic. Like before, go
to Get NewPart. This time, choose the source.slb directory
and choose Vsrc. Place this voltage source on the schematic by clicking
the left mouse button, and then click the right mouse button so you don't
place another source. You need to define the voltage value of this source.
Do so by double clicking the left mouse button on the red (selected) component.
A window should pop up that has several options for this source. Scroll
down to the DC = line, and type 15 (for 15 volts). Save the attribute
and click on OK.
-
You need to define the resistor values as well. Select each resistor and
replace the default resistor values with 470 and 270. To make your schematic
more readable, you may wish to select the text around the resistors and
move it to the side slightly.
-
Now connect your components together by going to the Draw menu and
selecting Wire. Use the mouse to place the wires between all components
(left mouse button to start drawing, left to stop, space bar to start again).
-
You must now add a ground to your circuit. Find AGND in the port.slb
directory, and place it where indicated on your schematic.
PSPICE
simulations will not work unless you have defined a ground reference for
your circuit.
-
Perform an electrical rules check to be sure your circuit schematic will
simulate properly. (Analysis menu, Electrical Rule Check).If all
goes well, you will see a small window flash on the screen and nothing
else). If no errors are reported in your schematic, proceed to the next
step. If errors are reported, fix them now. If you have not done so,
now is a good time to save your schematic. Choose a name that will
help you identify which problem this is. Ask for help if you need it.
-
Now you will simulate your circuit. Do this by going to the Analysis
menu and choosing Simulate. When the circuit is finished simulating,
a PSPICE window will appear. Select File in this window,
and Examine Output. Scroll down towards the bottom of the file until
you come to a series of headings that say Node and Voltage. The voltage
at each circuit node should be reported. Identify which node voltages are
associated with which circuit elements and note this in your lab book.
-
Scroll further down the output file. Note the source current and total
power dissipation for the circuit are reported. The voltage source current
is reported as -2.027E-2, or -20.27 mA. You have already calculated Is
for this circuit in the pre-lab. Does your answer agree with PSPICE's?
-
Enter the circuit from Exercise 2 of the pre-lab in PSPICE and simulate
the circuit. With the information provided by the PSPICE simulation, determine
all the voltages and currents associated with the circuit.
Part II: Solving Simultaneous Equations Using MATLAB (Gaussian elimination
method).
The purpose of this part of the lab is to learn how to solve a system of
linear simultaneous equations using MATLAB. In class we solved the following
system by using the Gaussian elimination method.
30 I1 - 10 I2 = 150 (1)
-10 I1 + 25I2 = -100 (2)
In MATLAB, this is done with the use of the \ (backslash) operator or
matrix left division. In order to do that, MATLAB requires us to input
the coefficients of the system in a two dimensional array, also known as
a matrix. Equations (1) and (2) can be written in matrix form as follows:
=
This has the general form
A I = b
where, in general, A is an n by n matrix (n rows, n columns), b is an
n by 1 column vector, and I is an n by 1 unknown vector to solve for. In
this example, you will enter the following sequence:
A = [30 -10; -10 25]
b = [150 -100]'
I = A \ b
The \ operator invokes the Gaussian elimination algorithm and
the ' (transpose symbol) transforms b from a row vector to a column vector.
Adding a ; (semicolon) to the end of each statement will stop MATLAB from
displaying the matrix you have just entered. For this lab, it is recommended
you do not end your statements with a semicolon.
-
You will now solve the system of equations given in equations (1) and (2)
using MATLAB. Follow the instructions listed here.
-
In Windows, to call up MATLAB, go down to the taskbar and click on the
Start button. Go to the Programs menu and bring up the MATLAB for Windows
menu. Select the MATLAB icon. A MATLAB working window will appear. At the
prompt, type "diary". (More about "diary" later).
-
Type the following commands in the MATLAB window. A brief explanation of
each command appears after it. Notice that after you enter each vector,
it will be echoed back on your screen.
A = [30 -10; -10 25] % establishes the 2 x 2 "A" matrix
b = [150 -100]' % establishes "b" as a 2 x 1 column vector(the
' mark changes b from a row vector to a column vector)
I = A \ b % Invoke the Gaussian elimination algorithm
-
Solve each of the following systems of linear equations using MATLAB. Verify
your results by substituting the solutions back into the original equations.
-
x1 + 4x2 + 5x3 = -1
3x1 - 2x2 + 6x3 = 13
4x1 - 2x3 = 2
-
x1 - 4x2 + 2x3 + x4 = 8
-4x1 + 3x3 - x4 = -1
2x1 + 3x2 + 5x4 = 17
- x2 + 5x3 - 5x4 = -4
-
Exit MATLAB. Look in your directory and find diary. Browse diary either
from a MS-DOS window using the type command or from any of the editors
present on the windows desktop. Print out a copy of the diary and paste
it in your lab book.
Questions:
-
What are the advantages of using PSPICE to analyze a circuit? What are
the disadvantages?
-
On a separate sheet of paper, write down all of the voltages and currents
you obtained from PSPICE for part 2. Take these answers home with you and
compare them to those you obtained in the handout problem from Homework
No. 3.
-
What is the command "diary" for in MATLAB?
June 2000
Copyright 2000, New Mexico Tech