Академический Документы
Профессиональный Документы
Культура Документы
Control 2
DOCENTE: RIVERA REYES MARTHA V.
MARTÍN ALONSO SILVESTRE GARCÍA
PRACTICA 1
RC Circuit
Transient Analysis with Matlab
we can use the Kirchhoff’s current law (KCL) to write the following equation
where
Vm is the initial voltage across the capacitor
RC is the time constant
If the capacitor is not charged initially, that is v0(t) = 0 when t = 0, then the solution
to the equation above is given by
The following examples illustrate the use of Matlab for solving problems
related to RC circuits.
Assume that for the charging RC circuit above Vs = 10 volts and C = 10 microfarads.
Plot the voltage across the capacitor if R equals 5k ohm, 10k ohms and 20k ohms. This
just means that we are going to explore three time constants.
R2 = 10e3;
tau2 = R2*C;
V2 = Vs * ( 1 - exp(-t/tau2) );
R3 = 20e3;
tau3 = R3*C;
V3 = Vs * ( 1 - exp(-t/tau3) );
In the same charging circuit above, the input voltage is now a rectangular pulse with
an amplitude of 10 volts and a width of 0.5 seconds. If C = 10 microfarads, we’ll plot
the output voltage, v0(t), for a resistance R equal to 5k ohms, and 20k ohms. The plots
should start from 0s and end at 1s.
We are going to develop a function that will return the voltage and corresponding time
of the response. We need to use the two formulas mentioned previously and that’s why
we separate our code in two halves.
The input parameters are the voltage source (vs), the resistor (r) and capacitor (c).
Now, we are going to call the function from our main code, like this
% Given constants
vs = 10;
c = 10e-6;
% Case 1. R = 5k ohms
r1 = 5e3;
[v1, t1] = rectangular_RC(vs, r1, c);
% Add labels
title('RC circuit - rectangular input')
xlabel('Time (s)')
ylabel('Voltage (V)')
legend(['R_1 = ' num2str(r1)], ...
['R_2 = ' num2str(r2)])