Embedded Real Time Systems
Embedded Real Time Systems
Prof. Davide Brugali
Università degli Studi di Bergamo
What is an Embedded System?
“Any sort of device which includes a
programmable computer but itself is not
intended to be a general-purpose computer”
(Marilyn Wolf)
Definition
Slide credit P Koopman, CMU
A short list of embedded systems
Slide credit Vahid/Givargis, Embedded Systems Design: A Unified Hardware/Software Introduction, 2000
How many do we use?
⚫ Average middle-class American home has 40 to 50 embedded
processors in it
⚫ Microwave, washer, dryer, dishwasher, TV, VCR, stereo, hair dryer,
coffee maker, remote control, humidifier, heater, toys, etc.
⚫ Luxury cars have over 80 embedded processors
⚫ Brakes, steering, windows, locks, ignition, dashboard displays,
transmission, mirrors, etc.
⚫ Personal computers have over 10 embedded processors
⚫ Graphics accelerator, mouse, keyboard, hard-drive, CD-ROM, bus
interface, network card, etc.
- Mike Schulte
Types of Embedded Systems
Slide credit P Koopman, CMU
Some common characteristics of embedded systems
⚫ Single-functioned
▫ Executes a single program, repeatedly
• Tightly-constrained
▫ Low cost, low power, small, fast, etc.
• Reactive and real-time
▫ Continually reacts to changes in the system’s environment
▫ Must compute certain results in real-time without delay
Slide credit Vahid/Givargis, Embedded Systems Design: A Unified Hardware/Software
Introduction, 2000
Design Constraints
Other Design Considerations
Dependability
▫ Reliability: probability of system working correctly
provided that it worked at time t=0
▫ Maintainability: probability of system working
correctly d time units after error occurred.
[Some systems require no maintenance
throughout their operating lives (e.g. electric
kettles, computer keyboards), while some may
need it such as mobile phones and airplane
flight control (software upgrade)]
Real-Time Consideration
Correct operation of real-time systems means:
▫ Working correctly (functionally correct)
▫ Producing outputs in time!
i.e. correct result at the right time
Hardware vs Software
• Many functions can be done by software on a general
purpose microprocessor OR by hardware on an
application specific ICs (ASICs)
• For examples: game console graphic, PWM, PID
control
• Leads to Hardware/Software Co-design concept
Hardware vs Software
Microcontrollers
finite impulse response (FIR) filters
Hardware vs Software
ASIC : Application Specific Integrated Circuit
DSP : Digital Signal Processing
FPGA : Field Programmable Gate Array Slide credit – Ingo
Sander
Field Programmable Gate Array
FPGA with 20.000 logic ports
Field Programmable Gate Arrays (FPGAs) are semiconductor devices that are based
around a matrix of configurable logic blocks (CLBs) connected via programmable
interconnects.
FPGAs can be reprogrammed to desired application or functionality requirements after
manufacturing.
This feature distinguishes FPGAs from Application Specific Integrated Circuits (ASICs),
which are custom manufactured for specific design tasks.
Field Programmable Gate Array
FPGA with 20.000 logic ports
Digital Signal Processing
The main difference between is that a DSP processor has features
designed to support high performance, repetitive, numerically intensive
tasks.
DSP processors are designed specifically to perform a large number of
complex arithmetic calculations as quickly as possible.
As compared to general processors, the DSP processor is more efficient at
performing basic arithmetic operations, especially multiplications.
Digital Signal Processing
Applications of digital signal processing in communications
adaptive equalizers,
echo cancellers,
high-security encrypted low bit-rate speech transmission
Microcontroller-Based Embedded Computer
ROM or Flash to hold program
Flash ~256 KB ARM Core
~ 100 MHz
~100 KB
The Arduino Development Board
USB
PWR IN
(to Computer)
A printed circuit board RESET
designed to facilitate
work with a particular
microcontroller. I2C Bus
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS
Microcontrollers dominates processor market
General-Purpose Computer
Large Embedded Systems
• Embedded doesn’t mean small
• Large embedded systems such as network
switches and routers don’t use
microcontrollers
• CPU is typically in 100’s of MHz
• 500MB-1 GB RAM
• 250-500 MB Flash
• Power consumption could be an issue
• They are embedded systems like their smaller
counterparts in the sense that they perform a
single well-defined set of tasks
22
Domestic Robots
Service robotics
24
Service robotics
25
Service robotics
26
Agricultural Robots
Space Robotics
Autonomous vehicles
Correctness of Embedded Systems
Correctness
Response Time and Deadline
Real Time Systems
Segway
Controller design and implementation
What is special in ERTS
Real-Time Embedded control
▪ The responsiveness of the system (Car) can be measured by its rise time R.
▪ R is the time it takes to get close to its final state after the input changes.
▪ A good rule of thumb is the ratio R/T of rise time to sampling period is from
10 to 20.
▪ The faster a system respond to changes, the shorter the sampling period is.
Road slope, surface
SPORADICALLY R
+
Desired + Speed +
+ Actuator + Car
speed Controller
-
PERIODICALLY
Actual T
speed
Sensor
37
Real-Time Embedded control
Set timer to interrupt periodically with Period T;
at each interrupt, do;
read data from Sensor;
compute control output u;
write command to Actuator;
end do;
Road slope, surface
SPORADICALLY R
+
Desired + Speed +
+ Actuator + Car
speed Controller
-
PERIODICALLY
Actual T
speed
Sensor
38
Real-Time Embedded control
T
CPU
read comp write
Road slope, surface
SPORADICALLY R
+
Desired + Speed +
+ Actuator + Car
speed Controller
-
PERIODICALLY
Actual T
speed
Sensor
39
Real-Time Embedded control
Real Time
Embedded PC Software Microcontroller
with OS without OS
Road slope, surface
SPORADICALLY R
+
Desired + Speed +
+ Actuator + Car
speed Controller
-
PERIODICALLY
Actual T
speed
Sensor
Real-Time Embedded control
Min distance
CRUISE CONTROL WITH OBSTACLE DETECTION
▪ Regulate the speed of a car by adjusting the throttle:
▪ Input by the driver → sets a speed and car maintains it.
▪ Measures the speed through device connected to the motor shaft
▪ Disturbances: road surface and slope, wind
▪ Automatically regulates the speed according to the distance to the preceding car
41
Concurrent Real-Time Embedded control
T1
CPU { T2
communication
Obstacle distance
Distance
Sensor Environment
Monitor
PERIODICALLY T2
Road slope, surface
Desired +
speed + +
Speed
+ Controller
Actuator + Car
-
PERIODICALLY
Actual
speed
T1
Sensor
42
Distributed Real-Time Embedded control
T1
CPU 1
Network
T2
CPU 2
Obstacle distance
Distance
Sensor Environment
Monitor
PERIODICALLY T2
Network
Road slope, surface
Desired + Actual
speed + + speed
Speed
+ Actuator + Car
Controller
-
PERIODICALLY
T1
Sensor
43
Concurrent Real-time Applications
Real-time Application Real-time Application
Task Task
1 2 ...
Interrupt Interrupt
Handler Handler ... Real-time
1 2 Operating System
Hardware Hardware
NO
RT-Operating System RT-Operating System
Cyclic Executive &
Interrupt Handlers Scheduler
44
Distributed Real-time Applications
Real-time Application Real-time Application
Task Task
1 2 ...
Interrupt Interrupt
Handler Handler ... Real-time
1 2 Operating System
Hardware Hardware
CAN
Transceiver
45
Distributed Real-time Applications
Real-time Application Real-time Application
Task Task Task Task
1 2 ... 1 2 ...
Data / Events
Middleware Middleware
Real-time Real-time
Operating System Operating System
Ethernet / Ethercat
Hardware Hardware
46
Need for Special Network Technologies
▪ General-purpose networks, such as Ethernet, exhibit random and
nondeterministic behaviour due to the conflict arbitration methods used (e.g.,
CSMA/CD)
▪ Results in nondeterministic delays, including arbitrarily long delays in the
worst-case
▪ Results in packet dropping during periods of heavy network activity
▪ Fieldbus, used in process and factory automation
PROFIBUS, used in factory and process automation
▪ CANBUS, used in automotive
EtherCAT, Ethernet for Control Automation Technology
47
Classification of RT Systems
Slides based on the book “Real-Time Systems: Design Principles
for Distributed Embedded Applications”, by H. Kopetz
Hard RT System versus Soft RT System
The design of a hard real-time system, which must produce the
results at the correct instant, is fundamentally different from the
design of a soft-real time or an on-line system, such as a
transaction processing system.
49
Hard RT System versus Soft RT System
Hard RT System versus Soft RT System
Hard RT System versus Soft RT System
Fail-safe versus Fail-Operational
For some hard real-time systems one or more safe states which can be reached
in case of a system failure, can be identified. Consider the example of a railway
signaling system. In case a failure is detected, it is possible to stop all the trains
and to set all the signals to red to avoid a catastrophe. If such a safe state can
be identified and quickly reached upon the occurrence of a failure, then we call
the system fail-safe.
Fail-safeness is a characteristic of the controlled object, not the computer
system. In fail-safe applications the computer system must have a high error-
detection coverage, i.e., the probability that an error is detected, provided it has
occurred, must be close to one.
There are, however, applications where a safe state cannot be identified, e.g., a
flight control system aboard an airplane. In such an application the computer
system must provide a minimal level of service to avoid a catastrophe even in
the case of a failure.
This is why these applications are called fail-operational.
Course content and organization
Course syllabus
o Part one: embedded system programming
• Arduino (periodic and reactive programming)
• Introduction to operating systems and RT OS
• Concurrent programming with POSIX
• RT Communication : CANBUS, DDS
• Component-based development
• UML MARTE
o Part two: Real Time scheduling
• Priority-driven scheduling
• Shared resources
• Oveload management
• Scheduling Aperiodic tasks
• ResponseTime Analysis
55
Teaching material
❑ Textbook
Giorgio C. Buttazzo, «Sistemi in Tempo Reale»,
Pitagora Editrice Bologna, 3° edizione
Giorgio C. Buttazzo, Hard Real-Time Computing
Systems, Springer
⚫ Course material
Send an email to brugali@[Link]
Subject: ERTS
Body: Name, ID number (matricola)
56
Exam
Written exam only
• Theoretical questions
• Scheduling exercises
• Preappello
• Monday 18 December 2023
58