Embedded Systems 2023

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

Embedded Systems

(EENG1755)
Al-Baha University
Engineering Faculty
Electric Engineering Dept.
BSc degree

Thamer Aladnan
([email protected])
August 2023
Course Assessment
Assessment Tasks Weight
Quiz 1 5%
Midterm 20%
Assignment 15%
Lab. 20%
Final Exam 40%
Total 100%

References
• Embedded Systems Design Using the MSP430FR2355 LaunchPadTM By Brock J. LaMeres · 2020.
• PIC Microcontroller and Embedded Systems Using Assembly and C for Pic18, By Muhammad Ali
Mazidi, Danny Causey, Rolin McKinlay · 2016.
Embedded Systems
• An embedded system is a combination of computer
hardware (microprocessor , memory, input output and
peripheral devices ) and software (Program code)
designed for a specific function. Embedded systems
may also function within a larger system. The systems
can be programmable or have a fixed functionality.
• Embedded systems are multi-disciplines topic.
• General-purpose computers are used for a wide range of
apps.
• Embedded systems are used in apps such as: TV, phones,
washing machines, power plants renewable systems (e.g.
solar PV systems), conventional and electric automobiles,
HVAC (heating ventilation and air-conditioning systems),
…, etc.
Embedded Systems
• components can be integrated on a single chip (ICs).
• Include a variety of peripherals (timers, analog-to-
digital converters, digital-to-analog converters, serial
interfaces).
• Small size makes them very versatile.
• May come with firmware (only the needed software
which is not intended to be changed frequently).
• May contain Real Time Operating Systems (RTOS)
which are used as a task scheduler.
• Low cost (around 100 Saudi Riyals).
Embedded Systems Engineering

Science(s) Technology Product Service

Calculus, Sensors, Embedded systems Making life easier


Physics, Actuators,
Electromechanics, Microprocessors,
Control theories, Other supporting
AI Algorithms, tools, etc.
Programming
languages, etc.
Some Examples of Embedded Systems
Anti-lock brakes
Auto-focus cameras
Automatic teller machines
Automatic toll systems Modems
Automatic transmission MPEG decoders
Avionic systems Network cards
Battery chargers Network switches/routers
Camcorders On-board navigation
Cell phones Pagers
Cell-phone base stations Photocopiers
Cordless phones Point-of-sale systems
Cruise control Portable video games
Curbside check-in systems Printers
Digital cameras Satellite phones
Disk drives Scanners
Electronic card readers Smart ovens/dishwashers
Electronic instruments Speech recognizers
Electronic toys/games Stereo systems
Factory control Teleconferencing systems
Fax machines Televisions
Fingerprint identifiers Temperature controllers
Home security systems Theft tracking systems
Life-support systems TV set-top boxes
Medical testing systems VCR’s, DVD players
Video game consoles
Video phones
Washers and dryers
An Application of Embedded Systems
• Heating System (Controlling Room’s Temperature)
Micro-processor, Micro-controller, Micro-computer
• CPU (Central Processing Unit) includes ALU (Arithmetic Logic Unit), control unit, registers,
timing (clock), etc. and performs arithmetic, logic, and other operations (instructions).
• CPU can be referred to as Micro-processor.
• A Micro-controller includes a micro-processor.
• Micro-processor + memory + I/O ports = Micro-controller
• A Micro-controller + OS (Operating System) = Micro-computer
• A Micro-computer is different from a general-purpose computer.

CPU Memory
(ALU, control unit, clock)
(RAM, ROM, SD) I/O ports OS
µ-processor

µ-controller
µ-computer
Real Examples
• CPUs are available in different characteristics (X-bit, speed,
single/dual core) based on the apps and tasks to perform. CPUs
• Arduino UNO is more likely a Micro-controller.
• Raspberry-Pi is more likely a Micro-computer.
• Both Arduino UNO and Raspberry-Pi devices are based on
CPUs.
• Different versions (Ard. UNO, Ard. nano, Rasp. Pi pico) have
different configurations and thus different applications.
• What it the best technology for your application?
Arduino UNO

C2000 TI

