In: Electrical Engineering
Consider an RC circuit with resistance R and capacitance C. The circuit is stimulated with a pulse of amplitude A and width T.
The purpose of this study is to understand what happens to the impulse response, capacitor voltage, and resistor voltage for various resistor values: 600 ?, 1000 ?, and 1200 ?. The name of the MATLAB script will be called project2a. Excite the circuit with a rectangular pulse voltage of amplitude=5 V and pulse width of 10 ms. Plot the results of each resistor value from t=0 to t=20 ms on the same graph (3 graphs-impulse response, capacitor voltage, and resistor voltage). Label all axes, put a grid on the graph, and apply the proper legend. Comment on and explain the results.
For all cases of the study, the capacitor will have a value of 1 µF. Use the function below to make graphs.
function [ Vc Vr t ] = rc_voltages( A,R,C,T,Tend )
t=0:0.0001:Tend;
for i=1:length(t)
if t(i)
Vc(i)=A*(1-exp(-t(i)/(R*C)));
Vr(i)=A*exp(-t(i)/(R*C));
else
Vc(i)=A*(exp(T/(R*C))-1)*exp(-t(i)/(R*C));
Vr(i)=A*(1-exp(T/(R*C)))*exp(-t(i)/(R*C));
end
end
end
Hello,
Please find the answer
attached below. If the answer has helped you please give a
thumbs up rating. Thank you and have a nice
day!
NOTE: The given function requires a minor tweak to give you the correct answer. The statement "if t(i)" is replaced by "if t(i)>T", because this part represents the decaying part of the reponse, which happens after the pulse input dies down.
******* Matlab Code *******
Function definition:
function [ Vc, Vr, t ] = rc_voltages( A,R,C,T,Tend )
t=0:0.0001:Tend;
for i=1:length(t)
if t(i)>T
Vc(i)=A*(1-exp(-t(i)/(R*C)));
Vr(i)=A*exp(-t(i)/(R*C));
else
Vc(i)=A*(exp(T/(R*C))-1)*exp(-t(i)/(R*C));
Vr(i)=A*(1-exp(T/(R*C)))*exp(-t(i)/(R*C));
end
end
end
Main file:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% pulse response of rc circuit
A =
5;
% amplitude
T = 10e-3; %
pulse width
R1 =
600; %
resistor values
R2 = 1000;
R3 = 1200;
C =
1e-6; %
capacitor value
Tend = 20e-3;
%%%%%%%% calling the function to calculate the responses
[ Vc1, Vr1, t ] = rc_voltages( A,R1,C,T,Tend );
[ Vc2, Vr2, t ] = rc_voltages( A,R2,C,T,Tend );
[ Vc3, Vr3, t ] = rc_voltages( A,R3,C,T,Tend );
sys1 = tf(1,[R1*C
1]);
% system description for RC circuit
sys2 = tf(1,[R2*C 1]);
sys3 = tf(1,[R3*C 1]);
imp1 =
impulse(sys1,t);
% impulse response from system description
imp2 = impulse(sys2,t);
imp3 = impulse(sys3,t);
%%%%%%%%%%%% plots for R1-C %%%%%%%%%%%%%%
figure;
subplot(3,1,1);
plot(t,imp1);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Impulse plot for R1-C circuit')
subplot(3,1,2);
plot(t,Vc1);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Capacitor plot for R1-C circuit')
subplot(3,1,3);
plot(t,Vr1);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Resistor plot for R1-C circuit')
%%%%%%%%%%%% plots for R2-C %%%%%%%%%%%%%%
figure;
subplot(3,1,1);
plot(t,imp2);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Impulse plot for R2-C circuit')
subplot(3,1,2);
plot(t,Vc2);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Capacitor plot for R2-C circuit')
subplot(3,1,3);
plot(t,Vr2);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Resistor plot for R2-C circuit')
%%%%%%%%%%%% plots for R3-C %%%%%%%%%%%%%%
figure;
subplot(3,1,1);
plot(t,imp3);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Impulse plot for R3-C circuit')
subplot(3,1,2);
plot(t,Vc3);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Capacitor plot for R3-C circuit')
subplot(3,1,3);
plot(t,Vr3);
grid;
xlabel('Time (s)');
ylabel('Amplitude');
title('Resistor plot for R3-C circuit')
********** End of code*********
First, copy and paste both the above files to your working directory. Remember to save the first file as a function file, otherwise Matlab will throw an error. Now execute the main file. You will get the following output:
Explanation:
Since the given circuit is an RC circuit, The voltage across the resistor will rise exponentially as long as the pulse input is given. Once the pulse input is removed, the voltage drops to zero. The voltage across the capacitor can be found out by applying the Kirchoff's voltage law across the loop, which will be decaying as the voltage across the resistor rises. Since R1<R2<R3, the time constants of the circuits (R*C) will be the highest for circuit 3. This can be seen by a corresponding increase in the time it takes for the impulse response to decay, compared to the first circuit.