CS3691 Embedded Systems and Iot
CS3691 Embedded Systems and Iot
SET-1
PART -A
1.Embedded systems
An embedded system is a computer system with dedicated hardware and software
designed for a specific function within a larger device or system. It typically has real-time
constraints and limited resources (processing power, memory).
2. Give the format and list the functions of the instruction DJNZ for 8051
DJNZ decrements the value of register by 1.If the initial value of register is 0,
decrementing the value will cause it to reset to 255 (0xFF Hex). If the new value of register is
not 0 the program will branch to the address indicated by relative addr.
3.Memory Device interfacing
Memory device interfacing is the process of connecting memory devices, such as
RAM and ROM, to a microprocessor or microcontroller. This allows the processor to access
and store data that is essential for its operation.
4.Context Switching in RTOS
In an RTOS (Real-Time Operating System), context switching is the mechanism
that allows the OS to efficiently manage multiple tasks running on a single CPU.
5.Raspberry Pi
The Raspberry Pi is a series of small single-board computers developed in the
United Kingdom by the Raspberry Pi Foundation with the intention to promote the teaching
of basic computer science in schools. The Raspberry Piis a credit-card sized computer that
plugs into a TV and a keyboard. It has a central processing unit (CPU), memory (RAM),
input/output (I/O) interfaces, and it can be powered using a Micro USB cable or via GPIO
pins.
6.Raspberry Pi is better than Arduino
Raspberry Pi computers have a more advanced architecture and come with more
powerful CPU’s than Arduino board. They are compatible with most modern operating
systems and come equipped with integrated graphics processing units (GPUs).
7.IoT Communication APIs
IoT Communications APIs are a set of protocols and interfaces that allow IoT
devices and platforms to communicate with one another. These APIs enable developers to
create apps that interface with IoT devices over conventional web protocols including HTTP,
MQTT, CoAP, and others.
8.GPS Functions
A GPS operates independently of the user’s internet connection or telephone signal.
However, their presence increases the effectiveness of GPS positioning. GPS was initially
developed by the US government for military purpose, but currently, anyone with a GPS
receiver can receive radio signals from GPS satellites.
9.Challenges in Embedded System Design
Computer Design Requirements.
System-level requirements.
Life-cycle support.
Component acquisition.
Business model.
Design culture.
10. Application specific integrated circuit(ASIC)
An Application-Specific Integrated Circuit (ASIC) is a specialized integrated circuit
(IC) chip designed and manufactured for a specific use or function. Unlike general-purpose
chips that can be used in various applications, ASICs are tailored from the ground up to meet
the exact needs of a particular electronic device.
PART – B
11(A) Explain the block diagram or architecture of 8051
The 8051 architecture provides many functions (CPU, RAM, ROM, I/O, interrupt logic,
timer,etc.) in a single package
Features of 8051:
8-bit ALU, Accumulator, 8-bit Registers and 8-bit data bus; hence it is an 8-bit
microcontroller
16-bit program counter
8-bit Processor Status Word(PSW)
8-bit Stack Pointer
Internal RAM of128bytes
On chip ROM is4KB
Special Function Registers (SFRs) of 128bytes
32 I/O pins arranged as four 8-bit ports (P0 -P3)
Two 16-bit timer/counters : T0 andT1
Two external and three internal vectored interrupts
Full duplex UART (serialport)
BLOCK DIAGRAM
INTERNAL ARCHITECTURE OF 8051 MICROCONTROLLER :
The Internal architecture and the various Registers and units are described below
Accumulator (Acc):
•Operand register
• Implicit or specified in the instruction
•Has an address in on chip SFR bank
B Register:
Used to store one of the operands for multiplication and division, otherwise, scratch pad
considered as a SFR.
Stack Pointer (SP):
8 bit wide register. Incremented before data is stored on to the stack using PUSH or CALL
instructions. Stack defined anywhere on the 128 byte RAM.
Data Pointer (DPTR):
16 bit register contains DPH and DPL Pointer to external RAM address. DPH and DPL
allotted separate addresses in SFR bank
Port 0 To 3 Latches & Drivers:
Each I/O port allotted a latch and a driver Latches allotted address in SFR. User can
communicate via these ports P0, P1, P2, and P3.
Serial Data Buffer:
Internally had TWO independent registers, TRANSMIT buffer (parallel in serial out – PISO)
and RECEIVE buffer (serial in parallel out –SIPO) identified by SBUF and allotted an
address in SFR.
Program Status Word (PSW):
Set of flags contains status information
Timer Registers:
for Timer0 (16 bit register – TL0 & TH0) and for Timer1 (16 bit register – TL1 & TH1) four
addresses allotted in SFR
Control Registers:
Control registers are IP, IE, TMOD, TCON, SCON, and PCON. These registers contain
control and status information for interrupts, timers/counters and serial port. Allotted separate
address in SFR.
Timing and Control Unit:
This unit derives necessary timing and control signals for internal circuit and external system
bus.
Oscillator:
generates basic timing clock signal using crystal oscillator.
Instruction Register:
Decodes the opcode and gives information to timing and control unit.
EPROM & program address Register:
provide on chip EPROM and mechanism to address it. All versions don’t have EPROM.
RAM & RAM Address Register:
provide internal 128 bytes RAM and a mechanism to address internally
ALU:
Performs 8 bit arithmetic and logical operations over the operands held by TEMP1 and
TEMP 2.User cannot access temporary registers.
SFR Register Bank:
set of special function registers address range: 80 H to FF H. Interrupt, serial port and timer
units control and perform specific functions under the control of timing and control unit.
12(A) Explain the context switching mechanism for moving the CPU from one executing
process to another with an example?
* The Context switching is a technique or method used by the operating system
to switch a process from one state to another to execute its function using CPUs in the
system. When switching perform in the system, it stores the old running process's status in
the form of registers and assigns the CPU to a new process to execute its tasks. While a new
process is running in the system, the previous process must wait in a ready queue. The
execution of the old process starts at that point where another process stopped it. It defines
the characteristics of a multitasking operating system in which multiple processes shared the
same CPU to perform multiple tasks without the need for additional processors in the system.
Example of Context Switching:
* Suppose that multiple processes are stored in a Process Control Block (PCB).
One process is running state to execute its task with the use of CPUs. As the process is
running, another process arrives in the ready queue, which has a high priority of completing
its task using CPU. Here we used context switching that switches the current process with the
new process requiring the CPU to finish its tasks. While switching the process, a context
switch saves the status of the old process in registers. When the process reloads into the CPU,
it starts the execution of the process when the new process stops the old process. If we do not
save the state of the process, we have to start its execution at the initial level. In this way,
context switching helps the operating system to switch between the processes, store or reload
the process when it requires executing its tasks.
Context switching triggers:
Following are the three types of context switching triggers as follows.
Interrupts
Multitasking
Kernel/User switch
* Interrupts: A CPU requests for the data to read from a disk, and if there are any interrupts,
the context switching automatic switches a part of the hardware that requires less time to
handle the interrupts.
* Multitasking: A context switching is the characteristic of multitasking that allows the
process to be switched from the CPU so that another process can be run. When switching the
process, the old state is saved to resume the process's execution at the same point in the
system.
* Kernel/User Switch: It is used in the operating systems when switching between the user
mode, and the kernel/user mode is performed.
PCB
A PCB (Process Control Block) is a data structure used in the operating system to store all
data related information to the process. For example, when a process is created in the
operating system, updated information of the process, switching information of the process,
terminated process in the PCB.
Steps for Context Switching :
* There are several steps involves in context switching of the processes. The following
diagram represents the context switching of two processes, P1 to P2, when an interrupt, I/O
needs, or priority-based process occurs in the ready queue of PCB.
* As we can see in the diagram, initially, the P1 process is running on the CPU to execute its
task, and at the same time, another process, P2, is in the ready state. If an error or interruption
has occurred or the process requires input/output, the P1 process switches its state from
running to the waiting state. Before changing the state of the process P1, context switching
saves the context of the process P1 in the form of registers and the program counter to the
PCB1. After that, it loads the state of the P2 process from the ready state of the PCB2 to the
running state.
The following steps are taken when switching Process P1 to Process 2:
* First, thes context switching needs to save the state of process P1 in the form of the
program counter and the registers to the PCB (Program Counter Block), which is in the
running state.
* Now update PCB1 to process P1 and moves the process to the appropriate queue, such as
the ready queue, I/O queue and waiting queue.
* After that, another process gets into the running state, or we can select a new process from
the ready state, which is to be executed, or the process has a high priority to execute its task.
* Now, we have to update the PCB (Process Control Block) for the selected process P2. It
includes switching the process state from ready to running state or from another state like
blocked, exit, or suspend.
* If the CPU already executes process P2, we need to get the status of process P2 to resume
its execution at the same time point where the system interrupt occurs. Similarly, process P2
is switched off from the CPU so that the process P1 can resume execution. P1 process is
reloaded from PCB1 to the running state to resume its task at the same point. Otherwise, the
information is lost, and when the process is executed again, it starts execution at the initial
level.
Priority Inversion :
• Priority inversion occurs when a low-priority job executes while some ready higher-priority
job waits.
Consider three tasks Tl, T2 and T3 with decreasing priorities. Task T1 andT3 share some data
or resource that requires exclusive access, while T2 does notinteract with either of the other
two tasks.
Task T3 starts at time t0 and locks semaphore s at time tv At time t2, Tl arrives and preempts
T3 inside its critical section. After a while, Tl requests to use the shared resource by
attempting to lock s, but it gets blocked, as T3 is currently using it. Hence, at time t3
continues to execute inside its critical section.Next, when T2 arrives at time t4, it preempts
T3, as it has a higher priority and does not interact with either Tl or T3.
The execution time of T2 increases the blocking time of Tl, as it is no longer dependent
solely on the length of the critical section executed by T3.
When tasks share resources, there may be priority inversions.
Priority inversion is not avoidable; However, in some cases, the priorityinversion could be
too large. Simple solutions :
1. Make critical sections non-preemptable.
2. Execute critical sections at the highest priority of the task that could use it. Timing
anomalies As seen, contention for resources can cause timing anomalies due to priority
inversion and deadlock.
Unless controlled, these anomalies can be arbitrary duration, and can seriously disrupt
system timing. It cannot eliminate these anomalies, but several protocols exist to control them
:
1. Priority inheritance protocol
2. Basic priority ceiling protocol
3. Stack-based priority ceiling protocol
Wait for graph :
• Wait-for graph is used for representing dynamic-blocking relationship among jobs. In the
wait-for graph of a system, every job that requires some resource is represented by a vertex
labeled by the name of the job.
• At any time, the wait-for graph contains an (ownership) edge with label x from a resource
vertex to a job vertex if x units of the resource are allocated to the job at the time.
• Wait-for-graph is used to model resource contention. Every serial reusable resource is
modeled. Every job which requires a resource is modeled by vertex with arrow pointing
towards the resource.
13(A) Explain the Architecture of Arduino and Explain the shields of Arduino
Arduino architecture:-
Hardware Architecture:-
The input and output (I/O) components of the Arduino hardware design typically include a
microcontroller board. Although subsequent boards might use various microcontrollers, the
ATmega328P and ATmega2560 are the most popular Atmel AVR-based Arduino boards.
2.USB B Type port : An Arduino board's USB B Type port is a rectangular connector. It is
utilized to link the Arduino to other electronics or computers. The Arduino can receive power
and data via this port. It is frequently employed to communicate data between the Arduino
board and a computer and to program the Arduino. Because the USB B Type connector is
dependable and standardized, several USB cables will work with it. Older Arduino models
frequently include them, although more recent ones might have USB C Type connectors.
3. Analog Input Pins: A number of analog input pins on Arduino boards allow users to read
analog signals from sensors and other analog devices. These pins use an analog-to-digital
converter (ADC) to turn the analog input into a digital value.
4. Power Pins: Ground (GND), 5V, and 3.3V are among the several power pins that Arduino
boards generally offer. Power is provided to the board and external components using these
pins.
5. ATmega16U2: It is a typical microcontroller chip for Arduino boards. It acts as a USB-
to-serial converter, enabling the Arduino board to talk to a computer via the USB interface.
The ATmega16U2 serves as a link between the computer and the ATmega328P, which is the
primary microcontroller on the Arduino board. It manages USB communication protocols
and transforms the computer's serial data into a form that the main microcontroller can
interpret. As a result, the Arduino may be programmed and data can be transferred through
USB from the board to the PC.
6. Other Components: The Arduino board has other parts to help it function, including
crystal oscillators, voltage regulators, and capacitors.
Software Architecture:
A condensed version of C++, the Arduino programming language is simple to learn even for
newcomers. It has built-in libraries that offer pre-written routines for typical operations
including managing digital and analog I/O, corresponding over a variety of protocols (such
UART, I2C, and SPI), and utilizing timers and interrupts.
SHIELDS OF ARDUINO:
Arduino shields are the boards, which are plugged over the Arduino board to expand its
functionalities. There are different varieties of shields used for various tasks, such as Arduino
motor shields, Arduino communication shields, etc.
Arduino motor shields help us to control the motors with the Arduino board.
Types of Shields:
o Ethernet shield
o Xbee Shield
o Proto shield
o Motor shield
o LCD shield
o Bluetooth shield
Ethernet shield:
o The Ethernet shields are used to connect the Arduino board to the Internet. We need
to mount the shield on the top of the specified Arduino board.
o The USB port will play the usual role to upload sketches on the board.
o The latest version of Ethernet shields consists of a micro SD card slot. The micro SD
card slot can be interfaced with the help of the SD card library.
o We can also connect another shield on the top of the Ethernet shield. It means that we
can also mount two shields on the top of the Arduino board.
Xbee Shield:
o We can communicate wirelessly with the Arduino board by using the Xbee Shield
with Zigbee.
o It reduces the hassle of the cable, which makes Xbee a wireless communication
model.
o The Xbee wireless module allows us to communicate outdoor upto 300 feet and
indoor upto 100 feet.
Proto shield:
Motor shield:
o The motor shield helps us to control the motor using the Arduino board.
o It controls the direction and working speed of the motor. We can power the motor
shield either by the external power supply through the input terminal or directly by the
Arduino.
o We can also measure the absorption current of each motor with the help of the motor
shield.
o The motor shield is based on the L298 chip that can drive a step motor or two DC
motors. L298 chip is a full bridge IC. It also consists of the heat sinker, which
increases the performance of the motor shield.
o It can drive inductive loads, such as solenoids, etc.
o The operating voltage is from 5V to 12V.
o The applications of the motor shield are intelligent vehicles, micro-robots, etc.
LCD shield:
o The keypad of LCD (Liquid Crystal Display) shield includes five buttons called as up,
down, left, right, and select.
o There are 6 push buttons present on the shield that can be used as a custom menu
control panel.
o It consists of the 1602 white characters, which are displayed on the blue backlight
LCD.
o The LED present on the board indicates the power ON.
o The five keys present on the board helps us to make the selection on menus and from
board to our project.
o The LCD shield is popularly designed for the classic boards such as Duemilanove,
UNO, etc.
Bluetooth shield:
o The Bluetooth shield can be used as a wireless module for transparent serial
communication.
o It includes a serial Bluetooth module. D0 and D1 are the serial hardware ports in the
Bluetooth shield, which can be used to communicate with the two serial ports (from
D0 to D7) of the Arduino board.
o We can install Groves through the two serial ports of the Bluetooth shield called a
Grove connector. One Grove connector is digital, while the other is analog.
o The communication distance of the Bluetooth shield is upto 10m at home without any
obstacle in between.
The Internet of Things is rapidly growing, and as a result, there is an increasing need for
devices to communicate with each other. In this blog, we will discuss the various IoT
communication technologies that enable these devices to connect and communicate with each
other.
1.Wi-Fi
Wi-Fi is a widely used wireless communication technology that allows devices to connect to
the internet and communicate with each other over a wireless network. Wi-Fi offers high-
speed data transfer and has a wide range, making it ideal for IoT devices that require high
bandwidth, such as cameras and video doorbells. Wi-Fi is also easy to set up, and devices can
2. Bluetooth
power, short-range technology that allows devices to communicate with each other over short
distances. Bluetooth is ideal for devices that require low bandwidth and operate within a small
range, such as smartwatches, fitness trackers, and wireless headphones. Bluetooth is also easy
to set up and can be used to create a mesh network, allowing devices to communicate with
3. Zigbee
Zigbee is a low-power, wireless communication protocol that is designed for IoT devices.
Zigbee is ideal for devices that require low bandwidth and operate within a small range, such
as smart sensors and light bulbs. Zigbee is highly scalable and can support large networks of
devices. It also has low power consumption, allowing devices to operate on battery power for
extended periods.
4. Z-Wave
Z-Wave is a wireless communication protocol that is designed for home automation systems.
It operates on a low-power, mesh network, allowing devices to communicate with each other
over long distances. Z-Wave is highly reliable and secure, making it ideal for home security
systems. It also has low power consumption, allowing devices to operate on battery power for
extended periods.
5. LoRa
LoRa is a long-range, low-power wireless communication protocol that enables IoT devices to
communicate over long distances. LoRa is ideal for devices that require low bandwidth and
environmental monitoring devices. LoRa is highly scalable and can support large networks of
A physical design of an IoT system refers to the individual node devices and their protocols
Each node device can perform tasks such as remote sensing, actuating, monitoring, etc., by
Building connections
Data processing
Providing storage
Providing interfaces
The devices generate data, and the data is used to perform analysis and do operations for
improving the system. For instance, a moisture sensor is used to obtain the moisture data
Architecture of Zigbee:
Physical layer: The lowest two layers i.e the physical and the MAC (Medium
Access Control) Layer are defined by the IEEE 802.15.4 specifications. The
Physical layer is closest to the hardware and directly controls and communicates
with the Zigbee radio. The physical layer translates the data packets in the over-
the-air bits for transmission and vice-versa during the reception.
Medium Access Control layer (MAC layer): The layer is responsible for the
interface between the physical and network layer. The MAC layer is also
responsible for providing PAN ID and also network discovery through beacon
requests.
Network layer: This layer acts as an interface between the MAC layer and the
application layer. It is responsible for mesh networking.
Application layer: The application layer in the Zigbee stack is the highest
protocol layer and it consists of the application support sub-layer and Zigbee
device object. It contains manufacturer-defined applications.
Zigbee Applications:
1. Home Automation
2. Medical Data Collection
3. Industrial Control Systems
4. meter reading system
5. light control system
The Raspberry Pi operates in the open source ecosystem: it runs Linux (a variety of
distributions), and its main supported operating system, Pi OS, is open source and runs a suite
of open source software. The Raspberry Pi Foundation contributes to the Linux kernel and
various other open source projects as well as releasing much of its own software as open
source.
Machine learning: Some Raspberry Pi models are powerful enough to run machine
learning models on the device itself.
15(A) Write a program Smart Healthcare and explain with relavent diagrams
The specific program for a smart healthcare IoT system will depend on the chosen
application and functionalities.
1. System Components:
Sensors: These collect health data like heart rate, blood pressure, glucose levels (for
diabetics). Examples include wearables, smart implants, ingestible sensors.
Processing Unit: This unit pre-processes the sensor data and transmits it securely.
This could be a local gateway or cloud-based server.
Communication Module: This transmits the data to a healthcare platform or mobile
app. Options include Wi-Fi, Bluetooth, cellular networks.
Healthcare Platform/App: This visualizes the data, generates alerts, and allows
communication between patients and healthcare providers.
2. Additional Considerations:
Smart Lighting –
Smart lighting for home helps in saving energy by adapting the life to the
ambient condition and switching on/off or dimming the light when needed.
Smart lighting solutions for homes achieve energy saving by sensing the human
movements and their environments and controlling the lights accordingly.
Smart Appliances –
Smart appliances with the management are here and also provide status
information to the users remotely.
Smart washer/dryer can be controlled remotely and notify when the washing and
drying are complete.
Smart refrigerators can keep track of the item store and send updates to the users
when an item is low on stock.
Intrusion Detection –
Home intrusion detection systems use security cameras and sensors to detect
intrusion and raise alerts.
Alert can we inform of an SMS or an email sent to the user.
Advanced systems can even send detailed alerts such as an image shoot or short
video clips.
Smoke/gas detectors –
Smoke detectors are installed in homes and buildings to detect smoke that is
typically an early sign of Fire.
It uses optical detection, ionization for Air sampling techniques to detect smoke.
Gas detectors can detect the presence of harmful gases such as CO, LPG, etc.
It can raise alerts in the human voice describing where the problem is.