Lab 4: RC Timers - CS Course Webpages

advertisement
TEXAS A&M UNIVERSITY
ENGR 111B:
Foundations of Electrical &
Computer Engineering
Lab 4: RC Timing
Team Members: _________________________
_________________________
Section Number: __________
Team Number: __________
This Lab is due by the Beginning of the Next Lab Session.
Written By:
Dr. Hank Walker
Lorne Liechty
Lab 4: RC Timing
Time Limit: 1 week
OVERVIEW
Now that the basics of circuit construction, measurement and resistors have been
mastered, we will enter into more difficult concepts of basic circuitry, and introduce more
of the functionality of the robots. In this lab students will be introduced to the following
material.
- Capacitors
- RC Timing
- Comparators
BACKGROUND
To assist students in completing the exercises required by this lab, the following
background information has been provided. It is recommended that each student read all
of the following information as a beneficial review of the topics required.
CAPACITORS
The next circuit element that we will be studying closely is the capacitor. Where
resistors were elements used to dissipate power and limit current, capacitors are elements
which store energy and suppress voltage fluctuations. At their simplest, capacitors are
two parallel plates which store charges on them. The diagrams in Figure B1 should assist
in explanation:
Figure B1: Diagram of a
Charging Capacitor
At the quantum level, when a voltage is applied to a capacitor electrons flow from
the source onto one plate of the capacitor and from the opposite plate of the capacitor to
the source. As the electrons leave the capacitor, they produce empty spaces without
electrons on the surface of the capacitor and therefore produce an overall positive charge
on that plate. The initial movement of electrons once the voltage source is connected
produces a maximum current onto or from the capacitor; as the voltage resulting from the
charge on the capacitor raises, the difference in voltage between the plates of the
capacitor and the terminals of the supply decreases. Eventually, the voltage across the
capacitor will equal the voltage at the source, at which point no current will flow in the
circuit.
Capacitors are made of a variety of materials. Two common types are ceramic and
electrolytic. Ceramic capacitors work well over a wide range of frequencies, and do not
have any orientation between their pins. Electrolytic capacitors have higher capacity,
work best at lower frequencies, and have a polarization – one pin is marked as “-“
(minus) on the package and is typically connected to ground. Reversing the connections
can damage the capacitor.
Capacitor values are sometimes marked directly on the package. For small capacitors, a
numbering and lettering system is used to mark capacity and tolerance. As with resistors,
if there is a three-digit number, the last digit is the power of ten, so a capacitor marked
104 will be 100,000. The units are picofarads, so 104 is 100,000 pF or 0.1 F and 105 is
1 F. See the following link for a more thorough explanation:
http://wiki.xtronics.com/index.php/Capacitor_codes.
General Equations
The equations which model the voltage and current on a capacitor, shown below:
1
dV (t )
V (t ) 
i (t )dt
i (t )  C
C
dt
are more complicated than that of a resistor, which was simply V  I * R . The reason for
capacitor voltage spike suppression is seen in the first equation in that the integral of the
current must be taken in order to alter voltage. This result means that there must be a
relatively large change in current over time in order for the voltage to change by a
significant amount. Conversely, since the current is proportional to the derivative of the
voltage, a quick change in voltage will result in a large change in the current across the
capacitor. The simulation outputs given in Figure B2 should help in understanding these
concepts.

Figure B2: Graph of Voltage and
Current in Capacitive Circuit
In the equations given above, the capacitance, C, is written in units of Farads, and
is equal to:
Q
C
V , Q = charge stored on capacitor
As mentioned previously, capacitors store energy; the charge stored on the capacitor
results as energy E stored in the capacitor which is valued according to the following
equation:
E
1
CV 2
2
Another important aspect of capacitors is how they reduce in circuits. Similar to
how resistor networks can be simplified into equivalent resistors, capacitor networks can
be simplified into equivalent capacitances. The equations for these reductions are given
below:
Series:
1
1
1
1


 ... 
