Real-time control systems, and scheduling
see also some OS-related for real-time system, Control systems, or Frequency Domain
time domain versus frequency domain
use Laplace transform to convert from time domain to frequency domain
Consider the following circuit:
RCdtdvo(t)+vo(t)vi(t)=vi(t)=1
graph LR
Diff{{differential equations}} -- "Laplace transform" --> Algebraic{{algebraic equations}} -- "inverse Laplace transform" --> End{{time domain solution}}
L{f(t)}=∫0∞f(t)−stdt=F(s)
Item no.1.2.3.4.5.6.7.f(t)δ(t)u(t)tu(t)tnu(t)e−atu(t)sin(ωt)u(t)cos(ωt)u(t)F(s)1s1s21sn+1n!s+a1s2+ω2ωs2+ω2s
δ(t)=0,t=0,∫0∞δ(t)dt=1
example: Given a unit step function u(t)={01t<0t≥0
U(s)=L{u(t)}U(s)=∫0∞u(t)e−stdt=−s1e−stdt=−s1(0−1)=s1
L−1{F(s)}=2πj1ω→∞lim∫σ−jωσ+jωF(s)estds
if L[f(t)]=F(s) then we have
L[f′(t)]L[∫0tf(t)dt]=sF(s)−f(0)=sF(s)
For higher derivatives we have L[f′′(t)]=s2F(s)−sf(0)−f′(0)
we can replace s with jw
ex: G(jw)=1+jwRC1, so ∣G(jw)∣=∣1+jwRC1∣=1+(wRC2)1
reasoning: we substitute Laplace transform with Fourier transform with s=jw
example for a first-order system
Y(s)y(t)∵total response=s(s+5)s+2=5s2+5(s+5)3=52+53e−5t=forced+natural
stability: total response = natural response + forced response
the output response of a system
- natural (transient) response: 53e−5t
- forced response (steady-state) response: 52
poles and zeros
zeros and poles generate the amplitude for both forced and natural response
Y(s)=s(s+5)s+2
s=0,−5 are poles and s=−2 are zeros
- at origin, generated step function
- at -5 generate transient response e−5t
We will consider first-order and second-order system
first-order systems, time constant
Output of a general first-order system is
Y(s)=X(s)G(s)=s(s+a)a
thus the time domain output is y(t)=1−e−at
usually, t=a1, and y(t)=0.63, hence 63.2% to find the rise time.
response in time domain
Tr, time for the waveform to go from 0.1 to 0.8 of its final value
for first order: Tr=a2.2
Ts, time for response to reach and stay with 2% of its final value
for first order: Ts=a4
second-order systems
general order system:
G(s)=s2+as+bb
Thus the pole for this system:
s1,s2=2−a+a2−4b
natural frequency
happens when a=0
The transfer function is G(s)=s2+bb, and poles will only have imaginary ±jw
wn=b is the frequency of oscillation of this system.
in a sense, this is the undamped case:
damping coefficient
complex poles has real part σ=−2a
damping ratio is defined as:
ζ=natural frequencyexponential decay frequency=wn∣σ∣
So that a=2ζwn
general second order
G(s)s1,s2=s2+2ζwns+wn2wn2=−ζwn±wnζ2−1
observations
Condition | Poles | pole type | Damping Ratio (ζ) | Natural Response c(t) |
---|
Undamped | ±jωn | imaginary | ζ=0 | Acos(ωnt−φ) |
Underdamped | ωd±jωd | complex | 0<ζ<1 | Ae(−σd)tcos(ωdt−φ) where wd=wn1−ζ2 |
critically damped | σ1 | real | ζ=1 | Kteσ1t |
overdamped | σ1σ2 | real | ζ>1 | K(eσ1t+eσ2t) |
underdamped second-order step response
Transfer function C(s) is given by
C(s)=s(s2+2ζwns+wn2)wn2
response in time-domain via inverse Laplace transform:
c(t)=1−1−ζ21e−ζwntcos(1−ζ2ωnt+φ)
where φ=tan−1(1−ζ2ζ)
peak time Tp
time required to reach the first or maximum peak
Tp=ωn1−ζ2π
percent overshoot
%OS (percent overshoot)
%OS=eζπ/1−ζ2×100%
or in terms of damping ratio ζ:
ζ=π2+ln2(100%OS)−ln100%OS
relations to poles
G(s)s1,s2TpTs=s2+2ζwns+wn2wn2=−ζwn±wnζ2−1=ωn1−ζ2π≅ζωn4
same envelope
same frequency
same overshoot
reference: slides, and awesome calculator
excerpt from real-time system slides
If a system is stable and has a final constant value, then one can find steady state value without solving for system’s response. Formally:
t→∞limx(t)=s→0limsX(s)
sketching root locus
Rule | Description |
---|
Number of Branches | Number of closed-loop poles, or the number of finite open-loop poles = number of finite open-loop zeros |
Symmetry | About the real axis |
Start and End Points | Starts at poles of open loop transfer function and ends at finite and infinite open loop zeros |
Behaviour at ∞ | Real axis: σa=# finite poles - # finite zerosΣfinite poles−Σfinite zeros Angle: θa=# finite poles - # finite zeros(2k+1)π where k=0,±1,±2,±3 |
Breakaway/Break-in Points | Located at roots where dsd[G(s)H(s)]=0 |
Control Type | Transfer function T(s) | Key Characteristics | Effects |
---|
Proportional (P) | 1+KpGpKpGp | Basic control action | - Affects speed of response - Cannot eliminate steady-state error |
Integral (I) | s2+s+KIKI | Integrates error over time | - Eliminates steady-state error - Output reaches 1 at steady state |
PI | s2+(1+Kp)s+KIKI+sKp | Combines P and I | - P impacts response speed - I forces zero steady-state error |
Derivative (D) | (1+KD)s+1KDs | Based on rate of change | - Adds open-loop zero - Can affect stability - Provides damping effect |
PID control
GC(s)=Kp+sKI+KDs
in time domain:
u(t)=KPe(t)+KI∫0te(η)dη+KDdtd(e(t))
Component | Discrete-Time Equation |
---|
Proportional | u(k)=KPe(k) |
Integral | u(k)=KIT∑i=1ke(i) |
Derivative | u(k)=TKD[e(k)−e(k−1)] |
approximate of PID controller: u(k)=KPe(k)+KIT∑i=1ne(i)+TKD[e(k)−e(k−1)]
Time Domain x(t) | Laplace Transform X(s) | Z Transform X(z) |
---|
δ(t)={10t=0t=kT,k=0 | 1 | 1 |
δ(t−kT)={10t=kTt=kT | e−kTs | z−k |
u(t) (unit step) | s1 | z−1z |
t | s21 | (z−1)2Tz |
t2 | s32 | (z−1)3T2z(z+1) |
e−at | s+a1 | z−e−aTz |
1−e−at | s(s+a)a | (z−1)(z−e−aT)(1−e−aT)z |
te−at | (s+a)21 | (z−e−aT)2Tze−aT |
t2e−at | (s+a)32 | (z−e−aT)3T2e−aTz(z+e−aT) |
be−bt−ae−at | (s+a)(s+b)(b−a)s | (z−e−aT)(z−e−bT)z[z(b−a)−(be−aT−ae−bT)] |
sinωt | s2+ω2ω | z2−2zcosωT+1zsinωT |
cosωt | s2+ω2s | z2−2zcosωT+1z(z−cosωT) |
e−atsinωt | (s+a)2+ω2ω | z2−2ze−aTcosωT+e−2aTze−aTsinωT |
reference: examples for z-transform
Sequence | Transform |
---|
δ(k−n) | z−n |
1 | z−1z |
k | (z−1)2z |
k2 | (z−1)3z(z+1) |
ak | z−az |
kak | (z−a)2az |
sinak | z2−2zcosa+1zsina |
cosak | z2−2zcosa+1z(z−cosa) |
aksinbk | z2−2azcosb+a2azsinb |
akcosbk | z2−2azcosb+a2z2−azcosb |
properties
Linearity: if x(n)=af1(n)+bf2(n) then X(z)=aF1(z)+bF2(z)
Time shifting:
Z[x(t)]x(k−n)x(k+n)=X(z)=z−nX(z)=znX(z)
The idea to convert analog to digital
T is the sampling period, and T1 is the sampling rate in cycles per second
error=2n+1M
where n is number of bits used for digitalisation
resolution of A/D converter
minimum value of the output that can be represented as binary number, or 2nM
sampled data system
reference input r is the sequence of sample values r(kT)
A sampler is a switch that closes every T seconds:
r∗(t)=k=0∑∞r(kT)δ(t−kT)(t>0)
Transfer function of sampled data:
R∗(s)=L(r∗(t))=k=0∑∞r(kT)e−ksT
definition
Let z=esT, we have the following definition:
Z{r(t)}=F(z)=Z(r∗(t))=k=0∑∞r(kT)z−k
zero-order hold
Transfer function of Zero-Order hold
L(u(t)−u(t−T))=s1−sesT
finding the discrete transfer function
G(s)=s3+6s2+8ss2+4s+3
G(s)G(t)G(z)=s3+6s2+8ss2+4s+3=s0.375+s+20.25+s+40.375=L−1(G(s))=0.375+0.25e−2t+0.375e−4t=Z(G(t))=0.375z−1z+0.25z−e−2Tz+0.375z−e−4Tz
G(z)→x(k)
power series
use: when G(z) is expressed as the ratio of two polynomials in z
G(z)=a0+a1z−1+a2z−2+…
partial fraction
For example: G(z)=(z−1)(z−2)z=z−1−z+z−2z=∑k=0∞(−1+2k)z−k
thus, g(kT)=2k−1
stability
system | pole location criteria on z-plane |
---|
Stable | All poles inside unit circle |
Unstable | Any poles outside unit circle |
Marginally Stable | One or more poles on unit circle, remaining poles inside unit circle |
mapping from s-plane to z-plane
z=eαT(cosωT+jsinωT)
we assume s=α+jω
Location on s-plane | Value of α | Value of eαT | Mapping on z-plane |
---|
Imaginary axis (jω) | α=0 | eαT=1 | On unit circle |
Right half-plane | α>0 | eαT>1 | Outside unit circle |
Left half-plane | α<0 | eαT<1 | Inside unit circle |
final value theorem
If limk→∞x(k) exists, then the follow exists:
k→∞limx(k)=z→1lim(z−1)X(z)
- derive open loop function KGHˉ
- Factor numerator and denominator to get open loop zeros and poles
- Plot roots of 1+KGHˉ=0 in z-plane as k varies
GH(z)ˉ=D(z)N(z)
For determine discrete systems and vice versa.
G(z) with a Zero-Order hold
G(z)=(1−z−1)Z[sGp(s)]=G∗(z)−z−1G∗(z)
example: Find G(z) if Gp(s)=s+1s+2
G∗(s)g∗(t)g∗(kT)G∗(z)=z−12z−z−e−Tz=sGp(s)=s2−s+11=2−e−t(inverse Laplace transform)=2−e−kT
block diagram reduction
a. C(z)=G1(z)G2(z)E(z)
b. C(z)=Z[G1(s)G2(s)]E(z)
The product of G1(s)G2(s) must be evaluated first
model for Open-loop system
The output of open-loop system is
C(z)=G(z)D(z)E(z)
closed loop sample data system
E(z)=R(z)−Z[G(s)H(s)]E(z)∵R(z)C(z)=1+Z[G(s)H(s)]G(z)
using digital sensing device
C(z)=1+Z(G(s)H(s))Z[G(s)R(s)]
using digital controller
R(z)C(z)=1+G1(z)Z(G2(s)H(s))G1(z)G1(z)
time response
T(z)=1+G(z)G(z)
System Type | Transfer Function | Diagram |
---|
Basis | R(z)C(z)=1+Z[G(s)H(s)]G(z) | |
w/ digital sensing device | C(z)=1+Z(G(s)H(s))Z[G(s)R(s)] | |
w/ digital controller | R(z)C(z)=1+G1(z)Z(G2(s)H(s))G1(z)G1(z) | |
Assume the transfer function is given by
D(s)=E(s)U(s)=K0s+bs+a
u(k)=(1−bT)u(k−1)+K0(aT−1)E(k−1)+K0e(k)
The corresponding z-transform
E(z)U(z)=1+(bT−1)z−1K0(aT−1)z−1+K0=z+(bT−1)K0z+K0(aT−1)=[K0(aT−1)+zK0]/[z+(bT−1)]
example: Given D(s)=s+aa, u(kT)=u(k)
U(s)(s+a)=aE(s) (Laplace transform) gives Tu(k+1)−u(k)+au(k)=ae(k)
difference equation is u(k+1)=(1−aT)u(k)+aTe(k)
z-transform is E(z)U(z)=1+(aT−1)z−1aTz−1=z+(aT−1)aT
discrete equivalent
Consider the example
D(s)=E(s)U(s)=s+aa→U(s)s=aE(s)−aU(s)→u′(t)=−au(t)+ae(t)
u(t)=∫0t[−au(τ)+ae(τ)]dτ
u(kT)=u(kT−T)+∫kT−TkT[−au(τ)+ae(τ)]dτ
We can use the following approximation methods for the second term from D(z) to D(s)
D(s) | rule | z-transfer function D(z) | approximation | z-plane to s-plane | stability |
---|
s+aa | forward | (z−1)/T+aa | s←Tz−1 | z←sT+1 | discrete → continuous |
s+aa | backward | (z−1)/(Tz)+aa | s←Tzz−1 | z←1−Ts1 | discrete ← continuous |
s+aa | trapzoid | (2/T)[(z−1)/(z+1)]+aa | s←T2z+1z−1 | z←1−Ts/21+Ts/2 | discrete ↔ continuous |