0% found this document useful (0 votes)
52 views

Lab 2: Step: Theoretical Solution

This document describes an experiment comparing the theoretical, simulated, and experimental step responses of an RC circuit. The theoretical solution was derived using Laplace transforms. The simulation used MATLAB to model the circuit with Euler's method. Experimental data was collected using a DAQ system. All solutions followed the general trend of an RC step response but differed slightly due to modeling approximations and component value discrepancies. This highlights the importance of using appropriate modeling methods.

Uploaded by

April Ferguson
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Lab 2: Step: Theoretical Solution

This document describes an experiment comparing the theoretical, simulated, and experimental step responses of an RC circuit. The theoretical solution was derived using Laplace transforms. The simulation used MATLAB to model the circuit with Euler's method. Experimental data was collected using a DAQ system. All solutions followed the general trend of an RC step response but differed slightly due to modeling approximations and component value discrepancies. This highlights the importance of using appropriate modeling methods.

Uploaded by

April Ferguson
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Group 29

Due: 24 September 2013


Lab 2: Step
Introduction:
The purpose of this lab was to perform a step response test on a simple passive circuit with a RC
low-pass filter. The results of the test, the experimental step solution, was then compared with the
theoretical step solution and simulation of the circuit. The general step response of an RC circuit is
defined as follows:
() {




The theoretical solution was obtained using the differential equation that describes the RC circuit which
was then derived using Laplace. The circuit has an input voltage of 1V and an initial condition of the
output voltage which is equal to zero. The differential equation for the RC circuit is as follows:

())


()

()

Where R is the resistance and is equal to 5.1k
C is the capacitance in the circuit and is equal to 3.3F
V
out
is the output voltage of the RC circuit, in Volts
V
in
is the input voltage of the RC circuit, in Volt
and = R*C and is referred to as the time constant

The simulation solution was obtained using MATLAB code and the experimental solution was obtained
using LabVIEW and a test circuit in which the data was collected using Data Acquisition (DAQ) hardware.
The actual solution to the differential equation is shown below.


Results:
Theoretical Solution
The theoretical solution was derived by hand calculations using a Laplace transform technique, a partial
fraction expansion, and then transforming the solution back using the inverse Laplace function. The
calculations were performed as follows:



Given Differential equation:

())

()

()

()

()

()
Group 29
Due: 24 September 2013

Reformatted equation:
Apply Laplace:
* + *+ *+
() () ()


()

( )

Partial Fraction Expansion:

( )



( )

Reformatted Equation:
()

)

Apply Inverse:

*()+

)
}


Therefore:







Simulation Solution
MATLAB code in the appendix shows the code which provided the solution for the simulation of the RC
circuit. The circuit was simulated by Eulers method, using a for loop. This iterated through the
derivative, found the solution of the voltage output with each iteration, and then plotted the
corresponding vector against time (Figure 1). As seen below, the two plots are nearly ideal. Note that
this was done with a time step of 0.002 seconds. The lower the time interval, the more accurate the
simulation.

Group 29
Due: 24 September 2013
















Figure 1: Plot Comparing Theoretical and Simulated Voltage Output
Experimental Solution
The experimental solution was obtained using DAQ hardware and LabVIEW code which outputs the step
voltage to the RC circuit and then collects the RC circuit response in a spreadsheet format. The block
diagram is shown below. The results were then plotted and compared to the theoretical trend (Figure
2). As seen below, the collected data is differs from the theoretical more than the simulated data.


















Figure 2: Plot Comparing Theoretical and Data Voltage Output
Group 29
Due: 24 September 2013



Figure 3: Labview Block Diagram for Experimental Solution

Discussion and Conclusion:
All of the solutions, theoretical, experimental, and the simulation of the circuit, follow the same general
trend. All solutions do not exactly follow the step function because the capacitor requires some of the
input voltage to charge, and this takes time. As the capacitor come to full charge, the full input voltage
is transferred to the output voltage. The experimental and theoretical plots differ slightly due to
discrepancies between the ideal resistor and capacitor values and the actual values. The simulation and
theoretical plots differ because the simulation is an approximation, not an exact solution. As the
simulation step size decreases, the simulation solution approaches the theoretical solution. These
discrepancies can be seen in Figure 1 and 2. This lab shows the importance of choosing proper modeling
methods depending on the desired accuracy.





Group 29
Due: 24 September 2013
Appendix A: Matlab Code

% Lab 2
% System Dynamics
% Group 29
clear all
close all
clc

% Ploting Theoretical Vout

%Calculated using Lagrangian methods, see lab appendix

t_theo = [0:0.002:.25] %This sets the intial time interval
R = 5.1*10^3
C = 3.3*10^-6 %R and C constants
Tau = R*C %reduces constants

V_theo = [1-exp(-t_theo/Tau)] %obtained from lagrangian analysis

%Simulation Vout (Euler's Method)

%Here, since the RC circuit models a first order differential equation,
%Euler's method is an appropriate approximation. Euler's method starts at
%time zero, takes an interval step size, finds the current slope (dy/dx),
%and linearly projects to the next interval step. This repeats for the rest
%of th desired interval.

y_sim= zeros(100,1); %Sets an initial vector for the output voltage
y_sim(1)=0; %Sets the output voltage to start at 0
stepsize=0.002 %This sets the step size. A much smaller step size could
%have been chosen, and would be more accurate, but makes
%plotting this against the theoretical function
%indistinguishable.

for n = 1:100; %For loop to run through the interval
dy = (1/Tau)*(1-y_sim(n)); %This equation comes from the diff eq for an
RC
%circuit, solved for dy/dx (slope)
y_sim(n+1)=y_sim(n)+dy*stepsize; %Linearly projects to the next
point
n=n+1; %Increases the index
end

t=[0:stepsize:(stepsize*(n-1))]; %creates step interval vector

% Experimental Data

Experimental_Data = importdata('Lab2Test3.txt'); %imports test data

Time = Experimental_Data(:,1)/1000; %Creates time vector from data

Group 29
Due: 24 September 2013
Voltage = Experimental_Data(:,2); %Creates voltage vector from data


% Step Function Input

%This section just makes a step function with y=0 for x<0 and y=1 for x>0

x1=[0,3]
y1=[1,1]

x2=[0,0];
y2=[0,1];

x3=[-1,0]
y3=[0,0]

% Theoretical, Simulation, and Input Plot

figure;
plot(t_theo,V_theo,'g-','LineWidth',2)
axis([-.02 .25 0 1.05])
hold on
plot(t,y_sim,'LineWidth',2)
plot(x1,y1,'r','LineWidth',2)
plot(x2,y2,'r','LineWidth',2)
plot(x3,y3,'r','LineWidth',2)
legend('Theoretical','Simulation Trend','Input Voltage')
xlabel('Time (seconds)')
ylabel('Voltage (Volts)')
title('Theoretical Voltage vs. Simulation Voltage')

%Theoretical, Experimental, and Input Plot

figure(2);
plot(t_theo,V_theo,'g-','LineWidth',2)
axis([-.02 .25 0 1.05])
hold on
plot(Time, Voltage,'k','LineWidth',2)
plot(x1,y1,'r','LineWidth',2)
plot(x2,y2,'r','LineWidth',2)
plot(x3,y3,'r','LineWidth',2)
legend('Experimental Data','Theoretical','Input Voltage')
xlabel('Time (seconds)')
ylabel('Voltage (Volts)')
title('Theoretical Voltage vs. Experimental Voltage')

You might also like