Raspberry-Pi
Relevant Definitions
Embedded Systems Design Considerations
Operational Considerations—have to do with the scenarios within which the product will operate.
Operational requirements usually cover the following concerns (here are suggested areas, but they do
not include of all possibilities):
1. Mission profiles
2. How an operator uses the system—the human interface
3. Environment
1. Mechanical shock
2. Vibration
3. Corrosion (possibly salt spray or toxic environments)
4. Humidity
5. Temperature range
6. Vacuum
7. Dust
8. Radiation (only for space environments or nuclear power)
4. Infrastructure needed
5. Logistics and maintenance
6. Responsible party for generating the requirements
Embedded Systems Design Considerations
Functional Considerations—have to do with the physical plant and situations within which the product
will reside. Functional requirements usually cover the following concerns (here are suggested areas):
1. Interfaces (perhaps from ICDs)—human, mechanical, electrical, software, special
2. (e.g., optics)
3. Mechanical—size, shape, weight, volume, density
4. Electrical—power sources, distribution
5. Responsible party for generating the requirements
Embedded Systems Design Considerations
Performance Considerations—have to do with the metrics and parameters that describe the product’s
capability. Performance requirements can cover, but are not limited to, the following concerns:
• Responsible party for generating the requirements
• Sensor parameters (here are just some possible considerations, these may or may not apply to your
project):
• Measurand
• Speed of transduction—samples per second
• Span
• Full scale output
• Linearity—%, SNR
• Threshold
• Resolution—ENOB
• Accuracy—SNR
• Precision
• Sensitivity—%
• Hysteresis
• Specificity
• Noise—SNR, % budget
• Stability
Embedded Systems Design Considerations
Performance Considerations—have to do with the metrics and parameters that describe the product’s
capability. Performance requirements can cover, but are not limited to, the following concerns:
• Data throughput
• Bytes or samples per second
• Data transmission protocol
• Data storage
• Control
• Operation
• Electrical—power consumption, efficiency, signal integrity
• Mechanical—strength, motion required
• Structural—capability to withstand environments in mission profiles
• Optical (probably not needed in many projects)
• Calibration
• Dependability
• Reliability
• Maintainability
• Testability
• Fault tolerance
• Longevity
Embedded Systems Design Considerations
Performance Considerations—have to do with the metrics and parameters that describe the product’s
capability. Performance requirements can cover, but are not limited to, the following concerns:
• Power consumption
• Dissipation and cooling
• Electromagnetic compatibility (EMC)
• Conducted susceptibility
• Radiated susceptibility
• Conducted interference
• Radiated interference
Embedded Systems Requirements
• Flexibility measures how easy it is to add new capabilities to the product. You might refer to it as
augmentation, extensibility, extendability, or expandability.
• Integrity relates to security. This quality requirement category describes what is required to block
unauthorized access to certain system functions, how to prevent information loss, how to ensure that
the system is protected from virus infection, and how to protect the privacy and safety of data entered
into the system.
• Upgradability—systems that have a high probability of later revisions should be designed to support
easy upgrades.
• Interoperability defines the ease in which the system can exchange data or services with other
systems.
• Reliability defines the probability of the system operating without failure for a specific period of time.
Ways to measure system reliability include the percentage of operations that are completed correctly
and the average length of time the system runs before failing.
• Robustness, or “ fault tolerance,” is the degree to which a system continues to function properly
when presented with invalid inputs, or defects in connected software or hardware or mechanical
components, or unexpected operating conditions. System robustness can be viewed as an aspect of
reliability.
Embedded Systems Requirements
• Usability, or “ ease of use,” refers to the many factors that constitute what users often describe as
user-friendliness.
• Maintainability measures how easy is it to correct a defect or modify the system. It depends on how
easily the system can be understood, changed, and tested.
• Portability addresses the effort required to migrate a system component from one operating
environment to another. Portability may include the ability to internationalize and localize a product
and has aspects similar to reusability.
• Reusability defines the effort involved to convert a system component for use in other applications.
Lack of reusability leads to systems that are more costly to develop. Reusable systems are modular,
well documented, independent of a specific application and operating environment, and somewhat
generic in capability.
• Testability or verifiability is an important class of requirement. This class of requirement addresses the
ease with which system components or the integrated product can be tested for defects. This is very
important for complex algorithms and logic, as well as subtle functionality interrelationships.
• Security against cyber-attack for internet-based apps.
General Embedded Systems’ Hardware
1- Central Processing Unit (CPU)
2- Memory Unit
3- Input/Output (I/O) Units
4- Power Supply

