1
1
Embedded System and
Applications BNF 30603
1. Introduction to Embedded
System2. The
Human and Physical
Interfaces
3. Serial Interfaces, Timer, Data
Acquisition and Manipulation
4. Interrupts, Delays, and
Multi-tasking
5. Real Time Operating
System
6. ChibiOSReal Time Operating
System
7. Interrupts, Delays, and Semaphores with ChibiOS
2
Review: Embedded Systems vs General Purpose Computer
The Human and Physical InterfacesSwitchKeypad LED DisplaysLiquid Crystal DisplaysSome Simple SensorsDigital Input CharacteristicsActuators: Motors and Servos Interfacing to Actuators
3
4
A computer
has..
A microprocessor
Large memory –RAM, ROM, HDD
I/O units
Networking unit
Operating System
5
An embedded system also has the same structure but at a smaller size
6
A system whose principal function is not computational, but which is controlled by a computer embedded within it [1]
Embedded systems are information processing systems that are embedded into a larger product and are normally not directly visible to the users [5]
Any device that includes a programmable computer but not itself intended to be a general-purpose computer [3]
7
Because most devices need control system!
These control systems are embedded within the device, usually unrecognizable
Embedded systems are everywhere
Millions units are produced yearly for various purposes, vs millions of desktop units
8
The observation that the number of transistors in a dense integrated circuit doubles approximately every two years. The observation is named after Gordon E. Moore, the co-founder of Intel and Fairchild Semiconductor.
9
The Derbot AGV
Derbot AGV Block Diagram 10
Digital Camera Block Diagram 11
HOME OFFICE AND COMMERCE
MOTOR CAR
Washing machine Photocopier Door mechanism
Fridge Checkout machine Brake system
Burglar alarm Printer Engine control
Microwave oven Scanner In-car entertainment
Central heating controller
Climate control
Toys and games
12
Source: tech.ubm.com13
GENERAL PURPOSE EMBEDDED
Intended to run a fully general set of applications
Runs a few applications often known at design time
End-user programmable Not end-user programmable
Faster is always better Operates in fixed run-time constraints, additional performance may not be useful/valuable
Differentiating features: • Speed (need not be fully predictable) • Software compatibility • Cost (e.g. RM3k vs RM5k per laptop)
Differentiating features: • Power • Cost (e.g. RM100 vs RM200) • Size • Speed (must be predictable)
14
MicroP MicroC
A chip that contains only theprocessor – need other chips tomake a working system
More flexible Can have very few I/O or many I/O
devices using the same processor Used as general-purpose processor
when large embedded software hasto be located in the externalmemory chips
A chip that contains all thecomponents of a computer –processor, memory, I/O
Less flexibility Less component count Less powerful Used when a small or part of the
embedded software has to belocated in the internal memory andwhen on-chip functional units suchas interrupt-handler, timer, etc. arerequired
15
COMMON CHARACTERISTICSOF EMBEDDED SYSTEMS
Connected to
physical
environment
through sensors
and actuators
Dedicated user
interface – push
buttons, pedals,
steering wheels
Have to be dependable
Reliability – will not fail
Maintainability – can repair
Availability – reliable + maintainable
Safety – fail, will not cause any harm
Security – secured data
Dedicated towards a
certain application –
extra program
makes the system
less dependable
Real-time constraints
Hard
Soft
Firm
Hybrid systems
– include analog
and digital parts
Have to be
efficientReactive systems
Idle
Input?
Execute
task
Y
N
cost
energy
code-
size
run-
time
weight
16
1. Hard RTS
Failure to meet even a single deadline may lead to complete catastrophic system failure
2. Soft RTS
Performance is degraded but not destroyed by failure to meet response-time constraint
3. Firm RTS
Few missed deadlines will not lead to total failure, but missing more than a few may lead to complete or catastrophic system failure
17
Example:
1. Air Traffic Control: a service provided by ground-based controllers who direct aircraft on the ground and through controlled airspace, and can provide advisory services to aircraft in non-controlled airspace. The primary purpose of ATC worldwide is to prevent collisions, organize and expedite the flow of traffic, and provide information and other support for pilots.
2. Car Engine Management Control
3. Pacemaker: a small device that's placed in the chest or abdomen to help control abnormal heart rhythms. This device uses electrical pulses to prompt the heart to beat at a normal rate.
4. Fire Alarm System
18
Example:
1. Automatic Washing machine
2. Air-conditioning
3. CD Player
19
Example:
1. Music Sound System in the computer
2. Door Bell Ringing System
20
Find two examples of hard, soft and firm real-time embedded system in:
1. Automotive
2. Home Appliances
3. Industrial Automation / Food Industry
4. Medical System
21
Unit cost: the monetary cost of manufacturing each copy of the system, excluding NRE cost.
NRE cost (Non-Recurring Engineering cost): The monetary cost of designing the system. Once the systemis designed, any number of units can be manufactured without incurring any additional design cost(hence the term “non-recurring”).
Size: the physical space required by the system, often measured in bytes for software, and gates ortransistors for hardware.
Performance: the execution time or throughput of the system.
Power: the amount of power consumed by the system, which determines the lifetime of a battery, orthe cooling requirements of the IC, since more power means more heat.
Decreasing one may increase another
22
23
Embedded computer reads signals, outputting control signals, interact with human user and possibly interact with an external system via network
Input devices – sensors for measurement or data entry devices for human interaction
Output devices - displays or alarms, and motors or actuators for the physical system
24
25
Extensively used in embedded systems.
Need to convert the switch position to a logic level that can be read by a microcontroller port bit.
Switches are used as direct user interface in the form of push-buttons, toggle switches, slide switches, etc.
Connecting switch to logic input26
Allows numeric or alphanumeric information to be entered.
It is widely used in photocopiers, burglar alarms, central heating controllers.
Arranged in a 4 × 3 matrix, with four rows and three columns
Keypad with pull-up resistors
27
Reading a keypad with a microcontroller port (a) Flow diagram (b) Outputs for keypad 28
LEDs made of gallium arsenide (GaAs) emit light in the infrared, and if phosphorus is added in increasing proportions, the light moves to visible red and ultimately to green.
Driving LEDs from logic gates. (a) Gate output sourcing current to LED (b) Gate output sinking current
from LED29
There are eight LEDs in the digit (including the decimal point), but instead of 16 connections being needed, only nine is enough, one for each segment and one for the common connection. The actual pin connections in the example shown lie in two rows, at the top and bottom of the digit. There are 10 pins in all, with the common anode or cathode taking two pins.
30
Control is exercised by three control lines:
– Register Select (RS), which determines whether an instruction or character data is being transferred
– Read/Write (R/W), which determines data direction
– Enable (E), which provides a clock function to synchronise data transfer.
The user can access two registers, depending on the state of the RS line:
– An instruction register, used to transfer instructions (RS = 0)
– A data register, used to transfer display data, for example character codes (RS = 1). 31
Large range of sensors available today, which includes ‘smart’ or ‘intelligent’ sensors, which are integrated onto an IC and have on-chip signal processing
Microswitch – mechanical position sensing
Some of Derbot’s sensors and actuators
32
Light-dependent resistors (LDR) –made from a piece of exposedsemiconductor material. When lightfalls on it, it creates hole–electronpairs in the material, which improvethe conductivity. When light isremoved, the hole–electron pairsrecombine and conductivity falls. Theoverall effect is that as illuminationincreases, the LDR resistance falls.
33
Optical methods are very useful in sensing objects and surfaces. In oneconfiguration the presence of an object can be sensed if it breaks a lightbeam, in another if it reflects the beam.
The reflective optical sensor (a) Principle of operation (b) Electrical connection34
Widely used for sensing and measurement, from simple distancemeasurement to complex medical imaging. The Derbot AGV uses anultrasonic reflective sensor to detect obstacles in its path or to allow it torun parallel to a wall.
The sensor consists of a transmitter and receiver and, to the extent that it isbased on a reflective principle, is initially similar to the reflective opto-sensor.
The big difference lies in the fact that the ultrasound source is pulsed and thetime taken for the echo to return is measured; from this a distance can becalculated.
35
If a microcontroller is to receive logic signals, then it is essential that thosesignals are at voltage levels which are recognized by it as being either Logic0 or Logic 1
These voltage levels are usually defined by logic family, for example TTL(Transistor Transistor Logic) or CMOS (Complementary Metal OxideSemiconductor)
When one device is connected to another, and each is supplied by the samevoltage and is of the same logic family, then it is usually safe to assume that logiclevels will be safely and reliably transferred
However, if signals are generated from a non-logic source, e.g. a sensor, or if theyhave been received over a long communication link, or have been subject tointerference, then it may be that they are not correctly interpreted by thereceiver 36
Port bit input voltage levels, 5V supply 37
Different forms of signal corruption. (a) Spikes in signal, potentially harmful to device input.
(b) Spikes in signal. (c) Excessively slow edges. (d) DC offset in signal38
Clamping voltage spikes – with current-limiting resistor Schmitt trigger Analog input filtering Opto-isolation Digital input filtering
39
To cause physical movement - linear, i.e. movement in a straight line, or rotary
Solenoids – for linear movement Servos – for angular movement only DC and stepper motor – for angular or rotary Pneumatic and hydraulic – for high forces
40
Both can be used for continuous rotary motion or for precise angular displacement
DC motors - range from the extremely powerful to the very small. DC motors drive huge electric trains, but also drive tiny mechatronic systems
Stepper motors - ability to interface very directly with a digital system. Each digital pulse sent to a stepper controller can be used to advance the motor shaft position by a known angle
41
Simple DC Switching Only very small electrical loads, like LEDs, can be driven
directly by a microcontroller port bit. Larger loads, drawing beyond 10 or 20 mA, or powered from a voltage higher than the logic supply voltage, need to be interfaced via power switching devices
Transistor switches provide an easy way of switching DC loads – MOSFET and bipolar
42
Simple DC Switching
Transistor switching of DC loads.
(a) Resistive, bipolar transistor. (b)
Resistive, MOSFET. (c) Inductive,
MOSFET
43
Reversible switching: the H-bridge Some loads, however, for example DC or stepper motors,
need to have a reversible voltage applied, even if only a unipolar supply voltage is available. The way this is usually achieved is by a simple yet ingenious circuit connection called the H-bridge
Two pairs of switching devices, usually transistors, are connected between supply rail and 0V
Each pair has a ‘high-side’ and a ‘low-side’ switch
44
Reversible switching: the H-bridge
The principle of the H-bridge
45
Serial InterfacesSPI, I2C, USART, USB
Timer
Data Acquisition and Manipulation
46