You are on page 1of 45

INTRODUCTION TO EMBEDDED

SYSTEMS

By Melaku M.
Definition

• “Any sort of device which includes a


programmable computer but itself is not
intended to be a general-purpose
computer”
Cont…d
• The basic idea of an embedded system is a simple
one. If we take any engineering product that
needs control, and if a computer is incorporated
within that product to undertake the control,
then we have an embedded system. An
embedded system can be defined as a system
whose principal function is not computational,
but which is controlled by a computer embedded
within it.
• These days embedded systems are everywhere,
appearing in the home, office, factory, car or
hospitals.
Types of Embedded Systems
Typical Embedded Systems

• Are designed to observe (through sensors)


and control something (through actuators)
E.g. air conditioner senses room temperature
and maintains it at set temperature via
thermostat
Embedded System Block Diagram
Ex.
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
– Must finish operations by deadline
Cont…d
Application-specific functionality
• specialized for one or one class of applications
Deadline constrained operation
• system may have to perform its function(s)
within specific time periods to achieve
successful results
Resource challenged
• systems typically are configured with a modest
set of resources to meet the performance
objectives
Cont…d
Power efficient
• many systems are battery-powered and must
conserve power to maximize the usable life of the
system.
Form factor
• many systems are light weight and low volume to
be used as components in host systems
Manufacturable
• usually small and inexpensive to manufacture
based on the size and low complexity of the
hardware.
Design Constraints
Design Challenges
• Does it really work?
– Is the specification correct?
– Does the implementation meet the spec?
– How do we test for real-time characteristics?
– How do we test on real data?
• How do we work on the system?
– Observability, controllability?
– What is our development platform?
• More importantly – optimizing design
metrics!!

12
Design Metrics
• Common metrics
• Unit cost: the monetary cost of manufacturing each copy of the
system, excluding NRE cost
• NRE cost (Non-Recurring Engineering cost): The one-time
monetary cost of designing the system
• Size: the physical space required by the system
• Performance: the execution time or throughput of the system
• Power: the amount of power consumed by the system
• Flexibility: the ability to change the functionality of the system
without incurring heavy NRE cost
Cont…d
• Time-to-prototype: the time needed to
build a working version of the system
• Time-to-market: the time required to
develop a system to the point that it can be
released and sold to customers
• Maintainability: the ability to modify the
system after its initial release
• Correctness, safety, many more
Input and output technology
• A sensor converts some physical
characteristics of its environment into
electrical signals
Examples of sensor
• Photo-voltaic sensor
• Temperature sensor
• Pressure sensor
Actuators

 An actuator converts electrical


signals into some physical actions.
 The physical action may be:
• Motion, change of thermal, electrical,
pneumatic, or physical characteristics of
some objects.
Actuators

 Examples of actuators
• Motors
• Heaters
• Hydraulic and pneumatic actuators
Processors
 Microprocessors and Micro-Controller
 Key requirement:
• Energy Efficiency
• High code density
Microprocessors
 CPU for computers
 No RAM, ROM, I/O on CPU chip itself
 Example: Intel’s x86, Motorola’s 680x0

Data Bus
CPU
General Serial
purpose RAM ROM I/O Port Timer
port
Microproce
ssor
Address Bus
Microcontroller
A micro-controller is a single silicon
chip device which integrates a number
of the components of a microprocessor
system onto a single microchip.
• The CPU core
• Memory (both ROM & RAM)
• Some parallel digital I/O & more
Components of a Micro-controller
 A timer module to allow the micro-
controller to perform tasks for
certain time period.
 A serial I/O port to allow data flow
b/n the micro-controller and other
devices.
Components of a Micro-controller

 An ADC to allow the micro-controller


to accept analogue input data for
processing.
Why Micro-controller?
 Low cost, small packaging
 Low Power Consumption
 Programmable
Re-programmable
 Lots of I/O Capability
 Single purpose
Microcontroller architecture
PIC16F877A
INTERFACING

• Interfacing is nothing but connecting an i/o


device or some other device with our
microcontroller.

• Basically, it is the effective interfacing, which


completes the embedded system, of Various
components like LCD, Switch, Led, Relay etc
with the microcontroller.
Memory Organization

 Data Memory
 Program Memory
 Access to both memories is possible in
each cycle b/c of the distinct buses.