Ceq C1 C 2
CN
Parallel: Ceq  C1  C2  ...  C N
RC TIMING
One use for capacitors is as a timing element. The timing of a capacitor is defined
by how long it takes for it to store or dissipate charge. In comparison, just like water
cannot instantly fill a bucket, a capacitor cannot instantly be fully charged. Since
resistors limit the flow of current through a circuit, and therefore limit the flow of charge
off of or onto a capacitor, resistors are used to vary capacitor timing. These circuits are
called RC timing circuits. The circuit shown in Figure B3 is a basic RC timing circuit.
Figure B3: Basic RC Charging Circuit
An analysis of the voltage across the capacitor with respect to time reveals how
this circuit can be used for timing. Figure B4 shows a simulation output of the RC circuit
shown, when connected to a 5V DC source, assuming the capacitor initially has no
charge.
Figure B4: Simulation Output of
Basic RC Timing Circuit
The green line in the graph shows the voltage source, V1, being increased to 5 volts at
time t = 1 ms, and being decreased to zero volts (ground) at time t = 6 ms. The red line
shows how the voltage on the capacitor changes over time. A larger capacitance or a
larger resistance, results in a longer time for the voltage to rise. In contrast, a smaller
resistance or a smaller capacitance results in a shorter voltage rise time. Further, these
same rules apply to the time it takes for a charged capacitor to discharge once its source
voltage has been removed and it has a path to ground.
Derivation of Timing Equations
Analyzing the simple RC circuit again, we shall derive the equation that governs
RC timing for a charging circuit. Looking at the circuit in Figure B3, we can a
combination of use Kirchoff’s current law and Ohm’s law to form the first equation at the
instant the switch is closed. Everything from that point is derivation.
dVC
dV
 VC  VS 
0  C 
R
dt
dt
RC
t
 VC  VS    t
1
1
 
 VC  VS   VC (0)  VS e RC

dVC  
dt  ln 
VC  VS 
RC
 VC (0)  VS   RC
I ( R)  I (C )  0 
VS  VC 
C
t


 VC  VS 1  e RC   VC (0) , V (0)  Initial Voltage on Capacitor
C


As you can see, our final equation is a time dependant voltage that allows us to know
how long it will take for the voltage on a capacitor to increase a certain amount once a
specified voltage has been applied across the RC combination.
If the circuit is arranged so that an initial voltage is being discharged from the
capacitor, as in Figure B5, a similar equation can be obtained.
Figure B5: Basic RC Discharge Circuit
The equation for the discharging capacitor voltage with respect to time follows a similar
derivation to the one shown previously for a charging capacitor. Beginning again with
Kirchoff’s current law at the instant the switch is closed:
I (C )  I ( R)  0  C
 V  t
 ln  C  
 VC (0)  RC
dVC 0  VC 
dV
 VC
1
1

dVC  
dt

0  C 
VC
RC
dt
R
dt
RC
 VC  VC ( 0 ) e
t
RC
, VC (0)  Initial Voltage on Capacitor
Use of Timing Equations
As shown in the derivations given in the previous section, the RC timing
equations are:
t


RC
VC  VS 1  e   VC (0)


