8051 Unit 5
8051 Unit 5
Embedded means something that is attached to another thing. An embedded system can be thought of as a computer
hardware system having software embedded in it. An embedded system can be an independent system or it can be a
part of a large system. An embedded system is a microcontroller or microprocessor based system which is designed to
perform a specific task. For example, a fire alarm is an embedded system; it will sense only smoke.
An embedded system has three components −
It has hardware.
It has application software.
It has Real Time Operating system (RTOS) that supervises the application software and provide mechanism to
let the processor run a process as per scheduling by following a plan to control the latencies. RTOS defines the
way the system works. It sets the rules during the execution of application program. A small scale embedded
system may not have RTOS.
So we can define an embedded system as a Microcontroller based, software driven, reliable, real-time control system.
Advantages
Easily Customizable
Low power consumption
Low cost
Enhanced performance
Disadvantages
Sensor − It measures the physical quantity and converts it to an electrical signal which can be read by an
observer or by any electronic instrument like an A2D converter. A sensor stores the measured quantity to the
memory.
A-D Converter − An analog-to-digital converter converts the analog signal sent by the sensor into a digital signal.
Processor & ASICs − Processors process the data to measure the output and store it to the memory.
D-A Converter − A digital-to-analog converter converts the digital data fed by the processor to analog data
Actuator − An actuator compares the output given by the D-A Converter to the actual (expected) output stored in
it and stores the approved output.
eCos
It stands for 'Embedded Configurable Operating System', and all of its components provide a wide range of
configuration options. The eCos operating system may support a wide range of popular embedded CPUs.
mbed OS
It is a free and open-source embedded operating system that offers a systematic and comprehensive environment for
intelligent hardware development.
VxWorks
Wind River Company firstly introduced it in 1983. It is supported with task synchronization, memory efficiency
management, and other features.
µC/OS-II:
It is introduced based on the μC/OS principle. μC/OS-II may handle 64 tasks and provide various functionalities such as
interrupt services, task scheduling, memory management, synchronization, and time management.
FreeRTOS
It is a lightweight operating system that supports the priority scheduling algorithm. It provides various functionalities like
memory management, message queue, task management, semaphore, time management, etc.
QNX
QNX was created in 1980 and is a commercial embedded real operating system that requires the POSIX specification to
compile.
µ Clinux
It stands for 'Micro-Control Linux', and it is the latest version of embedded Linux. It is capable of grab all features of the
Linux operating system.
The embedded operating system is commonly used in various areas, including car navigation systems, multimedia players,
airplane navigation systems, and medical equipment.
The car navigation system is a small computer system with a touch screen that enables the driver to navigate numerous
menus such as audio playback, radio, GPS and route mapping, fuel level, hands-free calls, and tire pressure monitoring
systems. All of these tasks are performed by the computer to improve the driving experience.
Parking Metering
Smart city parking meters use the embedded system to manage the user input and track time and costs. Depending on
the design, these devices contain a variety of built-in functions. For example, some sensors detect vehicle entry and exit,
while others require the driver to enter the parking space or vehicle license. A user interface offers the driver options,
including defining the expected return time and paying appropriately.
Medical Equipment
Medical equipment automatically monitors bio constants, administers drugs. If the bio constants exceed or fall below a
threshold value, it alerts the staff. As a result, it may help doctors treat the patients, monitor health issues, and save their
lives.
The navigation system of a plane is a good instance of a real-time operating system. The main computer of an airplane is
connected to most control systems such as the wing, engine, pressure controls, and safety. As a result, it is specifically built
to work inside a plane and help with takeoff, landing, and emergency operations.
Advantages
There are various advantages of an embedded operating system. Some of them are as follows:
Disadvantages
There are various disadvantages of an embedded operating system. Some of them are as follows:
Every electrical and electronics project designed to develop electronic gadgets that are frequently used in our
day-to-day life utilizes microcontrollers with appropriate interfacing devices. There are different types of
applications that are designed using microcontroller based projects. In maximum number of applications, the
microcontroller is connected with some external devices called as interfacing devices for performing some
specific tasks. For example, consider security system with a user changeable password project, in which an
interfacing device, keypad is interfaced with microcontroller to enter the password.
Interfacing Devices
Interfacing can be defined as transferring data between microcontrollers and interfacing peripherals such as
sensors, keypads, microprocessors, analog to digital converters or ADC, LCD displays, motors, external
memories, even with other microcontrollers, some other interfacing peripheral devices and so on or input
devices and output devices. These devices that are interfacing with 8051 microcontroller are used for
performing special tasks or functions are called as interfacing devices.
Interfacing is a technique that has been developed and being used to solve many composite problems in circuit
designing with appropriate features, reliability, availability, cost, power consumption, size, weight, and so on.
To facilitate multiple features with simple circuits, microcontroller is interfaced with devices such as ADC,
keypad, LCD display and so on.
SCADA for remote industrial plant is a practical application in which,analog to digital converter or ADC
interfacing with 8051 microcontroller is used. To continuously monitor the multiple operations of the remote
industrial plant, supervisory control and data acquisition (SCADA) is the best technology for achieving control
over various operations of industry remotely, thus increases efficiency and saves lot of manpower.
In this project temperature sensors are interfaced with microcontroller that is connected to a PC. Temperature
sensors connected are interfaced to microcontroller with the help of analog to digital converter. As, the signal
generated from sensors is analog, so these analog signals are converted into digital and then fed to the
microcontroller. For serial communication RS232 is a standard. RS232 interface is used for obtaining
communication between the computer and circuit such to transfer data between circuit and computer.
If the temperature exceeds the preset value, then microcontroller activates relay that will turn off the heaters and
an AV alarm will be generated if the system fails. Here the heaters are represented with lamps for
demonstration purpose.
Keypad or Keyboard
In general keypads or keyboards are used as input devices for computers. But, among various types of
interfacing devices, keypad is also one type of frequently used interfacing peripheral devices. In general, keypad
or keyboard consists of rows and columns, are called as matrix keypads (m rows*n columns keypads). These
are interfaced with microcontroller for entering values or names whenever it is required for the circuit.
Keypad or Keyboard
Thus,the system will avoid the unauthorized persons to operate the door. Even, if any unauthorized attempt
made to operate the door can be altered with an alarm system, here indicated by the lamp. In this project we can
improve the security of the system by using many interfacing devices can be used such as keypad, relay,
EEPROM, GSM modem.
The Keypad is used for entering the password, authorized person can change the password using an external
interfacing peripheral devices such as EEPROM. And further microcontroller interfacing GSM modem can be
used for sending an alert SMS to authorized person regarding unauthorized attempt if any, made to operate the
door with the wrong password.
LCD Display
An LCD display or liquid crystal display is one of the most frequently used interfacing devices that consist of
liquid crystals. It can be considered as a combination of solid and liquid (directly liquid is not used, but in fact
water liquid crystals are used). These LCD displays utilizes liquid crystals for producing visible images. LCD
displays are display screen super thin technology that is being used in cell phones, televisions, portable video
games, laptops, computer monitors, portable video games.
LCD Display
Application of LCD Interfacing with Microcontroller
The RFID based attendance system is a practical application of LCD display interfacing with 8051
microcontroller. This system is a modern way of taking students attendance in the classroom and it will avoid
conventional time consuming manual attendance system.
In this project, every student data is stored in a card that is used as identification for taking attendance of
students. If a student places his/her card in front of the RFID card reader, then this data is read and verified by
comparing it with previously stored data of the 8051 microcontroller. Based on the verification of data
matching, it displays a message on the LCD display. LCD displays interfaced with microcontroller that is used
for displaying a confirmation message, whether the student is present or absent.
If student’s attendance information is required, then by pressing the status button that is interfaced to the
microcontroller attendance can be retrieved. Thus, this system saves a lot of time as the data is stored in the
database. By interfacing the GSM system with this project, it can be used to send SMS alerts to the parents of
the students regarding the attendance.
Application of LCD Interfacing with Microcontroller Block Diagram by Edgefxkits.com
Microcontroller in Robotics
A robot microcontroller is basically the brain of the robot. It is used to collect the information from various input
devices such as sensors, switches and others. Then it executes a program and in accordance with it controls the
output devices such as motors, lights and others.
In a RTOS, Processing time requirement are calculated in tenths of seconds increments of time. It is time-
bound system that can be defined as fixed time constraints. In this type of system, processing must be
done inside the specified constraints. Otherwise, the system will fail.
It offers priority-based scheduling, which allows you to separate analytical processing from non-
critical processing.
The Real time OS provides API (Application Programming Interface) functions that allow cleaner
and smaller application code.
Abstracting timing dependencies and the task-based design results in fewer interdependencies
between modules.
RTOS offers modular task-based development, which allows modular task-based testing.
The task-based API encourages modular development as a task, will typically have a clearly
defined role. It allows designers/teams to work independently on their parts of the project.
An RTOS is event-driven with no time wastage on processing time for the event which is not occur.
Components of RTOS
The Scheduler: This component of RTOS tells that in which order, the tasks can be executed which is
generally based on the priority.
Symmetric Multiprocessing (SMP): It is a number of multiple different tasks that can be handled by the
RTOS so that parallel processing can be done.
Function Library: It is an important element of RTOS that acts as an interface that helps you to connect
kernel and application code. This application allows you to send the requests to the Kernel using a
function library so that the application can give the desired results.
Memory Management: this element is needed in the system to allocate memory to every program, which
is the most important element of the RTOS.
Fast dispatch latency: It is an interval between the termination of the task that can be identified by the
OS and the actual time taken by the thread, which is in the ready queue, that has started processing.
User-defined data objects and classes: RTOS system makes use of programming languages like C or
C++, which should be organized according to their operation.
Types of RTOS
Three types of RTOS systems are:
Task – A set of related tasks that are jointly able to provide some system functionality.
Job – A job is a small piece of work that can be assigned to a processor, and that may or may not
require resources.
Release time of a job – It’s a time of a job at which job becomes ready for execution.
Execution time of a job: It is time taken by job to finish its execution.
Deadline of a job: It’s time by which a job should finish its execution.
Processors: They are also known as active resources. They are important for the execution of a
job.
Maximum time: It is the allowable response time of a job is called its relative deadline.
Response time of a job: It is a length of time from the release time of a job when the instant
finishes.
Absolute deadline: This is the relative deadline, which also includes its release time.
Features of RTOS
Here are important features of RTOS:
Performance: Performance is the most important factor required to be considered while selecting
for a RTOS.
Middleware: if there is no middleware support in Real time operating system, then the issue of
time-taken integration of processes occurs.
Error-free: RTOS systems are error-free. Therefore, there is no chance of getting an error while
performing the task.
Embedded system usage: Programs of RTOS are of small size. So we widely use RTOS for
embedded systems.
Maximum Consumption: we can achieve maximum Consumption with the help of RTOS.
Task shifting: Shifting time of the tasks is very less.
Unique features: A good RTS should be capable, and it has some extra features like how it
operates to execute a command, efficient protection of the memory of the system, etc.
24/7 performance: RTOS is ideal for those applications which require to run 24/7.
It used for desktop PC and laptop. It is only applied to the embedded application.
Interrupt latency is not considered as Interrupt lag is minimal, which is measured in a few
important as in RTOS. microseconds.
No priority inversion mechanism is present The priority inversion mechanism is current. So it can not
in the system. modify by the system.
Disadvantages of RTOS
Here, are drawbacks/cons of using RTOS system:
RTOS system can run minimal tasks together, and it concentrates only on those applications which
contain an error so that it can avoid them.
RTOS is the system that concentrates on a few tasks. Therefore, it is really hard for these systems
to do multi-tasking.
Specific drivers are required for the RTOS so that it can offer fast response time to interrupt
signals, which helps to maintain its speed.
Plenty of resources are used by RTOS, which makes this system expensive.
The tasks which have a low priority need to wait for a long time as the RTOS maintains the
accuracy of the program, which are under execution.
Minimum switching of tasks is done in Real time operating systems.
It uses complex algorithms which is difficult to understand.
RTOS uses lot of resources, which sometimes not suitable for the system.
Summary:
RTOS is an operating system intended to serve real time application that process data as it comes
in, mostly without buffer delay.
It offers priority-based scheduling, which allows you to separate analytical processing from non-
critical processing.
Important components of RTOS system are: 1)The Scheduler, 2) Symmetric Multiprocessing, 3)
Function Library, 4) Memory Management, 5) Fast dispatch latency, and 6) User-defined data
objects and classes
Three types of RTOS are 1) Hard time 2) Soft time ,and 3) Firm time
RTOS system occupy very less memory and consume fewer resources
Performance is the most important factor required to be considered while selecting for a RTOS.
General-Purpose Operating System (GPOS) is used for desktop PC and laptop while Real-Time
Operating System (RTOS) only applied to the embedded application.
Real-time systems are used in Airlines reservation system, Air traffic control system,etc.
The biggest drawback of RTOS is that the system only concentrates on a few tasks.
Preemptive Multitasking
Preemptive multitasking is special task that is assigned to computer operating system, in which
it takes decision that how much time spent by one task before assigning other task for using the
operating system. Operating system has control for completing this entire process, so it is known
as “Preemptive”.
Cooperative Multitasking
Cooperative multitasking is known as “Non-Preemptive Multitasking”. Main goal of Cooperative
multitasking is to run currently task, and to release the CPU to allow another task run. This task is
performed by calling taskYIELD().Context-switch is executed when this function is called.
Round robin scheduling is a pre-emptive algorithm commonly used in operating systems to schedule
processes.
In round robin scheduling, the CPU is assigned to each process in a queue turn by turn for a time period.
Once the time is over, the process is moved to the end of the queue and the CPU is shifted to the next
process in the queue. In this manner, processes are handled from a cyclic queue until the burst time of a
process has passed.
Example
You will be able to understand round robin scheduling better through the example given below. First, we
need a list of processes, including their arrival and burst times. The quantum time per process will be 3, so
every process will execute for 3 seconds each.
Each box represents 1 second of CPU allocation time
Time = 0
At time=0time=0, the processes P1 and P2 enter the queue according to their arrival time and wait to be
executed. Since P1 arrives first, it is taken out of the waiting queue and executed for 3 seconds.
P1
Time = 2
P1P1P1
Time = 3
At time=3time=3, P1 stops executing and its burst time is over. Hence, it is not added back to the waiting
queue. P2 is removed from the waiting queue and executed for the next 3 seconds.
P1P1P1P2
At time=6time=6, P2 is done executing and its burst time is over. Hence, it isn’t added back to the
waiting queue. We remove the next process, P3, from the waiting queue and execute it for the next 3
seconds.
P1P1P1P2P2P2P3
Time = 9
At time=9time=9, P3 stops executing and is added back to the waiting queue because its burst time is not
over. Then, we remove the next process, P4, from the waiting queue and execute it for the next 3 seconds.
P1P1P1P2P2P2P3P3P3P4
Time = 12
At time=12time=12, P4 stops executing and is added back to the waiting queue because its burst time is
not over yet. Then, we remove process P3 from the waiting queue and execute it. As P3 has a burst time of
4 and has completed an execution of 3 seconds already, it is only executed for the next 1 second.
P1P1P1P2P2P2P3P3P3P4P4P4P3
Time = 13
At time=13time=13, P3 is done executing and its burst time is over. Hence, it is not added back to the
waiting queue. Then, process P4 is executed for the next 1 second only, as it was previously executed for 3
of its 4-second burst time.
P1P1P1P2P2P2P3P3P3P4P4P4P3P4
Time = 14
To deduce the average waiting time, we calculate the waiting time for each process and divide it by the
total number of processes.
P1 waiting time: 0
P2 waiting time: 0
P3 waiting time: 9
P4 waiting time: 10
The following is a table of all the advantages and disadvantages of using the round robin scheduling
algorithm.
Advantages Disadvantages
There is no issue of starvation as each process gets an equal Processes have to wait a longer duration for their
chance and time to be executed turn
Each of the processes gets equal time Context switching takes time
No process is given priority over the other Due to a longer waiting time and context switching,
the throughput is low
Algorithms that are backed by preemptive Scheduling are round-robin (RR), priority, SRTF (shortest remaining time first).
When a high-priority process comes in the ready queue, it doesn't have to wait for the running process to finish its burst
time. However, the running process is interrupted in the middle of its execution and placed in the ready queue until the
high-priority process uses the resources. As a result, each process gets some CPU time in the ready queue. It improves the
overhead of switching a process from running to ready state and vice versa, increasing preemptive scheduling flexibility. It
may or may not include SJF and Priority scheduling.
For example:
Let us take the example of Preemptive Scheduling. We have taken P0, P1, P2, and P3 are the four processes.
P0 3 2
P1 2 4
P2 0 6
P3 1 4
o Firstly, the process P2 comes at time 0. So, the CPU is assigned to process P2.
o When process P2 was running, process P3 arrived at time 1, and the remaining time for process P2 (5 ms) is
greater than the time needed by process P3 (4 ms). So, the processor is assigned to P3.
o When process P3 was running, process P1 came at time 2, and the remaining time for process P3 (3 ms) is less
than the time needed by processes P1 (4 ms) and P2 (5 ms). As a result, P3 continues the execution.
o When process P3 continues the process, process P0 arrives at time 3. P3's remaining time (2 ms) is equal
to P0's necessary time (2 ms). So, process P3 continues the execution.
o When process P3 finishes, the CPU is assigned to P0, which has a shorter burst time than the other processes.
o After process P0 completes, the CPU is assigned to process P1 and then to process P2.
There are various advantages and disadvantages of Preemptive scheduling. The advantages and disadvantages of non-
preemptive scheduling are as follows:
Advantages
1. It is a more robust method because a process may not monopolize the processor.
2. Each event causes an interruption in the execution of ongoing tasks.
3. It improves the average response time.
4. It is more beneficial when you use this method in a multi-programming environment.
5. The operating system ensures that all running processes use the same amount of CPU.
Disadvantages
Algorithms that are based on non-preemptive Scheduling are non-preemptive priority, and shortest Job first.
When a non-preemptive process with a high CPU burst time is running, the other process would have to wait for a long
time, and that increases the process average waiting time in the ready queue. However, there is no overhead in
transferring processes from the ready queue to the CPU under non-preemptive scheduling. The scheduling is strict
because the execution process is not even preempted for a higher priority process.
For example:
Let's take the above preemptive scheduling example and solve it in a non-preemptive manner.
o The process P2 comes at 0, so the processor is assigned to process P2 and takes (6 ms) to execute.
o All of the processes, P0, P1, and P3, arrive in the ready queue in between. But all processes wait till
process P2 finishes its CPU burst time.
o After that, the process that comes after process P2, i.e., P3, is assigned to the CPU until it finishes its burst time.
o When process P1 completes its execution, the CPU is given to process P0.
There are various advantages and disadvantages of non-preemptive scheduling. The advantages and disadvantages of
non-preemptive scheduling are as follows:
Advantages
Disadvantages
Using Microsoft Platform Builder, developers can build customized Windows CE operating systems as well
as components for embedded systems. Platform Builder is an integrated development environment that
comes with development tools for designing, creating, building, testing and debugging. Most parts of
Windows CE are offered in source code form, enabling hardware vendors to alter it in order to fit the
specific needs of their device.
Create BSP or board support packages specifically designed for the target device.
Create an OS design, based on either a standard or customized board support package (BSP), that
is used for creating a run-time image.
Create customized device drivers for the BSP using projects and catalog items.
Build the runtime image and download to the standard development board for debugging and
testing.
Export a software development kit for application developers.