Discrete Systems
Mark Cannon
Hilary Term 2014
0-1
Lecture 1
Sample rate selection and fast sampling systems
1-1
Introduction
Discrete system
–
a dynamic system with at least one discrete
(quantized) variable
This course concentrates on discrete time systems
where time is a discrete variable
e.g. microprocessor instruction cycle
. . . the state changes only at each clock pulse
Computers perceive the world (sensors)
& interact with it (actuators)
as if it was a discrete system
1-2
Introduction
Aims of the course:
? to model and analyse discrete (time) systems
? to control continuous time systems using computers
How it fits in with the rest of A2:
1-3
Introduction
Example – Engine management system (ECU)
A microprocessor regulates fuel, engine timing, gearbox and brake operation.
The ECU samples the outputs of numerous sensors,
e.g. throttle position, crankshaft position, car acceleration . . .
and uses a control algorithm to compute the required control signals
e.g. air and fuel flow-rates, ignition & valve timings . . .
1-4
Introduction
Example – Engine management system (ECU)
At each sampling instant, the ECU:
1. reads in sensor measurements from ADCs
2. uses these to compute the required control signals
3. outputs control signals to actuators via DACs
1-5
Introduction
Example – Engine management system (ECU)
The controller is a discrete time system (a microprocessor)
which interacts with continuous time systems (car, driver etc)
? Either design a continuous time controller, based on continuous time
vehicle models, and implement it approximately in discrete time
? Or design a controller directly in discrete time using discrete time models
We will look at both types of approach
1-6
Introduction
Reasons for the prevalence of digital control & signal processing
? Accuracy: digital signals are usually represented using 12 bits or more
? Reliability: processing digital signals avoids noise and uncertainty
that a↵ects analogue signal processing
? Flexibility: limited only by processing power (and programming ability!)
? Cost:
1-7
advances in technology make microcontrollers economical
even for small, low cost applications
Introduction
Reading:
G F Franklin, J D Powell & M Workman Digital Control of Dynamic
Systems 3rd edition, Addison Wesley, 1998.
. . . see also
M Sami Fadali & Antonio Visioli Digital Control Engineering: Analysis
and Design Academic Press, 2009
R C Dorf & R H Bishop Modern Control Systems Pearson Prentice Hall,
2008
Lecture notes & slides:
Lecture notes, slides and tutorial sheet 2A2H are on weblearn and
www.eng.ox.ac.uk/⇠conmrc/dcs
1-8
Sampled data systems
Continuous controller – continuous system
Methods of designing D(s) (A2 Intro to control theory course)
? Time domain: set damping ratio ⇣ and natural frequency !0
? Frequency domain: set gain and phase margins of D(s)G(s)
1-9
Sampled data systems
Discrete controller – sampled data system
Controller input e(kT ) & output u(kT ) are discrete variables
This lecture looks at how to approximate D(s) using di↵erence equations
when the sample rate 1/T is sufficiently large
1-9
Sampling: ADC
ADC produces a binary number (e.g. 12 bits)
usually converted to floating point format
Sample at a constant rate:
T = sample period or sampling interval
1/T = sample rate in Hz
(2⇡/T = sample rate in rad s
Notation:
sample
sampled signal: y(t)
! y(kT ), k = . . .
we also write
y(kT ) = y(k) = yk
1 - 10
1
)
2, 1, 0, 1, 2, . . .
Reconstruction: DAC
Discrete to continuous signal conversion is by DAC plus hold
e.g. ZOH (Zero-order hold):
y(kT )
discrete
DAC+ZOH
! y(t)
piecewise
continuous
A first-order hold (linear interpolation between samples)
is sometimes used instead of a ZOH
1 - 11
Nyquist sampling theorem
What continuous signal is represented by a given set of samples?
Infinitely many continuous signals have the same discrete samples:
An answer is provided by Nyquist’s sampling theorem:
A signal y(t) is uniquely defined by its samples y(kT ) if the
sampling frequency is more than twice the bandwidth of y(t).
1 - 12
Nyquist sampling theorem
Example – Sampled sinusoidal signal
Sample cos(ˆ
! t) at frequency !s = 2⇡/T :
y(t) = cos(ˆ
! t)
sample
! y(kT ) = cos(k !
ˆ T ) = cos(2⇡k !
ˆ /!s )
Identical samples are obtained from a sinusoid with frequency !s
cos (!s
!
ˆ )t
sample
! cos k(!s
!
ˆ )T = cos(2⇡k
!
ˆ:
2⇡k !
ˆ /!s )
= cos(2⇡k !
ˆ /!s )
1
0.5
cos(ˆ
! t)
⇡
y
0
⇡
−0.5
−1
0
0.2
0.4
0.6
0.8
cos (!s
!
ˆ )t
1
t
The spectrum of y(kT ) contains an alias at frequency !s !
ˆ !!
"
(a copy of the original signal y(t) shifted to a di↵erent frequency)
1 - 13
Nyquist sampling theorem
Example – Sampled sinusoidal signal
By the same argument, y(kT ) contains an infinite number of aliases at
!s ± !
ˆ , 2!s ± !
ˆ , 3!s ± !
ˆ, . . .
spectrum
of y(kT ):
The Nyquist sampling theorem requires !s > 2ˆ
!
+
y(t) and alias spectra do not overlap
y(t) can be recovered without distortion from y(kT ) (via low-pass filter)
[Nyquist’s sampling theorem is covered in full in the A1 course]
1 - 14
Euler’s approximation
x(t + t)
dx
= lim
t!0
dt
t
x(t)
dx
xk+1 xk
⇡
dt
T
=)
For small enough T , this can be used to approximate a continuous controller
by a discrete controller:
1. Laplace transform ! di↵erential equation
e.g.
D(s) =
U (s)
K(s + a)
=
E(s)
(s + b)
=)
⇣ de
⌘
du
+ bu = K
+ ae
dt
dt
2. Di↵erential equation ! di↵erence equation
e.g.
⇣e
⌘
uk+1 uk
ek
k+1
+ b uk = K
+ a ek
T
T
=) uk+1 = (1
=
bT )uk + Kek+1 + K(aT
1)ek
a1 uk + b0 ek+1 + b1 ek
1 - 15
Euler’s approximation
Discrete controller recurrence equation:
uk =
a1 uk
1
a2 uk
2
. . . + b0 e k + b1 e k
1
+ ...
coefficients a1 , a2 , . . . , b0 , b1 , . . . depend on T
Example
K(s + a)
,
(s + b)
1
G(s) =
s(s + 1)
Controller:
D(s) =
Plant:
K = 70, a = 2 rad s
1
, b = 10 rad s
Step response with continuous controller:
Plant Output y
1.5
1
0.5
0
1 - 16
0
0.5
1
1.5
Time (sec)
2
2.5
3
1
Euler’s approximation
Step responses with discrete controller:
1.5
Plant output y
Plant output y
1.5
1
0.5
0
0
1/T = 80 Hz
0.2
0.4
0.6
Time (sec)
0.8
1/T = 20 Hz
0.2
0.4
0.6
Time (sec)
0.8
1
0.8
1
1.5
Plant output y
Plant output y
0.5
0
0
1
1.5
1
0.5
0
0
1
1/T = 40 Hz
0.2
0.4
0.6
Time (sec)
0.8
1
1
0.5
0
0
1/T = 10 Hz
0.2
0.4
0.6
Time (sec)
1 - 17
Euler’s approximation
Observations:
At high enough sample rates Euler’s approximation works well,
i.e. discrete controller ⇡ continuous controller
but if sampling is not fast enough the approximation is poor
Typically we require
1/T > 30 ⇥ the system bandwidth
. . . here closed-loop system b/w ⇡ 1 Hz, so this gives 1/T > 30 Hz
In later lectures we consider:
better ways of representing continuous systems in discrete-time
ways of analysing discrete controllers directly
1 - 18
E↵ect of sampling
Lower sample rate
more oscillatory response
=)
— Why?
Sampling and reconstruction introduces:
delay
in time domain
& phase lag in freq. domain
can destabilize the closed loop system
On average u(kT ) is delayed by T /2 relative to u(t) due to the ZOH:
⇣
⇣⇣
⇣
)
u(t)
⇣⇣
⇣
⇣
ZOH output
⇣
)
fundamental component
⇣ of ZOH output
⇣
)
1 - 19
E↵ect of sampling
The ZOH delay of T /2 (sec) causes
1
phase lag = !T /2 (rad)
at ! rad s
phase lag = ⇡/2 = 90
at ! = ⇡/T [= Nyquist rate]
phase lag = ⇡/30 = 6
at ! = ⇡/(15T )
? 90 phase lag could be catastrophic
? If !samp > 30 ⇥ !max ,
then system bandwidth: !max < ⇡/(15T ),
so the maximum phase lag is less than 6
-
usually safe to ignore
? Any time needed to compute uk causes additional delay (!)
1 - 20
PID control
A continuous PID controller has transfer function:
✓
◆
U (s)
1
D(s) =
=K 1+
+ TD s
E(s)
TI s
In the time domain, u(t) and e(t) are related by a di↵erential equation:

