Lab5_Introduction

Download Report

Transcript Lab5_Introduction

RC Circuits
What have we learned so far?
 When we apply a voltage, the capacitor will charge up to
the applied voltage.
 The capacitor charges up exponentially.
 The capacitor takes about 5 time constants (5τ = 5RC)
to fully charge.
 The capacitor takes one time constant to charge 63.2%
of the way up.
 The same things hold true when a capacitor discharges
in an RC circuit.
RC Circuits
Capacitor Charging in RC Circuit
5
4.5
4
Capacitor Voltage (V)
3.5
1 kOhm
2 kOhm
10 kOhm
3
2.5
2
1.5
1
0.5
0
0
0.05
0.1
0.15
time (s)
0.2
0.25
RC Circuits
In Engineering Foundations, you wired up a series RC circuit
to a 1.5V battery and measured the voltage across the
capacitor as it charged using a multi-meter and a stop watch.
It worked OK because the cap charged pretty slowly.
RC Circuits
What happens if we have a voltage signal that changes over
time (ac signal) instead of a constant voltage (dc signal) like
we get from a battery?
RC Circuits
The capacitor will try to follow the signal by charging and discharging. For
example, if we apply a square wave and allow enough time for the
capacitor to charge and discharge, will we see something like this:
Series RC Circuit
1.5
Capacitor Voltage
Applied Voltage
1
volts
0.5
0
-0.5
-1
-1.5
0
0.5
1
1.5
time (sec)
2
2.5
Lab Today
We are going to apply square waves and sine waves to a
series RC circuit and measure the capacitor voltage as it
charges and discharges.
Data Acquisition Device (DAQ)
A DAQ is a cool little device that allows you to interface
software and hardware. Here is what we will do:
 Create a square wave or a sine wave in MATLAB
 Send the signal out through the DAQ as a voltage signal
applied across the RC circuit
 We will also use the DAQ as a voltmeter to measure the
voltage across the capacitor
 The DAQ will send these measurements back into MATLAB
so we can easily plot the voltage vs. time
Analog Discovery DAQ
Analog IN Channels:
The two orange wires labeled 1+ and
1- form an Analog IN channel. IN
means into the DAQ from hardware.
This input channel is our replacement
for the multi meter. The orange wires
will be placed across the capacitor to
measure the voltage.
The DAQ will take 10,000
measurements every second !!
The blue wires (2+ and 2-) are another
IN channel which we won’t use today.
Analog Discovery DAQ
Analog OUT Channels:
The yellow wire labeled W1 and black
ground wire labeled form an Analog
OUT channel. OUT means out of the
DAQ and applied to the circuit.
This output channel is our replacement
for the battery. These wires will be
placed across the RC circuit to apply a
voltage signal.
W2 allows for a 2nd Analog Out signal
but we won’t use that today.
MATLAB Code
On the metasite for Blackboard, there is an m-file called RC.m
This file has almost all of the code that you need for today.
there are a few lines you will need to fill in.
MATLAB Code
This section of code first clears all variables then checks to
make sure the DAQ is connected and is recognized by
MATLAB. If MATLAB can’t see the DAQ, it will print out
the statement in line 13 and terminate the program
MATLAB Code
This section of code gets things started by setting up a
session allowing MATLAB to communicate with the DAQ.
We used a variable name, DAQ,, to name our session.
MATLAB Code
This section of code turns on the Analog Input Channel (1+ and 1-)
to measure Voltage. We set the range on the voltmeter to read
voltages between -2.5 and 2.5 volts.
MATLAB Code
This section of code sets the sample rate to 10,000 samples
per second. So, we will get 10,000 voltage readings every
second. Try doing that with a stop watch!
MATLAB Code
This section of code turns on the Analog Output Channel
(W1) which will allow us to apply a square wave or sine wave
voltage signal across the RC circuit.
MATLAB Code
This section of code will ask the user to enter in the period,
T, of the square wave using an input statement.
MATLAB Code
This section of code is where your team will complete three
lines of code to create a square wave called AppliedVoltage
(a bit later on today)
MATLAB Code
This section of code will queue up your AppliedVoltage square wave and get it
ready to send out.
The startForeground command in line 61 is the start command and collects the
voltage measurements in a vector called CapVoltage and the corresponding
times in a vector called timestamps.
MATLAB Code
These commands ought to look pretty familiar!
Circuit