0% found this document useful (0 votes)
28 views104 pages

Dynamic Systems Modeling in Mechanics

The document discusses modeling dynamic systems, focusing on Newtonian mechanics and the dynamics of rigid bodies, including translational and rotational motion. It introduces concepts such as degrees of freedom, state representation, and the relationship between force, torque, and motion, using a helicopter model as an example. Additionally, it covers actor models, system properties like causality and linearity, and the transition from ordinary differential equations to transfer functions in system analysis.

Uploaded by

Yassine Blali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views104 pages

Dynamic Systems Modeling in Mechanics

The document discusses modeling dynamic systems, focusing on Newtonian mechanics and the dynamics of rigid bodies, including translational and rotational motion. It introduces concepts such as degrees of freedom, state representation, and the relationship between force, torque, and motion, using a helicopter model as an example. Additionally, it covers actor models, system properties like causality and linearity, and the transition from ordinary differential equations to transfer functions in system analysis.

Uploaded by

Yassine Blali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Modeling Dynamic Systems

Sadek Belamfedel Alaoui

Embedded Systems – Fall 2025

September 22, 2025

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 1 / 100
Newtonian Mechanics (review)

The motion of a physical object in


three-dimensional space is fully described by six
degrees of freedom (DOF): three translational
and three rotational.
Translational DOF: Position along the
three axes (x, y , z), where by convention:
x increases to the right,
y increases upwards,
z increases out of the page.
Rotational DOF: Orientation with respect
to the three axes:
Roll (θx ): rotation about the x-axis. By
convention, θx = 0 corresponds to being
horizontally flat along the z-axis.
Yaw (θy ): rotation about the y -axis. By
convention, θy = 0 corresponds to Figure: Modeling position with six degrees
pointing directly to the right (along the of freedom requires including pitch, roll,
x-axis). and yaw, in addition to position.
Pitch (θz ): rotation about the z-axis. By
convention, θz = 0 corresponds to a
horizontal orientation (relative to the
x-axis).

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 2 / 100
Newtonian Mechanics (review)

The state of a rigid body in space is


described by six time-dependent functions:
Position: The translational coordinates
(x, y , z) are collected in the vector

x(t) ∈ R3 , x : R → R3 .

Orientation: The rotational


coordinates (roll, pitch, yaw) are
collected in the vector Figure: Modeling position with six
degrees of freedom requires including
θ(t) ∈ R3 , θ : R → R3 . pitch, roll, and yaw, in addition to
position.
Changes in position and orientation are governed by Newton’s second law, which relates
force and acceleration.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 3 / 100
Newtonian Mechanics (review)

For the translational dynamics, the relation is given by

F(t) = M ẍ(t), (1)

where F(t) ∈ R3 is the applied force vector, M is the mass of the object, and ẍ(t) denotes the acceleration.

Velocity from acceleration:


Z t
ẋ(t) = ẋ(0) + ẍ(τ )dτ
0

With force F(t) and mass M:


Z t
1
ẋ(t) = ẋ(0) + F(τ )dτ
M 0

Position from velocity:


Z tZ Figure: A free body diagram of a block
τ
1 resting on a rough inclined plane, with its
x(t) = x(0) + t ẋ(0) + F(α)dαdτ
M 0 0 weight (W), normal reaction (N) and friction
(F) shown..

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 4 / 100
Newtonian Mechanics (review)
For the Rotational dynamics, the torque T relates to angular acceleration:
d
T(t) = (I(t)θ̇(t))
dt
where T is the torque vector in three axes and I(t) is the moment of inertia tensor of the object.

The moment depends on the geometry and


orientation of the object:
 
Ixx (t) Ixy (t) Ixz (t)
I(t) = Iyx (t) Iyy (t) Iyz (t)
Izx (t) Izy (t) Izz (t)

Simplified (spherical body):

T(t) = I θ̈(t)

Angular motion:

1 t
Z
θ̇(t) = θ̇(0) + T(τ ) dτ (2) Figure: Relationship between force F , torque
I 0
τ , linear momentum p, and angular
1 t τ momentum L in a system which has rotation
Z Z
θ(t) = θ(0) + t θ̇(0) + T(α) dα dτ (3) constrained to only one plane.
I 0 0

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 5 / 100
Example: Modeling helicopter

Model order reduction


A helicopter has:
A main rotor (provides lift and torque).
A tail rotor (counters the torque to prevent
spinning).
We consider only the role of the tail rotor:
Ignore all translational motion (position fixed at
origin). Figure: Simplified model of
Assume no pitch or roll (helicopter remains vertical). the helicopter.
Coordinate system is fixed to the helicopter.

Result: The problem reduces to one rotational degree of freedom — yaw.


Moment of inertia simplifies to a scalar Iyy .
Only rotation about the y-axis is considered.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 6 / 100
Example: Reduced order Helicopter model
The reduced-order dynamic model is given by:

Ty (t)
θ̈y (t) =
Iyy

Integrating both sides, we obtain:


Z t
1
θ̇y (t) = θ̇y (0) + Ty (τ ) dτ (4)
Iyy 0
Figure: Simplified model of
This represents a single integrator system with respect the helicopter.
to the torque input.
Remark
The critical observation about this example is that if we were to choose to model
the helicopter by, say, letting x : R → R3 represent the absolute position in space
of the tail of the helicopter, we would end up with a far more complicated model.
Designing the control system would also be much more difficult.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 7 / 100
Actor Models
A physical system can be modeled by a differential or integral equation that relates:

Inputs: e.g: force or torque,


Outputs: e.g: position, orientation, velocity, or rotational velocity.

Such a system can be seen as a component in a larger


system. In particular, a continuous-time system can be
depicted as:
Figure: Actor Model
Here, input and output signals are functions of time:

x : R → R, y :R→R

The domain R represents time, and the codomain is the signal value.
We may use R+ if the system starts operating at t = 0.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 8 / 100
System as a Mapping Between Signals

The system is modeled as a function:

S : X → Y, where X = Y = RR

Herea , X and Y are sets of real-valued functions.


