Title: Modelling and Frequency Design
1Modelling and Frequency Design
- CY2A7 (old course code CY2A2 for past
exams/notes) - Introduction to modelling.
- Crash course on Matlab code.
- Modelling basic systems
- Modelling frequency response of generalised
systems. - Modelling stability margins
- Separating Magnitude and Phase responses
- Approximations by hand
- Compensation techniques
- - Proportional, Phase lead, Phase lag/lead.
- 9 PI, PD PID controllers.
- 10 Modelling a complete system in Matlab,
including controller design to compensate for
undesired time response. -
2MATLAB for System Analysis
In MATLAB, represent transfer function with
polynomials c tf (915 1, 10 1) p tf
(1, conv(15 1,8 1) ) For some frequency
response need loop transfer function series
(c,p) multiplies 2tfs in series This does
not do cancelling, so simplify by minreal
(series(c,p)) For closed loop analysis, want
closed loop transfer function minreal
(feedback (series (c,p), 1) ) feedback
(t1,t2) is t1/(1t1t2).
3MATLAB results
Transfer function gt gt c 135 s
9 --------- 10 s 1 gtgt p
1 ------------------ 120 s2 23 s 1 gtgt
minreal (feedback (series (c,p), 1) )
feedback (t1,t2) is t1/(1t1t2).
0.1125 --------------------- s2 0.225 s
0.125 gtgt (feedback (series (c,p), 1) )
feedback (t1,t2) is t1/(1t1t2). 135
s 9 ------------------------------- 1200 s3
350 s2 168 s 10
4MATLAB results
Trans Func MATLAB tf(5 0,1) tf(2, 3 2
1) tf(4 5, 1 0) tf(5 4 1,1
0) Note, for those without the control toolbox,
Richard Mitchell has provided versions of the
above MATLAB functions these are on a separate
sheet. Matlab Richard Mitchell's version
tf rmtf NB rmtf(1)
needed series rmseries
feedback rmfback mineral rmmin
5function ans sotheory(k,a,b,c,t) returns
theoretical response of system with tf
k/(as2bsc) at all the values of time in the
vector t. Richard Mitchell, 19/9/00 if (a 0)
(b 0) (c 0) ans 0t elseif (a
0) (b 0) ans 0t k/c elseif (a 0)
(c 0) ans kt/b elseif (b 0) (c
0) ans kt.2/(2a) elseif (a 0)
ans (k/c) (1 - exp(-tc/b)) elseif (c 0)
ans kt/b - ak/b2 (ak/b2)exp(-bt/a) el
seif (b 0) w sqrt(c/a) ans
k(1-cos(wt))/c elseif (bb 4ac) f
0.5b/a ans k(1 - (1ft).exp(-ft))/c el
seif (bb gt 4ac) sq sqrt(bb - 4ac)
r1 0.5(b - sq)/a r2 0.5(b sq)/a
ans k (1 r2exp(-r1t)/(r1-r2)
r1exp(-r2t)/(r2-r1))/c else w
0.5sqrt(4ac - bb)/a d 0.5b/a ans
k (1 - exp(-dt).(dsin(wt)/w
cos(wt)))/c end
6MATLAB Theoretical Response
The Laplace transform lectures mean you should be
able to find the theoretical step response for a
system with transfer function . The following is
part of a MATLAB function to return such a step
response function ans sotheory(k,a,b,c,t)
returns theoretical response of system with tf
k/(as2bsc) at all the values of time in the
vector t. if (a 0) (b 0) (c 0)
ans (k/c) (1 - exp(-tc/b)) elseif (a 0)
(b 0) (c 0) w sqrt(c/a) ans
k(1-cos(wt))/c end NB to evaluate
exp(dt)sin(wt) do exp(dt).sin(wt) Note the
'.' operator Step Response of Such a System The
command step returns the simulated step response
and plots it. It needs the numerator and
denominator polynomials, with optional time. Can
call with output arguments, to get data but not
plot it.
7MATLAB Theoretical Response
The following code sets values for t, uses
sotheory to get the theoretical response, plots
that response, and then calls step to add the
simulated response. It assumes values for
variables k, a, b and c exist. t 00.150
set range of values of t plot (t, sotheory(k, a,
b, c, t) ) calc plot theoretical resp hold
on hold data for the graph step (k,a
b c,t) calc and plot step
response Alternative method op, dummy, t
step(k, a b c) use step to calc values
and t plot (t, op, t, sotheory (k, a, b, c, t),
) plot step calc plot theory
must not be curly in Matlab note dummy variable
(it is the 'state variable', which we can ignore
here) note also, plot one graph in so can see
agreement of two methods
8Simulation
As an intro, consider simulating system with
transfer function Could do by Here x
is state variable. Conceivably do by
But, this involves differentiating, done by
X values have errors, and tn-tn-1 is
small, so errors amplified. So avoid..
9Simulation
Uses differential of X we have already
got. Thus, algorithm to find O at a given time
is Sx (I X)/Ta find input to
integrator X Integrate (Sx) integrate this
to get X O X Sx Te compute O Can
extend concept to system with transfer
function Note, pn ltgt 0.
10How to Integrate?
Integration is area under the
curve. Assume we know integral up to previous
time. Then Euler's (poor) rectangular method
is Area Area Area of Rectangle due to
current input Area (CurInput)
(CurTime - Previous Time) Note Runge-Kutta is
better integration method.
11How to Integrate?
Hence we have the following MATLAB function to
find the step response. function resp RJMStep
(num, den, t) Euler Simulation of system with
tf num/den, at times in t. store output
response in resp. Note den(1) must not be
zero. Dr Richard Mitchell, 19/9/00 x zeros
(size(den)) x array of state variables set
to 0 n length(den) find length of
den array while length(num) lt n add leading
zeros to num, so same length as den num 0
num end resp 0 initialise response
array to 0 for ct 2length(t), for all time
x(1) (1 - dot(den(2n),x(2n)))/den(1)
calc input to first integrator x(2n)
x(2n) (t(ct)-t(ct-1))x(1n-1)
integrate all state vars resp resp
dot(num,x) add output
to resp array end
12 Accuracy!
Note to be reasonably accurate, t(ct) - t(ct-1)
must be sufficiently small. Example if t
00.110, t 00.0210
sotheory then We get three similar but different
results! NB How many people rely upon the
output of a computer program without really
understanding what is going on underneath???
13Impedances
Impedances in series (RLC circuit)
Impedances in parallel
14Amplifiers
Operational Amplifier Circuit mod2
If loop gain high,