Saeedpce Final
Saeedpce Final
Submitted to
Department of Humanities
Pillai College of Engineering ( PCE )
Dr. K. M. Vasudevan Pillai Campus Navi Mumbai -
410206, Maharashtra, India
Submitted by
i
Acknowledgment
We started this project with the help and support of many dedicated individuals, whose expertise and
encouragement have been crucial to us. Completing this project has been a fulfilling journey, and we are
truly thankful to everyone who played a part in its success. We extend our heartfelt gratitude to Principal
Mr. Sandeep Joshi for his unwavering support and encouragement throughout this endeavor. Our sincere
thanks also go to the Electronics and Telecommunication Engineering Department for creating a
stimulating and supportive learning atmosphere. We are especially appreciative of our Head of
Department, Prof. Dr. Avinash R. Vaidya, for his invaluable guidance and for laying a strong foundation
in this field. We also want to thank Prof. Sowmya Saudolla for her constant encouragement, insightful
advice, and steadfast support, which inspired us to excel and pursue personal growth. Lastly, we are
particularly grateful to our Project Guide, Prof. Ameet Mehta, for his invaluable mentorship, problem-
solving help, and commitment to our development. We genuinely appreciate the wisdom and inspiration
shared by each of these esteemed individuals. Additionally, we thank the teaching and non-teaching faculty
members, whose guidance and support have significantly enhanced our understanding and learning. We
would also like to express our deepest gratitude to everyone who has directly or indirectly assisted us in
completing this project.
ii
Executive Summary
The Ultrasonic Distance Calculator using the 8051 Microcontroller is designed to create an efficient,
accurate, and cost-effective system for measuring distances with ultrasonic technology. This system
calculates the distance from the sensor to an object by measuring the time it takes for an ultrasonic pulse
to travel to the object and back. The 8051 microcontroller emits an ultrasonic pulse from the sensor and
determines the distance based on the duration of the reflected signal, known as the echo. The resulting
distance is displayed on an LCD for easy reading. This project is particularly useful in applications that
require distance measurement, such as robotics, object detection, and various automation tasks. It provides
practical experience with embedded systems, sensor interfacing, and distance calculation methods. The
8051 microcontroller is energy-efficient, and the HC-SR04 sensor is affordable and readily available,
making the proposed system both practical and economical. Additionally, it can be enhanced by
incorporating features like temperature compensation for improved accuracy, wireless communication for
remote monitoring, or a multi-sensor setup for more complex applications.
iii
Table of Contents
Acknowledgement I
Executive Summary II
1. Introduction 1-2
4. Implementation 8
6. Limitations 16
7. Conclusion 17
References VI
Appendix VII
Glossary VIII
iv
Lists of Illustrations
Fig no. Name of Figure Page no.
3.1 Microcontroller 6
4.1 Implementation 8
4.4 FeedBack 18
v
Chapter 01
Introduction
The ultrasonic distance calculator is a novel project based on 8051 microcontroller that introduces the
techniques used to calculate distance using sound waves, the principles being, sound waves are sent out,
and the time it takes for the echoes to return is measured, so that the distance from any object can be
determined. All the features are put together into an 8051 microcontroller, packaged as one chip super
computer receiving signals from the ultrasonic sensor and measuring the time taken for the echo to return.
Besides bringing in the idea of units of hardware in this sense ultrasonic sensor, a LCD display is addressed
by the project in terms of algorithms and programming logic structures and interfacing technology. On the
other hand, the use of robotic project, ranging from automotive sensors up to industrial level measurement,
this work on the construction of an ultrasonic distance calculator is indeed an elegant and stimulating way
of dealing with sensors and microcontroller technology. Since there's an ever-increasing need for
automation and accuracy in measurements, projects like this add great value in teaching and application
towards the real world.
1.1 Fundamentals
Role of LEDs, resistors, capacitors, transistors in an electronic circuit. Programming of a microcontroller like
Arduino or Raspberry Pi to regulate an LED light output when the touch stimulus is responded to.
Familiarization of the touch sensing technique to identify a touch that could be capacitive or resistive. Design
patterns or sequences using the blinking LEDs and in f how to control the
LED flashes.
1
1.2 Objectives
• Distance Measurement: The use of ultrasonic waves as a means to determine precisely how far one place
is from the other is sound propagation and reflection based principle.
• Microcontroller programmation skills: In this, 8051 microcontroller programmation skills are required
for setting up of timers, managing I/O operation, and also the algorithm to determine the distance in terms
of logic.
•Sensor Interfacing: Interfacing an ultrasonic sensor, such as HC-SR04, with the 8051 microcontroller is
shown to ensure proper interconnection between those two devices.
• Data Display: Enables a loading of LCD display and thus indicates for a user who measures distance
visually, instantaneous feedback characterizing the project.
• Calibration and Precision: Calibration to ensure measured distances are accurate, and a learner knows
how temperature and humidity will affect measurements.
1.3 Scope
1. Apparatus-based education. It is very instrumental as a tool in making the students and hobbyists
appreciate the concepts involved with measuring distance, ultrasonic devices, and even more
microcontroller programming. .
2. Robotics: It can be used in robotics to detect obstacles and navigate- increasing the power of
autonomous machines.
2
3. Vehicle Applications: It can be employed in parking assist systems to measure distances such that
collision with other objects is avoided.
4.Industrial Automation: It can measure the level in tanks, so the levels of fluids are known within any
industrial process.
5.Home Automation: The technology can be utilized for smart home devices, sensitizing proximity, and
performing different automation tasks, such as controlling lighting depending on its presence detection.
1. Calibration Techniques: The project allows the possibility of studying calibration techniques which can
improve the accuracy tin measuring that may deepen us with sensor dynamics.
2. Interfacing Skills: It comprises acquiring interfacing skills in the use of different component (sensors,
displays).
3
Chapter 02
Literature Review
People in the field have actually done much study and applied it into various fields, including robotics,
automation, and industrial systems. This literature review is going to cover some fundamental principles
of ultrasonic distance measurement technology, the role of the 8051 microcontroller within embedded
systems, and how these technologies have been used in past projects.
4
Text Book Reference: "The 8051 Microcontroller and Embedded Systems" by Muhammad Ali Mazidi and
Janice Gillispie Mazidi, 2006. The authors covered several applications including sensor as well as
actuator interfacing along with several examples using 8051-based systems.
4. Current Trends
Despite the overwhelming applications of ultrasonic sensors, there are problems that need to be addressed
in order to make systems reliable and accurate in distance measurement.
Temperature Sensitivity: The speed of sound changes in air with changes in temperature; this could shift
in certain instances the accuracy of distance measurements. Compensation can occur by relating the speed
of sound to temperature measurements. L. S. Lala et al. have written a few books, one of the books is
5
"Embedded Systems Design Using the 8051 Microcontroller, 2004" that has some sensor calibration
techniques.
Range and Resolution: Ultrasonic sensors are highly limited in terms of range and resolution with small
or far away objects. A big part of a good article from John Smith about "Ultrasonic Distance Measurement:
Practical Applications" in 2016 discussed advanced signal-processing algorithms that can be applied to
extend the range and the resolution of ultrasonic sensors.
Environmental Interference: Ultrasonic sensors are interfering with the environment due to noise
generation by other devices or non-symmetrical shapes of objects. Current research is the use of multi-
sensor systems and signal filtering techniques for a robust and reliable ultrasonic distance measurement
system.
6
Chapter 3
Project Requirement
Hardware requirement is an integral part of the 8051 microcontroller in operating the system for the
Ultrasonic Distance Calculator. It is the brain of the project that controls the ultrasonic sensor, processes
input data, and works out the distance through the time of flight of the ultrasonic waves. It uses an HC-
SR04 ultrasonic sensor providing distance measurements based on the principles of high-frequency sound
waves emitted and detected by reflected pulses. The Trigger pin of the sensor triggers the measurement,
and the Echo pin captures the returned pulse; this signal is further processed by the microcontroller to
compute the distance. The computed distance is usually displayed in a 16x2 LCD, hence giving the user
instant feedback about the distance. Microcontroller
The hardware components used in the project are given below: Intel 8051 microcontroller. Members of
the MCS-51 family include the highly popular 80C51 that has been compatible with the Intel 8051
Microcontroller. The CPU is the heart of the microcontroller, where instructions are carried out, and all
operations are controlled. 4. The 80C51 has four parallel I/O ports labeled as P0, P1, P2, and P3. They
can be used to perform input and output operations.
7
Ultrasonic sensor
1. Emission: The sensor is a transmitter that emits an ultrasonic pulse emission.
2. Echo Reception: Following emission, the sensor waits for an echo which will bounce off some
number of objects.
3. Measure Time: It is the sensor's time measured when the pulse was released and returns as an
echo.
4 Distance Calculation: Using the equation: Distance=Time×Speed of Sound2 Distance = Time ×
Speed of Sound 2 Distance=2Time× Speed of Sound This formula incorporates the round trip for
consideration into the wave of sound.
A 16x2 LCD is a character display, which means that it shows 16 characters per line on two lines, so
it is ideal for embedded systems and microcontroller projects. It shows characters in 5x8 pixels
format. It works in 4-bit or 8-bit mode using control pins like RS (Register Select), RW (Read/Write),
and E (Enable). The liquid crystals are used to control the passage of light. When the electrical signal
passes through the liquid crystals, it creates the characters.
8
Chapter 4
Implementation
4.1 Hardware Implementation
9
4.2 Circuit Diagram
10
4.2 Software Implementation Program / Code
11
lcdcmd(0x30); // Initialize LCD in 8-bit mode delay(1);
lcdcmd(0x38); // 2-line and 5x7 matrix delay(1);
lcdcmd(0x0C); // Display on, cursor off delay(1);
lcdcmd(0x01); // Clear display delay(1);
lcdcmd(0x06); // Shift cursor to the right delay(1);
lcdcmd(0x80); // Ses cursor to (0,0) delay(1); }
void lcddat(unsigned char DATA) {
LCDrs = 1; // Data mode
LCDrw = 0; // Write mode
LCDen = 1; // Strobe the enable pin
LCDdata = DATA; // Put the value on the pins
LCDen = 0; // Disable after data is sent
delay(2); // Short delay for execution
}
void display_lcd(unsigned char location, unsigned char *d) {
lcdcmd(0x80 | location); // Set DDRAM address delay(1);
while (*d) { lcddat(*d++); // Send characters to LCD
delay(1); // Delay between characters
} } void send_pulse(void)
{
TH0 = 0x00; TL0
= 0x00; trig = 0;
trig = 1; // Generate 10 microseconds pulse
nop(); nop(); nop(); nop(); nop(); nop();
nop(); nop(); nop(); nop(); trig = 0; }
void lcd_number(int val) { int i = 3; char str[7] =
{"0000 CM"}; while (val) { str[i] = 0x30 | val % 10;
// Convert number to ASCII
val = val / 10; i--; } display_lcd(0xC5, str); // Display the
number on the LCD
12
} void get_range(void) { int range = 0; int
timerval; send_pulse(); while (INT0 == 0); //
Wait for echo to go high while (INT0 == 1);
// Wait for echo to go low timerval = TH0;
timerval = (timerval << 8) |
TL0;
TH0 = 0xFF; TL0
= 0xFF;
if (timerval < 35000) // Valid range check
range = timerval / 59; else range = 0; lcd_number(range);
// Display range on LCD
} void main(void) {
initialize(); // Initialize LCD
display_lcd(0x80, " OBSTACLE AT "); // Display message on LCD
TMOD = 0x09; // Timer0 in 16-bit mode with gate enable
TR0 = 1; // Enable timer run
TH0 = 0x00; TL0 =
0x00;
echo = 1; // Set pin P3.2 as input (echo pin) while
(1) { get_range(); // Continuously get range and display
delay(2);
}
}
13
4.3 Sensor Data Evaluation
14
Chapter 5
15
5.Effects of Environment
Expected Outcome: The system would be robust enough to work reliably in standard indoor conditions.
Findings: Two environmental factors may slightly influence the speed of sound and hence cause errors in
distance measurements-that is, the temperature and humidity of the environment. In greater detail, it has
been contended that increases in temperature cause the speed of sound to rise thereby causing slight
inaccuracy in distance measurements.
Conclusion: The system performed well under normal room conditions though more calibration should be
made by including temperature compensation for further improved accuracy. However, this level of error
(±1 cm) is acceptable for most practical applications.
1. Error Detection
Expected Result: It shall be able to detect missing objects or out-of-range distances. Findings: The LCD
shows "0 cm" when there is nothing in range or is out of range. No specific error handling has been done
for those cases where the sensor did not recognize a valid echo, either because the objects are too far away
or completely outside the beam of the sensor.
Outcomes Error handling is not all that sophisticated for a condition such as no object detected by the
system, but the "0 cm" displayed in the LCD serves to provide a crude form of feedback. One effective
approach could be to further develop more sophisticated error messages, like "Out of Range".
16
Chapter 6
Limitations
In the above design of the calculator using the 8051 microcontroller, there are a few limitations associated
with it and affects the system overall. First of all, the ultrasonic sensor HC-SR04 used here is of relatively
short range. It is typically good up to a distance of about 2 cm to 400 cm. For distances farther than this
range, the precision and reliability of distance measurements degrades and therefore not good for distance
measurements at a large distance. The sensor resolution affects the accuracy of the system usually in
terms of around 1 cm. This will lead to a number of errors and especially in the upper range because the
ability of the sensor to catch the reflected pulse is somewhat weak. Another limitation arising from the
sensor is its sensitivity to temperature and humidity, which affect how fast the sound travels and, hence,
the distance calculation accuracy. If it is not paid enough, these environmental variables make the
measurements inaccurate. In addition, the system is pretty inept when dealing with objects that are small,
have uneven surfaces or even if they adsorb sonic waves heavily. It does this because 8051 depends on
the return of sonic waves for its measurements. Last but not least, 8051 has little processing power with
little memory, so its performance might be a problem if higher order tasks or faster real-time accuracy are
an issue.
17
Chapter 7
Conclusion
The distance-measuring ultrasonic waves experiment was demonstrated successfully by using 8051
microcontrollers. Such an efficient yet low-cost solution finds various applications in real life in the
form of short-range detection of distance measurements. The system is basically on the principle of
sending an ultrasonic pulse and then measuring the time it takes for that pulse to return back after being
reflected from the object. The result is then displayed on the 16x2 LCD display in real-time with very
clear and readable output. The project shows how easy and effective the HC-SR04 ultrasonic sensor
could be joined to the 8051 microcontroller for easy tasks about distance measurements. It performs
reasonably well in performance within the operational range of the sensor, which is around 2 cm to 400
cm. It can give fairly accurate distance values with about 1 cm resolution. The system can be reliable
for using applications such as obstacle detection, simple robotics, and measurement tasks where there
is not a need for higher accuracy and longer range.
18
References
1. "Ultrasonic Distance Measurement using 8051," Electronics Projects Hub. [Online]. Available:
https://www.electronicsprojectshub.com/ultrasonic-distance-measurement-using-8051/. [Accessed:
Nov. 14, 2024].
3. "Distance Measurement using Ultrasonic Sensor," Arduino Project Hub. [Online]. Available:
https://create.arduino.cc/projecthub. [Accessed: Nov. 14, 2024].
19
Appendix
20
Glossary
1. Backscatter- The reflection of sound waves from an object back to the sensor. The time it takes for
the reflected wave to return is measured to calculate the distance.
2. Calibration- The process of adjusting a system or sensor to account for environmental conditions or
inherent errors, improving measurement accuracy. For ultrasonic systems, calibration may include
compensating for temperature or humidity effects on sound speed.
3. Obstacle Avoidance in Robotics- This information is used to help the robot navigate autonomously
by avoiding collisions.
4. Environmental Interference- The effect of external factors, like noise from other devices or irregular
shapes of objects, that can interfere with the ultrasonic sensor’s ability to accurately measure
distance. Researchers are exploring multi-sensor systems and signal filtering techniques to reduce
interference.
5. Time-of-Flight- The principle by which distance is measured, which is based on the time it takes for
the ultrasonic pulse to travel to an object and return. The time is measured and used to compute the
distance.
21