First Order System
Copyright (C) 2021 Miodrag Bolic
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details <https://www.gnu.org/licenses/>.
% Changing the path from main_folder to a particular chapter
main_path=fileparts(which('Main_Content.mlx'));
%addpath(append(main_path,'/Chapter2'))
cd (append(main_path,'/Chapter3/RC Circuit and Filters'))
addpath(append(main_path,'/Service'))
SAVE_FLAG=0; % saving the figures in a file
Introduction
This notebook provides introduction to models for basic first order systems.
First order systems are systems whose input-output relationship is a first order differential equation.
First order systems have single energy storing elements such as capacitor or inductor.
For the purpose of this model, we will be considing a RC circuit with a step response.
The value of the unit step response is zero at t = 0 and for all negative values of t. It will slowly increase from zero value and finally reaches its steady state value.
Model
The following simple model was created on Simscape to monitor the voltage across the capacitor with a unit step input voltage.
The parameters and chosen values for this circuit include:
- Resistance: R = 100 kOhm
- Capacitance: C = 800 nF
- Series resistance: r = 1e-6 Ohm
These values will be set into the simscape model:
model_name = 'FirstorderStep';
set_param('FirstorderStep/R','R','100')
set_param('FirstorderStep/C','c','800')
set_param('FirstorderStep/C','r','1e-6')
simOut = sim('FirstorderStep', 'CaptureErrors', 'on');
Warning: 'Input Port 2' of 'FirstorderStep/Scope' is not connected.
plot(simOut.out.Time,simOut.out.Data(:,1))
title('Response to a sinewave of a first order low-pass filter')
legend('Input signal at 60 Hz','Filtered signal')
annonation_save('b)',"Fig3.16b.jpg", SAVE_FLAG);
Configure Input
The unit step signal is configured as an input to the first order system. Tau is the time constant and in one time constant, the response curve should be at 63% of the final value. At five time constants, the response should reach 99% of the final value. The steady state can only be reached after an infinite amount of time however in practice it is reasonable to consider the time it takes to reach within 2% of the final value.
clear_all_but('SAVE_FLAG')
Plot Response
The exponetial respose curve is plotted here, it includes the voltage as a function of time for a simulation time of 1 s. The response reaches 63% of it's final value at tau and 99% at five tau.
simOut = sim('FirstorderStep', 'CaptureErrors', 'on');
Warning: 'Input Port 2' of 'FirstorderStep/Scope' is not connected.
plot(simOut.out.Time,simOut.out.Data(:,1))
a1=line([one_tau one_tau],[0 v_one_tau],'Color','red','LineStyle','-.')
a1 =
Line with properties:
Color: [1 0 0]
LineStyle: '-.'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [0.2800 0.2800]
YData: [0 3.1500]
ZData: [1×0 double]
Show all properties
a2=line([0 one_tau],[v_one_tau v_one_tau],'Color','red','LineStyle','-.')
a2 =
Line with properties:
Color: [1 0 0]
LineStyle: '-.'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [0 0.2800]
YData: [3.1500 3.1500]
ZData: [1×0 double]
Show all properties
a3=line([five_tau five_tau],[0 5],'Color','red','LineStyle','-.')
a3 =
Line with properties:
Color: [1 0 0]
LineStyle: '-.'
LineWidth: 0.5000
Marker: 'none'
MarkerSize: 6
MarkerFaceColor: 'none'
XData: [0.6000 0.6000]
YData: [0 5]
ZData: [1×0 double]
Show all properties
text(0,v_one_tau+0.2,'0.63V_{in}')
text(five_tau-0.13,5+0.2,'Capacitor fully charged')
text(five_tau,0.2,'\downarrow 5\tau')
%a4=line([0 1],[5 5],'Color','magenta','LineStyle','-.')
title('Response to a step function of a first order low-pass filter')
annonation_save('',"Fig3.17.jpg", SAVE_FLAG);