CIS 4930/6930
Principles of Cyber-Physical
Systems
Instructor: Hao Zheng
What are Embedded Systems?
Computers whose job is not primarily information processing,
but rather is interacting (sensing and control) with physical
processes
Examples:
Automotive controllers
Avionics
Medical devices
Industrial control
Infrastructure
Transportation
Energy management and conservation
A broader view is that of cyber-physical systems (CPS)
2
Embedded Everywhere!
3
What are Embedded Systems?
Computational
but not first-and-foremost a computer
Integral with physical processes
sensors, actuators, physical dynamics
Reactive
at the speed of the environment (timing matters!)
Heterogeneous
hardware/software/networks, mixed architectures
Networked
concurrent, distributed, dynamic
4
Differences Between Embedded Systems and
General-Purpose Computation:
Time matters
“as fast as possible” is not good enough
Concurrency is intrinsic
it’s not an illusion (as in time sharing), and
it’s not (necessarily) about exploiting parallelism
Processor requirements can be specialized
predictable, repeatable timing
support for common operations (e.g. FIR filters)
need for specialized data types (fixed point, bit vectors)
Programs need to run (essentially) forever
memory usage has to be bounded (no leaks!!)
rebooting is not acceptable
5
Other Characteristics of Embedded Sys.
• Dependable
• Reliability R(t) = probability of system working correctly
provided that is was working at t=0
• Maintainability M(d) = probability of system working
correctly d time units after error occurred.
• Availability A(t): probability of system working at time t
• Safety: no harm to be caused
• Security: confidential and authentic communication
• Making the system dependable must not be an
after-thought, it must be considered from the very
beginning
6
Other Characteristics of Embedded Sys.
• Efficiency
• Code-size efficient (especially for systems on a chip)
• Run-time efficient
• Weight efficient
• Cost efficient
• Energy efficient
7
Cyber-Physical Systems (CPS)
CPS are the tight integration of and coordination
between computation with physical processes.
CPS include embedded systems and networks to
monitor and control physical processes.
Future CPS will be much stronger in
Adaptability, autonomy, efficiency, functionality, reliability,
safety, and usability.
The challenge is the interactions between the
embedded computers and the physical processes.
Need to understand the joint dynamics of HW, SW,
networks and physical processes.
8
Applications
9
Medical Devices
Emerging direction: Cell phone
based medical devices for
affordable healthcare
e.g. “Telemicroscopy” project at
Berkeley
Robotic surgery
10
Medical Devices: Assisted Living
For example:
• Artificial eye: several
approaches, e.g.:
• Camera attached to
glasses; computer worn at
belt; output directly
connected to the brain,
“pioneering work by William
Dobelle”. Previously at
[www.dobelle.com]
Translation into sound; claiming much better
resolution.
[http://www.seeingwithsound.com/etumble.htm]
11
Medical Devices: Assisted Living (cont’d)
IEEE Spectrum, 1/2012
12
Infrastructures: Smart buildings
Examples
Integrated cooling, lightning,
room reservation, emergency
handling, communication
Goal: zero-net energy buildings
Expected contribution to fight
against global warming
13
Transportation: Avionics
Flight control systems,
Autonomous-collision avoidance,
pilot information systems,
power supply system,
flap control system,
entertainment system,
…
Dependability is of outmost
importance.
14
Transportation: Automotive electronics
About 80 computers (electronic control units, ECUs)
in a premium car today:
engine control, transmission, anti-lock brakes, electronic
suspension, parking assistance, climate control, audio
system, “body electronics” (seat belt, etc.), display and
instrument panel, etc.
linked together by CAN bus (today), FlexRay (tomorrow)
with up to 2km of wiring.
growing fraction of development costs, manufacturing
costs, and fuel consumption.
15
Transportation: DARPA Grand Challenge
16
Google Self-Drive Cars
http://youtu.be/PgTc4Np9YX4
17
Typical Embedded System Architecture
18
Structure of CPS
19
Where CPS Differs from the traditional
embedded systems problem:
The traditional embedded systems problem:
Embedded software is software on small computers. The technical
problem is one of optimization (coping with limited resources and
extracting performance).
The CPS problem:
Computation and networking integrated with physical processes.
The technical problem is managing dynamics, time, and
concurrency in networked cyber + physical systems.
20
A Key Challenge on the Cyber Side:
Real-Time Software
Correct execution of a program in C, C#,
Java, Haskell, etc. has nothing to do with how
long it takes to do anything. All our
computation and networking abstractions are
built on this premise.
Timing of programs is not repeatable,
except at very coarse granularity.
Programmers have to step outside the
programming abstractions to specify
timing behavior.
21
Techniques Exploiting the
Fact that Time is Irrelevant
Programming languages
Virtual memory
Caches
Dynamic dispatch
Speculative execution
Power management (voltage scaling)
Memory management (garbage collection)
Just-in-time (JIT) compilation
Multitasking (threads and processes)
Component technologies (OO design)
Networking (TCP)
…
22
What about “Real Time”?
What if you need “absolutely positively
on time”?
Today, most embedded software
engineers write code, build your
system, and test for timing.
The resulting system is brittle,
meaning the slight changes in the
operating conditions (or in the design
of the system) can cause big changes
in behavior. For example, replacing
the processor with a faster one can
cause real-time failures.
Prioritize and Pray!
23
A Story
A “fly-by-wire” aircraft, expected to be made for 50
years, requires a 50-year stockpile of the hardware
components that execute the software.
All must be made from the same mask set on the
same production line. Even a slight change or
“improvement” might affect timing and require the
software to be re-certified.
24
Abstraction Layers
The purpose for an
abstraction is to
hide details of the
implementation
below and provide
a platform for
design from above.
25
Abstraction Layers
Every abstraction
layer has failed for
time-sensitive
applications.
26
Is the problem
intrinsic in the
technology?
Electronics technology
delivers highly repeatable and
precise timing…
20.000 MHz (± 100 ppm)
… and the overlaying software
abstractions discard it.
27
CPS is Multidisciplinary
Computer Science: System Theory:
Carefully abstracts the Deals directly with
physical world physical quantities
Cyber Physical Systems:
Computational +
Physical
28
CPS is at boundary of EE and CS
29
Traditionally, embedded systems has been an industrial
(not academic) problem, principally about resource
limitations.
Small memory
Small data word sizes
Relatively slow clocks
When these are the key problems, emphasize efficiency:
write software at a low level (in assembly code or C)
avoid operating systems with a rich suite of services
develop specialized computer architectures:
programmable DSPs
network processors
develop specialized networks
Can, FlexRay, TTP/C, MOST, etc.
This is how embedded systems have been designed for 30 years
30
Content of an Embedded Systems Course
Traditional focus CPS focus
• Hardware interfacing • Modeling
• Interrupts • Timing
• Memory systems • Dynamics
• Imperative logic
• C programming
• Concurrency
• Assembly language
• Verification
• FPGA design
• …
• RTOS design
•…
31
Main Challenge
Models for the physical world and for computation diverge.
Physical: continuous time, differential equations
Computational: discrete time, logic
There is a huge cultural gap.
Physical system models must be viewed as semantic
frameworks, and theories of computation must be viewed as
alternative ways of talking about dynamics.
32
What this course is about
A principled, scientific approach to modeling and
analysis of embedded systems
Not about specific designs
Ad hoc designs can be fun, but it can also be very
painful when things go wrong…
Focus on model-based design for
embedded systems
33
Course Theme: Model-Based Design
• A principled, scientific approach to designing and
implementing embedded systems.
• Modeling of cyber and physical processes
• Analyze the model.
• Synthesize the cyber control for the physical processes.
• MBD allows rapid prototyping, system verification,
and design reuse.
• Reduce the development cost.
• Speed up development process.
34
Modeling, Design, Analysis
Modeling is the process of
gaining a deeper understanding
of a system through imitation.
Models specify what a system does.
Design is the structured creation of
artifacts. It specifies how a system does
what it does. This includes optimization.
Analysis is the process of gaining a deeper understanding
of a system through dissection.
It specifies why a system does what it does
(or fails to do what a model says it should do).
35
What is Modeling?
Developing insight about a system, process, or
artifact through imitation.
A model is the artifact that imitates the system,
process, or artifact of interest.
•If a model = good abstraction of a physical sys.
•Assertions about models => confidence in the
realization of the system.
36
More on Model-Based Design
1. Create a mathematical model of all the parts of the
embedded system
Physical world
Control system
Software environment
Hardware platform
Network
Sensors and actuators
2. Construct the implementation from the model
Construction may be automated, like a compiler
More commonly, portions are automatically constructed
37
Topics we will study
Model-Based Design
Represent systems based on mathematical models
System Analysis
Verify that your model & implementation will meet a spec.
Concurrency
Run multiple tasks correctly and efficiently
Real-Time
Ensuring that tasks finish on time
Joint discrete-continuous dynamics
Consider CPS as a whole
38
Read Chapter 1 of Lee & Seshia
39