Simulation Project 3: Electrical Circuit Simulator
Note:
This is one of a few options for the CMPSC 201 Simulation Project. This option is designed with
electrical engineering students in mind, but it is written to be accessible to anyone in the course who is
interested. This project was designed in conjunction with Greg Link (PSU '06) of the Electrical and
Computer Engineering Department at York College of Pennsylvania and Josh Petko of the PSU Electrical
Engineering Department.
Be sure to read the background information on simulations and random numbers on the
general Simulation
Project page
.
Theory
In this project you will be simulating an electrical circuit called a
low pass filter
. The circuit has an input
voltage,
V
in
, and has a resistor (resistance
R
S
) and capacitor (capacitance
C
). There's a load on the circuit, and
its resistance is denoted by
R
L
. At the end of a pass through this circuit, the voltage will change, resulting in
output voltage
V
out
. You'll also need to consider the current in different parts of the circuit.
Consider the following illustration of our circuit:
The equations that govern this circuit are:
Equation 1:
Equation 2:
Equation 3:
Equation 4:
The voltage is governed by a function. In this project, we'll look at what happens with two different flavors
of voltage functions:
•
Step Function:
Start the voltage at 0, change it to 1 on the first step, and keep it at 1. Alternatively,
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
invert this situation: start at 1, go to 0, stay at 0.
•
Sine Function:
Use a sine wave with time as an input to determine the voltage at a given time. The
frequency of the sine function will produce varying effects.
To simulate this circuit, we'll also need a
time step
, i.e. how much time to wait between passes through the
circuit. Each pass through the circuit will correspond to an iteration of a loop in your simulation.
Before you begin coding, you have some algebra to do. Use the equations above to find an expression for the
derivative of
v
out
with respect to time, i.e.
dv
out
/
dt
. What you'll have is a firstorder differential equation that
you'll use to reset the voltage during each time step of the simulation.
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '10
 Decimal, decimal places

Click to edit the document details