04 ExtendedAndTimedAutomata

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Introduction to

Embedded Systems

Edward A. Lee & Prabal Dutta


UC Berkeley
EECS 149/249A
Fall 2017

Chapter 3, 4: Extended Finite State Machines, Timed


Automata, Hybrid Automata
Recall FSM Notation

state

initial state
transition

self loop

EECS 149/249A, UC Berkeley: 2


Garage Counter Example
Recall this example, which counts cars in a parking
garage:

EECS 149/249A, UC Berkeley: 3


Extended State Machines

Extended state machines augment the FSM model with


variables that may be read or written. E.g.:

Question: What is the size of the state space?


EECS 149/249A, UC Berkeley: 4
General Notation for Extended State Machines

We make explicit declarations of variables, inputs, and


outputs to help distinguish the three.

EECS 149/249A, UC Berkeley: 5


Extended state machine model of a traffic light
controller at a pedestrian crossing:

This model assumes one reaction per second


(a time-triggered model) EECS 149/249A, UC Berkeley: 6
Quiz: What is the Size of the State Space for the
Traffic Light Controller?

EECS 149/249A, UC Berkeley: 7


Behaviors and Traces

•  FSM behavior is a sequence of (non-stuttering) steps.


•  A trace is the record of inputs, states,
and outputs in a behavior.
•  A computation tree is a graphical
representation of all
possible traces.

FSMs are suitable for formal


analysis. For example, safety
analysis might show that some unsafe
state is not reachable.
EECS 149/249A, UC Berkeley: 8
EECS 149/249A, UC Berkeley: 9
Discrete System (FSM)

Continuous System

Hybrid System jump

flow

EECS 149/249A, UC Berkeley: 10


Where do Hybrid Systems arise?
q  Digital controller of physical “plant”
o  thermostat
o  intelligent cruise/powertrain control in cars
o  aircraft auto pilot
q  Phased operation of natural phenomena
o  bouncing ball
o  biological cell growth
q  Multi-agent systems
o  ground and air transportation systems
o  interacting robots

EECS 149/249A, UC Berkeley: 11


An alternative to FSMs that is explicit about the
passage of time: Timed automata, a special
case of hybrid systems.

EECS 149/249A, UC Berkeley: 12


Example: Mouse Double Click Detector

This simple form of hybrid system is called a timed


automaton, where the dynamics is just passage of time.
EECS 149/249A, UC Berkeley: 13
Quiz: How many states does this automaton
have?

EECS 149/249A, UC Berkeley: 14


Example: Timed Automaton to Prevent
Thermostat Chattering

Temperature threshold is 20 with minimum times Tc and


Th in each mode
h

EECS 149/249A, UC Berkeley: 15


Example: Timed Automaton to Prevent
Thermostat Chattering

Temperature threshold is 20 with minimum times Tc and


Th in each mode τ(t)

... t
(a) 20
h t1 t1 + Th

h(t)
1 ... t
(b) 0

s(t)

Tc
... t
(c) 0

EECS 149/249A, UC Berkeley: 16


Timed automaton model of a traffic light controller

This light remains green at least 60 seconds, and then


turns yellow if a pedestrian has requested a crossing. It
then remains red for 60 seconds.
EECS 149/249A, UC Berkeley: 17
When do reactions occur in a hybrid automaton?

Reactions are occurring continually, with the continuous


state variable x being continually updated.
EECS 149/249A, UC Berkeley: 18
Example: “Tick” Generator (Timer)
How would you model a timer that generates a ‘tick’
each time T time units elapses?

A similar timed automaton can model a generator


of a timer interrupt.

EECS 149/249A, UC Berkeley: 19


Hybrid Automaton Model of Toyota Powertrain
Control Example

Exhaust manifold
Fuel injectors

Measured
A/F
Software
Measured
Air Flow

AIR Intake manifold

[Slide due to J. Deshmukh, Toyota] EECS 149/249A, UC Berkeley: 20


Hybrid Automaton Model of Toyota Powertrain
Control Example
Four Operating Modes:
1.  Startup: Wait for O2 sensors
to start giving accurate
readings (temp dependent),
employ open-loop control
2.  Normal: Use combination of
feedback PI control and
feedforward control to
regulate A/F ratio
3.  Power: Driver depresses
gas pedal more (higher
throttle angle) – switch to
feedforward
4.  Sensor Failure: switch to
feedforward control
“Powertrain Control Verification Benchmark”, Jin et al.,
HSCC 2014 EECS 149/249A, UC Berkeley: 21
Hybrid Automaton for Bouncing Ball

y – vertical distance from ground (position)


a – coefficient of restitution, 0 · a · 1
If you plotted y(t), what would it look like?

EECS 149/249A, UC Berkeley: 22


Hybrid Automaton for Bouncing Ball

y – vertical distance from ground (position)


a – coefficient of restitution, 0 · a · 1

EECS 149/249A, UC Berkeley: 23


Sticky Masses

y1(t)

y2(t)

Displacement of Masses
3.0 y1(t)
y2(t)
2.5

2.0

1.5

1.0

0.5
0.0

0 5 10 15 20 25 30 35 40 45 50
time

EECS 149/249A, UC Berkeley: 24


Sticky Masses
y1(t)

y2(t)

Displacement of Masses
3.0 y1(t)
y2(t)
2.5

2.0

1.5

1.0

0.5
0.0

0 5 10 15 20 25 30 35 40 45 50
time

EECS 149/249A, UC Berkeley: 25


When do reactions occur in a hybrid automaton?

Suppose x and y are discrete and pure signals.


When does the transition occur?
Answer: at the earliest time t when x is absent after entering s1.
This will always be the same time when s1 is entered. Why?
If x is absent when s1 is entered, then the transition is taken then.
If x is present when s1 is entered, then it will be absent at a time
infinitesimally larger. How to model this rigorously?
EECS 149/249A, UC Berkeley: 26

You might also like