27
The PIC Family: Program Memory
 EPROM (Erasable Programmable Read
Only Memory)
• One Time Programmable (OTP) chips are
EPROM chips, but with no window.
 FLASH
• Re-writable
• Much faster to develop
28
The PIC Family: Program Memory
 Mid-range PIC processors have 13 bit
program counter.
 Width of program memory bus is 14
bits.
 Program memory space divided into 4
pages of 2k each.
29
Memory Map

30
Stack

 Mid-range PIC 8-level deep 13 bit wide


hardware stack.
 PC is pushed onto the stack when CALL
instruction is executed or Interrupt
occurs.

31
The PIC Family: Data Memory
 PICs use general purpose “file
registers” for RAM (each register is 8
bits for all PICs)

32
Interrupts
• An interrupt is any service request that
causes the CPU to stop its current
execution stream & to execute an
instruction stream that
services/generates the interrupt.
Interrupts

 When the CPU finishes servicing the


interrupt, it returns to the original
execution stream at the point where
it left out.
Interrupt request
mechanism

35
PIC Peripherals: Digital I/O
 All PICs have digital I/O pins called ports.
 Ports are used to control & monitor external
devices as a source.

 Ports have 2 control registers


• TRISX sets whether each pin is an input or
output
• PORTX sets their output bit levels
Embedded programming
basics
• Select the language to be used
• Use PIC16F877A
• Write a program on mikroc
• Create hex file(compile)
• Draw circuit diagrams on proteus software
• Load the hex file to the controller
• Simulate it.
What language to use?
• In the process of making a better embedded
system, the selection of the Programming Language
is very important.

• Factors of selecting the language


• Size: The memory that the program occupies is
very important as Embedded Processors like
Microcontrollers have a very limited amount of ROM.
Cont…d
• Speed: The programs must be very fast i.e. they must

run as fast as possible. The hardware should not be

slowed down due to a slow running software.

• Portability: The same program can be compiled for

different processors.

• Ease of Implementation and Maintenance

• Readability
basic structure of an Embedded C Program
Multiline Comments . . . . . Denoted using /*……*/
Single Line Comments . . . . . Denoted using //
Preprocessor Directives . . . . . #include<…> or #define
Global Variables . . . . . Accessible anywhere in the program
Function Declarations . . . . . Declaring Function
Main Function . . . . . Main Function, execution begins here
{
Local Variables . . . . . Variables confined to main function
Function Calls . . . . . Calling other Functions
Infinite Loop . . . . . Like while(1) or for(;;)
Statements . . . . .
….
}
Function Definitions . . . . . Defining the Functions
{
Local Variables . . . . . Local Variables confined to this Function
Statements . . . . .
….….
}
Configuring PIC16F877A
• Every pin has its own name
• A pin can be declared as input or output
• Pin declaration:
• TRISB.B6=1/0; //1 for input device 0 for
output device
• PORTB.B6 = 1/0;
EX: Interfacing & controlling an LED
• Define a pin of a controller for the LED to be
connected
command: trisc.b0=0;//LED is output device
• Tell the controller to send a high voltage to its
pin where the LED is connected which is port
C pin number 0
command: portc.b0=1;
Write a code for the following schematic diagram.
• double temp,temp1;
• void main() { • else {
• trisa.b0=1;//sensor • portb.b2=0;
• trisb.B1=0;//fan • portb.b3=0;
• trisb.B2=0;//heater • portb.b1=0; }
• trisb.B3=0;//buzzer • if(temp1>=30) {
• portb.b3=0; • portb.b1=1;
• portb.b1=0; • portb.b3=0;
• portb.b2=0; • portb.b1=0; }
• while(1){ • else {
• temp=adc_read(0); • portb.b2=0;
• temp1=0.488*temp; • portb.b3=0;
• if(temp1<10){ • portb.b1=0; }
• portb.b2=1; • if(temp1>=40) {
• portb.b3=0; • portb.b2=0;
• portb.b1=0; } • portb.b3=1;
• else { • portb.b1=1; }
• portb.b2=0; • else {
• portb.b3=0; • portb.b2=0;
• portb.b1=0; } • portb.b3=0;
• if((temp1>=10) && (temp1<30)) { • portb.b1=0; } } }
• portb.b2=0;
• portb.b3=0;
• portb.b1=0; }

You might also like