22_Discretization
22_Discretization
Automotive Engineering
• Fully accurated theory for digital signals and purely digital controllers is
complicated (finite automata, quantized controllers etc.) – now is done by
Cyber Physical Systems (CPS) community
1 0.8
e(t) u(k)
0.8
e(k) 0.6 u(t)
0.6
0.4
0.4
0.2
0.2
0 0
e
u
-0.2
-0.2
-0.4
-0.4
-0.6
-0.6
-0.8
-1 -0.8
0 1 2 3 4 5 0 1 2 3 4 5
t t
x(k)
x(t)
t (s)
Let 𝑥𝑥(𝑘𝑘) = 𝑥𝑥(𝑘𝑘𝑘𝑘) be the discrete-time signal obtained from 𝑥𝑥(𝑡𝑡) using
a sampling frequency 𝝎𝝎𝒔𝒔 = 𝟐𝟐𝝅𝝅/𝑻𝑻.
Finally, don’t forget that A/D converter also truncates data (real
numbers are transformed to float, double, long double etc.)
So, practically the ideal reconstruction is impossible, however, the
quality of signal recovery can indeed be very high!
An Illustration
continuous-time signal
Fourier transform
𝑟𝑟𝑟𝑟𝑟𝑟
𝐵𝐵 = 17 , 𝜔𝜔𝑠𝑠 ≥ 2𝐵𝐵, 𝑇𝑇 ≤ 2𝜋𝜋/𝜔𝜔𝑠𝑠 = 𝜋𝜋/𝐵𝐵 = 0.185 𝑠𝑠
𝑠𝑠
Applying a Naïve Reconstruction (ZOH)
B=17 rad/s, ωs ≥ 2B T ≤ 0.185 s
METHOD:
'zoh' Zero-order hold
'foh' First-order hold
'imp' Impulse-invariant
'tustin' Tustin
'prewarp' Tustin approximation with frequency pre-warping
'matched' Matched pole-zero
And third derivative? Just apply the previous formula to the derivative (to
be discussed in relation to exercise).
In reality, discretization can be done in frequency domain by applying a
formal rule (a bit later, based on z-transform).
On Github, a function c2d_euler is available (not included into official
Control Systems Toolbox!), written by Dr. Tamas Kis
https://www.mathworks.com/matlabcentral/fileexchange/90267-euler-c2d-
transformation-c2d_euler
𝒚𝒚 𝒌𝒌𝑻𝑻 − 𝒚𝒚 (𝒌𝒌 − 𝟏𝟏)𝑻𝑻
• Backward Euler is sometimes used: 𝒚𝒚̇ 𝒌𝒌𝑻𝑻 ≅
𝑻𝑻
Example: Travelling Mass
Traveling mass subject to friction
• This simple model is commonly used for the design of cruise control
systems.
• Assume that we measure only sampled values of the input u(k)=u(kT) and
are interested only in the sampled output y(k)=y(kT) (at other time, we have
no measurements)
• We can derive the (approximate) model of such a discretized system
(defined for k=1,2,…):
Tβ T
y(k) = 1 − y(k − 1) + u(k − 1)
M M
Euler’s Method for State Equation
𝑥𝑥(𝑡𝑡)
̇ = 𝐴𝐴𝐴𝐴(𝑡𝑡) + 𝐵𝐵𝐵𝐵(𝑡𝑡) 𝒙𝒙(𝒌𝒌 + 𝟏𝟏) = (𝑰𝑰 + 𝑻𝑻𝑻𝑻)𝒙𝒙(𝒌𝒌) + 𝑻𝑻𝑩𝑩𝑩𝑩(𝒌𝒌)
𝑦𝑦(𝑡𝑡) = 𝐶𝐶𝐶𝐶(𝑡𝑡) + 𝐷𝐷𝐷𝐷(𝑡𝑡) 𝒚𝒚(𝒌𝒌) = 𝑪𝑪𝑪𝑪(𝒌𝒌) + 𝑫𝑫𝑫𝑫(𝒌𝒌)
Big disadvantage of the Euler forward method: for large sampling period, the stability can
be destroyed. For instance, a system with exponentially decaying solution may acquire
unbounded solutions, as shown by the example:
𝑥𝑥(𝑡𝑡)
̇ = 𝐴𝐴𝐴𝐴(𝑡𝑡) + 𝐵𝐵𝐵𝐵(𝑡𝑡) 𝑥𝑥(𝑘𝑘 + 1) = (𝐼𝐼 + 𝑇𝑇𝑇𝑇)𝑥𝑥(𝑘𝑘) + 𝑇𝑇𝐵𝐵𝐵𝐵(𝑘𝑘)
𝑦𝑦(𝑡𝑡) = 𝐶𝐶𝐶𝐶(𝑡𝑡) + 𝐷𝐷𝐷𝐷(𝑡𝑡) 𝑦𝑦(𝑘𝑘) = 𝐶𝐶𝐶𝐶(𝑘𝑘) + 𝐷𝐷𝐷𝐷(𝑘𝑘)
𝑥𝑥(𝑡𝑡)
̇ = 𝐴𝐴𝐴𝐴(𝑡𝑡) + 𝐵𝐵𝐵𝐵(𝑡𝑡) ?
𝑦𝑦(𝑡𝑡) = 𝐶𝐶𝐶𝐶(𝑡𝑡) + 𝐷𝐷𝐷𝐷(𝑡𝑡)
• Hint: you will need to solve the linear equation to find 𝑥𝑥(𝑘𝑘) as a function
of 𝑥𝑥(𝑘𝑘 − 1) and 𝑢𝑢(𝑘𝑘).