µ-controller
Central Processing Unit (CPU)
Central Processing Unit (CPU)
• Control Unit:
Central Processing Unit (CPU)
• Registers:
Central Processing Unit (CPU)
• ALU:
Central Processing Unit (CPU)
• Central Processing Unit is often called the brain of computer.
• A CPU controls all the internal and external devices and performs arithmetic and logic operations.
• The primary functions of the CPU are as follows:
1. The CPU transfers instructions and input data from main memory to registers, i.e. internal memory.
2. The CPU executes the instructions in the stored sequence.
3. When necessary, CPU transfers output data from registers to main memory.
• The primary difference between register and memory is that register holds the data that the CPU is
currently processing whereas, the memory holds the data the that will be required for processing. The
Register ranges from 32-bits register to 64-bits register whereas, the memory capacity ranges from
some GB to some TB.
• Most ALUs can perform the following operations:
1. Logical operations (AND, NOT, OR, XOR).
2. Arithmetic operations (addition, subtraction, multiplication and division).
3. Bit-shifting operations (shifting or rotating a word by a specified number of bit to the left or right
with or without sign extension).
4. Comparison operations (=, <, < =, >, > =)
Processors Hardware Architectures
Von-Neumann vs Harvard

Von-Neumann Processor Harvard Processor

Control Bus
Control Bus Read/Write
Read/Write
Von-Neumann vs Harvard Processor Architecture
Instructions Processing
• Processing methods:
1- RISC.
2- CISC.
• Pipelining feature
Instructions Processing
CISC vs RISC
Instructions Processing
• Pipelining is a technique for breaking down a
sequential process into various sub-operations
and executing each sub-operation in its own
dedicated segment that runs in parallel with all
other segments. Clk.1 Clk.2 Clk.3
• Pipelining is the process of storing and
prioritizing computer instructions that the
processor executes. It lets the processor
perform an instruction in multiple steps. The
processing happens in a continuous, orderly,
somewhat overlapped manner.
• Pipelining is applicable to both RISC and CISC
approaches.
• Cache can be employed in pipelining to improve
memory access speed.
Classes of Instructions
• Data Movement Instructions
Classes of Instructions
• Data Manipulation Instructions
Classes of Instructions
• Program Flow Instructions
Instructions writing
• Op-coding

• Operand
Instructions writing
Bus System
Bus System

Control Bus (CB)


It carries control signals
like (read, write, transfer,
etc.)
Memory Types
Program Memory
Data Memory
Memory mapping
• Memory-mapping is a mechanism that maps a portion of a file, or an
entire file, on disk to a range of addresses within an application's
address space. The application can then access files on disk in the same
way it accesses dynamic memory.
• The objectives of memory mapping are (1) to translate from logical to
physical address, (2) to aid in memory protection, and (3) to enable
better management of memory resources.
Program Development Flow
Program Development Flow

MSP430 is just a family of µ-controllers from Texas Instrument.