du
de
1
d2 e
=K
+
e + TD 2
dt
dt
TI
dt
Using Euler’s approximation (for 1st and 2nd derivatives)
gives approximate discrete time controller:

uk uk 1
ek ek 1
1
ek 2ek 1 + ek 2
=K
+
e k + TD
T
T
TI
T2
⇣
⇣
T
TD ⌘
2TD ⌘
TD
=) uk = uk 1 + K 1 +
+
ek
1+
ek 1 +
ek
TI
T
T
T
i.e. a linear recurrence equation: uk =
a1 uk
1
+ b0 e k + b1 e k
1
+ b2 e k
1 - 21
PID control
Example
Servo-motor speed:y rad s
input:u Volts
Y (s)
3.6 ⇥ 105
= G(s) =
U (s)
(s + 60)(s + 600)
1
PID controller parameters: K = 5, TD = 8 ⇥ 10
4
, TI = 3 ⇥ 10
3
Continuous controller step response:
Speed (rad/s)
1.5
1
0.5
0
0
1
2
3
4
Time (ms)
5
6
7
Bandwidth ⇡ 1/(4 ms) = 250 Hz
=) need to sample at 30 ⇥ 250 = 7.5 kHz
1 - 22
8
2
2
PID control
Check the bandwidth estimate . . .
open loop bode magnitude plot,
20 log|G(j!)|:
closed loop bode magnitude plot,
G(j!)D(j!)
20 log
:
1 + G(j!)D(j!)
20
2
0
15
−2
−4
Gain (dB)
Gain (dB)
10
5
0
−6
−8
−10
−12
−14
−5
−16
−10 0
10
1
2
10
10
Frequency (rad/s)
3
4
10
10
−18 0
10
1
2
10
10
Frequency (rad/s)
3
10
. . . closed loop system bandwidth = 1.5 ⇥ 103 rad s
⇡ 250 Hz
1 - 23
PID control
Discrete controller with 10 kHz sample rate:
Speed (rad/s)
1.5
1
0.5
0
0
1
2
3
4
Time (ms)
5
6
7
8
5
6
7
8
Discrete controller with 3.3 kHz sample rate:
Speed (rad/s)
1.5
1
0.5
0
0
1 - 24
1
2
3
4
Time (ms)
4
10
1
PID control
Try to improve response at 3.3 kHz sample rate by changing K, TD & TI
Increase damping by:
)
? reducing K
? increasing TD
e.g. K = 3.2, TD = 1.1 ⇥ 10
3
(trial and error)
New response at 3.3 kHz sample rate:
Speed (rad/s)
1.5
1
0.5
0
0
1
2
3
4
Time (ms)
5
6
7
8
1 - 25
Summary
Sample rate for digital signal processing
& fast sampling approximations of digital control systems.
fs > 2B allows exact reconstruction of a signal with bandwidth B
(Nyquist sampling theorem)
Continuous controllers may be approximated in discrete time by di↵erence
equations e.g. using Euler’s approximation
Reconstruction by a ZOH introduces a delay of T /2, which is equivalent
to a phase delay of !T /2 at frequency !
ZOH phase delay implies a more oscillatory response
but negligible e↵ect if fs > 30B
We can design discrete controllers for lower sample rates
but this requires more accurate analysis of discrete signals and systems
1 - 26