For a Charging Capacitor:
For a Discharging Capacitor:
VC (0) 
VC  VC ( 0 ) e
t
RC
Initial Voltage on Capacitor
Now that we have seen the equations, we need to know how to use them. The voltage is
a decaying exponential function, which means that the voltage will change quickly at
first, but then level off to a final value along an exponential curve. The quantity RC is
known as the time constant of the circuit and is often symbolized as the letter  (tau).
For each time constant elapsed, the exponential component of the voltage is, in effect,
varied by a power of e 1 or 0.3679. A general assumption is that after 5 time constants
have passed, the capacitor has reached its final value (95% of its value in three time
constants). With these equations it is possible to determine the voltage across the
capacitor at any given time based upon the voltage supplied, the RC constant, and the
initial voltage on the capacitor.
RC TIMING
Shown below in Figure B6, is a basic RC timing circuit connected to a
comparator with biased reference voltage, which provides a digital value to indicate when
a specified voltage has been reached by the charging capacitor. The reference voltage
comes from the tap on a potentiometer with one end connected to the supply and the
other to ground. This permits the tap output to be varied from 0 V to the supply voltage.
Figure B6: Basic RC Timed Comparator Schematic
Comparators
In order to understand how the RC timing circuit functions, it is necessary to first
understand how a comparator works. A comparator makes a comparison between two
voltages and returns a HIGH or LOW logic output based upon which input was of greater
magnitude. A schematic representation of a comparator is given in Figure B7, along with
labels of its different components.
Figure B7: Schematic Representation
of a Comparator
As you can see, a comparator has both positive (+) and negative (-) input terminals. If
the voltage on the positive terminal is higher, then the output will be equal to the
positive supply voltage. If the voltage on the negative input terminal is higher, then
the output will be equal to the negative supply voltage. In the case of RC timing, this
allows the user to set what voltage bias the capacitor must reach in order to trigger the
comparator logic. In our comparator, the negative supply voltage is ground.
General Circuit Operation
The RC timing circuit starts with the capacitor discharged. The reference voltage
is set by the potentiometer. Once the reference voltage is exceeded by the timing
capacitor voltage, the comparator produces a change in digital logic output from 0V to
5V, assuming a 5V supply. (In this lab, you will directly use your battery output, so the
voltage will be about 7.2V). Figure B8 provides a simulation example of the RC timed
comparator configuration shown in Figure B6.
Figure B8: Simulation Model of RC Timer / Comparator Configuration
The time constant of the RC timing circuit is equal to approximately 10 seconds,
which allows ample room for timing anything in this lab.
LAB EXERCISES
The lab will use the circuit shown in Figure L1. The RC timing circuit and
potentiometer feed a comparator, which in turn drives a MPSA06 transistor, which drives
the motor. (This is what is known as an NPN transistor. It is different from a MOSFET in
that there is effectively a diode from the input (left side, termed the base) to the bottom
connection, termed the emitter. The collector is the pin connected to the motor. This
transistor has enough current-carrying capacity to power the motor. The comparator
outputs can only pull down to ground. They cannot pull up to the supply voltage. The
10k resistor on the comparator output serves the function of pulling the output up to the
supply voltage.
Left
Motor
100k
3
8
1k
C
B
100 F
1
10k
2
4
MPSA06
E
Figure L1: Schematic of RC Timing Circuit
The LM393 is a packaged in an 8-pin DIP – dual inline package. It has four pins on each
side, as shown in Figure L2. The notch on the top of the package orients it. In some
chips, there is no notch, and instead there is an indented circle next to pin 1. Be sure you
have the chip correctly oriented, since hooking it up backwards can destroy it.
Figure L2 shows how the two comparators in it are connected to the pins. We will be
using only the left comparator. Its pins are labeled in Figure L1, that is, the positive input
is pin 3, the negative input is pin 2, and the output is pin 1. Pin 8 is the supply to the
comparator, and pin 4 is ground. In general in most DIP packages, the upper right pin is
power and lower left is ground, when holding it with the notch at the top. However the
actual pin-out diagram of a chip should be checked on its datasheet.
Figure L2: Functional Schematic and Pin Diagram of LM393 Comparator
Figure L3 shows how to wire up your LM393 to the protoboard. Note that you
place the LM393 so that the legs (pins) are on each side of the channel running down the
middle of the protoboard.
Figure L3: IC Connection Guide
For Protoboard
Figure L4 shows the pin diagram of the MPSA06 NPN transistor. It is packaged in what
is known as a TO-92 “can”. It has a flat side, which allows you to orient the collector (C),
base (B) and emitter (E). The collector is connected to the motor, base to the comparator
output, and emitter to ground. These pins are shown in Figure L1.
Figure L4: Packaging Diagram of MPSA06 NPN Transistor. It is housed in a TO-92 package. With the
flat side up, the emitter is pin 1 on the left, base in the middle, and collector on the right. (Most transistors
have the base in the middle and collector on the right).
PART I: SPIN AND GO
Wire up the left motor using the circuit described above. (As in the previous lab, if
your front wheel causes the robot to “buck”, have it go in the reverse direction). Hook the
right motor directly to power. This circuit will cause the robot to “spin and go”. Initially
the comparator output voltage will be low, as in Figure B8. The NPN transistor will be
turned off, so the left motor will be turned off. The right motor will cause the robot to
spin to the left. When the RC circuit has charged up to the point that its voltage is larger
than the reference voltage, the comparator output will go high, the left motor will turn on,
and the robot will go approximately straight.
Remember that the voltage on the comparator input from the RC circuit is:
V  VFinal * (1  e
t
RC
)  Vi
where VFinal is the battery voltage, Vi is the initial voltage on the capacitor (zero if you
leave the power off long enough), RC is the RC time constant, and t is the time.
1. The RC time constant of the circuit is 100 k times 100 F, or 10 seconds. In one
RC time constant, the capacitor charges up from ground to approximately 0.63
times the battery voltage (1 – e-1). Measure your battery voltage and set your
potentiometer tap output to be 0.63 times the battery voltage. Use your multimeter
to adjust the pot.
2. Turn the power on, set the robot down, and time how long it takes before it goes
straight. Record this time in Table R1 below. To get more accurate time
measurements, you do not need to place the robot on the ground.
3. Turn the power off and wait for about a minute, to let the capacitor fully
discharge. You can also use a wire to short between the capacitor and ground.
4. Set the potentiometer to be 0.39 times the battery voltage (1 – e-0.5). This should
produce a time delay of half the RC time constant, or 5 seconds. Repeat the time
measurement and record in Table R1.
5. What theoretical potentiometer value is needed to have a time delay of only 15
seconds? Record in Table R1.
6. What is the actual potentiometer value for a 15 second delay? Record in Table
R1.
Written by Texas A&M University
1
7. The main drawback of RC timing circuits is that the timing varies with capacitor
and resistor values. Capacitors often have +/- 10% or +/- 20% variation, while our
resistors have +/- 5% variation. Using these tolerances, complete Table R2 to
compute the variation in time for the circuit to charge to 63% of 7.2V
(approximately 4.5V).
As you can see, this circuit will charge the capacitor once the voltage is
connected. One way to ensure that your capacitor has no charge on it is to use a piece
of wire to briefly short the capacitor output to ground before turning on the power.
Remember to remove this wire or the capacitor will never charge.
You can use your multimeter to measure voltages in the circuit. Since the
capacitor voltage rises slowly, you can see this on the voltmeter. However you should
be aware that the voltmeter has a finite resistance that may disturb the voltage on the
capacitor (since the multimeter would be taking some of the current that the 100 k
resistor is supplying). On other nodes in the circuit this will not be a problem.
PART II: GO AND TURN
1. Swap the inputs 2 and 3 of the comparator. Now the output will remain high until
the RC circuit has charged up to greater than the reference voltage. The result is
that the robot will first go in approximately a straight line, then spin to the left
after the time delay.
2. Repeat your experiments from part I. Are the time delays the same? If not, why
not?
Written by Texas A&M University
2
RESULTS: to be uploaded onto elearning.tamu.edu
1.
Reference voltages for time delays
Battery Voltage (V)
0.63 * Battery Voltage (V)
0.63 Voltage Time Delay (s)
0.39 * Battery Voltage (V)
0.39 Voltage Time Delay (s)
Theoretical voltage for 15 s delay (V)
Actual voltage for 15 s delay (V)
Table R1
2.
Timing to 4.5V Including Tolerances
20% Cap Tolerance
10% Cap Tolerance
Min
Max
Min
Max
95 kΩ
100 kΩ
105 kΩ
~
~
~
~
~
~
Table R2
Written by Texas A&M University
3
REPORT: to be uploaded onto elearning.tamu.edu
REPORT REQUIRMENTS
Answer the following questions:
-
When you set the reference to 0.63 times the supply voltage, was the time delay
close to 10 seconds? If not, what are possible explanations for the error?
Did your measurements fall in the ranges in Table R2?
Explain any error between theoretical and actual resistance in the 15 second delay
in Table R1.
Was there any difference in time delays for “go and spin” compared to “spin and
go”? If so, what are possible explanations?
Written by Texas A&M University
4
Download