However, this flow is applicable to most µ-controllers.
Clock System
Watchdogs
• Special Watchdogs
Some microcontrollers contain an optional (“watchdog”) timer that resets (restarts) the microcontroller if the timer
hasn’t been read by the main loop after a certain length of time. Thus, if the microcontroller’s program gets stuck in
an infinite loop in a subroutine, it will have failed to read the watchdog timer, and the program will get restarted.
The watchdog timer is a nice feature for rescuing a stranded robot. It’s especially nice if the microcontroller sets a flag
so the start of the program can determine why it was reset. For example, a sumo robot could immediately start
fighting if it was reset because of an infinite loop. Instead of a “hung” robot being a stationary target for an opponent,
it would resume fighting after a brief pause.
If your microcontroller doesn’t include a watchdog timer, you can create one using the standard interrupt timer.
Simply decrement a counter in the interrupt routine but constantly store a large value in that counter in the main
loop. If, for whatever reason, the main loop fails to execute, eventually the interrupt routine will have decreased the
counter to zero. In that event, simply have the interrupt routine call the first line of code in the robot’s program
(usually setup), and the robot’s program will start over.
• Low-Voltage Watchdog
Another type of watchdog module built into many microcontrollers is a low-voltage detector. Unrelated to timers, this
built-in module constantly monitors the microcontroller’s power supply pin and halts the microcontroller if the
voltage drops below the minimum operating specification.
By halting the microcontroller, the low-voltage watchdog prevents the microcontroller from executing improperly,
perhaps setting pins to undesired states or over-writing the program in nonvolatile memory. The low-voltage module
regularly kicks in during power-up and power-down, thus making the circuit safe for robot builders who like using
huge values for bulk capacitors.
Common Microcontrollers
• PIC Microcontrollers
PIC Stands for Peripheral Interface Controller is a kind of microcontroller components was used in
the development of electronics, computer robotics, and similar devices.
• ARM Microcontrollers
ARM stands for Advanced RISC Machine. It’s the most popular Microcontrollers Programming in the
digital embedded system world, and most of the industries prefer only ARM microcontrollers since it
consists of significant features to implement products with an excellent appearance.
• 8051 Microcontrollers
Intel created 8051 microcontrollers in 1981. It is an 8bit microcontroller.
• Atmel AVR Microcontrollers
AVR is developed in the year 1996 by Atmel Corporation. The architecture of AVR was developed by
Alf-Egil Bogen and vegan wollan. AVR derives its name from its developers and stands for Alf-Egil
Bogen Vegan Wollan RISC microcontroller, also known as Advanced Virtual RISC.
• MSP Microcontrollers
MSP stands for Mixed Signal Processor. It’s the family from Texas Instruments. Built around a 16 -bit
CPU, the MSP is designed for low cost and respectively, low power dissipation embedded
statements.
Atmel AVR Microcontrollers Program Data
memory memory

AVR is a family of microcontrollers developed


since 1996 by Atmel, acquired by Microchip
Technology in 2016. These are modified Harvard
architecture 8-bit RISC single-chip
microcontrollers. AVR was one of the first
microcontroller families to use on-chip flash
memory for program storage.
AVR microcontrollers find many applications
as embedded systems. They are especially
common in hobbyist and educational embedded
applications, popularized by their inclusion in
many of the Arduino line of open
hardware development boards.
AVR uses the Harvard architecture – with
separate memories and buses for program and
data. It has a fast-access register file of 32 x 8
general purpose working registers with a single
clock cycle access time. Atmel 8-Bit AVR® Core Architecture
Atmel AVR Microcontrollers
AVR microcontrollers are built using a modified
Harvard Architecture. This means the Flash Program
Memory space is on a separate address bus than the
Static Random-Access Memory (SRAM). There are
two data bus, one that can access all data and the
In/Out data bus with limited access to a small section
of memory.
The AVR microcontrollers contain On-chip In-System
Reprogrammable Flash memory for program storage.
Flash Program memory space is divided into two
sections - Boot Loader Section and Application
Program Section in the device. The size of the
different sections is configured by the BOOTSZ Fuses.
The Flash memory has a typical endurance of at
least 10,000 write/erase cycles. Constant tables can
be allocated within the entire program memory
address space, using the Load Program Memory
(LPM) instruction.
Atmel AVR Microcontrollers
The Application section is the section of the Flash that is used by a user for storing the application code. The
protection level for the Application section can be selected by the application Boot Lock bits. The Application
section can never store any Boot Loader code since the Store Program Memory (SPM) instruction is disabled
when executed from the Application section
the Boot Loader software must be located in the BLS since the Self Programming Mode (SPM) instruction can
initiate a programming when executing from the BLS only.
The SPM instruction can access the entire Flash, including the BLS itself. The protection level for the Boot
Loader section can be selected by the Boot Loader Lock bits. The example shown is from the AVRmega328PB
datasheet
AVR Families ( 8-Bit AVR® Core )
• Classic AVR (AT90Sxxxx)
This is the original AVR chip, which has been replaced by newer AVR chips
AVR Families ( 8-Bit AVR® Core )
• Mega AVR (ATmegaxxxx)
These are powerful microcontrollers with more than 120 instructions and lots of
different peripheral capabilities, which can be used in different designs
AVR Families ( 8-Bit AVR® Core )
• Tiny AVR (ATtinyxxxx)
As its name indicates, the microcontrollers in this group have less instructions and
smaller packages in comparison to mega family. You can design systems with low costs
and power consumptions using the Tiny AVRs. Limited instruction set: The instruction
sets are limited. For example, some of them do not have the multiply instruction
AVR Families ( 8-Bit AVR® Core )
• Special purpose AVR
The ICs of this group can be considered as a subset of other groups, but their
special capabilities are made for designing specific applications. Some of the
special capabilities are: USB controller, CAN controller, LCD controller, Zigbee,
Ethernet controller, FPGA, and advanced PWM
ATmega32 (core of this course)
The ATmega32 is a low power, 8-bit microcontrollers based on the AVR® enhanced RISC architecture. The
ATmega32 is a 40/44-pins device with 32 KB Flash, 2 KB SRAM and 1 KB EEPROM. By executing instructions in a
single clock cycle, the devices achieve CPU throughput approaching one million instructions per second (MIPS) per
megahertz.

