The document presents the design of a smart fuel theft detector system. It begins with an acknowledgment and dedication section. It then provides a table of contents and list of figures. The document discusses conducting a survey on fuel theft, presenting the problem and goals of the project. It describes the methodology and components of the solution, including using ultrasonic and slope sensors, a microcontroller, GPRS module for data transmission. It concludes with experimental results on the sensors and an overall conclusion.
5. Page | 5
Contents
ACKNOWLEDGMENT...............................................................................Error! Bookmark not defined.
Table of Figures..................................................................................................................................6
CH 1 SURVEY...................................................................................................................................7
1.1 THE SURVEY ........................................................................................................................7
1.2 RESULTS AND ANALYISIS ......................................................................................................9
CH 2 Introduction..........................................................................................................................11
2.1 PROBLEMTO SOLVE...........................................................................................................11
2.2 ABSTRACT.........................................................................................................................12
2.3 METHODOLOGY.................................................................................................................13
2.4 ENVIRONMENT OF WORK ..................................................................................................14
CH 3 SOLUTION.............................................................................................................................15
3.1 FUEL MEASURMENT...........................................................................................................15
3.1.1 THE FIRST PROPER SENSOR (HC-SR04) .........................................................................15
3.1.2 THE SECONDPROPER SENSOR(LSM303DLH)…………………………………………………………………16
3.1.3 MICROCONTROLLER.................................................................................................187
3.1.3 FILTERING & PROCESSING......................................................................................... 219
3.2 TRANSMISSION OFDATA……………………………………………………………………………………………………….22
3.2.1 GPRS MODULE……………………………………………………………………………………………………………….22
3.2.2 INTERFACING BETWEEN THE GPRS AND THE CONTROLLER ...........................................25
3.2.3 TRANSMISSION USING GPRS MODULE.........................................................................25
3.3 The Whole system .............................................................................................................25
CH 4 CONCLUSION ANDOBSERVATIONS…………………………………………………………………………………………….25
4.1 Experiment on the Sensor..................................................................................................27
4.2 CONCLUSION.....................................................................................................................29
Bibliography.....................................................................................................................................31
APPENDEX A.1: The Code of the PIC16f877a.......................................................................................32
6. Page | 6
Table of Figures
Figures1.2-1 The surveyresults………………………………………………………………………………………………………………7
Figure 3.1-1 Ultrasonic principle ........................................................................................................13
Figure 3.1-2 The HC-SR04 ultrasonic sensor........................................................................................14
Figure 3.1-3 The Principle of Work Ultrasonic Sensor...........................................................................17
Figure 3.1-4 Timing Diagram of the Ultrasonic Sensor.........................................................................17
Figure 3.1-5 The LSM303DLE slope sensor..........................................................................................20
Figure3.1-6 PIC16f877a…………………………...................................................................................................17
Figure 3.1-7 Flow Chartfor the Microcontroller .............................................................................. 2422
Figure 3.2-1 GPRS module.................................................................................................................25
Figure 4.1-1: 12cm distance from a rigid body ....................................................................................27
Figure 4.1-2: 16cm distance from a rigid body ....................................................................................27
Figure 4.1-3: 20cm distance from a rigid body ....................................................................................27
Figure 4.1-4: 24cm distance from a rigid body ....................................................................................27
Figure 4.1-5: Test of the Sensor on Fluids............................................................................................28
7. Page | 7
CH 1 SURVEY
1.1 THE SURVEY
Afterwe choose ourprojectidea we did a short survey about the projectto ensure thatthe system
isimportantfor the ownersof transport companies, aswell as find out if they have usedotherdevices
to solve the problem and how the success of these devices. In addition to that we want to identifythe
extent of the Palestinian marketneed forthe project and the possibility of marketingit effectively.
Our surveyis shownbelowinArabicaswe distributedit:
الى إرسالها و دقيق بشكل التنك داخل الوقود كمية حساب على يعمل جهاز بناء على المشروع فكرة تقوم
تج مناسبة بطريقة الجهاز وصمم دوري بشكل الشركة مقرعلهثم ومن الوقود إستهالك مقدارتتبع على قادرا
عن السرقة إكتشافالسرقة عن تبلغ فورية رسالة بإرسال يقوم حيث حدوثها دوكمية.المسروقة الوقود
ت على العمل فريق تساعد بطريقة وضع التالي اإلستبيانوقعوساعات يوميا المسروقة الوقود كميات
الوسائل جميع اإلعتبار بعين األخذ مع السرقة حالة مع التعامل طريقة منالبيانات هذه تسهل حيث السرقة
.الوقود سرقة في المتبعة
مادوري بشكل المستهلكة الوقود لكميات الدقيقة المعرفة أهمية هي
مهمجدا
مهم
محايد
غيرمهم
الشعوربالوقود سرقة
متأكدالسرقة وجود من
شاكالسرقة بوجود
اللي علم
متأكدسرقة وجود عدم من
فيالوقود سرقة تكون الغالب
أثناءالمركبة عمل
خارجالمركبة عمل ساعات
فيالسابقتين الحالتين كلتا
فيقبل من الوقود سرقة تكون الغالب
سائقالشاحنة
ناسُأ(أثناء العمل خارج اخرون)العمل عن المركبة توقف
الأعلم
9. Page | 9
1.2 RESULTS AND ANALYISIS
Evenour sample wasnotlarge enoughdue to the limitedcompaniesandfoundationswhichare
nearto us, we can say the following:
The majorityof companiesstatedthatit isveryimportantforthemto identifyexactlytheir
expenses onthe fuel consumption.
A significantnumberof the sample suffersfromuncertaintyinthe amountof itsfuel
consumption.
Some of the companiesare sure thatthere issome kindof fuel theftfromtheirvehicles.
Some of the companieshave alreadybought asystemtofindtrackthe fuel consumptionin
theirvehicles.
Some of the companiesmentionedthatthe fuel theftisperformedbypersonsnotfromthe
drivers.
To understandthe surveyoutputsee the figuresbellow.
Figures1.2-1 the survey results
10. Page | 10
As we expected,thisphenomenaispresentandneedtoa reliable andcost-effective solutionwhich
can calculate the fuel consumptionanddetectthe fuel theftif happened.
11. Page | 11
CH 2 Introduction
2.1 PROBLEM TO SOLVE
Due to the high fuel price, fuel theft became worrying phenomenon and it is very
important for companies and foundations to monitor its fuel consumption rate in order to put
its best budget.
According to the Palestinian distributing fuel stations the cost of one litter of diesel in
excess of 5.7 NIS (as of 12:00 a.m. April 29, 2013), so any storage of fuel can be a target for
theft as well as transportation vans. In our project we provide a smart electrical system to help
our client to deal with this problem and we aim to protect our clients from the fuel theft
especially the transportation vans and vehicles.
Our duty to stop the fuel theft so, before we start the smart fuel level detector idea, we set
some advice for the fuel consumers which can help to a void the fuel theft.
Consider installing a locking gas cap. Remember that many of the “fuel doors” that open
remotely or with a key are flimsy and easily compromised.
Avoid parking in dark, isolated areas (especially for extended periods).
At home, park in a locked garage where possible. If you don’t have a garage, park as
close as possible to the house and avoid parking on the street.
If you must park on a street or in a parking lot, attempt to locate your vehicle so the fuel
door is visible to you or other residents in your area.
If you have bulk fuel on your property, ensure you lock the tank and or dispenser to
prevent access.
Our fuel level detector continuously monitors your tank fuel with the ultrasonic fuel
detector, the easiest solution to prevent fuel theft and fraud.
Fuel theft: the moment our system tracks an unusual rate of decrease in the fuel-level (i.e.
in usual conditions, the vehicle consumes a certain amount of fuel; while in the theft case, the
rate of decrease of the fuel will be faster than the usual case) the fuel-tracker will send an
alarm via a GPRS module (may be a SMS) and can be automatically configured to ring an
audible alarm when the fuel theft occurs. The tracker is sensitive enough to detect when
someone tries to 'skim' excess fuel from a vehicles tank.
12. Page | 12
2.2 ABSTRACT
The level of the fuel, especially in cars and vehicles, is very important since it gives
indication about the remaining amount of fuel in the tank of the vehicle. However, particularly,
for the companies which have number of vehicles it is essential to monitor the fuel level at all
times in order to identify its budget and expenses also to capture the fuel theft.
The level measurement of fuel in the vehicle’s tank is a special case of general level
measuring applications because:
The flammability of the fuel, so it is very dangerous to put any electrical devices or
wires inside the fuel tank.
The very accurately closed tank, so it isn’t preferred to make holes other than the
main opening.
The dynamic motion of the fuel, which means that the measuring process must take
into consideration the road condition such that if the road is flat or has some slope
(either positive or negative).
In our project, we aim to design a smart fuel level measuring system which:
Measures the amount of fuel in the tank accurately and in real time.
Has the ability to measure the amount of fuel even if the vehicle is moving on a flat
or has some slope roads.
Can store the measurements in order to do some extra process such as consumption
rate per day or month … etc.
Can be configured with a microcontroller to send the measurements via GPRS.
Capture the fuel theft even if the vehicle is turned off!
Finally, our scope of work will be:
Specify which kind of sensors will be suitable for our requirements.
Make some data processing such as Filtering.
Store the measurements.
Capable to make data communication (GPRS).
Display the measurements as graphical representation.
Alarm in case of fuel theft.
13. Page | 13
2.3 METHODOLOGY
The methodology will be followed at this project is to:
Identify the elements of the project and the functionality of each one.
Identify the circumstances which presents in the environment surrounding the
project.
Find the best arrangement of the elements of the system in order to achieve the
best performance.
Find the best and safe way to take the measurements of the fuel.
Write the best code of the microcontroller to filter and process the sensor’s
measurement.
Connect the microcontroller to the GPRS module in order to send the measurements
to the site of the company.
14. Page | 14
2.4 ENVIRONMENT OF WORK
For the work environment there are many criteria that must be taken into consideration. If
we want to put the sensor on the surface of the tank we will be forced to make a suitable slot
to fix the sensor, for this reason it must be very careful because small arc will lead to huge
explosion. In addition of that, the large needed to speed and accurate transmission methods.
So in our project we have taken a lot of things in consideration, for example:
Chemical properties of the diesel.
Small dimensions of the sensor.
The temperature effect on the sensor reading.
A suitable sensor which works at low voltage.
Good transmission methods like GPRS and GSM.
All these things and more will make from our system as safe as possible.
15. Page | 15
CH 3 SOLUTION
3.1 FUEL MEASURMENT
3.1.1 THE FIRST PROPERSENSOR (HC-SR04)
In a large number of ultrasonic distance measurements, the operating principle is
the estimation of time of flight (ToF) Tf. The sensor generates ultrasonic pulses and
these pulses will be reflected to the receiver when it reaches the fuel surface as shown
in figure 3.1-1. So that the distance can be estimated directly by the formula:
V: represents the propagation velocity of the ultrasonic wave in the medium (air).
Figure 3.1-1 Ultrasonic principle
According to the previous equation we see that the distance depends directly on
the propagation velocity of the ultrasonic wave and this quantity depends on the
relative humidity and the temperature, and also on some chemical and physical
parameters of the fluid. More over the time of flight will control the measured
distance.
In the ultrasonic system two kinds of sensing are possible (1) :
The continuous wave method
The pulse echo method
In our project there are many things must be considered when we select the
sensor kind, so we saw the advantages and the disadvantages for both kind.
Let us start with the first type which is the continuous wave method. In this
method two separate transmitting and receiving elements are used, so that the level is
16. Page | 16
evaluated through the estimation of a phase shift. In this case good performance can
be obtained, but a more complex hardware system is necessary.
The pulse echo method, on the other hand, requires only one transducer that
operates alternately in transmitting and receiving method. Also pulse echo method
offers a simple and low cost solution, even it yields poorer results due to uncertainty
in the time delay measurement .These results, in fact, can be improved by using a
cheap software signal processing.
However, our HC-SR04 ultrasonic sensor is included under the continuous wave
method but with some modification which is instead of the output in the form of
phase shift it is here a PWM (pulse width modulation) such that the time of flight is
represented by the width of the echo signal from the ultrasonic.
The HC-SR04 (2) ultrasonic sensor as shown in figure 2.3-1 is small and
meets our requirements so as not to take large space on the tank.
As shown, it has four legs:
VCC: 5 volt
GND: zero volt (ground).
Trig: a 10us 5 volt pulse to start the sensor.
Echo: the output signal of the sensor.
Figure 3.1-2 The HC-SR04 ultrasonic sensor
Ultrasonic ranging module HC - SR04 provides (2cm - 400cm) non-contact
measurement function, the ranging accuracy can reach to 3mm. The module includes
ultrasonic transmitter, receiver and control circuit.
The basic principle of work, figure 3.1-2 clarifies this principle:
1- Using IO trigger for at least 10us high level signal.
2- The Module automatically sends eight 40 kHz and detect whether there is a
pulse signal back.
3- IF the signal back, through high level , time of high output IO duration is the time
from sending ultrasonic to returning.
4- Test distance = (high level time X velocity of sound (340 m/sec) / 2
17. Page | 17
Figure 3.1-3 The Principle of Work Ultrasonic Sensor
Timing diagram
Figure 3.1-4 Timing Diagram of the Ultrasonic Sensor
The Timing diagram is shown in figure 2.3-2. We only need to supply a short 10uS
pulse to the trigger input to start the ranging, and then the module will send out an 8
cycle burst of ultrasound at 40 kHz and raise its echo. The Echo is a distance object
that is pulse width and the range in proportion .We can calculate the range through
the time interval between sending trigger signal and receiving echo signal.
The formula to calculate the distance is:
uSec / 58 = centimeters
or uSec / 148 =inch
or the range = high level time * velocity (340 m/sec) / 2
It is recommended to use over 60ms measurement cycle, in order to prevent trigger
signal to the echo signal.
18. Page | 18
3.1.2 THE SECOND PROPERSENSOR(LSM303DLH)
Figure 3.1-5 The LSM303DLH slope sensor
Description:
The LSM303DLH is a system-in-package featuring a 3D digital linear acceleration sensor and a
3D digital magnetic sensor. The various sensing elements are manufactured using specialized
micromachining processes, while the IC interfaces are realized using a CMOS technology that
allows the design of a dedicated circuit which is trimmed to better match the sensing element
characteristics. The LSM303DLH includes an I2C serial bus interface that supports standard
mode (100 kHz) and fast mode (400 kHz).The system can be configured to generate an interrupt
signal by inertial wakeup/free-fall events, as well as by the position of the device itself.
Thresholds and timing of interrupt generators are programmable on the fly by the end user.
Magnetic and accelerometer parts can be enabled or put in power-down mode separately. The
LSM303DLH is available in a plastic land grid array (LGA) package, and is guaranteed to operate
over an extended temperature range from -30 to +85 °C. See the table below. (3)
Sensor Features
Analog supply voltage: 2.5V to 3.3V.
Digital supply voltage IOs:1.8V.
Power-down mode.
3 magnetic field channels and 3 acceleration channels.
16 bit data out.
I2C serial interface.
2 independent programmable interrupt generators for free-fall and motion
detection.
Embedded self-test.
Applications
Compensated compassing.
Map rotation.
Position detection.
19. Page | 19
Motion-activated function.
Free-fall detection.
Display orientation.
Vibration monitoring and compensation.
In our project, we used this sensor to determine the slope of the road so as to find the actual
fuel level even in the tilted roads this is due to the fact that most of our roads are tilted!
So we have derived an equation which relates the slope of the tank with the distance from the
Ultrasonic sensor to determine the fuel level as accurate as possible. However, the LSM303DLH
sensor communicates through the I2C protocol which is differ from the Ultrasonic which is
connected to the microcontroller directly, so we provide here some description of this protocol.
As for the coding of this sensor, it is attached in the appendix.
I2C serialinterface
I²C (Inter-Integrated Circuit, referred to as I-squared-C, I-two-C, or IIC) is a multimaster serial
single ended computer bus invented by Philips used for attaching low-speed peripherals to a
motherboard, embedded system, cell phone or other electronic device. At the low end of the
spectrum of communication options for "inside the box" communication is I2C .The name I2C is
shorthand for a standard Inter-IC (integrated circuit) bus.
I2C provides good support for communication with various slow, on-board peripheral devices
that are accessed intermittently, while being extremely modest in its hardware resource needs.
It is a simple, low-bandwidth, short-distance protocol. Most available I2C devices operate at
speeds up to 400Kbps, with some venturing up into the low megahertz range. I2C is easy to use
to link multiple devices together since it has a built-in addressing scheme. (4)
3.1.3 MICROCONTROLLER
All kinds of sensors need some device to process its readings and
measurements, so it’s common to find in such systems microcontrollers. The
common microcontrollers are PIC and ARDUINO. In our project we will use
the PIC microcontroller PIC16f877a which is shown in figure 3.1-5.
21. Page | 21
3.1.4 FILTERING & PROCESSING
After we did the survey we saw that there is a great importance to stop the fuel theft as
well as give accurate readings for the fuel level and in real time. As we said before, the
main function of our system to tracks an unusual rate of decrease in the fuel-level and we
said too the tracker is sensitive enough to detect when someone tries to 'skim' excess fuel
from a vehicles tank. After we stared the project we saw that there are two main
limitations to give an accurate reading in real time. Actually the two limitations are the
same but in different position and each one required special method to solve. The two
limitation leads to dynamic motion of the fuel. And because of the fuel inside the tank will
be dynamic, so it is important to take number of readings from the ultrasonic and then
make the filtering to it. We will perform the filtering process through the microcontroller
such that we will do averaging to these readings and take its average. Then we will
compare this reading of the fuel level with another reading after a specific time (this time
is determined from the vehicle itself according to its usual consumption rate of fuel) then
if the difference is greater than the usual consumption rate of fuel then a warning signal
will be sent to the GPRS module which in turn will send it to the appropriate address to
alarm for fuel theft. By the way, figure 2.1-4 shows a flow chart for our programed
microcontroller.
In this part we would like to explain the two limitations and what are the methods
which we used to solve these two limitations.
The first problem occurs when the vehicle is moving on a flat road but this
road has large Protrusions. See the figures bellow
22. Page | 22
To solve this problem it is important to take number of readings from the ultrasonic sensor
and then make the filtering to it. We will perform the filtering process through the
microcontroller such that we will do averaging to these readings and take its average.
To solve this problem we did a simple averaging for the values because the normal
decreasing of the fuel level is small and so no needed to make a complicated filtering. See
the below equation
Simple filtration equation
The second limitation occurs when the vehicle is moving on a road has some
slope (positive or negative) slope. See the figure bellow.
Actually we sit some alternatives to solve this problem for example
The first method is to considerate the consumption rate only by reading the fuel level at
specific time and then we will compare this reading of the fuel level with another reading
after a specific time to calculate the consumption rate according the below equation. If the
consumption rate is greater than the usual consumption rate of the vehicle, the
microcontroller will send an alarm signal to the database on the company. In this way we
can detect the fuel theft which the main function of our project. But the same time we lose
an important thing which is know the fuel level in real time and so we will face some error
in the fuel consumption.
The second method depends on both the fuel level and the consumption rate at the same
time, and here we ignore the first reading (the reading which make a large variation). In
this method we set a three probability.
1) Large change in both fuel level and consumption rate.
In this case we ensure that there is a fuel theft or some problem in the fuel tank, so the
microcontroller will send an alarm signal to the database on the company.
2) Large change in the fuel level and usual change in the consumption rate.
In this case we ensure that the vehicle is moving on a road has some slope (positive or
negative slope. And here the microcontroller will send an approximate fuel level
which equals the previous fuel level (from the microcontroller memory) minus the
consumption rate. In this method we give approximation readings, which is good
23. Page | 23
comparing with the other alternatives on the market. But at the same time we faced a
big problem in our country “Palestine” because a high percentage of the roads have a
large slope, and so this method become un valuable in some cases.
3) Small change on the fuel level and large change on the consumption rate.
In this case no probabilities and we ensure that there is a fuel theft from the fuel tank
and so, the microcontroller will send an alarm signal to the database on the company.
The last method is depending on the same principle of the second method, but here with
more accurate approximation.
In this method we make an experiment to compare between the measured level and the
slope of the fuel level to calculate the accurate “actual” level depending on the bellow
equation.
Where:
D: the actual distance between the ultrasonic sensor and the fuel level
D`: the measured distance between the ultrasonic sensor and the fuel level
:the road slope (the measured angle by LSM303DLH sensor)
However, we can configure and program the microcontroller to periodically send its
reading to the GPRS module in order to allow the company to monitor and save the
consumption of the fuel by its vehicle.
24. Page | 24
Figure 3.1-7 Flow Chart for the Microcontroller
3.2 TRANSMISSION OF DATA
3.2.1 GPRS MODULE
It is a device used to send data through the wireless communication networks; it
needs a SIM card related to the cellular network which provides this service.
Fortunately, the local cellular network provides this service with cheap cost. All what we
need is to provide each module with a SIM card and connect it to the microcontroller to
enable the GPRS module to send the measurements. By the way, the size of GPRS
modules is small as shown in figure 3.2-1 which is very suitable for our project.
Doesthe falling
edge arrived
from the echo
Measure the echo time from
the interrupt (rising edge)
Increment counter
YESNO
Return from interrupt
Delay (1 mSec) to
allow the echo to
interrupt
Divide the echo time by 58
to get the distance in cm
Convert from binary to
decimal
Send the reading
to the GPRS
START
Enable Capture mode of the
microcontroller
Trigger The Sensor (Pulse
for 10uS)
Measure the echo time from
the interrupt (rising edge)
25. Page | 25
Figure 3.2-1 GPRS module
3.2.2 INTERFACING BETWEENTHE GPRS AND THE CONTROLLER
PIC-GSM is excellent board for adding remote monitoring and control in remote
places by GSM cellular network or Ethernet or internet network. (5)
The GSM antenna is built in the board so no need for external expensive GSM
antennas. PIC-GSM have two inputs which could be connected to alarm sensors or just
buttons for user actions (like call pre-loaded phone numbers), on-board temperature
sensor up to 30 meter distance from the module. So we can connect the microcontroller
easily to it in order to achieve the communication between them.
3.2.3 TRANSMISSIONUSING GPRS MODULE
The readings of the sensor will be sent through the GPRS module to a web server in
order to store, process and display the fuel rate consumption for each vehicle to allow
the company to benefit as best as possible to identify its budget.
3.3 The Whole system
As an overall sight on our system, based on the circumstances mentioned in section 1.4, we
have designed our system such that:
The ultrasonic HC-SR04 will be fitted on the surface of the tank with small hole
(45X20 mm2) with insolating layer to isolate the connections from the fuel inside the
tank, this hole is required to let the ultrasonic waves propagates inside the tank to
measure the level of the fuel.
The four pins of the Ultrasonic HC-SR04 will be connected to the microcontroller.
The microcontroller and the GPRS module will be fitted inside the cabin of the
vehicle in order to facilitate the maintenance if required.
26. Page | 26
Finally, the needed power for the system will be fed from the battery of the vehicle and
since those component of the system is a very low power elements there will be no worry
about the consumed power from the battery of the vehicle.
27. Page | 27
CH 4 CONCLUSION ANDOBSERVATIONS
4.1 Experiment on the Sensor
At this part, we have tested the performance of the sensor in measuring the distances from
different objects.
As figures 4.1-1 to 4.1-4 show, the measured distance is displayed on an LCD with the object
is a rigid black body, from those pictures we can see that this sensor is very accurate with taking
into consideration that the object which we intend to measure its distance must be 2cm away
from the sensor as shown in the figures.
Figure 4.1-1: 12cm distance from a rigid body Figure 4.1-2: 16cm distance from a rigid body
Figure 4.1-3: 20cm distance from a rigid body Figure 4.1-4: 24cm distance from a rigid body
2cm
2cm12cm
20 cm 24 cm
16 cm
28. Page | 28
Also to ensure that the ultrasonic waves of this sensor don’t penetrate the surface of the
fuel we have performed this part to measure the distance between the sensor and the surface
of the water inside a container of water as shown in figure 4.1-5.
Figure 4.1-5: Test of the Sensor on Fluids
As drawnon the picture,the distance measuredbythe sensorisexactlythe distancebetweenthe
surface of the waterand the sensoras provedfromthe rulerinthe picture.
AS a result,we are nowsure that thissensorwill be able tomeasure exactlythe level of the fuel
inside the tankandthe ultrasonicwaveswon’tpenetrate the fuel.Finally,the remainingthingistodo
the filteringandgetthe propermeasurementwhenthe vehicleisinmotionona tiltedroad.
2c
m
5
cm
Heightof water
inside the container
Ultrasonic
Sensor
12 cm
17 cm
29. Page | 29
4.2 CONCLUSION
As a result of the high cost of the fuel, it is very essential for the companies – which have its
own transportation vehicles and vans- to identify and calculate its consumption and expenses
on the fuel so as to put their efficient and reliable budget.
Also, as we found from the survey, most of the local companies mentioned that it’s very
important for them to know as exact as possible their fuel consumption and expenses.
Moreover, we found there is a critical need for those companies to protect their vehicles from
the fuel theft whoever the thief.
From the need of our market in Palestine, we took the first step in our project and then
started to combine the main features of our system in order to meet the needs of those
companies and foundations. Our duty is to design a ‘smart’ system to mainly detect the fuel
theft in various conditions and secondly allow those companies and foundations to know
exactly their expenses on the fuel.
In the first part of our graduation project, we have studied the circumstances surrounding
the environment of the system and then identified the best and reliable components which will
be assembled and built in the next part of the graduation project in the next semester. The
main part is the sensor responsible to take the level of the fuel inside the tank and we have
chosen the Ultrasonic HC-SR04 sensor for that role, then we have selected the PIC16f877a
microcontroller to filter and process the Ultrasonic readings, finally we have preferred the
GPRS module to transmit the readings to the server of the company in order to store and
handle those readings as they want.
In the second part of our graduation project, we have built the system, combined the
sensors, added new elements like the LSM303DLH, derived mathematical equation to relate the
slope of the road with the fuel level, sent the readings to the microcontroller then through the
serial port to the computer.
One of the problems we faced was the lack and the high cost of the GPRS modules in our
market, as a result, we couldn’t perform the transmission using it, instead we have sent the
data using the serial port of the computer to a database to simulate the real database of the
target company.
Finally, based on our study in the electrical engineering department at an-Najah University,
we hope to design a valuable and useful system so as to contribute to solving one of the
30. Page | 30
problems which our companies face regarding the fuel theft and consumption, which – to some
extent- will help them to do their best in achieving their jobs as better as possible.
32. Page | 32
APPENDEX A.1: The Code of the PIC16f877a
We have written the code in the second part of the project using the PICC language as
follows:
The ultrasonic code:
#include <ultraTest.h>
#include <LCD.C>
#include <math.h>
#use fast_io(B)
int32 echo,timer1; // distancein binary
float height,area,volume;
#int_CCP1
void CCP1_isr(void)
{
set_timer1(0);
clear_interrupt(INT_CCP1);
}
#int_CCP2
void CCP2_isr(void)
{
echo =ccp_2;
clear_interrupt(INT_CCP2);
}
void trig() // triger thesensor by 10usec pulseon the triger pin RB#