a
the notation AR (which can also be written (A → R)
Figure: Actor Model
represents the set of all functions with domain A and
codomain R.

If the system depends on parameters p and q, we may write:

Sp,q or S(p, q)

A block like this, with function-valued inputs and outputs, is called an actor.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 9 / 100
Actor model for the helicopter

The actor model for the helicopter can be depicted as follows:

Figure: Actor Model

The input and output are both continuous-time functions. The parameters
of the actor are the initial angular velocity θ̇y (0) and the moment of
inertia Iyy . The function of the actor is defined by (4).

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 10 / 100
Composition of Actor Models
Cascade composition:

Figure: Cascade Composition


Feedback composition:

Figure: Feedback Composition

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 11 / 100
Composition of Actor Models
Exercise: servomechanism canonical form

Compute the transfer function of the following system in closed-loop:

Figure: Feedback Composition

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 12 / 100
Composition of Actor Models
Exercise: servomechanism canonical form

Compute the transfer function of the following system in closed-loop:

Figure: Feedback Composition

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 13 / 100
Composition of Actor Models
Exercise: servomechanism canonical form

We have

Y (s) = H1 (s)e(s) with e(s) = E (s)−H2 (s)Y (s)

which implies that

Y (s) = H1 (s)E (s) − H1 (s)H2 (s)Y (s)

that is Figure: Cascade Composition


H1 (s)E (s)
Y (s) =
1 + H1 (s)H2 (s)

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 14 / 100
Properties of Systems: Causal systems

A system is causal if its output depends only on current and past inputs.

Let x|t≤τ represent a function called the restriction in time that is only defined for times
t ≤ τ , and where it is defined, x|t≤τ (t) = x(t). Hence if x is an input to a system, then
x|t≤τ is the ”current and past inputs” at time τ .

Causal systems
Consider a continuous-time system S : X → Y , where X = AR and Y = B R for some
sets A and B. This system is causal if for all x1 , x2 ∈ X and τ ∈ R,

x1 |t≤τ = x2 |t≤τ ⇒ S (x1 ) = S (x2 )|t≤τ


t≤τ

That is, the system is causal if for two possible inputs x1 and x2 that are identical up to
(and including) time τ , the outputs are identical up to (and including) time τ .

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 15 / 100
Properties of Systems: Strictly causal systems

Strictly causal systems


A system is strictly causal if for all x1 , x2 ∈ X and τ ∈ R,

x1 |t<τ = x2 |t<τ ⇒ S (x1 ) t<τ


= S (x2 )|t<τ

That is, the system is strictly causal if for two possible inputs x1 and x2 that
are identical up to (and not including) time τ , the outputs are identical up
to (and including) time τ . The output at time t of a strictly causal system
does not depend on its input at time t.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 16 / 100
Properties of Systems: Memoryless systems

Memoryless systems
Consider a continuous time system S : X → Y , where X = AR and
Y = B R for some sets A and B. Formally, system S is memoryless if there
exists a function f : A → B such that for all x ∈ X ,

(S(x))(t) = f (x(t))

for all t ∈ R. That is, the output (S(x))(t) at time t depends only on the
input x(t) at time t.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 17 / 100
Properties of Systems: Linearity

Linearity and Time Invariance


A system S : X → Y , where X and Y are sets of signals, is linear if it
satisfies the superposition property:

∀x1 , x2 ∈ X and ∀a, b ∈ R, S (ax1 + bx2 ) = aS (x1 ) + bS (x2 ) .

It is easy to see that the helicopter system defined in our example is linear
if and only if the initial angular velocity θ̇y (0) = 0.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 18 / 100
Properties of Systems: Time invariance
To define time invariance, we first define a specialized continuous-time actor
called a delay. Let Dτ : X → Y , where X and Y are sets of continuous-time
signals, be defined by

∀x ∈ X and ∀t ∈ R, (Dτ (x)) (t) = x(t − τ ).

Here, τ is a parameter of the delay actor.


Time Invariance
Here, τ is a parameter of the delay actor. A system S : X → Y is time
invariant if

∀x ∈ X and ∀τ ∈ R, S (Dτ (x)) = Dτ (S(x)).

The helicopter system is not time invariant. A minor variant, however, is


time invariant: Z t
1
θ̇y (t) = Ty (τ )dτ
Iyy −∞
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 19 / 100
Properties of Systems: Linear and Time invariance

Linear Time Invariance


A linear time-invariant system (LTI) is a system that is both linear and
time invariant.

A major objective in modeling physical dynamics is to choose an LTI model


whenever possible. If a reasonable approximation results in an LTI model,
it is worth making this approximation. It is not always easy to determine
whether the approximation is reasonable, or to find models for which the
approximation is reasonable. It is often easy to construct models that are
more complicated than they need to be.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 20 / 100
From ODEs to Transfer Functions

General linear time-invariant (LTI) system:

y (n) (t)+an−1 y (n−1) (t)+· · ·+a1 ẏ (t)+a0 y (t) = bm u (m) (t)+· · ·+b1 u̇(t)+b0 u(t).

u(t) = input, y (t) = output.


Coefficients ai , bj are constants (time-invariant).
Order of the ODE = n.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 21 / 100
Step 1: Apply Laplace Transform

With zero initial conditions, Laplace transform gives:

s n + an−1 s n−1 + · · · + a1 s + a0 Y (s) =




bm s m + bm−1 s m−1 + · · · + b1 s + b0 U(s).



(5)

Y (s) = L{y (t)}, U(s) = L{u(t)}.


Derivatives become multiplication by s in Laplace domain.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 22 / 100
Step 2: Define Transfer Function

Y (s) bm s m + bm−1 s m−1 + · · · + b0


G (s) = = .
U(s) s n + an−1 s n−1 + · · · + a0

G (s) is a rational function of s.


Degree of denominator = order of system.
If m ≤ n, G (s) is proper. If m < n, it is strictly proper.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 23 / 100
Step 3: Poles and Zeros

(s − z1 )(s − z2 ) · · · (s − zm )
G (s) = K · .
(s − p1 )(s − p2 ) · · · (s − pn )

pi = poles (roots of denominator).


zj = zeros (roots of numerator).
Poles and zeros determine system dynamics and response.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 24 / 100
Example

ODE:
y (3) + 6y (2) + 11ẏ + 6y = 2u (3) + 16u (2) + 22u̇ − 40u.

2s 3 + 16s 2 + 22s − 40
G (s) = .
s 3 + 6s 2 + 11s + 6

Order = 3 (cubic denominator).


Proper but not strictly proper (deg N = deg D).
Poles at −1, −2, −3, zeros at −4, −5, 1.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 25 / 100
Properties of Systems: LTI System Characterization
The response of an LTI system is described by the transfer function G (s):

Y (s) = G (s)U(s)

Alternatively, using the impulse response g (t) = L−1 {G (s)}:


Z t
y (t) = g (τ )u(t − τ )dτ
0

An impulse input u(t) = δ(t) yields the output:

y (t) = g (t)

Example of a non-rational transfer function:

y (t) = u(t − T ) ⇒ G (s) = e −sT

Observation: G (s) = e −sT is not a rational function, so it cannot be modeled by


a differential equation.
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 26 / 100
Bounded and Unbounded Signals

A signal x(t) is bounded if ∃k > 0 such that |x(t)| ≤ k for all t ≥ 0.

Examples of bounded signals:


Step: 1(t)
Sinusoid: sin(ωt + ϕ)
Decaying exponential: e −at 1(t), a > 0

Examples of unbounded signals:


Ramp: t · 1(t)
Growing exponential: e at 1(t), a > 0

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 27 / 100
Properties of Systems: Stability

A system is said to be bounded-input bounded-output stable (BIBO stable


or just stable) if the output signal is bounded for all input signals that are
bounded.

Bounded-Input Bounded-Output (BIBO) Stability


Consider a continuous-time system with input w and output v . The input
is bounded if there is a real number A < ∞ such that |w (t)| ≤ A for all
t ∈ R. The output is bounded if there is a real number B < ∞ such that
|v (t)| ≤ B for all t ∈ R. The system is stable if for any input bounded by
some A, there is some bound B on the output.

Key idea: Stability must hold for all bounded inputs.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 28 / 100
Properties of Systems: Stability

Theorem (Integral Criterion for Stability)


A system with impulse response g (t) is BIBO stable ⇐⇒
Z ∞
|g (t)|dt < ∞
0

Theorem (Rational Transfer Functions)


A system with rational, proper G (s) is BIBO stable ⇐⇒ all poles of G (s)
have negative real parts.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 29 / 100
Proof of Theorem 1: Sufficiency

R∞
Assume 0 |g (t)|dt ≤ kg and |u(t)| ≤ ku .

Z t
|y (t)| = g (τ )u(t − τ )dτ
0
Z t
≤ |g (τ )||u(t − τ )|dτ
0
Z t
≤ ku |g (τ )|dτ ≤ ku kg
0

⇒ Output is bounded.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 30 / 100
Proof of Theorem 1: Necessity (by Contradiction)

R∞
Assume system is BIBO stable but 0 |g (t)|dt = ∞.
Then ∃t1 s.t. Z t1
ky
|g (t)|dt >
0 ku
Construct input: 
ku
 g (t) > 0
u(t1 − t) = 0 g (t) = 0

−ku g (t) < 0

Then, Z t1
y (t1 ) = ku |g (t)|dt > ky
0
Contradiction: output is unbounded.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 31 / 100
Properties of Systems: Stability
The Routh-Hurwitz Stability Criterion

The first step in applying the Routh-Hurwitz criterion is to construct the Routh table from
the coefficients of an nth degree polynomial:

s n + an−1 s n−1 + an−2 s n−2 + · · · + a1 s + a0

1 Set up the first two rows: The table has n + 1 rows, labeled from s n down to s 0 .
The coefficients of the first two rows are taken directly from the polynomial in a
zig-zag pattern.
sn 1 an−2 an−4 . . .
s n−1 an−1 an−3 an−5 . . .

2 Calculate subsequent rows: All other coefficients in the table are calculated from
the two rows immediately preceding them. For example, the elements of the s n−2
row (b1 , b2 , . . . ) are calculated using the following determinant formula:

1 1 an−2 1 1 an−4
b1 = − , b2 = − , ...
an−1 an−1 an−3 an−1 an−1 an−5

This pattern of calculation continues row by row until the table is complete down to
the s 0 row.
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 32 / 100
Properties of Systems: Stability
The Routh-Hurwitz Stability Criterion

Investigate the stability of the system:


s +2
G (s) =
s4 + 4s 3 + 5s 2 + 12s + 10

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 33 / 100
Properties of Systems: Stability
The Routh-Hurwitz Stability Criterion

s4 1 5 10
Construction of Routh table is constructed as s3 4 12
follows: s2 ... ...
s1 ...
s0 ...
The coefficients for the s 2 row:
1 1 5 1
b1 = − = − (12 − 20) = 2
4 4 12 4

The second element is calculated as:


1 1 10 1
b2 = − = − (0 − 40) = 10
4 4 0 4

For the s 1 row:


1 4 12 1
c1 = − = − (40 − 24) = −8
2 2 10 2
For the s 0 row:
1 2 10 1
d1 = − = (0 − (−80)) = 10
−8 −8 0 8

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 34 / 100
Properties of Systems: Stability
The Routh-Hurwitz Stability Criterion

The complete Routh table is given by:


s4 1 5 10
s3 4 12
s2 2 10
s1 -8
s0 10

Stability Analysis The Routh-Hurwitz criterion states that the number of


roots with positive real parts is equal to the number of sign
changes in the first column. The elements in the first column
are {1, 4, 2, −8, 10}.
There are two sign changes in this column: one from 2 to
-8, and another from -8 to 10. Therefore, the system is
unstable and has two poles in the right-half plane.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 35 / 100
Properties of Systems: Stability
The Routh-Hurwitz Stability Criterion

Once the Routh table is fully constructed, the stability of the system is
determined by examining the signs of the elements in the first column.
Stable System: The roots of the polynomial have negative real parts
if and only if all the elements of the first column are positive. A
necessary condition for this to be true is that all coefficients of the
original polynomial must be positive.

Unstable System: If there are nonzero elements in the first column


but they are not all positive, the system is unstable. The number of
roots with positive real parts is equal to the number of sign
changes in the sequence of elements in the first column.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 36 / 100
Properties of Systems: Stability
The Routh-Hurwitz Stability Criterion

The standard procedure for interpreting the Routh table assumes that no
element in the first column is zero. If a zero does appear, one of two
special cases must be handled.
Case 1: An Entire Row is Zero This situation indicates that an even
polynomial is a factor of the original polynomial. The roots
of an even polynomial are symmetric with respect to the
origin of the complex plane.
Procedure: Form an auxiliary polynomial using the
coefficients from the row immediately above the row of
zeros. The power of s for the first term corresponds to the
row’s label, and subsequent powers decrease by two [9].
Analyzing the roots of this auxiliary polynomial is necessary
to determine if the system is marginally stable or unstable [9,
10].

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 37 / 100
Properties of Systems: Stability
The Routh-Hurwitz Stability Criterion

The standard procedure for interpreting the Routh table assumes that no
element in the first column is zero. If a zero does appear, one of two
special cases must be handled.
Case 2: A Zero in the First Column Only This occurs when the first
element of a row is zero, but at least one other element in
that same row is nonzero.
Procedure: To proceed, replace the zero in the first column
with a small positive constant ϵ and continue calculating
the rest of the table as usual. After the table is complete,
determine the signs of the first-column elements by taking
the limit as ϵ → 0. The number of sign changes will reveal
the number of roots in the right-half plane.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 38 / 100
Example: Is the Delay System Stable?

y (t) = u(t − T ) ⇒ G (s) = e −sT


Impulse response:
Z ∞
g (t) = δ(t − T ) ⇒ |g (t)|dt = 1 < ∞
0

Conclusion: Delay system is BIBO stable.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 39 / 100
Marginal Stability and Imaginary Poles

If G (s) has simple poles on the imaginary axis (e.g., s = ±jω) and others
in Left-Half Plane (LHP):
Then:
System is not BIBO stable
Impulse response is bounded
Output may be bounded for some inputs
Example:
 
s +1 1 1 1
G (s) = ⇒ g (t) = + sin ωt − cos ωt 1(t)
s(s 2 + ω 2 ) ω2 ω ω2

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 40 / 100
Special Case: Input Matching Pole

Z t
1
G (s) = ⇒ y (t) = u(τ )dτ
s 0
If u(t) = 1(t) (step), then:

y (t) = t · 1(t) ⇒ Unbounded ramp

However, periodic inputs with zero DC1 yield bounded output.

1
If a signalR has a zero DC component, it means that the average value of the signal
T
is zero i.e. T1 0 x(t) dt = 0 where x(t) is the signal, and T is the period of the signal.
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 41 / 100
Exercise: Helicopter Model

Given the following Helicopter model:


Z t
1
θ̇y (t) = θ̇y (0) + Ty (τ ) dτ
Iyy 0
Figure: Simplified model
of the helicopter.

1 Determine the transfer function of the helicopter.


2 Is the helicopter model stable?

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 42 / 100
Feedback Control

ψ is an input signal specifying the desired angular velocity.


e represents the difference between the actual and the desired angular velocity.
The controller simply scales the error signal by a constant K , providing a control input to
the helicopter.

Figure: Proportional control system that stabilizes the helicopter

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 43 / 100
Feedback Control

Using the equation of motion of the helicopter,


we have:
Z t
1
θ̇y (t) = θ̇y (0) + Ty (τ ) dτ (6)
Iyy 0
Figure: Proportional control system that stabilizes
the helicopter

Substituting the control input Ty (t) = Ke(t), and the error signal e(t) = ψ(t) − θ̇y (t), the
equation becomes:
Z t
K 
θ̇y (t) = θ̇y (0) + ψ(τ ) − θ̇y (τ ) dτ (7)
Iyy 0
Thus, we can express the control system in terms of the error signal e(t) and the control input
Ty (t):
e(t) = ψ(t) − θ̇y (t), and Ty (t) = Ke(t)
For simplicity, we assume that ψ(t) = 0 for all t, meaning that we wish to control the helicopter
to keep it from rotating at all. Thus, the desired angular velocity is zero. In this case, equation
(7) simplifies to: Z t
K
θ̇y (t) = θ̇y (0) − θ̇y (τ ) dτ (8)
Iyy 0

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 44 / 100
Feedback Control
Using the fact from calculus that, for t ≥ 0,
Z t
ae aτ dτ = e at u(t) − 1 (9)
0

Let the input be Ty = u, where u is the unit step, given by



0, t < 0
∀t ∈ R, u(t) = .
1, t ≥ 0

This means that prior to time zero, there is no torque applied to the system, and starting
at time zero, we apply a torque of unit magnitude. This input is clearly bounded. It never
exceeds one in magnitude. However, the output grows without bound. Thus, we can infer
that the solution to (8) is
θ̇y (t) = θ̇y (0)e −Kt/Iyy u(t). (10)
(Note that although it is easy to verify that this solution is correct, deriving the solution
is not so easy. For this purpose, Laplace transforms provide a far better mechanism.) We
can see from (10) that the angular velocity approaches the desired angular velocity (zero)
as t gets large as long as K is positive. For larger K , it will approach more quickly. For
negative K , the system is unstable, and angular velocity will grow without bound.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 45 / 100
Remark on Helicopter Torque Control

Remark
The previous example is somewhat unrealistic because we cannot indepen-
dently control the net torque of the helicopter. In particular, the net torque
Ty is the sum of the torque Tt from the top rotor and the torque Tr from
the tail rotor:
∀t ∈ R, Ty (t) = Tt (t) + Tr (t).

Here, Tt is determined primarily by the thrust needed to maintain or


change altitude, which is largely independent of the helicopter’s rotational
control. Therefore, in practice, we must design a control system that
manipulates Tr to stabilize the helicopter regardless of the behavior of Tt .

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 46 / 100
Modified Helicopter Model
Setup: Assumptions:
Consider the helicopter model with two Torque from top rotor is given by
inputs:
Tt : torque from top rotor (treated as Tt = b u(t)
external input),
Tr : torque from tail rotor (controlled for constant b and step input u(t).
input). Helicopter starts from rest.
Feedback control system only controls Goal: analyze how well this system performs
Tr . under disturbance Tt .

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 47 / 100
Modified Helicopter Model
Setup: Assumptions:
Consider the helicopter model with two Torque from top rotor is given by
inputs:
Tt : torque from top rotor (treated as Tt = b u(t)
external input),
Tr : torque from tail rotor (controlled for constant b and step input u(t).
input). Helicopter starts from rest.
Feedback control system only controls Goal: analyze how well this system performs
Tr . under disturbance Tt .

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 47 / 100
Modified Helicopter Model
Setup: Assumptions:
Consider the helicopter model with two Torque from top rotor is given by
inputs:
Tt : torque from top rotor (treated as Tt = b u(t)
external input),
Tr : torque from tail rotor (controlled for constant b and step input u(t).
input). Helicopter starts from rest.
Feedback control system only controls Goal: analyze how well this system performs
Tr . under disturbance Tt .

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 47 / 100
Example: Model Transformation

Step 1: Algebraic Model Transformation


Equivalent model in Figure 2.4(b) uses:
 a2 
Ka1 + a2 = K a1 +
K

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 48 / 100
Example: Model Transformation

Step 2: Use Commutativity of Addition


Further transformation yields Figure (c).
The boxed portion matches the system from the helicopter Example.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 49 / 100
Example: Input to Control System

Desired Output:
ψ(t) = 0
Input to control system:

Tt (t) b
x(t) = ψ(t) + = u(t)
K K
Exploiting the previous system response in equation (10), we obtain:

b  
θ̇y (t) = u(t) 1 − e −Kt/Iyy
K

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 50 / 100
Example: Input to Control System

Desired Output:
ψ(t) = 0
Input to control system:

Tt (t) b
x(t) = ψ(t) + = u(t)
K K
Exploiting the previous system response in equation (10), we obtain:

b  
θ̇y (t) = u(t) 1 − e −Kt/Iyy
K

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 50 / 100
Example: Input to Control System

Desired Output:
ψ(t) = 0
Input to control system:

Tt (t) b
x(t) = ψ(t) + = u(t)
K K
Exploiting the previous system response in equation (10), we obtain:

b  
θ̇y (t) = u(t) 1 − e −Kt/Iyy
K

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 50 / 100
Discrete-time system

A linear Single-Input–Single-Output (SISO) discrete-time system can be


modeled by the difference equation:

y (k + n) = − an−1 y (k + n − 1) − · · · − a0 y (k)
+ bn u(k + n) + · · · + b0 u(k)

where u is the input, y is the output, and k is the discrete time variable (k
= 0, 1, 2,...).

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 51 / 100
The Z-Transform
Definition

For a discrete-time signal x(k), where k = 0, 1, 2, . . . , the Z-transform is defined by


the infinite series:
X∞
X (z) = Z{x(k)} = x(k)z −k
k=0

Here, z = re jω is a complex variable.


The series is convergent over a region in the complex plane of the form |z| ≥ r0 ,
which is known as the region of convergence.

Example: Z-Transform of an Exponential Function


Let x(k) = aλk , where λ is a complex number.
∞ ∞  k
X X λ
X (z) = aλk z −k = a
z
k=0 k=0
1 az
=a = , if |z| > |λ|
1 − (λ/z) z −λ

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 52 / 100
Key Properties of the Z-Transform

Linearity:

Z{a1 x1 (k) + a2 x2 (k)} = a1 X1 (z) + a2 X2 (z)

Time Shift by n:
n−1
" #
X
Z{x(k + n)} = z n X (z) − x(i)z −i
i=0

If initial conditions are zero, Z{x(k + n)} = z n X (z).


If x(i) = 0 for i < 0, Z{x(k − n)} = z −n X (z).

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 53 / 100
Key Properties of the Z-Transform

Convolution: The Z-transform of a convolution summation is the


product of the individual Z-transforms.
(∞ )
X
Z x1 (ℓ)x2 (k − ℓ) = X1 (z)X2 (z)
ℓ=0

Final Value Theorem: If all poles of (z − 1)X (z) are inside the unit
circle, then the final value of the signal x(k) can be found from its
transform X (z).

lim x(k) = lim (z − 1)X (z)


k→∞ z→1

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 54 / 100
Discrete-Time Transfer Functions

The transfer function of a discrete-time system is the ratio of the


Z-transform of the output to the Z-transform of the input, assuming
zero initial conditions.
Y (z)
G (z) =
U(z)

We can find the transfer function by taking the Z-transform of the


system’s difference equation. For the general nth -order difference
equation, this yields:

bn z n + bn−1 z n−1 + · · · + b0
G (z) =
z n + an−1 z n−1 + · · · + a0

The roots of the numerator polynomial N(z) are the zeros of G (z),
and the roots of the denominator polynomial D(z) are the poles of
G (z).
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 55 / 100
Z-transform
Remarks

The Z-transform is a mathematical tool used for analyzing


discrete-time systems .
It plays a role for discrete-time systems that is analogous to the role
the Laplace transform plays for continuous-time systems.
It allows us to represent a linear discrete-time system, often described
by a difference equation, as a transfer function.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 56 / 100
Stability Condition

Theorem
A discrete-time system represented by a rational proper transfer function
G (z) is stable if and only if all poles of G (z) are inside the unit circle; that
is, |pi | < 1 for all poles pi .

This is equivalent to the condition on the impulse response g (k):



X
|g (k)| < ∞, where g (k) = Z −1 {G (z)}.
k=0

Key Idea
For discrete-time systems, the stability boundary is the unit circle in the
z-plane, whereas for continuous-time systems, it is the imaginary axis in
the s-plane.
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 57 / 100
Discrete Systems
Definition and Characteristics

Definition: A discrete system operates in a sequence of discrete steps and


is said to have discrete dynamics.
Operation:
It reacts in sequence to a sequence of input events.
Each reaction is assumed to be instantaneous.
Reactions are triggered by the environment, either event triggered (e.g., when
an input event is present) or time triggered (e.g., at regular time intervals).
Signals: Pure vs. Valued:
Discrete signals consist of sequences of instantaneous events in time.
Pure signals:
Carry no value; only presence/absence matters.
Often used for triggering reactions.
Valued signals:
Carry associated data values.
Used to communicate computed information or system state.
Input and output signals of a discrete system are typically discrete in nature.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 58 / 100
Discrete systems
Example Parking Garage Counter

A system counting cars entering and leaving a garage.


Input events (ArrivalDetector, DepartureDetector) are pure sig-
nals.
The Counter increments/decrements its count and produces the new
value as output (a valued, discrete signal).

Model of a system that keeps track of the number of cars in a parking garage

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 59 / 100
Discrete systems
Modeling Parking Garage Counter as FSM

The guard up ∧ ¬down is a predicate that evaluates to true when up


is present and down is absent.
If at a reaction the current state is 0 and this guard evaluates to true,
then the transition will be taken and the next state will be 1.
Starting from state 0, the action indicates that the output should be
assigned the value 1.

FSM model for the garage counter


Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 60 / 100
Discrete systems
Logical Operators

Operands are Boolean values: {0, 1} or {False, True}.


The most common operators are:
∧: logical AND (true if both are true).
∨: logical OR (true if at least one is true).
¬: logical NOT (negation).

p q p∧q p∨q ¬p
0 0 0 0 1
0 1 0 1 1
1 0 0 1 0
1 1 1 1 0

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 61 / 100
Discrete Systems
Contrast with Continuous Systems and Modeling

Contrast with Continuous Systems:


Unlike continuous systems (which evolve smoothly and react
continuously to a continuum of inputs), discrete components evolve
abruptly.

Modeling Approach:
Discrete components are not conveniently modeled by ordinary
differential equations (ODEs).
Instead, state machines are used to model discrete dynamics, often
combined with continuous dynamics in hybrid system models.

Continuous components can be sampled and discretized to obtain a


discrete representation of the system.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 62 / 100
Discrete Systems
State Machine

A state machine Σ is defined as a state


machine with the tuple

Σ = (X, X0 , U, F , Y, h),

where
X is the set of states,
X0 is the set initial states,
U is the set of inputs,
Visual notation for a finite state machine
Y is the set of outputs, The guards is a boolean condition that
F ⊆ X × U × X is the transition must evaluate to true for a specific state
relation, generally defined by a transition to occur after a trigger event is
received. The action specifies what out-
difference equation of the form,
puts are produced on each reaction.
x(k + 1) = F (x(k), u(k))

h : X × Y → R is the output map.


Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 63 / 100
State Machine
Mealy Machines

Definition
A Mealy machine is a finite state machine where the output depends on both
the current state and current input.

M = (X, X0 , U, Y, F , ω)

X: finite set of states


X0 : initial state
U: input alphabet
Y: output alphabet
F : X × U → X: transition function
ω : X × U → Y: output function
Mealy Machine
Outputs are produced on transitions, not while in a state.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 64 / 100
State Machines
Moore Machines

Definition
A Moore machine is a finite state machine where the output depends only on
the current state, not the current input.

M = (X, X0 , U, Y, F , ω)
X: finite set of states
X0 ∈ X: initial state
U: input alphabet
Y: output alphabet
F : X × U → X: state transition
function
ω : X → Y: output function
(depends only on state) Moore Machine

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 65 / 100
Discrete systems
Properties of State Machines

Deterministic:
A state machine is deterministic if, for each state, there is at most one
transition enabled by each input value.
Receptiveness:
A state machine is receptive if, for each state, there is at least one transition
possible on each input symbol.
Deterministic and Receptive: If a state machine is both deterministic and
receptive, then for every state, there is exactly one transition possible on
each input value.
Nondeterministic: A state machine is nondeterministic if, there exist a
state, for which at least two transitions enabled by the same input value.
Mealy vs. Moore Machines:
Mealy machines produce outputs when a transition is taken.
Moore machines produce outputs when the machine is in a state.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 66 / 100
State Machine
Exercise

Design a state diagram for a Mealy machine that must recognize the
sequence “1101”.

The circuit has a single input to which the sequence is applied.

It has a single output ‘0’ as long as the sequence is not detected and
‘1’ as soon as the sequence is detected.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 67 / 100
State Machine
Mealy Machine for Sequence 1101

Mealy Machine
Mealy Machine for sequence 1101

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 68 / 100
Extended State Machine
Overcoming State-Space Limitations

Motivation: The basic FSM no-


tation becomes awkward and un-
wieldy when the number of states
gets very large.
FSM model for the garage counter
Definition: An extended state machine augments the FSM model
with variables that may be read and written as part of taking a tran-
sition between states.

Garage counter can be


represented compactly by the
extended state machine

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 69 / 100
Extended State Machine
Extended State Machines: Notation

Differences from FSMs:


1 Variable declarations are explicit → clarify whether an identifier is a variable,
input, or output.
2 Initialization: variables may be assigned initial values on the transition into
the initial state.
3 Transition annotations: now have the form

guard / output action set action(s)

Semantics:
Guard and output actions behave as in stan-
dard FSMs, but may reference variables.
Set actions update variables after guard
evaluation and output production.
Multiple set actions are executed sequen- Notation for extended state
tially. machines

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 70 / 100
Extended State Machines
Size of State Space

Let:
n := number of discrete states,
m := number of variables,
p := number of possible values for each variable,
then the size of the state space of the state machine is

|States| = n · p m

What is the size of the state space for the garage counter example?
What is the size of the state space for the traffic light controller
example?
In the traffic light controller, are all the states reachable?

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 71 / 100
Extended State Machine
Traffic Light Controller

– Time-triggered machine: reacts once


– Outputs:
per second.
– Initial state: red, with counter count sigR – red light on,
initialized. sigG – green light on,
– Behavior: sigY – yellow light on.
Stay in red for 60 seconds, then
transition to green.
In green:
If no pedestrian request, remain
green.
If pedestrian request:
If already green ≥ 60 s → transition
to yellow.
Else → transition to pending, then
move to yellow at 60 s. Extended state machine model of a traffic light
controller that keepstrack of the passage of time,
In yellow: remain for 5 seconds, then
assuming it reacts at regular intervals
return to red.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 72 / 100
Behaviors and Traces
Signals, Behaviors and languages

Signals:
For each port p of a state machine, its signal is a sequence of values
over time, represented as a function sp : N → Vp ∪ {absent}.
This function captures the value on the port at each reaction (if it’s
present or indicates its absence).
Behavior:
A behavior of a state machine is an assignment of such a signal to
each port such that the signal on any output port is the output
sequence produced for the given input signals.
Language of a State Machine (L(M)):
The language of a state machine M is defined as the set of all possible
behaviors for that state machine.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 73 / 100
Behaviors and Traces
Observation and execution trace

Observable trace: Let xi represent the valuation of the input ports


and yi the valuation of the output ports at reaction i. Then an
observable trace is a sequence

((x0 , y0 ) , (x1 , y1 ) , (x2 , y2 ) , · · · )

Execution trace: An execution trace includes the state trajectory,


and may be written as a sequence

((x0 , s0 , y0 ) , (x1 , s1 , y1 ) , (x2 , s2 , y2 ) , · · · )

where s0 = initialState. This can be represented a bit more


graphically as follows,
x0 /y0 x1 /y1 x2 /y2
s0 −−−→ s1 −−−→ s2 −−−→ · · ·

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 74 / 100
Hybrid Systems

Differential equations are used to model continuous dynamics.


State machines are used to model discrete dynamics.
Cyber-physical systems are hybrid systems that include both
continuous and discrete dynamics.
Hybrid system models must represent continuous and discrete
dynamics.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 75 / 100
Modal Models
Actor Model for State Machines

Input ports i1 , . . . , in .
Output ports o1 , . . . , on .
Ports have signals that are
either pure or valued.

An FSM represented as an actor

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 76 / 100
Modal Models
Continuous-Time Inputs & State refinement

Consider a thermostat modeled as


a state machine with states Σ =
{ heating, cooling}.
The input is a continuous-time signal
τ : R → R where τ (t) represents the
temperature at time t.
The initial state is cooling, and the tran-
sition out of this state is enabled at the A thermostat modeled as an FSM with a
earliest time t after the start time when continuous-time input signal
τ (t) ≤ 18.

when the system is in some abstract state (say Active), that state itself contains a refined
model - a sub-state machine (or refined dynamics) - that governs how inputs are mapped
to outputs while the system remains in that state.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 77 / 100
Hybrid Systems
Definition

A hybrid system:
Associates with each state of an FSM a
dynamic behavior.
Each state is associated with a state
refinement labeled in the figure as a
“time-based system”.
The state refinement defines dynamic
behavior of the outputs and (possibly)
additional continuous state variables
Each transition can optionally specify set
actions, which set the values of such
additional state variables when a
transition is taken
Notation for hybrid systems

A hybrid system is sometimes called a modal model because it has a finite number of modes,
one for each state of the FSM, and when it is in a mode, it has dynamics specified by the state
refinement.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 78 / 100
Hybrid Systems
A thermostat modeled as an FSM with a continuous-time input signal

This example models a thermostat as a state machine that interacts with a continuous-time
signal, a key concept in hybrid systems.
States (Σ): The thermostat has two
modes: {heating, cooling}.
Input: It receives a continuous-time
signal τ : R → R, where τ (t) is the
temperature at time t. This is a
generalization from discrete-event
inputs seen in earlier models.
Outputs: The system produces pure
signals, heatOn and heatOff, which
are present only at the instant a
transition is taken. A thermostat modeled as an FSM with a
Behavior: It uses hysteresis to avoid continuous-time input signal
rapid on/off switching (”chattering”)
near the setpoint temperature.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 79 / 100
Hybrid Systems
Timed Automata

Timed automata are modal models, where the time-based refinements have very simple
dynamics; all they do is measure the passage of time.
Core Concept: FSMs with Clocks
Each state refinement has a clock.
The states of the FSM are often referred to as
modes to distinguish them from the continuous
state variables.
The dynamic behavior within each mode
measures the passage of time.
A clock s is typically modeled by a first-order
differential equation like ṡ(t) = a, where a is a
constant.
Key Mechanisms:
Guards: Transitions between modes are A timed automaton modeling a thermo-
governed by guards that can incorporate stat with a single temperature thresh-
conditions based on the values of continuous old, 20, and minimum times Tc and Th
clock variables. in each mode. The notation := is an
Set Actions: When a transition is taken, it can assignment.
include set actions that reset clock variables.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 80 / 100
Hybrid systems
Timed Automata

(a) A temperature input to the hybrid system (Thermosta) (b) The output h, and (c) The
refinement state s
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 81 / 100
Hybrid systems
Timed Automaton

A timed automaton is a tuple A = ⟨Σ, L, L0 , C , F , E ⟩ that consists of the


following components:
Σ is a finite set called the alphabet or actions of A.
L is a finite set. The elements of L are called the modes or states of
A.
L0 ⊆ L is the set of start locations.
C is a finite set called the clocks of A.
F ⊆ L is the set of accepting locations.
E ⊆ L × Σ × B(C ) × P(C ) × L is a set of edges, called transitions of
A, where
B(C ) is the set of clock constraints involving clocks from C , and
P(C ) is the powerset of C .
An edge (ℓ, σ, g , r , ℓ′ ) from E is a transition from locations ℓ to ℓ′ with
action σ, guard g and clock resets r .
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 82 / 100
Hybrid Systems
Timed Automata

A timed automaton that generates a pure out-


put event every T time units A timed automaton variant of the traffic light
controller

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 83 / 100
Hybrid systems
Supervisory Control

Definition: Supervisory control is a level of a controller within a


control system, typically alongside low-level control.
Role: Its primary function is to determine the mode transition
structure of a system.
It decides which of several strategies the system should follow.
The low-level controller then implements the selected strategy by
determining the time-based inputs to the plant.
Modeling: Hybrid systems are ideally suited for modeling these
two-level controllers, effectively combining discrete transitions with
continuous dynamics.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 84 / 100
Hybrid systems
Example: Automated Guided Vehicle (AGV) Control

Objective: Keep an AGV closely following a


painted track.
Controller Structure: The AGV controller uses
four modes managed by supervisory control:
stop, straight, left, and right.
Supervisory Decisions (Mode Transitions):
Uses sensor input e(t), which estimates
displacement from the track (e(t) > 0 if left,
e(t) < 0 if right).
Defines guards for switching modes using
thresholds 0 < ε1 < ε2 :
If |e(t)| < ε1 : Stay in straight mode (close
to track).
If e(t) > ε2 : Switch to right mode (strayed
Automatic Guided Vehicle with four
too far left).
If e(t) < −ε2 : Switch to left mode (strayed
modes: stop, straight, left, right.
too far right).

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 85 / 100
Exercise: Automated Guided Vehicle

Vehicle Dynamics (The Plant):


Degrees of Freedom: The vehicle’s state at
time t is defined by its position (x(t), y (t)) ∈ R2
and its angle θ(t) ∈ (−π, π] relative to a fixed
coordinate frame.
Equations of Motion: The vehicle’s motion is
governed by a system of three differential
equations:
ẋ(t) = u(t) cos θ(t)
ẏ (t) = u(t) sin θ(t)
θ̇(t) = ω(t)
Low-Level Control (within modes): Each
mode has predefined differential equations
governing motion, specifying inputs like speed
u(t) and angular speed ω(t).
straight: u(t) = 10, θ(t) = 0 (constant Automatic Guided Vehicle with four
heading). modes: stop, straight, left, right.
left: u(t) = 10, θ(t) = π (turns left).
right: u(t) = 10, θ(t) = −π (turns right).
stop: u(t) = 0, θ(t) = 0 (vehicle halted).

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 86 / 100
Hybrid system
Automated Guided Vehicle with supervisory controller

Automatic guided vehicle with four modes: stop, straight, left, right.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 87 / 100
Hybrid systems
Supervisory Control

A trajectory of the AGV, annotated with modes

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 88 / 100
Composition of State Machines
What is Synchrony?

The term ”synchronous” generally means occurring or existing at the same time or
moving or operating at the same rate. However, its interpretation varies significantly
across different engineering and computer science domains:

Synchronous-Reactive (SR) Models:


Synchrony Hypothesis: Outputs of components are (conceptually) simultaneous with
their inputs.
Instantaneous & Simultaneous Execution: Components execute (conceptually)
simultaneously and instantaneously at each ”tick” of a global clock.
While real executions are not literally instantaneous, a correct execution must behave as
if they were. This usage is consistent with both general definitions.
In SR feedback models, inputs and outputs have the same value in every reaction.

Concurrent Software (Threads/Processes):


Synchronous Communication: Refers to a rendezvous style where sender and
receiver wait for each other, perceiving communication as simultaneous.
synchronized Keyword (Java): Defines code blocks not permitted to execute
simultaneously, which is an ”oddly inconsistent” usage.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 89 / 100
Composition of State Machines
What is Synchrony?

Circuit Design:
Involves a global clock that drives latches to record inputs on clock edges.
Similar to SR models, assuming zero delay between latches and
simultaneous/instantaneous execution due to the global clock.

Power Systems Engineering:


Electrical waveforms have the same frequency and phase.

Signal Processing:
Signals have the same sample rate, or their rates are fixed multiples of one another.
Synchronous Dataflow (SDF): Refers to fixed production and consumption rates of
tokens, *not* a global clock or instantaneous execution in the SR sense.

Composition of State Machines:


Synchronous Composition: A reaction of the composite system is a simultaneous
reaction of its component state machines.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 90 / 100
Composition of State Machines
Side-by-Side Synchronous Composition

Formal Semantics for two FSMs A and B:


States of composite C:
StatesC = StatesA × StatesB
Inputs of C: InputsC = InputsA × InputsB
Outputs of C:
OutputsC = OutputsA × OutputsB
Initial State of C:
(initialStateA , initialStateB )
Update Function of C:
Side-by-side composition
updateC ((sA , sB ), (iA , iB )) = ((s′A , s′B ), (oA , oB )) of two actors.

where (s′A , oA ) = updateA (sA , iA ) and


(s′B , oB ) = updateB (sB , iB )

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 91 / 100
Composition of State Machines
Side-by-Side Composition

Fundamental Principle: The inputs and outputs of the component actors


are assumed to be disjoint.

Synchronous Composition:
A reaction of the composed system is
a simultaneous reaction of all
component machines.
Conceptually, all components react
instantaneously at each global ”tick”.
Properties:
If component state machines are
deterministic, the synchronous
composition is also deterministic.
The composed system itself is a Example of side-by-side
FSM.
composition of two actors.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 92 / 100
Composition of State Machines
Side-by-Side Asynchronous Composition

Asynchronous Composition semantics:


1 A reaction of C is a reaction of one of A
or B, where the choice is nondeterminis-
tic
2 A reaction of C is a reaction of A, B, or
both A and B, where the choice is nonde-
terministic. A variant of this possibility
might allow neither to react.
Scheduling policies that let the environment
influence which machine reacts introduce two
new semantics.
3 A reaction of C is a reaction of one of A
or B, where the environment chooses
which of A or B reacts
State machine giving the semantics of
4 A reaction of C is a reaction of A, B, or asynchronous side-by-side of the previous
both A and B, where the choice is synchronous example.
made by the environment.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 93 / 100
Modeling Two Servers with Shared Request Queue

System Overview No New Request


Two servers (A, B) share a queue. A server is again nondeterministically
Requests arrive asynchronously. chosen.
Unknown service durations. If idle and pending ¿ 0:
Shared variable pending tracks Serve next request.
queued requests. Decrement pending.
If busy:
On Request Arrival Continue serving, or
Server A or B is chosen Finish current request:
nondeterministically. Go idle if no pending requests.
Else serve next and decrement
If idle: serve immediately. pending.
If busy:
May finish current job and serve
Key Point: All decisions are
new one, or nondeterministic to reflect uncertain
Increment pending. service times.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 94 / 100
Composition of State Machines
Side-by-Side Asynchronous Composition

Model of two servers with a shared task queue, assuming asynchronous composition under
semantics 1.
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 95 / 100
Composition of State Machines
Cascade composition

Synchronous Semantics: The primary model for


this composition is synchronous. A reaction of the
composite machine consists of a reaction of both
A and B, occurring logically in zero time.
Machine A reacts first, producing an output.
Machine B then immediately reacts to A’s
output within the same instantaneous step.
Example If A transitions from state sA1 → sA2 and B Cascade composition of two actors
transitions from sB1 → sB2 , the composite state
moves directly from (sA1 , sB1 ) to (sA2 , sB2 ).
Causality: While the reactions are instantaneous, they are causally related. The
behavior of machine B is affected by the output produced by machine A in the same
reaction.
Type Checking: For the composition to be valid, the data type of A’s output port
(Vo1 ) must be a subset of the data type of B’s input port (Vi2 ).

Vo1 ⊆ Vi2

Ordered Reactions: Cascade composition implies a clear, sequential ordering of


reactions within a single, composite reaction step.
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 96 / 100
Composition of State Machines
General Composition

Arbitrary interconnections of state machines are combinations of side-by-side and cascade


compositions, possibly creating cycles

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 97 / 100
Composition of State Machines
Hierarchical State Machines

Semantics: Hierarchical state machines are finite


state machines whose states themselves can be other
state machines.
Example In the Figure, state B has a refinement that
is another FSM with two states, C and D. What it
means for the machine to be in state B is that it is in
one of states C or D. In a hierarchical FSM, a state may have a
refinement that is another state machine.

Reaction Order: In one common semantic model, reactions occur in a depth-first fashion.
The deepest refinement of the current state reacts first, followed by its container, and so on
up the hierarchy.
Preemptive Transitions: To avoid subtleties, a preemptive transition can be used. Its
guard is evaluated before the refinement reacts. If the transition is taken, the refinement
does not react at all.
Entry Transitions: How a container state is entered determines the initial state of its
refinement.
Reset Transition: Indicated with a hollow arrowhead, this transition resets the refinement to
its initial state (e.g., entering B always goes to C).
History Transition: Indicated with a solid arrowhead (sometimes marked ”H”), this transition
causes the refinement to resume in whatever state it was last in.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 98 / 100
Extended State Machines
Remarks

FSMs provide
1 A way to represent the system for mathematical analysis, so that a
computer program can manipulate it.
2 A way to model the environment of a system.
3 A way to represent what the system must do and must not do - (i.e.,
its specification).
4 A way to check whether the system satisfies its specification in its
operating environment.ˆ For example, using reachability analysis, one
can determine that some unsafe state is not reachable.

Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 99 / 100
Sadek Belamfedel Alaoui (UM6P-CC) Embedded systems September 22, 2025 100 / 100

You might also like