Embedded Systems For Engineers and Students
Embedded Systems For Engineers and Students
Embedded Systems
For Engineers & Students
Sadia Adrees
Sheikh Muhammad Ibraheem
Copyright © 2023 by Sheikh Muhammad Ibraheem
Chapter 1.............................................................................. 2
Chapter 2............................................................................ 10
iii
Ibraheem & Sadia
Chapter 3 ............................................................................ 22
Chapter 4 ............................................................................ 33
iv
Table of Contents
Chapter 5............................................................................ 45
Chapter 6............................................................................ 61
v
Ibraheem & Sadia
Chapter 7 ............................................................................ 71
Chapter 8 ............................................................................ 79
Chapter 9 ............................................................................ 88
Chapter 10 .......................................................................... 98
vi
Table of Contents
vii
Ibraheem & Sadia
viii
Table of Contents
ix
Ibraheem & Sadia
x
Table of Contents
xi
Ibraheem & Sadia
xii
Table of Contents
References.................................................................... 330
xiii
Authors Biography
Sadia Adrees
(Born December 22, 2000) is a Pakistani writer instructor,
and software Engineer. She lives in Lahore Pakistan. She
started her education at “Moon star high school” and studied
there for 5 years then she went to “Laps school” because her
family migrated from one town to another in the same city.
For her matriculation degree, she went to “Al-Noorains High
School” and completed her degree in 2017 with a major in
biology, chemistry, physics, and Math. For higher secondary
xiv
Ibraheem & Sadia
xv
Embedded systems for engineers and Students
Preface
xvi
Ibraheem & Sadia
Book Portions:
xvii
Embedded systems for engineers and Students
xviii
Ibraheem & Sadia
This book will guide the reader about how he / she can design
various real time embedded systems using programming
techniques, understanding the working of various
microcontrollers, sensors and actuators.
Dear readers this book will not explain the basic knowledge
on embedded systems, this book will use the basic knowledge
on embedded systems, programming, devices and design
techniques to create a fully functional device.
In order to get most out of this book you are advised to read
this book thoroughly, must install various software on your
computer and must be motivate to do self - learning.
xix
Embedded systems for engineers and Students
xx
Part 01.
Introduction to
Embedded Systems
1
Chapter 1
Circuits & Electronics
1.1 Introduction
One of the main areas of technology is electrical engineering.
Digital electronics and computer technology are increasingly
regarded as separate disciplines. This is partially accurate,
but ultimately, all of these fields belong to electrical
engineering. Power engineering, telecommunications,
networking, control engineering, embedded systems
engineering, programable circuits, etc. are all parts of the
extremely broad area of electrical engineering. The circuits
are a common feature throughout all the primary fields inside
a huge field. Each of the aforementioned fields contains an
electrical circuit, circuit components, and a relationship
between voltages and currents. One must grasp the ideas of
circuits in order to master computer engineering,
telecommunication, electronics, electricity, etc.
2
1.2 Electrical Circuits
An electrical circuit is a channel that permits the flow of
electrical current. Circuit elements or circuit devices are the
components that make up an electrical circuit. The electrical
load and the power source are the two most fundamental
circuit components. The type of load can be capacitive,
inductive, or resistive.
3
sinusoidal in nature. Whereas DC circuit has no
frequency. It is just a straight line on the graph.
4
Potential Energy
Voltage = (1.1)
Charge
Joules
Volts = (1.2)
Coloums
5
as flowing in the same direction as positive charges.
Therefore, the direction of typical current flow in an
electrical circuit is reversed for negatively charged carriers
such as electrons (the charge carriers in metal wires and many
other components of electronic circuits).
6
electric power sector often provides it through an electrical
grid to homes and businesses (as domestic mains electricity).
Transmission lines provide for the efficient delivery of
electric power across great distances.
7
positive terminal). Active devices or power sources, such as
electric generators and batteries, are those in which this
occurs.
8
Power
Source
DC AC
Independent
DC Power
Voltage Source
Dependent
Independent
Current source
Dependent
9
Chapter 2
Embedded Systems
Engineering
10
2.2 Use of Embedded Systems
Every idea, every vision or every discussion that a man has
ever done in his – her life or are doing right now has some
sort of hidden meaning to it. And that meaning could be
anything. Every idea has way to use it. Some of us on this
planet are successful in finding it, some fail and some are
hard working. But if you are successful in understanding the
use of an idea, device, invention or discussion only than you
can concur.
1. Independent Systems.
2. Dependent Systems.
11
2.3 History of Embedded Systems
A digital computer called the Apollo Guidance Computer
(AGC) was employed by the Apollo program in the late
1960s and early 1970s to aid with spacecraft control during
lunar missions. It was created by Massachusetts Institute of
Technology (MIT) and developed by Charles Stark Draper
C. It was one of the earliest clearly modern embedded
systems.
12
Figure 2.1: Apollo Guidance Computer
13
were combined on the same chip as the CPU. Applications
for microcontrollers exist when general-purpose computers
would be prohibitively expensive. The use of embedded
systems has become more common as the price of
microprocessors and microcontrollers has decreased.
14
2.5 Embedded Systems Characteristics
As embedded systems are low-cost, low-performance
programming systems. They are usually classified into two
different ways.
15
In this system a total of five different components are
attached in which the microcontroller is the brain of the entire
system. It is also the most important component. Because
without a microcontroller there is no embedded system.
1 Soil sensors will sense the humidity level in the soil and
send the data to the microcontroller.
2 Microcontroller will accept this data in its IO pins and
then make the decisions based on the program installed
in its memory.
3 The input received from the soil sensor will be displayed
on the LCD.
4 If the soil is dry or undamped, the microcontroller will
send a command to the sprinklers, which will turn on the
sprinklers.
5 The turn on command will also be display on the LCD.
6 When the soil becomes enough damped or has reached
the maximum level. Soil sensor will send the data to the
microcontroller.
7 The microcontroller will read this data and turns off the
sprinkler.
16
Sensor output Micro Controller LCD display
Sprinklers Output
LCD Display
On/Off Microcontroller
Sensor input
17
various threads of processing. Large-scale operations like file
systems, network interfaces, etc. are implemented by user-
mode processes. Microkernels generally work better when
task switching and inter task communication happen quickly
and less effectively when they happen slowly. Exokernels
efficiently communicate through regular subroutine calls.
Application programmers have access to the system's
hardware and all of its software, and they are able to extend
both.
18
Reliability: Embedded systems are designed for specific
tasks and are often built to withstand harsh environments and
conditions, making them more reliable than general-purpose
computers.
19
of embedded systems are designed and developed by
engineers called electrical engineers, computer engineers or
more specifically embedded system engineers. This could
involve developing and testing software for embedded
systems, as well as designing and programming
microcontrollers and microprocessors.
20
Embedded
Systems
Engineering
21
Chapter 3
Embedded Systems
Hardware and Software
3.1 Introduction
For an embedded system to function properly, both the
hardware and software must be thoroughly researched during
design. The hardware and software must be created to satisfy
the system's precise criteria, including those for cost,
performance, and energy consumption. Hardware and
software engineers typically work together during the
development of embedded systems. In this chapter we are
going to study how hardware and software are crucial for any
embedded system. Let’s first start with the hardware of an
embedded system.
22
The embedded system's mind is controlled by the
microprocessor or microcontroller. It is in charge of carrying
out the software's commands and managing how the system
functions. A microcontroller is a dedicated CPU created to
carry out particular tasks, as opposed to a microprocessor,
which is a general-purpose CPU that may be programmed to
carry out a variety of activities. Microcontrollers are perfect
for embedded systems because they often have a smaller
footprint, use less power, and are less expensive than
microprocessors.
23
3.3 Digital and Analog Ports
Several I/O interface types are needed by embedded systems
in order to communicate with external hardware or sensors.
Analog interfaces, digital interfaces, and serial interfaces are
the three broad categories into which these interfaces can be
divided.
24
and engage in physical world interaction. These sensors and
actuators are not the core part of any embedded systems but
they are essential because without them an embedded system
is incomplete. In this chapter we are going to take an
introduction to sensors and actuators.
3.4.1 Sensors
25
4. Motion Sensor: Movements or positional changes
can be detected using motion sensors. Gyroscopes
and accelerometers are the two main categories that
they fall under. Gyroscopes monitor changes in
angular velocity, whereas accelerometers measure
changes in acceleration. Humidity sensors, gas
sensors, magnetic sensors, and proximity sensors are
other sensor types that are frequently employed in
embedded systems.
3.4.2 Actuators
26
dependability, designers must carefully examine the system's
needs and select the proper components.
27
FreeRTOS, Embedded Linux, and VxWorks are
some popular embedded operating systems.
2. Device Drivers: Device drivers are pieces of
software that allow the system to interact with
hardware components like sensors and actuators.
They act as a barrier between the hardware and the
software, allowing the software to access the
hardware without having to understand how it works
in detail.
3. Applications Software: The software that provides
the specific functionality of the embedded system is
known as application software. It is in charge of
carrying out the specific tasks that the system is
intended to carry out, such as monitoring
temperature or controlling a motor. A variety of
programming languages, including C, C++, Python,
and Java, can be used to create application software.
The programming language used is determined by
the application's specific requirements as well as the
system's available resources.
4. Middleware Software: Middleware is a software
layer that provides services and functions shared by
many different applications. It provides a set of
reusable components for use in the development of
complex embedded systems. Communication
protocols, data storage and retrieval, and security
functions are all components of middleware. They
can be used to reduce system complexity while
improving system reliability and performance.
28
3.6 Embedded Systems Software Development
The process of developing software for devices that are
embedded in other systems is known as embedded software
development. The requirements are specified first, followed
by the design, coding, testing, and deployment of the
software.
29
consistently in the intended environment, and any issues that
arise must be addressed as soon as possible.
30
automobiles. RTOS is intended for tasks that require a quick
response time, typically measured in microseconds or
milliseconds.
31
advantages and disadvantages. The programming language
chosen is determined by a number of factors, including the
application requirements, the hardware platform, and the
developer's skills and experience.
32
Chapter 4
Interfacing Techniques in
Embedded Systems
4.1 Introduction
In the previous chapter we studied the hardware and software
components of embedded systems. In this chapter we are
going to study about the interfacing techniques that are used
in embedded system engineering. An embedded system is
connected to other devices or systems using interfacing
techniques so that they can interact and exchange data. Here
are a few typical communication methods for embedded
systems:
33
provides high-speed data transfer and supports a variety
of peripherals, including keyboards, mice, and printers.
4 Ethernet: Ethernet is a networking standard that enables
communication between devices over a local area
network (LAN). Ethernet is commonly used in
embedded systems to enable internet connectivity and
remote access.
5 Wireless Communication: This technique involves the
transmission of data over wireless communication
channels, such as Wi-Fi, Bluetooth, and Zigbee.
Wireless communication is useful in situations where a
physical connection is not possible or practical.
6 Analog and Digital Interfaces: Analog and digital
interfaces are used to connect sensors, actuators, and
other analog or digital devices to an embedded system.
Analog interfaces are used to measure analog signals,
such as voltage, current, or temperature, while digital
interfaces are used to transmit binary data.
34
UART transmits data in a sequential fashion, with start and
stop bits framing each data byte.
35
including varying word lengths and bit ordering (MSB first
or LSB first). When using the SS line for communication, the
master device chooses the slave device and sets the clock
frequency.
36
For data interchange and control in embedded systems, serial
communication protocols like UART, SPI, and I2C are
essential. The ability to properly interact with a variety of
peripheral devices is given to embedded system designers by
understanding their operating principles, settings, and
applications. Embedded systems can integrate complicated
functionality and connectivity in a variety of applications by
utilising various serial communication approaches to create
effective and dependable communication.
37
must be specified. For handshaking and signaling functions,
such as acknowledging data reception or signaling readiness
for data transfer, additional control lines may be employed.
38
They are also utilized in systems requiring high-speed data
transfer, such as graphics processing units (GPUs) and digital
signal processors (DSPs).
39
The proper network settings, including the SSID (Service Set
Identifier) and security protocols (such as WEP, WPA, and
WPA2), must be set up on Wi-Fi devices. The proper mode
(station or access point), encryption keys, and connection
parameters must be set while configuring Wi-Fi modules.
40
4.4.3 Zigbee Communication
41
LoRa employs a star-of-stars network topology, with
gateways acting as intermediaries between end devices and
the internet.
42
Hardware interfacing involves connecting and
communicating with external devices and peripherals
through physical interfaces and protocols. This section
focuses on commonly used hardware interfaces and
considerations.
1. GPIO Interface
2. Serial Communication Interface
3. Analog Interface
1. Device Drivers
2. Memory management
3. Communication Protocols
43
Part 02. Sensors,
Actuators, and
Controllers
44
Chapter 5
Microcontrollers and
Microprocessors
5.1 Introduction
In the previous chapters we studied an introduction to the
embedded systems. In this chapter however we are going to
study about microcontrollers, which are the heart of any
embedded system working independently or dependently.
45
5.2 Microcontroller Architecture
A microcontroller, commonly known as an MCU
(microcontroller unit), is a tiny computer that is housed on a
single VLSI integrated circuit (IC) chip. One or more CPUs
(processor cores), memory, and programmable input/output
peripherals are all included in a microcontroller.
46
consumption are the key considerations. They just have a few
I/O ports and a modest quantity of memory. In comparison to
8-bit microcontrollers, 16-bit microcontrollers are more
capable and have more memory and I/O ports. They are
generally employed in more sophisticated applications like
industrial control systems and automobile systems. The most
powerful and equipped with the greatest number of memory
and I/O ports are 32-bit microcontrollers. High-performance
apps like those found in smartphones and tablets frequently
employ them.
47
Federico Fagin and Ted Hoff led a team that designed the
chip, which was produced using a 10-micrometer technique.
The 4004 could do approximately 92,000 operations per
second at a clock rate of 740 kHz. It could address up to 640
bytes of memory and contained 2,300 transistors. The chip
was created with the intention of being used in calculators,
but it quickly spread to a variety of devices, including
watches, cash registers, and even traffic lights. The 4004
marked the beginning of the microprocessor revolution that
would eventually give rise to the potent processors found in
modern computers and mobile devices. The introduction of
the 4004 signalled the start of the microprocessor revolution,
which transformed how we live and work by enabling
smaller, more inexpensive, and more widely available
computers.
48
5.4 Microcontroller Types
In the above paragraphs we looked at the microcontrollers
and also understood the basic categories like 8 bit, 16 bit etc.
In this paragraph we’ll look in depth in the categories and
various types of microcontrollers.
49
and the ARM Cortex-M from ARM are two examples of 32-
bit microcontrollers.
50
5.5 Microcontrollers Working
The working of any microcontroller either 8, 16, 32 or 64 bit
can be broadly classified into three main stages: input,
processing, and output.
5.5.1 Input
Here ultrasonic sensor will sense some object and send the
output as analog signal to the input pins of the
microcontroller. From the input pins this signal will be sent
to the ADC which will convert this analog signal to digital
signal. This signal will then be processed by the
microcontroller.
5.5.2 Processing
51
often kept in the read-only memory of the microcontroller
and is written in a particular programming language (ROM).
The processing stage involves applying complex
mathematical, logical, and other processes to the input data.
5.5.3 Output
52
Figure 5.3: (Left) Microcontroller and (Right)
Microprocessor
53
amount of electricity and may be supplied by batteries. They
can be used in a variety of applications because they are also
reasonably priced.
54
industrial controls, and consumer electronics, and are now a
necessary part of many objects we use every day.
55
5.9 At mega 328 Processor
The Atmega 328 and Atmega 328P are both microcontroller
chips developed by Atmel Corporation. They are widely used
in the Arduino platform and in many other embedded
systems due to their low power consumption, high
performance, and rich set of features.
The Atmega 328 and Atmega 328P can both operate at clock
speeds of up to 20 MHz, making a wide variety of
applications possible. The Arduino platform, a well-liked
open-source electronics prototyping platform, makes
extensive use of them. For those new to developing
embedded systems, the Arduino platform offers a
straightforward and user-friendly interface for programming
and interacting with the Atmega processors.
56
Robotics, home automation, sensor networks, and a host of
other applications frequently use the Atmega 328 and
Atmega 328P microcontrollers. They are particularly well
suited for applications that need high performance, low
power consumption, and a wide range of functions. Its
widespread use in embedded systems and on the Arduino
platform is evidence of its adaptability and potency as
microcontroller chips.
57
unauthorized programs, is another important feature. This
qualifies the Cortex-M7 for use in high-security applications
including banking and medical equipment.
58
complex mathematical operations with high speed and
accuracy.
59
Technology. It is part of the AVR family of 8-bit MCUs and
is widely used in a variety of applications, from consumer
electronics to industrial automation.
60
Chapter 6
Microcontroller
Manufacturers
61
flash IP integrated circuits. Its products include linear,
interface, and wireless products, as well as microcontrollers
(PIC, dsPIC, AVR, and SAM), serial EEPROM devices,
serial SRAM devices, embedded security devices, radio
frequency (RF) devices, temperature, power, and battery
management analogue devices.
62
technology, and EMI/EMC performance are the main
characteristics of the 8-bit microcontrollers.
63
1930, the business has been at the forefront of innovation in
the electronics sector. It is among the biggest global suppliers
of embedded and analogue processing chips.
64
6.5 MSP430 Microcontroller Series
One of the most well-known microcontroller series in the
market, the MSP430 from Texas Instruments, is constructed
utilising a 16-bit RISC architecture. The MSP430 has a
reputation for using little power. It has a 25 MHz maximum
speed. Six more low-power settings for the MSP430 allow it
to disable unused clocks and CPU. Additionally, the
controller can remain in sleep mode for a longer amount of
time, resulting in lower average current consumption, thanks
to the MSP430's quick wake-up time of less than 1
microsecond. The device is offered with the customary
accessories in a variety of settings.
65
The MSP430 microcontroller series, in general, is a flexible,
low-power option for a variety of applications, including
wearable technology, portable medical equipment, and other
battery-operated systems. The MSP430 family is a great
option for designers wishing to add intelligence and control
to their projects due to its low power consumption and broad
range of peripheral ports.
6.6 ST Microcontrollers
STMicroelectronics N.V., also known as ST or STMicro, is
a multinational Dutch company with French and Italian roots
that specialises in technology. It is listed on the French stock
exchange, with its headquarters in Plan-les-Ouates, a town
close to Geneva, Switzerland. ST is the largest European
semiconductor contract manufacturing and design company.
The company resulted from the merger of two government-
owned semiconductor companies in 1987. Thomson
Semiconductors of France and SGS Microelettronica of Italy.
66
all part of the company's microcontroller range. Applications
for the company's microcontrollers include consumer
electronics, industrial control systems, and automotive
systems.
67
displays. These components can be soldered onto a
breadboard or attached to the board via jumper wires. There
are numerous shields that can be put into the Arduino board
to provide capabilities like Wi-Fi, Ethernet, GPS, or
Bluetooth.
68
In 2005, the group decided to produce a more user-friendly
version of Wiring for non-technical users. This platform
was named "Arduino" after a tavern in Ivrea where they
frequently gathered.
69
Figure 6.6: Arduino IDE
70
Chapter 7
Arduino UNO R3
71
7.2 Components of Arduino UNO R3
The UNO is one of the most widely used microcontroller
boards. It is essential to have the idea of board’s component
components that make it function effectively.
7.2.1 Microcontroller
72
Figure 7.2: Arduino UNO Power Diagram
73
functions as a USB-to-serial converter, implements the USB
interface.
74
oscillator. The clock signal for the microcontroller is
provided by a 16MHz crystal oscillator on the PCB.
7.2.9 ICPs
75
components to ground. These pins are all labelled
GND.
76
Table 7.2: Digital Pins of Arduino
77
2. 1x 16-bit Timer/Counter with a dedicated period
register, input capture and compare channels
3. 1x USART with fractional baud rate generator and
start-of-frame detection
4. 1x controller/peripheral Serial Peripheral Interface
(SPI)
5. 1x Dual mode controller/peripheral I2C
6. 1x Analog Comparator (AC) with a scalable
reference input
7. Watchdog Timer with separate on-chip oscillator
8. Six PWM channels
9. Interrupt and wake-up on pin change
1. 16 KB ISP Flash
2. 512B EEPROM
3. 512B SRAM
4. debugWIRE interface for on-chip debugging and
programming
7.5.4 Security
78
Chapter 8
Arduino Nano
79
The Arduino Nano is an all-around capable and flexible
microcontroller board that is perfect for a variety of
applications, from straightforward projects to more
complicated ones. It is a fantastic option for anyone
interested in electronics and programming due to its
simplicity of use, low price, and variety of features.
8.2.1 Microcontroller
80
can understand. Using the USB connector, the board can also
be powered and programmed..
81
Figure 8.1: Arduino Nano Board
82
A0 to A5: These pins can be used to measure analogue
signals because they are connected to the on-board analog-
to-digital converter (ADC). They can also function as digital
input and output pins.
These pins, D3, D5, D6, D9, D10, and D11, allow pulse
width modulation (PWM), a method for regulating the output
signal's intensity. PWM is frequently used to regulate motor
speed, servo motor control, and LED brightness.
83
8.3.3 Power Pins
84
Figure 8.2: Arduino Nano Power Supply
85
AREF: The ADC's reference voltage is supplied by this pin.
It is possible to utilise it to increase the precision of analogue
measurements.
8.4.1 Features
1. 22 Digital Pins
2. 8 Analog Pins
3. 6 Pulse Width Modulation Output
86
2. 6-20V unregulated external power supply (pin 30)
3. 5V regulated external power supply (pin 27)
1. Idle
2. ADC Noise Reduction
3. Power-save
4. Power-down
5. Standby
6. Extended Standby
87
Chapter 9
Arduino Leonardo
9.1 Introduction
Arduino Nano is a small, adaptable, and simple-to-use
microcontroller board. is a microcontroller board based on
the ATmega32u4. It is part of the Arduino family of boards,
which are widely used in the maker and DIY communities.
The Leonardo is one of the most popular boards in the family
due to its low cost and flexibility. It has a built-in USB
connector that enables direct computer connection without
the use of an additional programmer. six analog inputs, 20
digital input/output pins, and a single 16MHz crystal
oscillator are all present on the Leonardo.
88
As the Leonardo can be programmed using the Arduino
Integrated Development Environment, programming is
actually quite simple (IDE). Users can develop and upload
code to Arduino boards and used the IDE, a free and open-
source software development environment.
9.2.1 Microcontroller
89
9.2.2 USB
90
The board can be reset using this button. It resets the
microcontroller and restarts the board's running code when
pressed.
91
Figure 9.1: Arduino Leonardo Board
92
1. Connect the Arduino Leonardo to your computer
using a USB cable.
2. Open the Arduino IDE on your computer and create
a new sketch.
3. In the Arduino IDE, go to File -> Examples -> USB
-> Keyboard or Mouse, depending on whether you
want to use the Arduino as a keyboard or a mouse.
4. Upload the code to the Arduino Leonardo.
5. Once the code is uploaded, your Arduino Leonardo
will start emulating a keyboard or mouse, depending
on the code you uploaded.
6. You can now use your Arduino Leonardo to send
keystrokes and mouse movements to your computer.
For example, if you uploaded the Keyboard code,
you can use the Keyboard.write() function to send
keystrokes to your computer. If you uploaded the
Mouse code, you can use the Mouse.move() function
to move the mouse cursor on your computer.
You can power your Arduino board using the Barrel jack, or
7-12V DC Power Jack, which is connected to an adapter.
While the board is compatible with adapters that provide a
93
power range of 5-20 volts, the manufacturer recommends
using an adapter within the 7-12 volts range.
9.4.2 Vin
There are six PWM (Pulse Width Modulation) pins in the set
of digital pins, which are 3, 5, 6, 9, 10, 11, and 13. Provide
8-bit PWM output with the analogWrite() function.
94
1. Serial Clock is referred to as SCL-It. The pin that
sends the clock data is what is meant by this term. It
synchronizes the data transmission between the two
devices. The master device provides the Serial
Clock.
2. Serial Data is referred to as SDA-It. It is described as
the pin that is utilized by the slave and master to
transmit and receive data between them. Because to
this, it is also referred to as a data line, whereas SCL
is referred to as a clock line.
95
and ATmega32u4 microcontroller foundation, this board is
simple to program and connect to a computer.
9.5.2 Adaptability
Compatibility
96
9.5.4 Built in USB Interface
97
Chapter 10
Arduino Portenta Series
98
The board is built on a powerful 32-bit dual-core Arm
Cortex-M7 and Cortex-M4 processor and features a range of
connectivity options, including Wi-Fi, Bluetooth, Ethernet,
and CAN. It also has a rich set of peripherals, including
analog inputs and outputs, digital inputs and outputs, and
advanced motor control capabilities. The Arduino Portenta's
ability to run in low-power modes makes it appropriate for
battery-powered applications. This is one of its primary
advantages. Additionally, it offers sophisticated security
features like a secure bootloader and a cryptographic
coprocessor.
99
carried out in parallel by using two processors, making the
process quicker and more effective. The Cortex-M4 core is
optimized for low-power and real-time applications,
while the Cortex-M7 core is designed for high-performance
applications. The Portenta board can perform a variety of
activities, including high-speed data processing and analysis
as well as real-time control and communication.
100
10.3 Portenta Microcontroller Series
The Arduino Portenta series is a powerful and versatile
family of development boards designed for professional
applications. The Portenta H7 and the Portenta Vision Shield
are the two major boards in the Portenta series. The
STM32H747 microcontroller, which uses a dual-core ARM
Cortex-M7 and Cortex-M4 architecture and operates at 480
MHz and 240 MHz, respectively, is the foundation of the
high-end development board known as the Portenta H7.
Additionally, it features WiFi, Bluetooth, Ethernet, and LTE-
M connection as well as 2 MB of Flash memory and 1 MB
of RAM. It also contains a number of cutting-edge hardware
features, including a hardware cryptography engine, a 12-bit
DAC, and a 16-bit ADC, which allow it to accomplish
challenging jobs like secure communications, computer
vision, and machine learning.
101
Figure 10.2: Arduino H7 Comparison
102
utilizing the platform and to create original applications fast
using the well-known Arduino IDE. Moreover, a variety of
programming languages and frameworks, including as
Python, TensorFlow, and OpenCV, are supported by the
Portenta series, making it a perfect platform for developers
with different backgrounds and skill sets.
103
The Portenta H7 is made to work with the Arduino
ecosystem, which has a sizable developer community and a
sizable library of open-source code. This makes it simple to
start utilising the platform and to create original applications
fast using the well-known Arduino IDE. The board is a great
platform for developers with a variety of backgrounds and
skill levels because it supports a wide range of programming
languages and frameworks, including as Python,
TensorFlow, and OpenCV.
104
Figure 10.4 H7 Board Description
105
10.5 Components of Portenta H7
It includes a number of advanced components that provide
the power, flexibility, and connectivity required for projects
such as industrial automation, robotics, and IoT.
106
The Portenta's interoperability with the Arduino environment
is one of its primary advantages. A sizable developer
community and a sizable collection of open-source code are
both part of this ecosystem. This makes it simple to start
utilising the platform and to create original applications fast
using the well-known Arduino IDE. The board is a great
platform for developers with a variety of backgrounds and
skill levels because it supports a wide range of programming
languages and frameworks, including as Python,
TensorFlow, and OpenCV.
107
There are 20 PWM pins on the board, which can be used to
provide PWM signals for operating actuators like motors.
These pins are arranged on the board in a single row and have
the labels PWM0 through PWM19. To operate motors and
other actuators, PWM signals can be produced using these
pins. They can produce signals with frequencies between
31Hz and 62.5kHz and have an 8-bit resolution.
108
Figure 10.5 H7 Ports
The board features six serial ports that can be used for UART,
SPI, or I2C protocol communication with external hardware.
Serial1 to Serial6 is the designation for these ports, which are
109
arranged in two rows on the board. UART, SPI, or I2C
protocols can be used to connect to other devices utilising
these ports. Moreover, they can be set up to provide
interruptions as data is received.
The board also has several other pins, such as power and
ground pins, reset pins, and JTAG pins, which are used for
debugging and programming the board. The other pins on the
board are used for power and ground, reset, JTAG, and other
purposes related.
110
Figure 10.6: H7 Ports Configuration
111
10.7 Industrial Applications of Portenta H7
The Arduino Portenta is designed to meet industry-grade
certification standards, including CE, FCC, and RoHS. The
board is also compliant with EN 55032 Class B and EN
62368-1 safety standards, making it highly reliable and safe
to use in industrial applications.
112
with other devices and sensors in the industrial environment
because to its cutting-edge connectivity choices, including
Wi-Fi, Bluetooth, and cellular connectivity. This makes it
possible to gather, analyze, and make decisions using data in
real-time.
113
10.8 Expanding Capabilities of Portenta H7
Arduino Portenta H7 comes with a wide variety of industrial
application its advance architecture allows it to be a great
choice for modern industrial applications. However its
functionality can be enhanced using various sensors and
actuators for more practical applications.
114
The Arduino Portenta H7 can connect wirelessly to other
devices because to its integrated Wi-Fi, Bluetooth, and
cellular connectivity. You can use external communication
modules like Zigbee, LoRa, or Ethernet modules if you need
to communicate with gadgets that do not support these
protocols. Using extension modules like communication
shields or breakout boards, these modules can connect to the
board.
115
Chapter 11
Raspberry Pie Series
11.1 Introduction
The Raspberry Pi series has become incredibly popular
among hobbyists and makers due to its low cost and
versatility. The devices can be used for a wide range of
projects, from basic programming exercises to complex
automation systems. One of the most significant advantages
of the Raspberry Pi is its small form factor, which makes it
an excellent choice for projects where space is limited. The
devices are also energy-efficient, consuming very little
power, which makes them an ideal choice for battery-
powered projects or those that need to run continuously.
116
a wide range of programming languages, including Python,
C++, and Java, making them accessible to developers of all
skill levels.
117
based on the RP2040 microcontroller chip, which was
designed by the Raspberry Pi Foundation specifically for use
in microcontroller boards. The Raspberry Pi Pico is a low-
cost and versatile microcontroller board that can be
programmed in C/C++ and MicroPython.
118
However, one disadvantage of the Raspberry Pi Pico is that
it is not as well-known as other microcontroller boards,
which means that there may be fewer resources and
community support available. Additionally, the Raspberry Pi
Pico is not as powerful as some other microcontroller boards,
which may limit its use in more complex projects.
119
sensors, making it a versatile choice for a variety of
projects.
Overall, the Raspberry Pi Pico is a powerful and versatile
microcontroller board that offers a low-cost and low-power
solution for embedded applications. While it may not be as
well-known as other microcontroller boards, it has a growing
community of developers and makers who are using it for a
wide range of projects.
120
11.4.4 GPIO Pins
The Pico has 26 GPIO pins that can be used for digital
input/output, analog input, and various communication
protocols such as I2C, SPI, and UART.
11.4.5 USB Port
The Pico has a micro-USB port that can be used for power,
programming, and data transfer.
11.4.6 Power Management
The Pico has a built-in power management system that
allows it to operate from a range of power sources, including
USB, external batteries, and solar panels.
11.4.7 Onboard Voltage Regulators
The Pico has two voltage regulators that provide stable 3.3V
and 1.8V outputs for powering external components.
11.4.8 Crystal Oscillator
The Pico has an onboard crystal oscillator that provides
accurate timing for the microcontroller.
11.4.9 LED Indicators
The Pico has two onboard LED indicators that can be used
for debugging and status indication.
The Raspberry Pi Pico packs a lot of features into a small and
affordable package, making it an excellent choice for a wide
range of projects, from simple hobby projects to more
complex industrial applications.
121
11.5 Pin Configuration of Raspberry Pi Pico
Raspberry Pi Pico is a microcontroller board that offers a
variety of pins for connecting to other devices and
peripherals. These pins can be used for a wide range of
applications, from driving LEDs and motors to
communicating with sensors and other devices. The pins are
arranged in a particular order and labeled with different
names and functions, depending on their capabilities. In this
section, we will discuss the pin configuration of Raspberry Pi
Pico in detail and explain the function of each pin.
122
Here is a detailed description of each pin on the Raspberry Pi
Pico board:
123
The BOOTSEL pin is used for boot selection and can be
connected to ground or 3.3 volts to select the boot mode of
the board.
11.5.7 SWCLK and SWDIO Pins
These pins are used for SWD programming and debugging
and can be connected to an external debugger for
programming the board.
11.5.8 RUN Pin
The RUN pin is used for resetting the board and can be
connected to ground or 3.3 volts to reset the board.
11.5.9 5V and VIN Pins
These pins are not used on the Raspberry Pi Pico board, but
they can be used for powering the board from an external
power supply or for providing power to external devices. The
5V pin provides an unregulated voltage of 5 volts, while the
VIN pin can handle a voltage range of 1.8 to 5.5 volts.
Each pin on the Raspberry Pi Pico has a specific function and
purpose, and understanding these functions is crucial for
successful hardware programming and development. The
following is a detailed overview of each and every pin on the
Raspberry Pi Pico:
124
10. GP9: General-purpose input/output pin
11. GP10: General-purpose input/output pin
12. GP11: General-purpose input/output pin
13. GP12: General-purpose input/output pin
14. GP13: General-purpose input/output pin
15. GP14: General-purpose input/output pin
16. GP15: General-purpose input/output pin
17. GP16: General-purpose input/output pin
18. GP17: General-purpose input/output pin
19. GP18: General-purpose input/output pin
20. GP19: General-purpose input/output pin
21. GP20: General-purpose input/output pin
22. GP21: General-purpose input/output pin
23. GP22: General-purpose input/output pin
24. GP26: General-purpose input/output pin
25. 3V3: 3.3V power supply pin
26. GND: Ground pin
The pin configuration of Raspberry Pi Pico provides a
flexible and versatile platform for connecting to a wide range
of devices and peripherals. With its numerous pins and
capabilities, the board is suitable for a wide range of
applications, from basic prototyping and experimentation to
advanced electronics projects.
125
Raspberry Pi Pico can be used to build automation systems
for various industries. Its programmability and GPIO pins
allow it to control various sensors, actuators, and devices. It
can be programmed to automate processes, monitor
equipment, and collect data.
11.6.2 Internet of Things (IoT)
Raspberry Pi Pico can be used in IoT projects due to its
connectivity options such as Wi-Fi, Bluetooth, and Ethernet.
It can be used to build smart devices such as temperature
sensors, door locks, and home automation systems.
11.6.3 Robotics
Raspberry Pi Pico can be used to build robots due to its
capability to control various motors and sensors. It can be
programmed to perform tasks such as object detection,
obstacle avoidance, and path planning.
11.6.4 Automotive
Raspberry Pi Pico can be used in automotive projects to
control various systems such as lighting, audio, and
infotainment. It can also be used to monitor vehicle
performance and collect data for analysis.
11.6.5 Aerospace
Raspberry Pi Pico can be used in aerospace projects due to
its small size, low power consumption, and robustness. It can
be used to control various systems such as navigation,
communication, and propulsion.
11.6.6 Agriculture
Raspberry Pi Pico can be used in agriculture projects to
monitor environmental conditions such as temperature,
126
humidity, and soil moisture. It can also be used to control
irrigation systems and automate farming processes.
11.6.7 Healthcare
Raspberry Pi Pico can be used in healthcare projects to
collect and analyze patient data. It can be used to monitor
vital signs, track medication schedules, and control medical
equipment.
11.6.8 Manufacturing
Raspberry Pi Pico can be used in manufacturing projects to
automate processes such as assembly line operations, quality
control, and inventory management. It can also be used to
monitor equipment performance and collect data for analysis.
11.6.9 Energy Management
Raspberry Pi Pico can be used in energy management
projects to monitor and control energy usage. It can be used
to collect data from sensors and control systems such as
lighting, HVAC, and power management
11.6.10 Security
Raspberry Pi Pico can be used in security projects to control
access systems, monitor surveillance cameras, and detect
intrusions. It can also be used to analyze data from sensors
such as motion detectors, door sensors, and smoke detectors.
Raspberry Pi Pico has a vast range of industrial applications
due to its versatility, affordability, and programmability. Its
small size and low power consumption make it an ideal
choice for projects where space is limited, and energy
efficiency is crucial.
127
Chapter 12
STM Microcontroller Series
12.1 Introduction
STM series is a range of microcontrollers developed and
produced by STMicroelectronics, a global leader in the
semiconductor industry. STM microcontrollers are widely
used in various electronic applications such as automotive,
industrial, consumer electronics, and healthcare. These
microcontrollers are known for their high performance, low
power consumption, and advanced peripherals, making them
an attractive choice for developers.
128
Overall, STM series microcontrollers are a popular choice for
developers due to their high performance, low power
consumption, and wide range of features and peripherals.
They are used in various industries and applications, from
small hobby projects to complex industrial automation
systems. With their compatibility with popular development
tools and software, STM microcontrollers offer developers a
flexible and reliable solution for their projects.
129
hardware encryption. Also includes advanced analog
peripherals and Ethernet.
STM32L0 Series: Ultra-low-power 32-bit microcontrollers
with a wide range of connectivity options and a rich set of
peripherals.
STM32L1 Series: Ultra-low-power 32-bit microcontrollers
with advanced analog peripherals and a wide range of
connectivity options.
STM32L4 Series: Ultra-low-power 32-bit microcontrollers
with advanced features such as hardware encryption,
advanced graphics support, and USB.
STM32WB Series: Wireless microcontrollers with Bluetooth
Low Energy and Zigbee support, as well as a rich set of
peripherals.
STM8 Series: 8-bit microcontrollers with a compact form
factor and a wide range of peripherals.
Each STM microcontroller series is designed for specific
applications and use cases, with varying levels of
performance, power consumption, and feature sets.
Therefore, it is essential to choose the right series based on
your project requirements.
12.3 STM32F407VG
The STM32F407VG is a microcontroller from the STM32F4
family, which is a high-performance series of
microcontrollers based on the ARM Cortex-M4F core. It is
designed for embedded applications that require high
processing power, low power consumption, and rich
connectivity options. The STM32F407VG has a clock speed
130
of up to 168 MHz, 1 MB flash memory, and 192 KB RAM,
making it suitable for a wide range of applications
Advantages
12.3.1 High Processing Power
The STM32F407VG has a clock speed of up to 168 MHz
and a floating-point unit (FPU), which makes it capable of
performing complex mathematical operations quickly and
efficiently.
12.3.2 Rich Connectivity Options
The microcontroller has various connectivity options such as
Ethernet, USB, CAN, and SPI, which makes it suitable for
applications that require communication with other devices.
131
12.3.3 Low Power Consumption
The STM32F407VG has a low power consumption mode
that reduces the power consumption to as low as 2.7 µA in
standby mode, making it suitable for battery-powered
applications.
12.3.4 Large Memory
With 1 MB flash memory and 192 KB RAM, the
STM32F407VG has enough memory to store and run
complex applications.
12.3.5 Rich Peripherals
The microcontroller has a variety of built-in peripherals such
as ADCs, DACs, timers, and PWM controllers, which makes
it easier to interface with other components.
Disadvantages
12.3.6 Complexity
The STM32F407VG is a complex microcontroller that
requires a significant amount of expertise to use efficiently.
12.3.7 Cost
Compared to other microcontrollers, the STM32F407VG is
relatively expensive.
12.3.8 Power Supply
The microcontroller requires a 3.3V power supply, which
may not be compatible with some applications.
Factors
12.3.9 Development Environment
132
The STM32F407VG requires a specialized development
environment, which includes an Integrated Development
Environment (IDE), a debugger, and a programmer.
12.3.9 Application Requirements
The microcontroller is suitable for applications that require
high processing power, low power consumption, and rich
connectivity options. Developers should consider the
application requirements before choosing this
microcontroller.
12.3.10 Expertise
The STM32F407VG requires a significant amount of
expertise to use efficiently. Developers should have
experience with embedded programming and
microcontroller architectures before using this
microcontroller.
The STM32F407VG is a powerful and versatile
microcontroller that is suitable for a wide range of
applications. Its high processing power, rich connectivity
options, and low power consumption make it an attractive
choice for developers who require a powerful and efficient
microcontroller. However, its complexity and cost may make
it less suitable for some applications.
133
STM32F407VG has a 1 MB flash memory for program
storage. It allows for firmware updates and modifications
without the need for additional hardware.
12.4.3 SRAM
The microcontroller also has 192 KB of SRAM, which
provides temporary storage for data during program
execution.
12.4.4 GPIO Pins
STM32F407VG has 82 general-purpose input/output (GPIO)
pins, which can be configured to interface with various
sensors, actuators, and other devices.
12.4.5 ADC
The microcontroller has a 12-bit analog-to-digital converter
(ADC) with up to 24 channels, which allows for precise
measurement of analog signals.
12.4.6 DAC
STM32F407VG also has a 12-bit digital-to-analog converter
(DAC) with two channels, which allows for accurate output
of analog signals.
12.4.7 Timers
The microcontroller has 14 timers, which can be used for
various purposes such as measuring time intervals,
generating PWM signals, and controlling motors.
12.4.8 Communication Interfaces
STM32F407VG has several communication interfaces
including UART, SPI, I2C, CAN, and USB. These interfaces
134
enable the microcontroller to communicate with other
devices and systems.
12.4.9 DMA
The microcontroller has a direct memory access (DMA)
controller, which allows for high-speed data transfer between
peripherals and memory.
12.4.10 Power Management
STM32F407VG has several power-saving features such as
multiple low-power modes, which help to extend the battery
life of battery-powered devices.
STM32F407VG is a highly capable microcontroller with a
range of components that enable it to interface with various
devices and perform complex tasks. Its powerful processor,
ample memory, and versatile communication interfaces
make it an ideal choice for a wide range of applications.
135
Figure 12.2 Board’s Pin Configuration
136
NRST: Active-low reset pin for the microcontroller
BOOT0: Pin used for boot selection (boot from flash
or system memory)
137
12.6 Industrial Applications of STM32F407VG
STM32F407VG is a powerful microcontroller with a wide
range of industrial applications. Its advanced features, high
performance, and low power consumption make it an
attractive choice for various projects. Here are some
industrial applications of STM32F407VG:
138
12.6.5 Aerospace
STM32F407VG can be used in aerospace projects due to its
small size, low power consumption, and robustness. It can be
used to control various systems such as navigation,
communication, and propulsion.
12.6.6 Medical Devices
STM32F407VG can be used in medical devices due to its
advanced features, such as low power consumption, high
accuracy, and fast processing speed. It can be used to control
various medical equipment, such as monitoring devices,
infusion pumps, and diagnostic equipment.
STM32F407VG has a vast range of industrial applications
due to its versatility, advanced features, and low power
consumption. Its small size and high processing speed make
it an ideal choice for projects where space is limited, and
performance is crucial.
139
Chapter 13
ESP Microcontroller Series
13.1 Introduction
The ESP series is a family of low-cost, low-power
microcontrollers designed for embedded applications and
IoT projects. The series is developed by Espress if Systems,
a Shanghai-based semiconductor company. The ESP series is
known for its Wi-Fi capabilities, which make it an attractive
choice for IoT projects that require wireless connectivity.
One of the standout features of the ESP series is its low power
consumption, making it an ideal choice for battery-powered
IoT devices. The microcontrollers also come with built-in
Wi-Fi or Bluetooth connectivity, eliminating the need for
additional components.
140
As, the ESP series has become a popular choice for IoT
projects due to its low cost, low power consumption, and
wireless connectivity capabilities. Its versatility and ease of
use have made it accessible to hobbyists, while its
capabilities have made it suitable for more advanced projects.
• ESP8266
• ESP32
• ESP8285
• ESP32-S2
• ESP32-C3
• ESP32-S3
• ESP32-H2
• ESP32-C6
• ESP32-WROOM
• ESP32-WROVER
• ESP32-PICO
• ESP32-DevKitC
• ESP-WROVER-KIT
• ESP-LyraT
• ESP32-Sense Kit
Each series of the ESP microcontrollers has its own unique
features and specifications, making them suitable for various
IoT and automation projects. The ESP series has become
increasingly popular due to its low cost, ease of use, and
excellent community support.
141
13.3 ESP8266 Microcontroller
The ESP8266 is a low-cost Wi-Fi enabled microcontroller
that has gained popularity due to its ease of use and low cost.
Developed by Espressif Systems, it is designed for IoT
projects and can be programmed using the Arduino IDE. The
ESP8266 has a built-in Wi-Fi module, making it ideal for IoT
projects that require a wireless connection.
142
Advantages
13.3.1 Low Cost
The ESP8266 is one of the most affordable Wi-Fi enabled
microcontrollers available in the market.
13.3.2 Ease of use
The ESP8266 can be programmed using the Arduino IDE,
which is a popular development environment among
beginners.
13.3.3 Built-in Wi-Fi
The ESP8266 has a built-in Wi-Fi module, making it easy to
connect to a wireless network.
13.3.4 Large Community
The ESP8266 has a large community of users, which means
there are plenty of resources and tutorials available online.
Disadvantages
13.3.5 Limited RAM
The ESP8266 has limited RAM, which can be a problem for
complex projects.
13.3.6 Single-Core
The ESP8266 is a single-core microcontroller, which means
it may not be suitable for projects that require high processing
power.
13.3.7 Power Consumption
The ESP8266 consumes more power than some of the other
microcontrollers in the ESP series.
143
Factors
13.3.8 Applications
The ESP8266 is ideal for IoT projects that require a low-cost
Wi-Fi enabled microcontroller.
13.3.9 Connectivity
The built-in Wi-Fi module makes it easy to connect the
ESP8266 to a wireless network.
13.3.10 Programming
The ESP8266 can be programmed using the Arduino IDE,
which is a popular development environment among
beginners.
The ESP8266 is a low-cost, Wi-Fi enabled microcontroller
that is ideal for IoT projects. Its ease of use and large
community make it a popular choice among beginners.
However, its limited RAM and single-core architecture may
not be suitable for all projects.
144
The Wi-Fi module is a key component of the ESP8266 and
allows it to connect to Wi-Fi networks. It supports IEEE
802.11 b/g/n wireless standards and can operate in both
client and access point modes.
13.4.3 Flash Memory
The ESP8266 has integrated flash memory that is used for
storing firmware and user programs. It comes with either
512KB or 4MB of flash memory depending on the variant.
13.4.4 RAM
The ESP8266 has 80KB of RAM that is used for storing
program data and variables.
13.4.5 Power Management Unit (PMU)
The PMU is responsible for managing the power supply to
the ESP8266. It includes a voltage regulator, a power-on-
reset (POR) circuit, and other components that ensure stable
and reliable operation.
13.4.6 I/O Pins
The ESP8266 has several General-Purpose Input/Output
(GPIO) pins that can be used for interfacing with other
components. It also has a built-in ADC and PWM
functionality.
145
1.VCC: This pin provides a power supply voltage of 3.3V to
the microcontroller.
2.GND: This pin is the ground pin and is used to complete
the circuit.
3.GPIO0: This pin is used for programming and boot mode
selection. It should be pulled up or down depending on
the mode.
4.GPIO1: This pin is used for UART communication.
5.GPIO2: This pin is used for I2C communication.
6.GPIO3: This pin is used for SPI communication.
7.GPIO4: This pin is a general-purpose input/output pin.
8.GPIO5: This pin is a general-purpose input/output pin.
9.GPIO6: This pin is a general-purpose input/output pin.
10.GPIO7: This pin is a general-purpose input/output pin.
11.GPIO8: This pin is a general-purpose input/output pin.
12.GPIO9: This pin is a general-purpose input/output pin.
13.GPIO10: This pin is a general-purpose input/output pin.
14.GPIO12: This pin is a general-purpose input/output pin.
15.GPIO13: This pin is a general-purpose input/output pin.
16.GPIO14: This pin is a general-purpose input/output pin.
17.GPIO15: This pin is a general-purpose input/output pin
and is also used for boot mode selection.
It is important to note that some of these pins have specific
functions and may require additional circuitry for proper use.
Additionally, some pins are also used for communication
interfaces and may be unavailable for general-purpose use
when in use for communication. It is important to refer to the
microcontroller's datasheet and reference manual for more
detailed information on pin configuration and usage.
146
Figure 13.2 Functional Diagram of ES8266EX
147
13.6 Industrial Application of ESP8266
The ESP8266 has gained popularity due to its low cost, ease
of use, and Wi-Fi connectivity, making it a popular choice
for IoT applications. Some of the industrial applications of
ESP8266 include:
148
13.6.6 Smart Cities
The ESP8266 can be used in smart city applications, such as
monitoring traffic flow and air quality. It can be used to
collect data from sensors and then transmit this data to a
central server for analysis.
The ESP8266 is a versatile microcontroller that can be used
in a wide range of industrial applications. Its low cost, ease
of use, and Wi-Fi connectivity make it an attractive choice
for IoT projects.
149
Chapter 14
Advance Sensors
14.1 Introduction
In this chapter and a few following chapters we’ll be studying
in depth about the sensors, actuator, and modules that can be
used with microcontrollers especially Arduino
microcontroller boards.
Sensors are the devices that can detect the change in their
physical surroundings and can measure them. These sensors
convert the physical data in the form of temperature, light, or
sound and converts it into an electrical signal which is much
easier for a microcontroller or a computer system to process.
Sensors play a key role in modern robotics, internet of things
(IOTs), electronics, automation systems, and measurement
systems.
14.2 Sensors
There a vast variety of sensors that can used to process a vast
variety of data. Some of these sensors are used in medical
equipment, military equipment, robotics industry, and many
other industries. The design of a specific sensor is based on
its utility.
150
space telescopes and International Space Station (ISS) are not
common in market and not every country on the planet is
capable on making such advance sensors.
151
performs any data processing required to produce a
meaningful output, such as calibration or scaling.
Sensing Signal
Element Conditioner
Microcontroller ADC
Data Processing
152
14.4 Temperature Sensors
Temperature sensors are widely used in industrial,
automotive, medical, and consumer electronics applications.
They are the instruments that measure the temperature of an
object or environment and generate an electrical signal
corresponding to the temperature.
153
3. Thermistors: They are made from semiconductor
materials and are known for their high sensitivity to
temperature changes. Thermistors are made from
ceramic or metal oxide materials and their resistance
decreases with increasing temperature. They are
commonly used in automotive and consumer
electronics applications.
4. IC temperature sensors: They are integrated circuit
(IC) chips that are designed specifically for
measuring temperature. They use a temperature-
dependent voltage or current to measure the
temperature. They are easy to use and offer high
accuracy and stability.
154
5. Convert the raw temperature data into a meaningful
temperature value using appropriate calibration and
scaling techniques.
6. Use the temperature value for your desired
application, such as controlling a heating system,
monitoring the temperature of a room, or displaying
the temperature on a display.
155
DHT11/DHT22: These are digital temperature and humidity
sensors that can measure temperatures in the range of -40°C
to 80°C with an accuracy of ±2°C.
156
MCP9808: This is a digital temperature sensor that can
measure temperatures in the range of -40°C to 125°C with an
accuracy of ±0.5°C.
157
14.5.1 Working of Light Sensors
158
frequency response, you should select a sensor that
suits your requirements.
2. After you've decided on a light sensor, you'll need to
connect it to your microcontroller. The connections
will vary depending on the type of sensor and the
microcontroller platform, but typically, the power
and ground pins of the sensor must be attached to the
corresponding pins on the microcontroller. You must
also connect the sensor's output pin to an analog and
digital input pin on the microcontroller.
3. After interacting the light sensor to the
microcontroller, make a program that reads the
sensor output and performs the desired action. If
you're using a photoresistor to detect light, for
example, you can write a program that reads the
voltage on the analog signal pin and adjusts the
brightness of an LED or triggers a relay based on the
light level. Similarly, if you're using a photodetector
or photodiode, you can create a program that reads
the current or voltage on the input pin and takes
action based on the amount of light.
There are several light sensors that can be used with Arduino
boards. Here are some common ones:
159
BH1750: BH1750 is another digital light sensor that
communicates with Arduino over the I2C bus. It can measure
both ambient light and artificial light and is commonly used
in smartphones, laptops, and tablets to adjust the screen
brightness according to the surrounding light levels.
160
14.6.1 Working with Ultrasonic Sensors
161
that reads the sensor output and performs the desired
action.
2. To connect the sensor to the microcontroller,
typically connect the sensor's power and ground pins
to the corresponding pins on the microcontroller.
You will also need to connect the sensor's trigger pin
to a digital output pin on the microcontroller and the
sensor's echo pin to a digital input pin on the
microcontroller.
3. Sending a trigger signal to the sensor, measuring the
time it takes for the sound waves to bounce back, and
calculating the distance to the object based on the
time measurement are typical steps in the program
that reads the sensor output and performs the desired
action. Based on the distance measurement, the
program can then perform an action such as turning
on an LED, sounding an alarm, or controlling a
motor.
162
JSN-SR04T: Another popular ultrasonic sensor, the JSN-
SR04T, can measure distances up to 6 meters with a 2mm
accuracy. It uses the UART interface to communicate with
Arduino and is commonly used in water level measurement,
obstacle avoidance, and other applications.
163
SRF05: The SRF05 is an ultrasonic sensor capable of
measuring distances up to 4 meters with a 3mm accuracy. It
communicates with the Arduino through the GPIO pins and
is widely used in robotics, automation, and other
applications.
164
These are just a few examples of ultrasonic sensors that can
be used in conjunction with Arduino. Other ultrasonic
sensors may be more appropriate for your project, depending
on its requirements. Before choosing a sensor for your
project, it's always a good idea to read the datasheets and
specifications.
165
it. They are commonly used in temperature
measurement and thermal imaging systems.
3. Infrared photodiodes detect infrared radiation by
converting it into an electrical signal. They are
commonly used in remote control systems, where
they detect the infrared signal emitted by a remote
control and convert it into an electrical signal.
4. Infrared reflective sensors detect the presence or
absence of an object by measuring the amount of
infrared radiation reflected back from the object.
They are commonly used in object detection and
position sensing applications.
166
Infrared Thermometer Sensor this type of sensor detects the
infrared radiation emitted by objects to determine their
temperature. Temperature sensing and thermal imaging are
two applications for these sensors.
167
Infrared Line Sensor this sensor detects ground lines by
emitting an infrared beam and measuring its reflection. Line-
following robots frequently use these sensors.
168
An accelerometer works on the principle of a mass-spring
system. The basic idea is to measure the displacement of a
proof mass from its initial position when an external force is
applied. The proof mass is attached to a spring, which is in
turn attached to a fixed frame. When the accelerometer
experiences acceleration, the proof mass moves relative to
the frame, compressing or stretching the spring. The
displacement of the proof mass is then measured and used to
calculate the acceleration.
169
the microcontroller's input pins. The accelerometer's output
pins typically provide an analog signal that must be
converted to a digital signal using an Analog to Digital
Converter (ADC). The microcontroller can process the signal
after it has been converted to a digital signal.
170
MMA7361 - It is a low-power, 3-axis MEMS accelerometer
that can measure acceleration in the range of ±1.5 g, ±6 g,
and ±11 g.
171
BMA180 - It is a low-power, 3-axis MEMS accelerometer
that can measure acceleration in the range of ±1 g, ±1.5 g,
±2 g, ±3 g, ±4 g, ±8 g, and ±16 g.
14.9 Magnetometer
A magnetometer is a sensor that is used to measure magnetic
fields. It can measure the strength, direction, and magnitude
of the magnetic field. Magnetometers are used in various
applications such as navigation, mapping, and geology.
172
strength of the induced voltage is proportional to the strength
of the magnetic field. The magnetometer measures the
induced voltage and uses it to determine the strength of the
magnetic field.
173
variety of applications, including navigation, mapping, and
geology.
174
14.10 Pressure Sensors
A pressure sensor is a sensor that helps to measure the
pressure of liquids or gases. It is widely used to monitor and
control pressure in a wide range of industries including
automotive, aerospace, and medical etc.
175
2. Capacitive pressure sensors operate on the principle
of a change in capacitance caused by applied
pressure. An oscillator circuit can measure the
capacitance change, which is proportional to the
pressure. This sensor type is commonly used in
medical and aerospace applications.
3. Piezoelectric pressure sensors operate on the
principle of an electric charge change caused by
applied pressure on a piezoelectric crystal. An
amplifier circuit can measure the charge change,
which is proportional to the pressure. This type of
sensor is common in high-pressure applications like
oil and gas.
176
MPXV7002DP Pressure Sensor Module: This module
communicates via analog interface and is based on the
Freescale MPXV7002DP chip. It measures pressures from 0
to 2 kPa and has a resolution of 1 kPa.
177
LPS331AP Pressure Sensor Module: This module is based
on the STMicroelectronics LPS331AP chip and
communicates over I2C interface. It has a pressure range of
260-1260 hPa and a resolution of 0.01 hPa.
178
14.11 Touch and Sound Sensors
Touch and sound sensors are two different types of sensors
that can detect and measure physical events. They can
communicate with microcontrollers like Arduino to obtain
data and carry out various tasks.
179
The microcontroller then amplifies and processes the
signal.
2. Digital sound sensors work by converting sound
waves into a digital electrical signal that can be read
by a microcontroller. The sensor contains a
microphone that detects sound waves and converts
them into a digital signal using an analog-to-digital
converter (ADC). The digital signal is then processed
by the microcontroller.
180
MPR121 Capacitive Touch Sensor Module: This module is a
capacitive touch sensor that communicates over I2C
interface. It has 12 touch pads and can be used with a variety
of Arduino boards.
181
14.11.4 Sound Sensors Available in Market
182
14.12 Moisture and Water Level Sensors
Moisture and water level sensors are electronic devices that
measure the amount of moisture and water content in a
specific material or environment. They are widely used in
many industries, including agriculture, horticulture, food
processing, environmental monitoring, and many others.
These sensors aid in determining the optimal level of
moisture or water content required for proper plant, crop, and
material growth and maintenance. In this article, we will go
over the operation, types, and interfacing of moisture and
water level sensors with a microcontroller in great detail.
183
dielectric constant of the material, resulting in an increase in
capacitance. Electromagnetic moisture sensors operate on the
principle of measuring a material's dielectric constant.
Moisture changes the electromagnetic properties of the
material, resulting in a change in the dielectric constant.
184
between the sensor and the water surface. As the
water level rises, the capacitance also increases.
5. Ultrasonic water level sensors: These work by
measuring the time it takes an ultrasonic pulse to
travel from the sensor to the water's surface and back.
6. Pressure water level sensors: These sensors work on
the principle of measuring the pressure of the water
at a particular depth.
185
Grove - Moisture Sensor (SEN113) - This sensor measures
soil moisture content from 0 to 50% and has an analogue
output signal that Arduino can read. It has a wide operating
voltage range of 3.3V to 5V, making it compatible with a
variety of microcontrollers.
186
Waterproof Ultrasonic Sensor (SEN0205) - This sensor has
a measurement range of 3-500cm to a water surface. It
employs a non-contact, waterproof ultrasonic sensor with a
digital output signal that can be read by Arduino.
187
Water Level Sensor Depth Detection Module (SEN0257) -
This sensor detects water levels in tanks and other containers
while also measuring water temperature. It detects the water
level with a contact-based probe and has a digital output
signal that Arduino can read. It is capable of measuring water
levels up to 3 meters deep.
188
A heart rate sensor's operation is based on the
electrocardiogram (ECG) signal. The ECG signal measures
the electrical activity of the heart muscle and is used to
diagnose a variety of heart conditions. The ECG signal is
made up of waves such as the P wave, QRS complex, and T
wave. Each of these waves represents a different stage of the
electrical activity of the heart.
Heart rate sensors are classified into two types: contact and
non-contact sensors. Contact sensors require electrodes to be
placed directly on the skin, whereas non-contact sensors
detect heart rate using other methods, such as optical sensors.
189
14.13.4 Heart Rate Sensors Available in Market
190
ECG Monitor Sensor Module Kit - This sensor uses ECG to
measure the heart rate and provides a digital output signal
that can be read by Arduino.
191
Chapter 15
Advance Modules
15.1 Introduction
In this chapter we’ll be studying in depth about the modules
and actuator that can be used with microcontrollers especially
Arduino microcontroller boards.
192
15.2 Modules
There a vast variety of modules that can used to process a
vast variety of data. Some of these modules just like sensors
are used in medical equipment, military equipment, robotics
industry, and many other industries. The design of a specific
modules is based on its utility. A module may contain one or
more than one sensor based on it utility.
1. Wi-Fi Module
2. Bluetooth Module
3. Global Positioning System Module
4. GSM Module
5. Display Module
6. Motor Driver Modules
193
when one is found. If necessary, the device can then join to
the network by inputting a password.
Once linked, the gadget can wirelessly send and receive data.
The Wi-Fi module functions as a bridge between the device
and the wireless network, allowing it to connect to the
internet and communicate with other network devices.
194
status information, which will allow you to control it and
connect to the wireless network.
Here are the few Wi-Fi modules that are available in market
that are inexpensive and are easy to interface with
microcontroller like Arduino.
195
Wi-Fi standards 802.11b/g/n. It has TCP/IP support and can
be programmed using AT commands.
196
2. Standalone Bluetooth modules are separate devices
that can be added to any electronic device. These
modules are more powerful than embedded modules,
and they offer more features and capabilities.
Standalone Bluetooth modules are typically used in
industrial applications, where reliability and
performance are critical.
197
HC-05 Bluetooth module is a common DIY electronics
project component. It is simple to operate and has a range of
up to 10 metres. The HC-05 supports the serial
communication protocol (UART) and can be interfaced with
a microcontroller such as Arduino with just four pins.
198
above the Earth send signals to the GPS receiver. GPS
satellites provide data on their location, transmission time,
and other parameters. This information is used by the GPS
receiver to determine its location.
199
use, while SPI communication provides faster data transfer
rates.
200
network. They are often utilized in remote control,
monitoring, and tracking applications. In this post, we will
discuss how GSM modules function, their many varieties,
how they interface with microcontrollers, and a list of widely
available GSM modules for Arduino microcontrollers.
201
Receiver/Transmitter) or SPI (Serial Peripheral Interface)
communication. UART communication is simple and easy to
use, while SPI communication provides faster data transfer
rates.
202
15.6.1 Working of Display Modules
203
communication protocol used depends on the type of display
module and the microcontroller.
204
E-Ink Display this display module uses the E-Ink technology,
which provides a low power consumption display with high
contrast. It can be interfaced with an Arduino microcontroller
using the Adafruit-GFX library.
205
15.7.3 Types and Available in the Market
206
Part 03 Embedded
C and C++
Programming
207
Chapter 16
Introduction to
Programming
16.1 Introduction
Programming is the method by which we interact with
computers. While many individuals believe that computers
are intelligent and operate independently, the truth is quite
different since computers are actually unintelligent devices.
They require specific instructions or directives to function.
Thus, we provide the computer with commands to enable it
to perform various tasks in accordance with our needs. This
process of providing instructions to the computer is known
as programming.
208
16.2 History of Programming
Programming languages have been a critical component in
the advancement of computer science and technology. The
need for programming languages arose from the desire to
communicate with computers in a way that was more
accessible and understandable to humans. Prior to the
invention of programming languages, computers could only
be programmed using machine code, which was written in
binary and was difficult for humans to read and write. The
invention of programming languages removed this barrier
and made it easier for humans to write code that computers
could understand.
209
comprehend. They have facilitated the development of a
diverse range of software and applications, ranging from
scientific simulations to websites and mobile apps.
Additionally, programming languages have played a
significant role in the progress of computer science and
technology.
210
Assembly Language: It is a type of low-level language in
which instead of numeric we use symbols for the instructions.
Assembly language is also known as the second-generation
language (2GL). In this language to represent elementary
operations we use English-like abbreviations. These
abbreviations are known as mnemonics.
For example
211
1. Procedural Languages: These Languages are a type
of high-level language that follows a sequence of
instructions to achieve a desired output. It is also
known as a third-generation language (3GL). The
computer executes these instructions one by one in
sequence, and a compiler is used to convert these
high-level language instructions into machine
language. Essentially, these instructions tell the
computer what to do and how to do it. Examples of
procedural languages include Pascal, ADA, BASIC,
and FORTRAN.
2. Non – Procedural Languages: g Non-Procedural
Programming Languages is a type of high-level
language in which the user specifies what output is
desired, but not necessarily how to achieve it. The
user does not need to write traditional program logic
as the computer automatically generates the
necessary steps to produce the output. This type of
language is also known as fourth-generation
language (4GL). For example SQL, Prolog, USP.
3. Object-Oriented Languages: Object-oriented
programming language (OOP) is a programming
paradigm in which a program is structured as a
collection of objects, each consisting of data and
behavior. OOP is designed to manage the complexity
of large programs by breaking them down into
smaller, reusable objects. The code written in OOP
is easily understandable and modifiable due to its
clear structure. The principle of "Don't Repeat
Yourself" (DRY) is followed in OOP, which means
avoiding the repetition of code to reduce redundancy.
Some examples of Object-Oriented Languages
include, C++, PHP, Python, Java.
212
16.4 Frontend Programming
Frontend languages, also known as client-side languages, are
used to create the user interface and determine how the
website looks and feels
213
provide a seamless user experience, such as form validation,
dropdown menus, and sliders.
214
One of the most important aspects of backend programming
is database management. The backend programmer is
responsible for designing the database schema, writing
queries, and optimizing the database for performance. A
well-designed database can significantly improve the speed
and reliability of a web application.
215
16.6 Human and Machine Interaction
An important part of bridging the gap between humans and
machines is the use of programming languages. By supplying
a set of instructions that the machine can comprehend and
carry out, they enable human-computer interaction. Although
they can be converted into machine code that computers can
comprehend and execute, programming languages offer a
structure and syntax that is accessible and understandable by
humans.
216
and data analysis. Additionally, programming languages
have been instrumental in enabling the widespread use of the
internet and the development of the digital economy.
217
Chapter 17
Embedded Programming
17.1 Introduction
Embedded programming is the process of creating software
for devices with limited resources, such as processing power,
energy, and memory. The purpose of this programming is to
manage a specific function within a larger system. Examples
of embedded systems range from simple microwave ovens to
complex spacecraft.
218
17.2 Embedded C and C++ Programming
Embedded programming involves creating software that runs
on microcontrollers or other embedded systems. C and C++
are two popular programming languages used for embedded
programming. C is a procedural language that is often used
for low-level programming. It is efficient, fast, and has a
relatively small runtime, making it a popular choice for
embedded programming. C allows for direct access to
memory and hardware, which can be important in systems
with limited resources, such as microcontrollers. On the other
hand, C++ is a more modern programming language that is
built on top of C. It is an object-oriented language that allows
for code reuse, modularity, and abstraction. C++ is often used
for larger projects that require more structure and
organization. It includes features such as exception handling,
operator overloading, and templates, which can make it
easier to write complex code.
219
programmers have direct control over the hardware, enabling
them to write code tailored to the specific hardware
requirements of the system. Embedded C is primarily used
for low-level programming tasks, such as interfacing with
hardware, real-time systems, and embedded operating
systems.
220
ideal for programming embedded systems, while C++ added
object-oriented features such as inheritance, encapsulation,
and polymorphism.
Efficiency and speed: C and C++ are both renowned for their
efficiency and speed. For system-level programming, C is a
low-level language that is efficiently optimized, whereas
C++ offers a higher level of abstraction with little overhead.
Because of these characteristics, C and C++ are perfect for
creating software that must function quickly and efficiently.
221
a specific task or collection of tasks because of this
flexibility.
222
Here is a simple "Hello, world!" program written in
Embedded C:
#include<stdio.h>
int main()
{
printf("Hello, World!\n");
return 0;
}
#include<iostream>
int main()
{
std::cout<<"Hello, World!"<<std::endl;
return 0;
}
"Hello, world!" message to the console using the cout object.
The endl object is used to add a newline character at the end
of the message. The return statement at the end of the main
function returns a value of 0 to indicate that the program has
executed successful
223
Chapter 18
Syntax and Semantics of
Embedded Programming
18.1 Introduction
Embedded C and C++ programming languages have syntax
and semantics that are similar to standard C and C++
programming languages. However, they also have unique
features and extensions that are specific to embedded
systems. Embedded C and C++ syntax is designed to be
lightweight, which is useful for systems with limited
resources. Additionally, the languages are designed to
provide direct access to the hardware of the system, which
enables developers to interface with the hardware at a low
level. For example, Embedded C and C++ allow direct access
to memory through the use of pointers, which enables
developers to manipulate the memory at a low level.
224
variables that should be kept in the register to optimize their
access. This can improve the overall performance of the
system, as the processor accesses the variables faster from
the registers than from memory.
225
#include<stdio.h>
int main()
{
int x=2;
if (x>10)
{
print("x is greater than 10")
}
return 0;
}
#include<stdio.h>
int main ()
{
int x=2;
if (x>10)
printf("x is greater than 10");
else
printf ("x is less than equal to 10");
return 0;
}
226
#include<stdio.h>
int main ()
{
int x=2;
switch (x)
{ case 1:
printf("x is greater than 1");
break;
case 2:
printf ("x is less than equal to 2");
break;
default:
printf("x is not equal to 1 or 2")
}
return 0;
}
#include<stdio.h>
int main ()
{
for (int i=1; i<10; i++)
{
printf("%d\n",i);
}
return 0;
}
227
So, control structures in Embedded C and C++ enable us to
control the flow of execution of a program and execute
specific pieces of code based on certain conditions. The if
statement, switch statement, and loops like the for loop and
while loop are essential constructs for writing efficient and
reliable embedded software.
228
#include<stdio.h>
int main ()
{
// Assigning character 'A' to Char variable
char myChar = 'A';
// Output: The ASCII value of A if 65
printf ("ASCII value of %c is %d\n", myChar,
myChar);
return 0;
}
#include<stdio.h>
int main ()
{
// assigning the max value to short variable
short myshort =32767;
// output: the value of myshort is 32767
printf("the value of myshort is %d\n", myshort);
return 0;
}
Int is a 2- or 4-byte integer type (depending on the
implementation) that can store integer values in the range of
-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 when
used as a signed type, and 0 to 65,535 or 0 to 4,294,967,295
when used as an unsigned type. Here is an example:
229
#include<stdio.h>
int main ()
{
// assigning the max value to int variable
int myint =2147483647;
// output: the value of myint is 2147483647
printf("the value of myint is %d\n", myint);
return 0;
}
#include<stdio.h>
int main ()
{
// assigning the max value to long variable
long mylong =2147483647L;
// output: the value of mylong is 2147483647
printf("the value of mylong is %d\n", mylong);
return 0;
}
Note: The L suffix is used to indicate that the value is of type
long.
230
#include<stdio.h>
int main ()
{
// declare and initialize float variable called
"temperature"
float temperature = 98.6;
//print the value of temperature variable
printf("temperature is : %f\n", temperature);
return 0;
}
#include<stdio.h>
int main ()
{
// declare and initialize double variable called "pi"
double pi = 3.14159256;
//print the value of pi variable
printf("pi is : %f\n", pi);
return 0;
}
Double: A double data type is used to represent double-
precision floating-point numbers. It occupies 8 bytes (64 bits)
in memory. Here is an example:
231
Embedded C, the typedef keyword is used to define a
Boolean type as follows:
#include<stdio.h>
#inclue<stdbool.h> // includes bool library
int main ()
{
// declare and initialize boolean variable
bool israining =true;
if (israining)
{
//check if boolean is true or not
printf(" it is raining!\n");
}
else
printf(" it is not raining!\n");
return 0;
}
232
Void Type: In Embedded C/C++, void is a data type that
represents the absence of a value. It is commonly used to
define functions that do not return any value, such as
interrupt service routines. Unlike other data types, void
cannot be used to declare variables, but it can be used to
declare pointers to any data type.
Here is an example of a function that takes no parameters and
returns no value using void in Embedded C:
#include<stdio.h>
void display_message (void) // void function
{
printf(" Hello World!\n");
}
int main ()
{
// call the function
display_message ();
return 0;
}
In this example, the function display_message simply prints
the message "Hello, World!" to the console. Since the
function does not return any value, the return type is void.
233
#include<stdio.h>
enum day_of_week
{
monday,
tuesday,
wednesday,
thrusday,
friday,
saturday,
sunday,
};
int main ()
{
234
Array Types: Arrays are a fundamental data structure in
programming, and they are extensively used in embedded
systems for storing and accessing large sets of data. In
Embedded C and C++, an array is a collection of elements of
the same data type, which are stored in contiguous memory
locations. The size of the array is defined at the time of
declaration, and it cannot be changed during runtime.
Here's an example of declaring and initializing an array of
integers in Embedded C:
#include<stdio.h>
int main()
{
int number[5] ={1,2,3,4,5};
for (int i=0; i<5; i++)
{
printf("element %d: %d\n", i, numbers[i]);
}
}
In this example, we've declared an array of integers named
"numbers" with a size of 5. We've also initialized the array
with the values 1, 2, 3, 4, and 5.We then use a "for" loop to
iterate over the elements of the array and print their values to
the console. The loop runs from 0 to 4, since the index of the
first element of the array is 0 and the index of the last element
is 4.
235
variables of different data types under a single name. They
are widely used in embedded programming for representing
complex data structures such as packets, frames, and
configurations. Here's an example program that demonstrates
the use of a structured type in Embedded C:
#include<stdio.h>
// define a structured type called "person"
typedef structured
{
char name[50];
int age;
char occupation[50];
}person;
int main()
{
// declare a variable of type "person"
person Sadia;
// initialize the field "Sadia" variable
strcpy (Sadia.name, "Sadia Adrees");
Sadia.age =35;
strcpy (Sadia.occupation, "Software Engineer");
// print out the information of person
printf("Name: %s\n", Sadia.name);
printf("Age: %s\n", Sadia.age);
printf("Occupation: %s\n", Sadia.occupation);
return 0;
}
In this program, we first define a structured type called
"person" using the typedef keyword. This type contains three
fields: a character array called "name", an integer called
"age", and another character array called "occupation". We
236
then declare a variable called "john" of type "person", and
initialize its fields using the strcpy() function and assignment
statements. Finally, we print out the information about the
person using printf() statements.
#include<Stdio.h>
#include<string.h>
union data
{
int num;
floar fnum;
char str[20];
};
int main ()
{
union data value;
value.num =10;
// accessing union member
printf ("value of num: %d\n", value.num);
value.fnum =3.14;
// accessing same memory location to store different data
printf("value of fnum%f\n", value.fnum);
strcpy(value.str, "embedded c");
// accessing same memory location to store different data
printf("value of str %f\n", value.str);
return 0;
}
237
In this program, we define a union data that contains three
members: an integer num, a floating-point number fnum, and
a character array str. In the main function, we declare a
variable value of type union data. We then initialize the num
member of the union to 10 and print its value. We then assign
a floating-point value to the fnum member of the union and
print its value. Finally, we use the strcpy function to copy a
string into the str member of the union and print its value.
238
3. Declaring a character variable:
char ch;
Here, we are declaring a character variable named ch.
This variable can store any character value within its
range.
239
Here's an example program that demonstrates the usage of
functions in embedded C/C++.
#include<stdio.h>
// function declaration
void printMessage (char message[]);
int main()
{
//calling the function
char message [] ="Hello, world!";
printMessage(message);
return 0;
}
//function declaration
void printMessage(char message[])
{
printf("%s", message);
}
240
Chapter 19
Basics of Embedded
Programming
241
#include “i2c_lib.h”
int main ()
{
float temp = read_temperature();
printf("temparature: %.2f\n", temp);
return 0;
}
#include "uar_lib.h"
int main()
{
char buffer [100];
UART_read(buffer, 100);
printf("recieved data: %s\n", buffer);
return 0;
}
242
"set_motor_speed" from the PWM library. Here
is an example code snippet:
#include "pwm_lib.h"
int main()
{
set_motor_speed(50); // set motor speed at 50%
return 0;
}
#include "uart_lib.h"
int main()
{
char data[] ="Hello World!";
UAR_write (data, sizeof(data));
return 0;
}
243
19.2 Standard Input and Output (I/O) library
functions
The Standard Input and Output (I/O) library functions
in Embedded C programming provide a set of functions
for performing input and output operations on the
standard input and output streams, which are typically
connected to a console or terminal. The standard input
stream (stdin) is used for reading input from the user or
from another program, while the standard output stream
(stdout) is used for displaying output to the user or
sending data to another program. Here are some of the
commonly used Standard I/O library functions in
Embedded C programming:
1. printf():
The printf() function is used for formatted output
to the standard output stream. It takes a format
string as the first argument, which specifies the
format of the output string, followed by zero or
more additional arguments that are used to
populate the format string. Here is an example
code snippet:
int main()
{
int x=10, y=20;
printf("value of x is %d and value of y is %d\n",
x, y);
return 0;
}
244
2. scanf():
The scanf() function is used for formatted input
from the standard input stream. It takes a format
string as the first argument, which specifies the
format of the input string, followed by pointers to
the variables where the input values should be
stored. Here is an example code snippet:
int main()
{
int x, y;
printf(" enter value of x and y:");
scanf("%d %d, &x, &y");
printf("sum of x and y is %d\n", x+y);
return 0;
}
3. getchar():
The getchar() function is used for reading a single
character from the standard input stream. It does
not take any arguments and returns the ASCII
value of the character read. Here is an example
code snippet:
int main()
{
char c;
printf(" enter a character:");
c = getchar();
printf("ASCII value of character is %d\n", c);
return 0;
}
4. putchar():
245
The putchar() function is used for writing a single
character to the standard output stream. It takes a
single character as its argument and returns the
ASCII value of the character written. Here is an
example code snippet:
int main()
{
char c ='A';
putchar(c);
putchar('\n');
return 0;
}
246
1. Choose the Appropriate Hardware Component
The first step is to choose the appropriate
hardware component for the desired input or
output operation. For example, a temperature
sensor can be used to read the temperature of the
environment, while a motor driver can be used
to control the speed and direction of a motor.
2. Connect the Component to the Microcontroller
The next step is to connect the hardware
component to the microcontroller using the
appropriate interface. The interface can be
digital (e.g. GPIO pins) or analog (e.g. ADC,
DAC). The connections should be made
according to the pin-out of the microcontroller
and the datasheet of the hardware component.
247
#define LM35_PIN A0
void setup()
{
// initialize ADC
ADC_init();
}
void loop()
{
int volts= ADC_read(LM35_PIN);
float temp = (volt/1023.0*500;)
//LM35 output is 10mv/c
printf("temp: %f\n",temp);
delay(1000);
}
248
The motor driver can be connected to GPIO pins
of the microcontroller to control the direction
and PWM pins to control the speed. Here is an
example code snippet:
#define DIR_PIN 2
#define PWM_PIN 3
void setup()
{
GPIO_init();
PWM_init();
}
void loop()
{
//set direction and speed of motor
GPIO_write(DIR_PIN, HIGH); // forward motion
PWM_write (PWM_PIN, 50); // speed at 50%
delay(1000);
249
19.4 Interrupts and I/O Operations
Interrupts and I/O operations are closely related in
Embedded C programming. Interrupts are a mechanism
by which the microcontroller can be notified of a change
in the state of an input or output device, allowing the
microcontroller to respond to the change in real-time.
Now we will discuss how interrupts and I/O operations
work together in Embedded C programming, along with
some examples.
So, interrupts allow the microcontroller to execute a
specific code when an external event occurs, such as a
button press or a signal from a sensor. When an interrupt
is triggered, the processor will stop executing the
current code and jump to the interrupt service routine
(ISR) that handles the interrupt. Once the ISR has
completed, the processor returns to the main code.
In I/O operations, the microcontroller interacts with
input or output devices by sending or receiving data.
When an input device changes state, such as a sensor
detecting an object or a button being pressed, the
microcontroller must respond quickly to the change.
Interrupts allow the microcontroller to respond to
changes in real-time, enabling it to perform I/O
operations more efficiently.
Interrupts can be triggered by several sources, such as a
timer, a GPIO pin, or a communication module. The
microcontroller can be configured to handle interrupts
from multiple sources simultaneously, allowing it to
respond to multiple events simultaneously.
250
Here are some examples of how interrupts and I/O
operations work together in Embedded C programming:
#define DIR_PIN 2
#define PWM_PIN 3
void setup()
{
GPIO_init();
PWM_init();
}
void loop()
{
//set direction and speed of motor
GPIO_write(DIR_PIN, HIGH); // forward motion
PWM_write (PWM_PIN, 50); // speed at 50%
delay(1000);
251
buttonPress will be executed, which will print a
message to the console.
void setup()
{
//intialize GPIO pin as input
GPIO_init (INPUT_PIN);
// configure interrupt on the GPIO pin
attachInterrupt(INPUT_PIN, buttonPress,
RISING);
}
void loop()
{
// main execution code
}
void buttonPress()
{
// interrupt service routine to handle button
buttonPres
printf("Button pressed \n");
}
252
Overall, interrupts and I/O operations work together in
Embedded C programming to enable the
microcontroller to respond to external events in real-
time, making I/O operations more efficient. Interrupts
can be triggered by various sources, such as timers,
GPIO pins, or communication modules, allowing the
microcontroller to respond to multiple events
simultaneously.
void setup()
{
// intialize UART
UART_init();
// configure interrupt on UART recieve
attachInterrupt(UART_RX, reciever=Data,
RISING);
}
void loop()
{
// main execution code
}
void recieveData()
{
//interupt service routine to handle incoming Data
char data=UART_read();
if(data=='A')
{
//respong to 'A'
UART_write("A recieved\n");
}
}
253
Chapter 20
Advance Embedded
Programming
254
and SPI, and make it easy to control and communicate
with external hardware.
20.1.2 16-bit Microcontrollers
Embedded C and C++ programming for 16-bit
microcontrollers are similar to those for 8-bit
microcontrollers. The programming language is still C,
and the most commonly used compilers are still the Keil
compiler and the GNU Compiler Collection (GCC). The
libraries used for 16-bit microcontrollers are also similar
to those used for 8-bit microcontrollers, with the SPL
being the most commonly used library. However, 16-bit
microcontrollers typically have more complex
peripherals than 8-bit microcontrollers, and the libraries
may be more extensive.
20.1.3 32-bit Microcontrollers
Embedded C and C++ programming for 32-bit
microcontrollers involve using compilers that are
specifically designed for these microcontrollers, such as
the Keil compiler, the GCC, and the ARM Compiler.
The programming language for 32-bit microcontrollers
is usually C or C++, and the libraries used are usually
provided by the microcontroller manufacturer or a third-
party library. The libraries provide access to the
microcontroller's peripherals and may be more
extensive than those used for 8-bit and 16-bit
microcontrollers.
So, Embedded C and C++ programming are commonly
used for developing software for 8-bit, 16-bit, and 32-
bit microcontrollers. The programming language,
compiler, and libraries used may vary depending on the
255
type of microcontroller being used. However, the main
goal of the programming is to develop efficient and
reliable software for controlling and communicating
with external hardware.
256
I2C, or CAN, and configuring the
microcontroller's pins, clock speed, and other
settings to match the requirements of the
peripheral device.
257
using the appropriate protocol, such as SPI or
I2C. The peripheral driver for the display may
include functions for sending commands to the
display, such as setting the cursor position or
turning on/off the backlight, as well as functions
for writing data to the display, such as displaying
text or graphics.
258
20.3 Debugging Embedded C and C++ program
Debugging is the process of finding and fixing errors or
bugs in a program. Debugging embedded C and C++
programs can be more challenging than debugging
programs on a desktop computer, as there are often
fewer debugging tools and resources available.
However, there are still several effective methods for
debugging embedded programs:
1. Printing Debug Messages: One of the simplest
and most effective methods for debugging
embedded C and C++ programs is to use print
statements to output debug messages to a serial
port or other output device. These messages can
help identify where the program is executing,
which functions are being called, and the values
of key variables at different points in the
program. This method is especially useful for
debugging programs that run on
microcontrollers without a built-in debugger or
for programs running on systems where the
debugger cannot be connected to the system.
259
registers. Debuggers can also be used to analyze
the program's execution flow and identify errors
or unexpected behavior.
260
the program on a prototype device that is similar
to the final product.
261
2. OR (|): This operator performs a bitwise OR
operation on two numbers. The result is a
number in which each bit is set to 1 if the
corresponding bit in either operand is 1. For
example, the result of 0b1010 | 0b1100 is
0b1110.
262
Bitwise operators are often used for setting or clearing
individual bits in a register or for extracting specific bits
from a larger number.
For example, the following code sets bit 3 of a register:
register != (1 << 3);
This code sets bit 3 of the register to 1 by shifting the
number 1 three positions to the left and performing a
bitwise OR operation with the register.
Similarly, the following code clears bit 3 of a register:
register &= ~(1 << 3);
This code clears bit 3 of the register by shifting the
number 1 three positions to the left, inverting it using
the NOT operator (~), and performing a bitwise AND
operation with the register.
263
#define PI 3.14159
264
#include <stdio.h>
#define DEBUG
int main()
{
int x=5;
#idef DEBUG
printf("x=%d\n",x);
#endif
return 0;
}
265
Optimizing memory usage is critical in embedded
systems, as resources such as RAM and ROM are
limited. Efficient use of memory is achieved by
minimizing the code size and reducing the data storage
requirements. The optimization techniques can be
broadly classified into two types - memory optimization
and code optimization.
Memory optimization techniques aim to minimize the
memory footprint of the program by reducing the data
storage requirements. One of the commonly used
memory optimization techniques is data compression,
which reduces the size of the data by encoding it into a
compressed form. Another technique is data packing,
which optimizes the data storage by packing the data
tightly into memory.
Code optimization techniques aim to reduce the code
size and improve the program's execution speed. One of
the commonly used code optimization techniques is
function in lining, which reduces the overhead
associated with function calls by replacing the function
calls with inline code. Another technique is loop
unrolling, which reduces the number of loop iterations
by unrolling the loop code.
To optimize the memory usage, developers can use
memory-mapped devices instead of using I/O ports.
Memory-mapped devices allow direct access to the
hardware peripherals, which reduces the processing
overhead and reduces the code size. Memory-mapped
devices are assigned memory locations, which allows
the microcontroller to access them like any other
memory location. Another important technique used for
memory optimization is bank switching. Bank
266
switching allows the microcontroller to access more
memory than its actual address space by dividing the
memory into multiple banks. The microcontroller can
access only one bank at a time, and the bank is switched
depending on the memory address accessed by the
program.
So, memory mapping and optimization techniques are
important for developing efficient embedded systems.
By using memory-mapped devices, bank switching,
data compression, and code optimization techniques,
developers can minimize the code size and reduce the
data storage requirements, resulting in efficient use of
available memory resources.
267
speed and the number of loop iterations. The delay time
can be calculated using the following formula:
Delay time = Number of loop iterations × Time taken
for each iteration
For example, if we want to generate a delay of 1 second
using a loop delay, and the microcontroller's clock
frequency is 8 MHz, we can calculate the number of
iterations required as:
Number of iterations = (1 sec × 8 MHz) / 4
Assuming that each loop iteration takes 4 clock cycles,
the number of iterations required would be 2 million.
20.7.2 Hardware Timers
Hardware timers are used to generate accurate delays
and control timing in embedded systems. These timers
are available in most microcontrollers and are used to
generate interrupts at regular intervals. The interrupts
can be used to trigger specific actions or execute tasks
with precise timing. The timer's accuracy depends on
the processor clock frequency and the timer resolution.
Timer resolution is the smallest time interval that can be
generated by the timer. For example, a timer with a
resolution of 1 ms can generate a delay of 1 ms or
multiples of 1 ms.
For example, to generate a delay of 1 second using a
hardware timer, we can configure the timer to generate
an interrupt every 1 ms. When the timer interrupt is
triggered 1000 times, we can consider that the delay of
1 second has been generated.
268
Here's an example of how to generate a delay of 1
second using a hardware timer in Embedded C
programming:
In this example, we are using the Timer1 of the
ATmega328P microcontroller to generate a delay of 1
second. The delay_ms function uses the hardware timer
to generate a delay of the specified number of
milliseconds. The ISR function is the interrupt service
routine that is executed when the timer interrupt is
triggered. The count variable is used to count the
number of timer interrupts triggered, and the while loop
waits
269
mechanisms, and other features that enable efficient use
of system resources.
#include<avr/io.h>
#include<avr/interrupt.h>
#define F_CPU 800000UL
volatile unint16_t count =0;
ISR(TIMER1_COMPA_vect)
{
count++;
}
void delay_ms(unit_t ms)
{
count =0;
TCNT1 =0;
// timer compare value for 1ms
OCR1A = ((F_CPUR / 1000)/8)*ms
// set CTC mode
TCCR1B |= (1<<WGM12);
//set prescaler to 8
TCCR1B |= (1<<CS11);
// enable timer compare interrupt
TIMSK1 |= (1<<OCIE1A);
while (count <ms);
TCCR1B = 0; // stop timer
TIMSK1 = 0; // disable timer interrupt
}
int main(void)
{
DDRB |=(1<<PB0);
while (1)
{
PORTB^=(1<<PB0); //Toggle LED
delay_ms(1000); //delay 1second
}
}
270
The programming languages used for RTOS
development are typically C and C++, as these
languages provide low-level access to hardware and
memory resources, which is necessary for programming
embedded systems. Embedded C and C++
programming for RTOS involves designing software
that can manage hardware resources, handle interrupts,
and respond to real-time events. This requires a deep
understanding of the underlying hardware, as well as the
ability to write efficient code that can run on systems
with limited resources.
One of the key features of RTOS programming is the
ability to schedule tasks in a deterministic manner. This
involves using scheduling algorithms to determine
which tasks should be executed at any given time, based
on their priority levels and other factors. The priority of
a task is a measure of its importance, and tasks with
higher priorities are executed before tasks with lower
priorities. This ensures that critical tasks are given
precedence, and that real-time deadlines are met.
Another important aspect of RTOS programming is the
ability to handle interrupts in a timely manner.
Interrupts are events that occur outside of the normal
flow of program execution, and require immediate
attention. This can include hardware interrupts, such as
those generated by a timer or input device, as well as
software interrupts, such as those generated by other
tasks in the system. Interrupt latency refers to the time
it takes for the system to respond to an interrupt, while
interrupt response time refers to the time it takes to
complete the processing of the interrupt. Minimizing
interrupt latency and response time is critical for real-
time systems, as it ensures that the system can respond
271
to input events within the required timeframe. Finally,
embedded C and C++ programming for RTOS involves
implementing inter-task communication mechanisms
that allow tasks to communicate with each other and
share resources. This can include message passing,
semaphores, and other synchronization mechanisms
that ensure that tasks can operate safely and efficiently
in a multi-tasking environment. Efficient inter-task
communication is critical for real-time systems, as it
enables tasks to work together to achieve common
goals, and ensures that the system can respond to input
events in a timely and deterministic manner.
The embedded C and C++ programming for real-time
operating systems involves designing and implementing
software for embedded systems with real-time
requirements. This requires a deep understanding of
hardware resources and real-time programming
concepts, as well as the ability to write efficient and
deterministic code that can operate within the
constraints of limited system resources. Key features of
RTOS programming include scheduling algorithms,
interrupt handling mechanisms, and inter-task
communication mechanisms, which enable tasks to
work together to achieve common goals and ensure
timely response to input events.
272
corresponding interrupt service routine (ISR) starts
executing. Interrupt latency includes the time taken by
the hardware to handle the interrupt request, such as
saving the context and performing any necessary
operations, as well as the time taken by the operating
system to switch to the ISR. A short interrupt latency is
desirable in real-time systems to ensure timely response
to critical events.
Response time, on the other hand, is the time taken by
the system to complete a request after it has been
initiated. In the context of real-time systems, response
time is the time taken by the system to handle an event,
starting from the time the event is detected until the
response is generated. Response time includes the
interrupt latency, the time taken by the ISR to execute,
and any other time taken by the system to handle the
event. A short response time is desirable in real-time
systems to ensure timely handling of critical events.
In order to reduce interrupt latency and response time,
real-time systems use various techniques such as
interrupt prioritization, interrupt preemption, and
interrupt nesting. Interrupt prioritization is the process
of assigning different priorities to different interrupts,
such that higher priority interrupts are handled before
lower priority interrupts. Interrupt preemption is the
process of temporarily suspending the execution of a
lower priority interrupt to allow the handling of a higher
priority interrupt. Interrupt nesting is the process of
handling multiple interrupts simultaneously, such that a
higher priority interrupt can interrupt the handling of a
lower priority interrupt.
273
To ensure timely response to critical events, real-time
systems often use a fixed-priority preemptive
scheduling algorithm. In this algorithm, tasks are
assigned priorities based on their criticality, and higher
priority tasks are executed before lower priority tasks.
The preemptive feature allows the system to temporarily
suspend the execution of a lower priority task to allow
the execution of a higher priority task. This ensures that
critical events are handled in a timely manner.
As, interrupt latency and response time are critical
factors that determine the performance of real-time
systems. Interrupt prioritization, interrupt preemption,
and interrupt nesting are techniques used to reduce
interrupt latency and response time. A fixed-priority
preemptive scheduling algorithm is often used in real-
time systems to ensure timely handling of critical
events.
274
Part 04 Embedded
Systems Design
Engineering
275
Chapter 21
Modern Design and
Embedded Systems
Engineering
276
in identifying potential design problems and optimizing the
product before it starts production.
277
21.4 Sustainable Design Engineering
Sustainability is an increasingly important consideration in
modern design engineering. With the world facing
significant environmental challenges, designers must create
products that are not only functional and aesthetically
pleasing but also environmentally friendly. This involves
considering the entire lifecycle of the product, from raw
materials to disposal, and minimizing its impact on the
environment.
278
software technologies that allow them to swiftly and
efficiently develop complicated systems. Microprocessors,
microcontrollers, digital signal processors (DSPs), field-
programmable gate arrays (FPGAs), and software
development kits (SDKs) are examples of these tools.
279
must add security measures such as encryption and
authentication.
280
Chapter 22
Embedded Systems Design
Techniques
22.1 Introduction
In this chapter we’ll look in depth on the modern embedded
systems design techniques that design engineer uses to
develop modern embedded systems. We will also study about
the test and verification of embedded systems before their
launch and will learn what are real time embedded systems.
281
useful. This method can assist in identifying possible
concerns early in the design phase and allows for better
coordination between teams working on different portions of
the system.
282
1. Functional Decomposition
Functional decomposition is the process of breaking
down a system into smaller, more manageable sub-
systems or modules based on their functional
requirements. This allows for easier design,
development, and testing of individual modules,
which can then be combined to form the overall
system. Functional decomposition also helps to
identify any redundancies or overlaps in the system,
which can be eliminated to improve efficiency.
2. Standard Interfaces
Standard interfaces are a set of rules and protocols
that are used to enable communication between
different modules of a system. Standard interfaces
are critical in modular design because they allow
modules to be designed and tested independently of
each other, while ensuring that they can still work
together seamlessly. Standard interfaces also make it
easier to replace or upgrade individual modules
without affecting the rest of the system.
3. Design of Reuse
The modular design approach known as "design for
reuse" states that modules should be created with the
idea of reuse in other applications or systems. This
entails developing modular designs that are both
general enough to be applied in various situations
and precise enough to address the requirements of
the current system. By utilizing tried-and-true ideas
and architectures, design for reuse can drastically cut
down on design and development time while also
improving system performance.
4. Separation of Concerns
According to the design principle of separation of
concerns, various system components such as
functionality, performance, and user interface should
be divided into separate modules. Individual
modules can now be managed and changed more
283
easily without having an impact on the entire system.
Separation of concerns enhances the system's overall
performance and dependability while also making it
simpler to evaluate individual parts.
5. Component Based Development
A system is built utilizing pre-existing software
components rather than from scratch when
employing the component-based development
process. This kind of modular design enables
programmers to take advantage of code libraries,
frameworks, and architectures already in use to
construct systems more rapidly and effectively.
Greater flexibility and scalability are also made
possible by component-based programming because
it is simple to alter or upgrade individual components
without affecting the system as a whole.
284
they are developing and designing modern renewable energy
sources like generating energy from wind and sunlight. At
the same time scientists and engineers are also working on
designing more power efficient circuits.
1. Power budgeting
The first step in designing a low-power consumption
embedded system is to determine the power budget
for the system. This involves calculating the total
power consumption of each component in the system
and setting an upper limit for the overall power
consumption. Once the power budget has been
established, designers can work to reduce the power
consumption of individual components to stay
within the budget.
2. Efficient use of Components
In order to create a low-power embedded system, it
is essential to choose components with low power
consumption. To ensure that they consume less
power in both active and sleep modes, components
including microcontrollers, sensors, and
communication modules should be carefully chosen.
In addition, components' idle power consumption
can be decreased by using power management
strategies including clock gating, dynamic voltage
scaling, and power gating.
3. Efficient Code and Algorithm
The software running on an embedded system also
plays a role in power consumption. Efficient code
and algorithms can reduce the computational load of
285
the system, leading to less power consumption. For
example, algorithms that use a lower bit depth can
significantly reduce power consumption while still
providing sufficient accuracy for the application.
4. Energy Harvesting
Energy harvesting techniques can be used to
supplement or even replace the battery power in
embedded systems. Energy harvesting devices such
as solar cells, thermal energy harvesters, and
piezoelectric generators can be used to convert
ambient energy into electrical power. Energy
harvesting can extend the lifetime of battery-
powered systems and reduce the size of batteries
needed.
5. Sleep Modes
Components may not always need to be active in
embedded systems. When components are not
required, they can be put into a low-power state using
sleep modes. The lifespan of the system can be
increased and power consumption can be greatly
decreased by using sleep modes.
6. System Level Optimization
System-level optimization entails improving the
overall system to cut down on power usage. This
may entail maximizing the system's overall
architecture, designing for low-power
communication methods, and reducing the usage of
peripherals.
286
the lifetime of the system while still meeting its performance
and functionality requirements.
1. Safety Standards
Adhering to applicable safety standards is one of the
first stages in developing an embedded system that is
trustworthy and secure. IEC 61508, ISO 26262, and
DO-178C are a few examples of standards that offer
guidance for the creation of safety-critical systems.
The system will be built, tested, and documented to
fulfill particular safety criteria if these standards are
followed.
2. Redundancy
Redundancy is a useful method for enhancing
embedded systems' dependability. Critical systems
and components can be duplicated so that, in the case
of a failure, the system can still run. To ensure that
the system can function even if one component fails,
redundant sensors or processors might be deployed.
3. Fault Tolerance
Another method for enhancing the dependability of
embedded systems is fault tolerance. In order to
ensure that the system can continue to work in the
case of a breakdown, fault tolerance entails
engineering the system to identify and respond to
defects. To identify and address system flaws,
methods like watchdog clocks and error-correcting
codes can be used.
287
4. Testing and Verification
To guarantee the dependability and security of
embedded systems, testing and verification are
essential. Functional and non-functional testing
should both be done to make sure the system satisfies
all criteria. To confirm that the system can manage
multiple failure scenarios, testing should also
incorporate fault injection testing.
5. Software Design
The reliability and safety of an embedded system can
be considerably impacted by its software design.
Static analysis, code review, and other design
methods can help to increase the software's quality
and dependability. Additionally, methods like
model-based design and formal verification can be
used to make sure that the program complies with
strict safety standards.
6. Environmental Factors
The dependability and security of embedded systems
can potentially be affected by environmental
conditions. To make sure that the system can
perform dependably in the specified environment,
the system design should take various elements like
temperature, humidity, and electromagnetic
interference into account.
7. Maintenance and Upkeep
Finally, reliable operation and safety depend on the
system's proper maintenance and upkeep. To make
sure all of its parts are operating properly, the system
needs to undergo routine inspections, testing, and
maintenance. Any software updates or modifications
should also be thoroughly tested and confirmed to
make sure they don't affect the system's
dependability or safety.
288
The most stringent reliability and safety requirements for
embedded systems can be met by designers by adhering to
safety standards, implementing redundancy and fault
tolerance, testing and verifying the system, designing high-
quality software, taking environmental factors into account,
and maintaining the system.
289
22.7 Static and Dynamic Analysis
Static analysis is a technique that involves analyzing the
source code of a software application without actually
executing the code. The goal of static analysis is to identify
potential defects or errors in the code before the code is
actually executed. Static analysis can be performed
manually, but it is usually automated using tools that analyze
the code for common coding mistakes, such as buffer
overflows, null pointer dereferences, and uninitialized
variables.
290
22.8 Real Time Embedded System
Real-time embedded systems are computer systems that are
designed to interact with the physical world, typically
through sensors and actuators. They are characterized by
their ability to respond to events in real-time, often with
stringent timing requirements.
291
On the other hand, timing constraints for soft real-time
systems are less stringent than those for hard real-time
systems. If timing requirements are not met, there may be
consequences, but they are normally not as severe as in hard
real-time systems. Soft real-time systems can cope with a
certain amount of timing ambiguity or variance. Networked
systems, online gaming, and multimedia streaming are a few
examples of soft real-time systems.
292
tasks are always executed before lower-priority
tasks.
2. Earliest Deadline First (EDF): EDF is another
popular scheduling algorithm that prioritizes tasks
based on their deadline. The task with the earliest
deadline is given the highest priority and is
scheduled first. EDF can handle sporadic and
aperiodic tasks more efficiently than RMS.
3. Fixed Priority Scheduling (FPS): FPS is a scheduling
technique that assigns a fixed priority to each task in
the system. Tasks with higher priorities are executed
first, and lower-priority tasks are executed only when
there are no higher-priority tasks waiting to be
executed.
4. Round-Robin Scheduling (RR): RR is a scheduling
algorithm that allocates a fixed time slice to each task
in the system, allowing each task to execute for a
predefined time period before switching to the next
task.
293
Chapter 23
Tools and Project
Management
23.1 Introduction
In this chapter we’ll look in depth on the modern embedded
systems design engineering tools that engineers can use to
design a stunning product. We will also look in depth on
engineering project management and why it is an essential
part of any engineering project. However let’s first discuss
the modern engineering tools.
294
The engineering tools both either in hardware and software
can vary upon utility. If you are an embedded engineer but
working closely with architecture engineers then you may
need to utilize architecture engineering tools. Similarly if you
are in a team that is designing an electric car then you will
see how automotive engineering and electrical engineering
and computer engineering tools are used to design a perfect
electric car. In this book we are going to introduce you to the
three types of engineering tools that are software based.
295
be made and stored for later use may be included in the
design tool.
23.3.2 Simulation
23.3.3 Analysis
23.3.4 Optimization
23.3.5 Visualization
296
Here are some of the most used circuit simulation software
that are used by engineers to design any kind of circuit
including embedded systems circuits.
297
and money by simulating and analyzing the behavior of
circuits before they are created.
The brain of an IDE is the code editor. This text editor was
created with programming languages in mind. It offers
several tools, like syntax highlighting, code folding, and
auto-completion, to assist programmers in creating clean,
error-free code. Additionally, many IDEs offer plugins or
extensions that let developers adapt the editor to their
particular requirements.
298
ables and other data structures. IDEs often include powerful
debugging tools that can help developers diagnose and fix
complex issues quickly.
299
23.5 Computer Aided Drawings
Using computer software to develop, alter, and analyze
designs is known as computer-aided design (CAD). A branch
of computer-aided design (CAD) that specialises in
producing two- or three-dimensional drawings is called
computer-aided drawing (CAD). In many different
industries, including engineering, architecture, and product
design, CAD software is widely utilized. We will concentrate
on computer-aided drawing and its uses in embedded systems
engineering in this essay.
300
hobbyist and prototyping communities due to its
affordability and ease of use.
3. KiCAD: KiCAD is an open-source CAD software
that provides a range of tools for schematic capture
and PCB layout. It includes features such as 3D
visualization, component libraries, and netlist
generation. KiCAD is widely used by hobbyists and
small businesses due to its affordability and
community-driven development.
4. Proteus: Proteus is a popular CAD software used by
embedded systems engineers to design electronic
circuits and simulate their behavior. It provides a
range of tools for schematic capture, simulation, and
debugging. Proteus is widely used in the education
and research communities due to its comprehensive
set of features and ease of use.
5. SolidWorks Electrical: SolidWorks Electrical is a
popular CAD software used by embedded systems
engineers to design complex electrical systems. It
provides a range of features, including schematic
capture, 3D visualization, and wiring diagrams.
SolidWorks Electrical is widely used in the
automation and manufacturing industries due to its
comprehensive set of tools and capabilities.
301
Initlization
Finalizing Planning
Control
Execution
302
23.6.1 The Initiation Phase
303
management plan and that the project meets the project's
goals and objectives.
304
23.7 Project Time Management
Project time management is a critical aspect of project
management that involves developing and maintaining a
project schedule to ensure the project is completed on time.
Effective time management requires a project manager to
understand the project's scope, objectives, and requirements,
as well as the available resources and potential constraints.
Define Activities
Sequence Activites
Estimation of Duration
305
Once the activities are defined, the next step is to sequence
them in the correct order. The project manager determines
the dependencies between tasks and creates a project
schedule that outlines the order in which the activities will be
completed.
306
Effective time management requires the project manager to
communicate regularly with the project team and
stakeholders to ensure everyone is aware of the project
schedule and any potential delays or issues. The project
manager should also regularly review the project schedule to
identify any areas where the schedule can be improved, such
as by reallocating resources or adjusting activity durations.
307
Plan Cost Management
Estimate Costs
Budget Detrmination
Cost Control
308
aggregating the estimated costs for each task and activity to
determine the total project cost.
309
manager to understand the project's requirements, allocate
resources effectively, and use tools and techniques such as
cost baselines, earned value analysis, and cost of quality
analysis. By communicating regularly with the project team
and stakeholders and monitoring the project's cost
performance, project managers can effectively manage
project costs and ensure project success.
310
Chapter 24
Industrial and Future of
Embedded Systems
311
combination of sensors, such as cameras and radar, and
advanced algorithms to make real-time decisions.
312
in terms of safety, performance, and comfort. The automotive
industry relies on embedded systems to control various
functions of the vehicle, from the engine and transmission to
advanced driver assistance systems and entertainment
features. The development of embedded systems for
automotive applications requires expertise in multiple areas,
as well as compliance with strict regulations and standards.
With continued innovation and development, embedded
systems will play an increasingly important role in the
automotive industry, improving safety, performance, and the
overall driving experience.
313
imaging equipment can produce high-quality images quickly,
allowing healthcare professionals to make faster and more
accurate diagnoses. Similarly, diagnostic equipment can
automate the process of collecting and analyzing patient data,
reducing the time and effort required by healthcare
professionals.
314
24.3 Aerospace Industry
Embedded systems have revolutionized the aerospace
industry by providing increased safety, efficiency, and
reliability in aircraft design and operation. These computer
systems are integrated into aircraft, spacecraft, and satellites
to perform specific tasks and functions, such as navigation,
control, communication, and monitoring.
315
Another application of embedded systems in aerospace is in
space exploration. Embedded systems are used in satellites
and spacecraft to perform a range of functions, such as
navigation, communication, and scientific experiments. For
example, the Mars Rover is equipped with embedded
systems that allow it to navigate and explore the Martian
terrain, collect data, and communicate with Earth.
316
One of the most ubiquitous applications of embedded
systems in consumer electronics is in mobile devices such as
smartphones and tablets. These devices contain a range of
embedded systems, including processors, memory, sensors,
and wireless communication modules, all working together
to provide the user with a seamless experience. For example,
embedded systems enable smartphone users to navigate
through various applications, capture high-quality photos and
videos, and connect to the internet wirelessly.
317
While embedded systems offer many benefits in consumer
electronics, they also present challenges. One challenge is
ensuring the security and privacy of user data. Consumer
electronics devices collect a vast amount of personal data,
and embedded systems must be designed with strong security
measures to prevent unauthorized access and protect user
privacy.
318
24.5.2 Internet of Things (IoT)
24.5.4 Cybersecurity
319
24.5.6 Energy Efficiency
320
example, implantable medical devices such as pacemakers
and defibrillators use embedded systems to monitor and
regulate the patient's heartbeat. Other medical devices such
as insulin pumps, blood glucose monitors, and sleep apnea
machines also use embedded systems.
321
24.6.5 Industrial Automation
24.6.7 Agriculture
322
24.7 Careers and Opportunities in Embedded
Systems
Embedded systems are critical components of various
industries, from aerospace and defense to medical devices
and consumer electronics. As technology continues to
advance, the demand for skilled professionals in embedded
systems is growing rapidly. Here are some careers and
opportunities in embedded systems:
323
science, and they have experience with programming
languages such as C, C++, and Java.
324
hardware, firmware, or software development, there are
plenty of opportunities to build a rewarding career in
embedded systems.
325
Appendix I
Glossary
326
Compiler: A program that translates high-level programming
languages into machine code that can be executed by a
microcontroller.
327
Low-power mode: A power-saving mode used to reduce
power consumption in battery-powered embedded systems.
328
Traceability: The ability to trace the behavior of an
embedded system from its requirements to its
implementation and testing.
329
Appendix II
References
330
Liu, J. W. S. (2007). Real-time Systems. Prentice Hall.
331
Wolf, W. (2000). High-Performance Embedded Computing:
Applications in Cyber-Physical Systems and Mobile
Computing. Morgan Kaufmann Publishers.
332
Eker, J., Janneck, J. W., Lee, E. A., Liu, J., & Liu, X. (Eds.).
(2003). Heterogeneous concurrent modeling and simulation
in time-critical domains. Springer Science & Business
Media.
333
Luo, T., Hu, J., Zhang, Y., & Song, X. (2016). Energy-
efficient and time-constrained task scheduling in embedded
systems. Journal of Systems Architecture, 68, 39-49.
334
The End
335