• Special Microcontroller Features


– Power-on Reset and Programmable Brown-out Detection
– Internal Calibrated RC Oscillator
– External and Internal Interrupt Sources
• I/O and Packages
– 32 Programmable I/O Lines
– 40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF
• Operating Voltages
– 2.7V - 5.5V
• Speed Grades
– 0 - 16MHz
ATmega32 (core of this course)
Peripheral Features
– Two 8-bit Timer/Counters with Separate Prescalers and Compare Modes
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture Mode
– Real Time Counter with Separate Oscillator
– Four PWM Channels
– 8-channel, 10-bit ADC
– Byte-oriented Two-wire Serial Interface
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
ATmega32
ATmega32
ATmega32
ATmega32
ATmega32
ATmega32
ATmega32
Micro-controllers Power Consumption Reduction
In general, to minimize power consumption in a given application and
hence extend battery life, the following general procedures are followed:
• reduce the microcontroller operating voltage;
• reduce the microcontroller operating frequency;
• minimizetimespentinmicrocontrolleractivemodesandmaximizetimespentin
lowpower or sleep modes;
• minimize the transition time between power modes; and
• carefully examine the dependencies between modules.
Input/Output Ports
ADC and DAC
• Analog to Digital Converter (ADC)

• Digital to Analog Converter (DAC)


ADC and DAC Criteria
• Input pins on a microcontroller are similar to those available on logic chips. The input pins read a
voltage near ground (0 V) as low or a 0 bit. The input pins read a voltage near the regulated
voltage (usually 5 V) as high or a 1 bit. These are considered digital inputs. Voltages in the middle
(such as 2.5 V) are undefined and may read as either low or high.
• Analog input pins are also available on some microcontrollers. These analog-to-digital input pins
can convert a voltage (say, from 0 V to 5 V) to a numeric range (say, from 0 to 255) instead of just
a digital 0- or 1-bit value. In this example, a voltage of 2.5 V applied to an analog-to-digital input
pin would be read by the microcontroller as 128.
• AlthoughmostADCsproduce8-bitvalues(28 equals256,whichequals0to255),higher-end
microcontrollerscanresolve10bitsoreven12bits(212 equals4,096,whichequals0to4,095).That
means an 8-bit 5 V ADC reads a voltage in 5 V divided by 256, which equals 0.02 V increments, but
a 12- bit 5 V ADC can read a voltage in 5 V divided by 4,096, which equals 0.0012 V increments. A
12-bit ADC is necessary only if, for example, your robot needs to distinguish between 2.5 V and
2.5013 V. However, if distinguishing between 2.5 V and 2.52 V is more than enough for your
application, then a standard 8-bit ADC is perfectly adequate. The same is applicable for DAC.

You might also like