Design and Implementation of an Infrared Distance Sensing System with Real-Time Data Analysis Using Arduino and LabVIEW
Design and Implementation of an Infrared Distance Sensing System with Real-Time Data Analysis Using Arduino and LabVIEW
Mohammed Eltallaa
Zaid Ateh
Yasmin Alhendawy
14.01.2025
ID numbers Mohmmad:
20211102066
Zaid:
20221102036
Yasmin:
20211102068
1
Sensors - ME0348 (2025) Students project
Table of Contents
1.Introduction 3
1.1 Motivation 3
1.2 Objective 3
2. Methodology 4
2.1 IR Sensing Mechanism 4
2.2 LabVIEW 5
3.Concept of the system 6
3.1 Key Features of the system 6
3.2 Components and Materials6
3.3 Design and circuit modelling 7
3.4 Structural Analysis 8
4. Programming and Control 9
4.1 Arduino Code 9
4.2 Filtering inside Arduino 11
5. LabVIEW Implementation 12
5.1 Configuration 12
5.2 Data Visualization 13
6. Tests 14
6.1 Initial Testing 14
6.2 Calibration 14
7. Discussion 16
7.1 Performance Analysis 16
7.2 Summary of the system’s advantages and disadvantages 16
7.3 Future improvements 17
8. Final Concept 18
9. Conclusion 19
2
Sensors - ME0348 (2025) Students project
1 Introduction
1.1 Motivation
Infrared (IR) sensors are essential components in modern technology, enabling
precise detection of objects, distance measurement, and motion tracking across
various applications. These sensors operate by emitting infrared light and detecting
the reflections from nearby objects, making them versatile for both industrial and
personal use.
In this project, we aim to construct an IR sensor system, integrating hardware and
software components to achieve accurate and reliable measurements. The
hardware will include an infrared transmitter and receiver circuit designed to detect
objects or measure distances based on reflected IR light. On the software side, we
will utilize LabVIEW, a powerful graphical programming platform widely used for
data acquisition, processing, and visualization.
Through this project, we aim to understand the principles of IR sensing operations,
explore signal processing techniques, and harness LabVIEW's capabilities to design
a functional and interactive system. This document outlines the design,
construction, and testing process of an IR sensor, highlighting the integration with
LabVIEW to achieve a seamless, user-friendly solution for various usages.
1.2 Objective
The primary objective of this project is to design and construct an IR sensor system
capable of performing two key functions: detecting and measuring distances to
nearby objects. The project involves developing a robust hardware setup with an
infrared transmitter and receiver to generate and capture IR signals. By integrating
the IR sensor with LabVIEW, the system will enable real-time data processing,
visualization, and calibration to ensure accurate distance measurements.
In addition to distance detection, the IR sensor will be utilized in dynamic
environments as an obstacle/wall detector for robotic navigation. This functionality
will allow robots to identify and avoid obstacles, enhancing their ability to move
safely and efficiently in complex surroundings or mazes. By combining the
capabilities of the IR sensor with the advanced processing and control features of
LabVIEW, this project aims to create a versatile, reliable system that is suitable for
applications in automation, robotics, and beyond.
3
Sensors - ME0348 (2025) Students project
2 Methodology
2.1 IR Sensing mechanism
An IR sensor consists of two parts, the emitter circuit, and the receiver circuit. This
is collectively known as a photo-coupler or an optocoupler.
The emitter is an IR LED, and the detector is an IR photodiode. The IR photodiode is
sensitive to the IR light emitted by an IR LED. The photodiode’s resistance and
output voltage change in proportion to the IR light received. This is the underlying
working principle of the IR sensor.
The type of incidence can be direct incidence or indirect incidence:
1. direct incidence: the IR LED is placed in front of a photodiode with no
obstacle.
2. indirect incidence: both the diodes are placed side by side with an
opaque object in front of the sensor. The light from the IR LED hits the
opaque surface and reflects to the photodiode.
An IR receiver LED and an IR transmitter LED are both types of light-emitting diodes
(LEDs) that are used in infrared (IR) communication. Also, IR receiver LED is a
device that detects infrared signals from remote controls and other IR sources. It is
typically a small, clear, or translucent device that is sensitive to IR light in a specific
frequency range. When an IR signal is detected, the IR receiver LED will emit a small
amount of visible light, which can be used to confirm that a signal has been
received.
4
Sensors - ME0348 (2025) Students project
2.2 LabVIEW
LabVIEW provides a graphical interface to visualize sensor data, such as distance
readings or obstacle alerts. we can design custom dashboards with graphs,
indicators, and alarms to make the system intuitive and interactive.
Benefits of LabVIEW:
Easy Integration with Hardware
LabVIEW supports a wide range of hardware interfaces, including
microcontrollers (like Arduino or ESP32), data acquisition devices, and
sensors.
Using LabVIEW, you can directly communicate with your IR sensor system for
seamless operation.
Minimal Coding Requirements
5
Sensors - ME0348 (2025) Students project
6
Sensors - ME0348 (2025) Students project
(1) (2)
o R2 (10 kΩ): Pulls the transistor base to ground when the Arduino
output is low.
7
Sensors - ME0348 (2025) Students project
NPN Transistor: Used as a switch to control the IR LED. When the Arduino
digital pin is HIGH, the transistor allows current to flow through the IR LED,
turning it on.
Capacitor (10 µF): Stabilizes the power supply to prevent noise or
fluctuations in the circuit.
Operation:
The Arduino digital pin controls the IR LED. When the pin outputs HIGH, the
transistor switches on, completing the circuit for the IR LED to emit light.
The capacitor ensures stable operation, especially in noisy environments. And
allows high current through LED
8
Sensors - ME0348 (2025) Students project
object.
9
Sensors - ME0348 (2025) Students project
10
Sensors - ME0348 (2025) Students project
102. {
103. if (voltage >= voltageValues[i + 1] && voltage < voltageValues[i])
104. {
105. float slope = (distanceValues[i + 1] - distanceValues[i]) / (voltageValues[i +
1] - voltageValues[i]);
106. float distance = distanceValues[i] + slope * (voltage - voltageValues[i]);
107. return constrain(distance, 0, 25);
108. }
109. }
110. return constrain(distanceValues[0], 0, 25); }
2. This means sudden changes in the raw data are dampened because the new
value contributes only a small portion ( α = 0.1) to the updated filtered value.
3. Over time, the filter averages out the noise, resulting in smoother and more
stable readings.
The low-pass filter enhances the reliability of sensor data by reducing noise and
minimizing random fluctuations caused by environmental factors like electrical
interference or light variations. It ensures stable and steady distance readings,
preventing unnecessary jumps in the displayed values. Additionally, it smooths out
gradual changes in distance, providing a more consistent and user-friendly output.
Note: Calibration is included in the code of the Arduino, but we will discuss it after
the initial tests section.
11
Sensors - ME0348 (2025) Students project
5 LabVIEW Implementation
5.1 Configuration
12
Sensors - ME0348 (2025) Students project
10.While Loop (Black Box): Ensures continuous data reading and processing.
11.Stop Button: Terminates the loop and closes the serial connection.
This system allows for real-time data acquisition, filtering, and visualization,
showcasing how LabVIEW can integrate with hardware for effective data analysis.
1. "Before Filtering" Graph: Shows the raw, unfiltered data received from the
sensor. Noise or fluctuations in the signal are visible here.
2. "After Filtering" Graph: Displays the processed (filtered) data. This graph
typically has smoother and more reliable output, highlighting the effect of the
filtering process.
The graphs illustrate the change in readings over distance versus time. Before
filtering, the data was filled with unwanted noise and fluctuations. However, after
applying LabVIEW's built-in filter functions, the data became smoother, resulting in
better acquisition and improved signal clarity.
This front panel offers real-time control and visualization of the system, enabling the
user to monitor data quality and performance effectively.
13
Sensors - ME0348 (2025) Students project
6 Tests
6.1 Initial Testing
During initial testing of the IR sensor, we assumed the relationship between the
detected signal and distance was linear, which resulted in significant errors in the
measurements. However, after plotting data for 25 points, we discovered that the
relationship was non-linear. By fitting a quadratic curve to the data, we achieved a
more accurate representation of the sensor's behaviour, significantly improving its
performance and reducing errors.
6.2 Calibration
We calibrated the system through Arduino code at first we created Two arrays,
voltageValues[ ] and distanceValues[ ] to store known data points.
voltageValues[ ] represents the voltages observed at specific distances.
distanceValues[ ] represents the corresponding distances (in cm).
These points are obtained through experimental calibration, where voltage readings
are recorded at various distances (0 cm to 25 cm).
We used Interpolation to Estimate Distance:
The goal was to determine the distance corresponding to a given voltage, which
might not match any specific point in voltageValues[ ]. The code identifies two
calibration points (nearest neighbours) between which the given voltage lies and
uses linear interpolation to estimate the distance.
1. Calibration Data as Points on the Plot:
- The voltageValues[ ] represent the x-axis (voltage readings from the IR
sensor), while the distanceValues[ ] represent the y-axis (corresponding distances
in cm).
- These form a set of discrete data points, plotted as a curve based on the
relationship between voltage and distance. The curve is typically non-linear, as the
response of an IR sensor to distance is not perfectly proportional.
2. Finding the Range (Segment of the Curve):
14
Sensors - ME0348 (2025) Students project
- For a given voltage input, the algorithm identifies which two neighbouring points
(on the x-axis) the input voltage lies between. This corresponds to a segment of the
curve on the plot.
3. Linear Interpolation on the Curve:
- Within this segment, the calibration assumes the curve is approximately linear.
- By drawing a straight line between the two neighbouring points, the algorithm
estimates the corresponding distance for the input voltage. This is essentially
finding the y-coordinate for a given x-coordinate within the segment.
4. Constraining to the Measurable Range:
- Since the calibration only covers distances between 0 and 25 cm, any
interpolated distance outside this range is capped at 0 or 25 cm.
Visual Representation:
Imagine a plot with:
15
Sensors - ME0348 (2025) Students project
7 Discussion
7.1 Performance Analysis
1. Accuracy Across the Range:
- The sensor showed inconsistent accuracy in the range between 0 cm and 13
cm. This could be due to the non-linear relationship between voltage and distance,
which is more pronounced at closer ranges, making precise interpolation more
challenging.
- Between 13 cm and 22 cm, the sensor performed significantly better, with
accurate and reliable readings. The maximum effective range was determined to be
22 cm, beyond which the sensor was unable to provide reliable data.
16
Sensors - ME0348 (2025) Students project
strength and leading to longer perceived distances. This behaviour is due to the IR
sensor's dependence on the amount of reflected IR light, which varies based on the
surface's reflectivity and absorption properties.
17
Sensors - ME0348 (2025) Students project
8 Final Concept
This IR sensor system is a compact, cheap, versatile solution for measuring small
distances, utilizing pre-calibrated data and advanced filtering to ensure accurate
and stable readings. By integrating features like a low-pass filter and user-controlled
modes for single or average measurements, the system is designed to be reliable
and user-friendly. This system has a wide range of potential applications, including
proximity sensing, obstacle detection in robotics, maze-following robots, industrial
automation, and home security systems, making it a valuable tool for technological
solutions such as walls detecting mechanism for self-emptying vacuums.
Pins configuration:
01-> 5v
03-> ground
04-> analog in
05 -> digital out
18
Sensors - ME0348 (2025) Students project
9 Conclusion
Creating an IR sensor from scratch, incorporating all the filtering, calibration, and
integrating LabVIEW into the process, transforms the project into a rich learning
experience. The addition of LabVIEW introduces a dynamic dimension to the
development, enabling the visualization, processing, and analysis of data in real-
time. This reinforces the importance of integrating software tools with hardware for
effective system design.
By designing circuits, interpreting raw signals, and fine-tuning calibration processes,
we delve deep into the fundamentals of sensor design and signal processing.
LabVIEW serves as an invaluable tool, bridging the gap between theoretical
concepts and practical implementation. It allows for intuitive data representation
and interactive control, making complex processes more approachable and
enhancing debugging efficiency.
This project not only expands our technical skillset but also emphasizes the
importance of interdisciplinary thinking—merging hardware development with
software solutions. It challenges us to think critically, adaptively solve problems,
and continually improve. Ultimately, it cultivates a comprehensive understanding of
sensor systems while fostering a mindset of innovation and lifelong learning.
The End
19