Professional Documents
Culture Documents
Session: 2014-2018
Group Members:
DOST MUHAMMAD (REGISTRATION NO)
ABDUSSABOOR (REGISTRATION NO)
IZHAR AHMAD (REGISTRATION NO)
MUHAMMAD AYAZ (REGISTRATION NO)
Supervised by:
SUPERVISOR NAME
Engr. Iqbal Munir
GOVERNMENTCOLLEGE OF TECHNOLOGY
MINGORA AWAT
ABSTRACT
Nowadays bargaining the fare with the cab driver is an issue which mostly gets
unsuccessful as the cab driver demands a high fare which the client doesn’t want to give
and so the deal fails and sometimes exchange of harsh words occur. This all drama occurs
because there is not a proper channel of measuring a well and proper fare and no one has
even thought about this issue. We used to face such issues daily which led us to designing
a fuel consumption cost calculator in our final year project to get rid of this issue so we
prepared a prototype of the fuel cost calculator which could be installed in the cabs.
In our prototype we have used two flow rate sensors at the inlet and outlet of the engine
which are connected to the arduino. The readings of the inlet and outlet sensors are
registered on the LCD connected in the circuit to the arduino. Now when fuel is passé
through the sensors so four readings are displayed on LCD. One is inlet, the second is
outlet, third one is the consumption (difference between the inlet and outlet readings) and
the Trip readings (price of the fuel with the percentage multiplied).When this is installed
in the cabs it will automatically display the trip to the client and the issue will be solved.
i
APPROVAL CERTIFICATE
It is certified that the work presented in this thesis, entitle “DESIGN AND
FABRICATION OF FUEL COST CALCULATOR” was conducted by DOST
MUHAMMAD, IZHAR AHMAD, ABDUSSABOOR and AYAZ AHMAD under the
supervision of IQBAL MUNIR is hereby approved as partial fulfillment of the
requirement for the award of BTECH degree in ELECTRICAL.
Signature of Signature of
Supervisor Chairman
Signature of
External Examiner
ii
DEDICATION
Dedicated to our beloved parents and teachers who enabled us and gives us the
opportunity to achieve our goals and aims and to the whole Humanity as we had tried our
best to serve humanity through this project.
iii
ACKNOWLEDGEMENT
In the name of Allah, The most gracious, merciful, the most compassionate, the
One and only supreme power, the One who make everything possible, and the One
without Who’s will the simplest is impossible. We are thankful to our parents for their
prayers and support, as we could never have achieved this moment without them. We are
extremely grateful to our project supervisor IQBAL MUNIR for his guidance, support and
motivation we needed and also for the constructive criticism as it would have difficult to
complete this project without his support. It is also an honor for us to thank our
departmental staff for their support and encouragement during the course of our project.
Last but not least we are thankful to our well-wishers.
iv
TABLE OF CONTENTS
ABSTRACT........................................................................................................................i
APPROVAL CERTIFICATE..........................................................................................ii
DEDICATION..................................................................................................................iii
ACKNOWLEDGEMENT...............................................................................................iv
Chapter 1............................................................................................................................1
Introduction........................................................................................................................1
1. Fuel Cost Calculator........................................................................................................1
1.1.1 What is fuel cost calculator?...............................................................................1
1.1.2 Types of Fuel Cost Calculator............................................................................1
1.1.3 What’s new in this?............................................................................................1
1.2 Need of the Project....................................................................................................2
1.2.1 Online Cab Service.............................................................................................2
1.2.2 Maintenance of Vehicles....................................................................................3
1.2.3 Summary.............................................................................................................3
1.3 Aims and Objectives..................................................................................................4
1.3.1 Objectives...........................................................................................................4
1.4 Literature Review......................................................................................................4
1.4.1 YF-S201 Hall Effect Fuel Sensor.......................................................................4
1.4.2 Features...............................................................................................................5
1.4.3 Connection Details..............................................................................................6
1.4.4 Hall Effect Sensor...............................................................................................6
1.4.5 Working Principle...............................................................................................7
Chapter 2............................................................................................................................9
Methodology.......................................................................................................................9
2.1 Methodology..............................................................................................................9
2.2 Flow Chart.................................................................................................................9
2.3 Requirements...........................................................................................................10
2.4 Literature Review....................................................................................................11
2.4 Design of a Circuit...................................................................................................11
2.6 Coding/Programing..................................................................................................12
2.7 Flow Sensors............................................................................................................12
v
2.8 Fabrication and Analysis.........................................................................................13
2.9 Testing:....................................................................................................................13
2.9.1 Water Testing....................................................................................................13
2.9.2 Air Testing........................................................................................................13
Chapter 3..........................................................................................................................15
Hardware Description.....................................................................................................15
3.1 Project Pictures........................................................................................................15
3.2 Arduino UNO..........................................................................................................15
3.3 Arduino Software Development Environment........................................................22
3.4YF-S201 Hall Effect Water Flow Meter / Sensor....................................................23
3.4.2 Features.............................................................................................................23
3.4.3 Connection Details............................................................................................24
3.5 Liquid Crystal Display (LCD).................................................................................24
Important command codes for LCD..........................................................................28
3.6 Arduino 9V 1 Ampere Power Supply 220/110 Volt...............................................30
Product description........................................................................................................30
Product information.......................................................................................................31
Chapter 4..........................................................................................................................32
Design and Fabrication...................................................................................................32
4.1 Proteus Model..........................................................................................................32
4.2 Explanation of Flow Chart:.....................................................................................33
4.3 Software...................................................................................................................33
Chapter 5..........................................................................................................................41
Experimental Work.........................................................................................................41
5.1 Introduction..............................................................................................................41
5.2 Air Testing...............................................................................................................41
5.3 Testing of Prototype on Water.................................................................................41
5.4 Testing of Prototype on Bike...................................................................................42
5.5 Petrol Testing of Prototype......................................................................................42
Chapter 6..........................................................................................................................44
Conclusion and Future Works.......................................................................................44
6.1 Conclusion...............................................................................................................44
6.2 Future Works...........................................................................................................44
6.2.1 Diesel Engines..................................................................................................45
vi
6.2.2 Gas Engines......................................................................................................45
6.2.3 Sensor Selection................................................................................................45
6.2.4 Synchronization................................................................................................45
6.2.5 on Motor Bikes.................................................................................................46
vii
TABLE OF FIGURES
viii
Chapter 1
Introduction
1
1.1.3 What’s new in this?
The new thing which we added in this device is the global system for mobile
communication that is the GSM technology. As we know that in this era we need to have
all our data on the internet that it should be easily accessible every time and it should be
synchronized with the smartphone and we can easily check the demanded results anytime
and anywhere in the world. Basically our purpose was to serve the online cab services
that if they install this device in their cars they will not only get the fuel consumption but
the owner of the car can check how much and when fuel is consumed as the fuel
consumption record will automatically go to the server and that can be easily check from
any nearby internet source just you have to logon and then check that, secondly it can
also be checked on smartphone if we have that android application with us.
So what’s the benefit of keeping the internal record, the most prime advantage in
this is that, being an owner it is easy to keep check and balance on all rides if my vehicle
is running on any of the online cab services.
2
consumption of the car but are merely charged on the basis of distance travelled and
waiting time charges.
Secondly, if we only consider waiting charges, like if the vehicle is static so its
consuming some fuel but the new technology named as eco-idle has overcome this issue
as well and the max of new 660 CC cars have this technology by default even then we are
charged for this.
So, the basic need which we felt and which force us to design this project was to
convert the system of online cab services from charging on distance and time to charging
on the basis of fuel consumption. Secondly to make this a more friendly system for the
owner who is buying this because as its explained earlier that is very easy to use and we
can check the details everywhere and whenever we want to check. This will be easy for
the owner of the car to keep check and balance to avoid the losses.
3
1.2.3 Summary
Benefits of fuel consumption calculator and the need of this device for which we
made this was basically to serve the following some purposes.
Reduced rate for customers.
Justified earning for owners.
Less rate, more customers.
Proper maintenance overview of the vehicle.
Proper database and its synchronization with the internet and Android mobile
application.
1.3.1 Objectives
The first and foremost objective is to achieve a design for automobile that clearly indicate
the amount of fuel consumed in term of currency.
Secondly the design is such that its compatible plus it is less in cost and easily accessible.
The design is user friendly, so that the maintenance or changes to be performed are easy
and less costly.
This device efficiently reduced the cost of online cab services for the customer and in
turn will provide justified profit for the owner of the car.
Design is having a database which keeps records of the trips and thus can help us in
going preventive maintenance when required.
Design is able to show amount of fuel consumed in monetary terms as well as the
remaining amount of fuel in tank.
4
1.4 Literature Review
1.4.1 YF-S201 Hall Effect Fuel Sensor
This sensor sits in line with your water line and contains a pinwheel sensor to
measure how much liquid has moved through it. There's an integrated magnetic Hall
Effect sensor that outputs an electrical pulse with every revolution. The Hall Effect
sensor is sealed from the water pipe and allows the sensor to stay safe and dry.
The sensor comes with three wires: red (5-24VDC power), black (ground) and
yellow (Hall Effect pulse output). By counting the pulses from the output of the sensor,
you can easily calculate water flow. Each pulse is approximately 2.25 milliliters. Note
this isn't a precision sensor, and the pulse rate does vary a bit depending on the flow rate,
fluid pressure and sensor orientation. It will need careful calibration if better than 10%
precision is required. However, it’s great for basic measurement tasks!
We have as example Arduino sketch that can be used to quickly test the sensor, it
will calculate the approximate flow of water in liters/hour.
The pulse signal is a simple square wave so it’s quite easy to log and convert into
liters per minute using the following formula.
1.4.2 Features
Model: YF-S201
Sensor Type: Hall effect
Working Voltage: 5 to 18V DC (min tested working voltage 4.5V)
Max current draw: 15mA @ 5V
Output Type: 5V TTL
Working Flow Rate: 1 to 30 Liters/Minute
Working Temperature range: -25 to +80℃
Working Humidity Range: 35%-80% RH
Accuracy: ±10%
5
Maximum water pressure: 2.0 MPa
Output duty cycle: 50% +-10%
Output rise time: 0.04us
Output fall time: 0.18us
Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)
Pulses per Liter: 450
Durability: minimum 300,000 cycles
Cable length: 15cm
1/2" nominal pipe connections, 0.78" outer diameter, 1/2" of thread
Size: 2.5" x 1.4" x 1.4"
Red wire : +5V
Black wire : GND
Yellow wire: PWM output.
6
1.4.4 Hall Effect Sensor
A Hall Effect sensor is a transducer that varies its output voltage in response to
a magnetic field. Hall Effect sensors are used for proximity switching, positioning,
speed detection, and current sensing applications.
In a Hall Effect sensor, a thin strip of metal has a current applied along it. In the
presence of a magnetic field, the electrons in the metal strip are deflected toward one
edge, producing a voltage gradient across the short side of the strip (perpendicular to
the feed current). Hall Effect sensors have an advantage over inductive sensors in
that, while inductive sensors respond to a changing magnetic field which induces
current in a coil of wire and produces voltage at its output, Hall Effect sensors can
detect static (non-changing) magnetic fields.
Hall sensors are commonly used to time the speed of wheels and shafts, such as
for internal combustion engine ignition timing, tachometers and anti-lock braking
systems. They are used in brushless DC electric motors to detect the position of the
permanent magnet. In the pictured wheel with two equally spaced magnets, the
voltage from the sensor will peak twice for each revolution. This arrangement is
commonly used to regulate the speed of disk drives.
7
1.4.5 Working Principle
This illustration gives detailed working method of hall effect sensor based water
flow sensor, a turbine wheel embed with magnet is placed on a closed plastic envelope
and a Hall effect sensor placed, When the water flows through the pipeline, it makes the
turbine wheel to rotate and hence the magnet flux interferes the hall sensor, the rate
of interference is depends on the speed of water flow, so the hall effect sensor produce
pulse signal output, this pulse output can be calculated as water volume.
8
Chapter 2
Methodology
2.1 Methodology
Our approach towards achievement of our goals was just simple. We achieve
them by setting some small objectives and then the combinations of all these lead us to
the compilation of our project. Although it was a tough task to achieve the set goals on
the specified time, but we did that. Figure below shows the flowchart of our approach
towards this project, this may vary from person to person.
Requirements
(Design Conditions)
Literature Review
Designing of Circuit
Coding/Programing
Fabrication and
Analysis
Testing
9
2.3 Requirements
This is the first and foremost step in our project's methodology which is stated as
requirements or design conditions for the accomplishment of our project. Firstly we
wanted to design a fuel cost calculator so for that the most important was the sensor
requirement, then the requirement was that which type of sensor it should be. As we had
to measure the flow rate of the fuel flowing from tank to engine and then to convert that
with the help of pulses and electric wires and transfer that signal to aurdino which is
coded as such that it show us the cost of trip by simply multiplying the cost which is
coded with the milliliters of fuel used. So the first requirement was to have flow rate
sensor which must have easy connection with the aurdino so that it should transfer signals
of the flowrate measured easily to the aurdino. Secondly the requirement of the sensor
was also to fulfill the design requirements of the engine we selected that is the line size
etc.
The second requirement was the arduino selection which arduino microcontroller
we should select which can also serve our purpose easily and should not require that
much of space. Normally arduino UNO is available in the market but its size is too much
so we selected the arduino Nano which served our purpose and was comparatively small
in size so was very much suitable for us.
The third requirement with us was the selection of engine that, which engine
should we consider for our experiments so for that purpose the car was unavailable and
that was also not justified economically so we choose to have a 70 cc engine is that was a
cheap rates as compared to that of car, and we selected as 70cc engine for our Analysis,
on which we later failed to perform this because of the limitations discussed in later
chapters.
The fourth requirement was the selection of software for the design purpose, by
the term design in this I mean to say the design of a circuit and for that we had to choose
a software which is more user friendly and easy to use for us. So, we preferred to use
proteus for the design of our circuit.
Above we discussed some of the basic and major requirements or design
considerations for our project which fully explains the first step of our methodology for
the accomplishment of this project.
10
2.4 Literature Review
The second step in our project was the literature review of our project and mostly
of the hardware we are using in this project. Firstly the main thing was to check the
working principle of that flow sensor like on which principle that sensor is working and
would that serve our purpose or not. The second step was to check the details
specification of the sensor for example what is its line size, what is the working pressure,
working temperature range and working flow range etc.
Secondly we also had a detailed study about the arduino microcontroller that what
are the available types of this type of microcontroller available in the market and what is
the most suitable for us both economically and size wise because we needed the one
which is small in size and weight to have a minimum size of that.
While Literature review related to this project was not available as such as it was
fully a new idea which just came to our mind while travelling in an online cab service. So
we decided to work on it and make a device which can be installed to calculate and give
result in terms of currency of the fuel used in that.
11
Figure 3 Design of a Circuit
2.6 Coding/Programing
Actually our whole project is based on the programming and this is the actually
the main thing which took all of our time because we have two aurdinos installed in the
circuit to serve two different purposes. Each of the aurdino, its coding was a really hectic
task to fulfill so that why this step is the backbone of our project.
12
2.8 Fabrication and Analysis
This step include the fabrication of the designed circuit along with the coded
aurdino, so that to check whether the circuit and the code is running properly or not. The
methodology in this step was first to properly check the circuit its connections with the
battery and all the connections. To check the code which is burned in the aurdino that
whether it is working properly or not.
Fabrication also include the connections of the sensors on the respective pipes that
is the inlet pipe to the engine and the exit pipe to the engine. Inlet sensor is fitted in the
pipe coming from the petrol tank towards the engine and the exit sensor is installed on the
pipe which is carrying the unburnt, like we actually did not connected these pipes to the
engine but we made a prototype to demonstrate.
Analysis of this circuit and coding was done on the basis of the water flow firstly,
there were errors at first but then we removed them to maximum limit. After this we
tested this fabricated circuit on a 70cc bike engine, but due to limitations discussed in
later chapters we were not able to perform that on a 70cc engine.
This step, fabrication and analysis, lead us to the final testing our project, in this
we tested for all possible solutions the one which is left is the petrol engine of the car.
2.9 Testing:
The first step in testing is water testing, as the circuit was ready the most easy
thing available for us and for test was water testing to check the flow rate measured by
sensor is giving us the correct reading or not.so firstly we check it on water and our
reading of water flow were accurate with a little bit of errors. The amount of fuel
measured by the sensor was according to the reading of water we measured manually.
The second test of a testing process was of air is the sensor contain a pinwheel
and due to rotation of that wheel we could easily measure That Flow rate of the fluid
13
flowing.as we know that air is also a fluid and this sensor is designed for fluid so to check
the readings of the sensor on air was also a mandatory and we got good results a little bit
of errors.
14
Chapter 3
Hardware Description
"Uno" means one in Italian and was chosen to mark the release of
Arduino Software (IDE) 1.0. The Uno board and version 1.0 of Arduino
Software (IDE) were the reference versions of Arduino, now evolved to newer
releases. The Uno board is the first in a series of USB Arduino boards, and the
reference model for the Arduino platform; for an extensive list of current, past
or outdated boards see the Arduino index of boards.
Microcontroller ATmega328P
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limit) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
15
PWM Digital I/O Pins 6
Analog Input Pins 6
DC Current per I/O Pin 20 mA
DC Current for 3.3V Pin 50 mA
32 KB (ATmega328P) of which 0.5 KB
Flash Memory
used by boot loader
SRAM 2 KB (ATmega328P)
EEPROM 1 KB (ATmega328P)
Clock Speed 16 MHz
LED_BUILTIN 13
Length 68.6 mm
Width 53.4 mm
Weight 25 g
Programming
You can also bypass the bootloader and program the microcontroller
through the ICSP (In-Circuit Serial Programming) header using Arduino ISP or
similar; see these instructions for details.
The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source
code is available in the Arduino repository. The ATmega16U2/8U2 is loaded
with a DFU bootloader, which can be activated by:
16
On Rev1 boards: connecting the solder jumper on the back of the board (near the
map of Italy) and then rese ing the 8U2.
On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line
to ground, making it easier to put into DFU mode.
Warnings
The Arduino Uno has a resettable polyfuse that protects your computer's
USB ports from shorts and overcurrent. Although most computers provide their
own internal protection, the fuse provides an extra layer of protection. If more
than 500 mA is applied to the USB port, the fuse will automatically break the
connection until the short or overload is removed.
The Uno differs from all preceding boards in that it does not use the
FTDI USB-to-serial driver chip. Instead, it features the Atmega16U2
(Atmega8U2 up to version R2) programmed as a USB-to-serial converter.
Power
The Arduino Uno board can be powered via the USB connection or with
an external power supply. The power source is selected automatically.
17
The board can operate on an external supply from 6 to 20 volts. If
supplied with less than 7V, however, the 5V pin may supply less than five volts
and the board may become unstable. If using more than 12V, the voltage
regulator may overheat and damage the board. The recommended range is 7 to
12 volts.
Vin. The input voltage to the Arduino/Genuino board when it's using an external
power source (as opposed to 5 volts from the USB connection or other regulated
power source). You can supply voltage through this pin, or, if supplying voltage
via the power jack, access it through this pin.
5V.This pin outputs a regulated 5V from the regulator on the board. The board
can be supplied with power either from the DC power jack (7 - 12V), the USB
connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the
5V or 3.3V pins bypasses the regulator, and can damage your board. We don't
advise it.
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.
IOREF. This pin on the Arduino/Genuino board provides the voltage reference
with which the microcontroller operates. A properly configured shield can read
the IOREF pin voltage and select the appropriate power source or enable voltage
translators on the outputs to work with the 5V or 3.3V.
Memory
18
Input and Output
See the mapping between Arduino pins and ATmega328P ports. The
mapping for the Atmega8, 168, and 328 is identical.
Each of the 14 digital pins on the Uno can be used as an input or output,
using pinMode(),digitalWrite(), and digitalRead() functions. They operate at 5
volts. Each pin can provide or receive 20 mA as recommended operating
condition and has an internal pull-up resistor (disconnected by default) of 20-
50k ohm. A maximum of 40mA is the value that must not be exceeded on any
I/O pin to avoid permanent damage to the microcontroller.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite()
function.
LED: 13. There is a built-in LED driven by digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it's off.
TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the
Wire library.
The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10
bits of resolution (i.e. 1024 different values). By default they measure from
19
ground to 5 volts, though is it possible to change the upper end of their range
using the AREF pin and the analogReference() function. There are a couple of
other pins on the board:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a
reset button to shields which block the one on the board.
Communication
The ATmega328 also supports I2C (TWI) and SPI communication. The
Arduino Software (IDE) includes a Wire library to simplify use of the I2C bus;
see the documentation for details. For SPI communication, use the SPI library.
20
control lines (DTR) of the ATmega8U2/16U2 is connected to the reset line of
the ATmega328 via a 100 nanofarad capacitor. When this line is asserted (taken
low), the reset line drops long enough to reset the chip. The Arduino Software
(IDE) uses this capability to allow you to upload code by simply pressing the
upload button in the interface toolbar. This means that the bootloader can have a
shorter timeout, as the lowering of DTR can be well-coordinated with the start
of the upload.
This setup has other implications. When the Uno is connected to either a
computer running Mac OS X or Linux, it resets each time a connection is made
to it from software (via USB). For the following half-second or so, the
bootloader is running on the Uno. While it is programmed to ignore malformed
data (i.e. anything besides an upload of new code), it will intercept the first few
bytes of data sent to the board after a connection is opened. If a sketch running
on the board receives one-time configuration or other data when it first starts,
make sure that the software with which it communicates waits a second after
opening the connection and before sending this data.
The Uno board contains a trace that can be cut to disable the auto-reset.
The pads on either side of the trace can be soldered together to re-enable it. It's
labeled "RESET-EN". You may also be able to disable the auto-reset by
connecting a 110 ohm resistor from 5V to the reset line; see this forum
thread for details.
Revisions
1.0 pinout: added SDA and SCL pins that are near to the AREF pin and two
other new pins placed near to the RESET pin, the IOREF that allow the shields
to adapt to the voltage provided from the board. In future, shields will be
compatible with both the board that uses the AVR, which operates with 5V and
21
with the Arduino Due that operates with 3.3V. The second one is a not
connected pin, that is reserved for future purposes.
22
Figure 4 IDE of Aurdino
The sensor comes with three wires: red (5-24VDC power), black (ground) and
yellow (Hall effect pulse output). By counting the pulses from the output of the sensor,
you can easily calculate water flow. Each pulse is approximately 2.25 milliliters. Note
this isn't a precision sensor, and the pulse rate does vary a bit depending on the flow rate,
fluid pressure and sensor orientation. It will need careful calibration if better than 10%
precision is required. However, its great for basic measurement tasks!
23
We have as example Arduino sketch that can be used to quickly test the sensor, it
will calculate the approximate flow of water in liters/hour.
The pulse signal is a simple square wave so it’s quite easy to log and convert into
liters per minute using the following formula.
3.4.2 Features
Model: YF-S201
Sensor Type: Hall effect
Working Voltage: 5 to 18V DC (min tested working voltage 4.5V)
Max current draw: 15mA @ 5V
Output Type: 5V TTL
Working Flow Rate: 1 to 30 Liters/Minute
Working Temperature range: -25 to +80℃
Working Humidity Range: 35%-80% RH
Accuracy: ±10%
Maximum water pressure: 2.0 MPa
Output duty cycle: 50% +-10%
Output rise time: 0.04us
Output fall time: 0.18us
Flow rate pulse characteristics: Frequency (Hz) = 7.5 * Flow rate (L/min)
Pulses per Liter: 450
Durability: minimum 300,000 cycles
Cable length: 15cm
1/2" nominal pipe connections, 0.78" outer diameter, 1/2" of thread
Size: 2.5" x 1.4" x 1.4"
Red wire : +5V
Black wire : GND
24
Yellow wire: PWM output.
Pin
Function Name
No
25
Supply voltage; 5V (4.7V – 5.3V) Vcc
2
Selects command register when low, and data register when RS (Register
4
high Select )
5 Low to write to the register; High to read from the register Read/write
Sends data to data pins when a high to low pulse is given; Extra
voltage push is required to execute the instruction and
EN(enable) signal is used for this purpose. Usually, we make it
6 Enable
en=0 and when we want to execute the instruction we make it
high en=1 for some milli seconds. After this we again make it
ground that is, en=0.
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
26
16 Backlight Ground (0V) Led-
RS (Register select)
A 16X2 LCD has two registers, namely, command and data. The register select is used to
switch from one register to other. RS=0 for command register, whereas RS=1 for data
register.
27
Data Register: The data register stores the data to be displayed on the LCD. The data
is the ASCII value of the character to be displayed on the LCD. When we send data to
LCD it goes to the data register and is processed there. When RS=1, data register is
selected.
2 02 Return home
28
12 10 Shift cursor position to left
29
In the table above you can see starting addresses for each character with their
printing commands. The first character is generated at address 0x40 to 0x47 and is
printed on LCD by just sending simple command 0 to the LCD. The second character is
generated at address 0x48 to 0x55 and is printed by sending 1 to LCD.
2-flat-pin plug
110V input voltage
9V 1A output voltage
Connector size: 5.5 x 2.1mm
Center or Tip is positive, sleeve is negative
Product description
High quality switching 'wall wart' AC to DC 9V 1000mA wall power supply
manufactured specifically for Electronics. The output is Center/Tip positive
30
5.5mmx2.1mm connector. These are switch mode power supplies which mean the
output is regulated to 9V and the capable output current is much higher (1000mA!).
These will power most projects that don't require more than 1000mA of current.
Dimensions: 2.91 in x 1.57 in x 1.06 in (7.40 cm x 4.00 cm x 2.70 cm) Weight: 2.54 oz
(72 g),
Product information
ASIN B018OLREG4
31
Chapter 4
Design and Fabrication
32
4.1 Flow Chart
Engine
Consumption=
S1-S2
A(ml) T (Rs)
C(ml) R (ml)
33
4.3 Software
#include <LiquidCrystal.h>
LiquidCrystallcd(4,5,6,7,8,9);
bytestatusLed = 13;
// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
floatcalibrationFactor = 5.5;
floatflowRate;
unsignedintflowMilliLitres;
unsigned long totalMilliLitres;
//////////////////22222222222222222222
// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
float calibrationFactor2 = 9.5;
34
float flowRate2;
unsignedint flowMilliLitres2;
unsigned long totalMilliLitres2;
intremaining_Lt=0;
void setup()
{
lcd.setCursor(3,0);
lcd.print("FUEL COST");
lcd.setCursor(3,1);
lcd.print("CALCULATOR");
delay(3000);
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pinMode(sensorPin2, INPUT);
digitalWrite(sensorPin2, HIGH);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
35
// The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
// Configured to trigger on a FALLING state change (transition from HIGH
// state to LOW state)
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
pulseCount2 = 0;
flowRate2 = 0.0;
flowMilliLitres2 = 0;
totalMilliLitres2 = 0;
oldTime2 = 0;
/**
* Main program loop
*/
void loop()
{
remaining_Lt=totalMilliLitres-totalMilliLitres2;
lcd.setCursor(0,0);
lcd.print("A:");
lcd.print(totalMilliLitres);
lcd.print(" ");
lcd.setCursor(8,0);
lcd.print("T:");
36
lcd.print(totalMilliLitres2*0.093);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("C:");
lcd.print(totalMilliLitres2);
lcd.print(" ");
lcd.setCursor(8,1);
lcd.print("R:");
lcd.print(remaining_Lt);
lcd.print(" ");
if((millis() - oldTime) > 1000) // Only process counters once per second
{
// Disable the interrupt while calculating flow rate and sending the value to
// the host
detachInterrupt(sensorInterrupt);
// Because this loop may not complete in exactly 1 second intervals we calculate
// the number of milliseconds that have passed since the last execution and use
// that to scale the output. We also apply the calibrationFactor to scale the output
// based on the number of pulses per second per units of measure (litres/minute in
// this case) coming from the sensor.
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
// Note the time this processing pass was executed. Note that because we've
// disabled interrupts the millis() function won't actually be incrementing right
// at this point, but it will still return the value it was set to just before
// interrupts went away.
oldTime = millis();
37
// Divide the flow rate in litres/minute by 60 to determine how many litres have
// passed through the sensor in this 1 second interval, then multiply by 1000 to
// convert to millilitres.
flowMilliLitres = (flowRate / 60) * 1000;
unsignedintfrac;
// Enable the interrupt again now that we've finished sending output
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
38
if((millis() - oldTime2) > 1000) // Only process counters once per second
{
// Disable the interrupt while calculating flow rate and sending the value to
// the host
detachInterrupt(sensorInterrupt2);
// Because this loop may not complete in exactly 1 second intervals we calculate
// the number of milliseconds that have passed since the last execution and use
// that to scale the output. We also apply the calibrationFactor to scale the output
// based on the number of pulses per second per units of measure (litres/minute in
// this case) coming from the sensor.
flowRate2 = ((1000.0 / (millis() - oldTime2)) * pulseCount2) / calibrationFactor;
// Note the time this processing pass was executed. Note that because we've
// disabled interrupts the millis() function won't actually be incrementing right
// at this point, but it will still return the value it was set to just before
// interrupts went away.
oldTime2 = millis();
// Divide the flow rate in litres/minute by 60 to determine how many litres have
// passed through the sensor in this 1 second interval, then multiply by 1000 to
// convert to millilitres.
flowMilliLitres2 = (flowRate2 / 60) * 1000;
unsignedint frac2;
39
Serial.print("Flow rate2: ");
Serial.print(int(flowRate2)); // Print the integer part of the variable
Serial.print("L/min");
Serial.print("\t"); // Print tab space
// Enable the interrupt again now that we've finished sending output
attachInterrupt(sensorInterrupt2, pulseCounter2, FALLING);
}
}
/*
Insterrupt Service Routine
*/
voidpulseCounter()
{
// Increment the pulse counter
pulseCount++;
}
void pulseCounter2()
{
// Increment the pulse counter
40
pulseCount2++;}
Chapter 5
Experimental Work
5.1 Introduction
In this chapter we will study about the working of our project. We have
done some test on our prototype and it is done on three different fluids including
air, water and petrol to check its readings. The first test was very random i.e.
blowing air through sensors. It gave us the idea that the prototype is ready to
check on other fluids. Calibration factor for different fluids were used hit and
trials method. Prototype was also tested on bike using only one sensor i.e. at tank
outlet. Different tests and their results are given below.
41
2. 595 100 495 600 98 293 99
3. 251 150 101 250 148 56 20
4. 99 40 59 100 41 56 12
5.3bError
S.No Inlet Error Outlet Error Consumed Total Error Min & Max
Error Error
1. 4 2 1 7 (4-9)ml
2. 5 2 2 9 (5-10)ml
3. 1 2 1 4 (1-4)ml
4. 1 1 1 3 (1-4)ml
42
3. 99 50 49 100 49 52 10
4. 48 25 23 50 27 22 5
5.5bError
S.No Inlet Error Outlet Error Consumed Total Error Min & Max
Error Error
1. 8 0 2 10% (4-10)ml
2. 2 0 2 4% (4-10)ml
3. 1 1 2 4% (4-10)ml
4. 2 2 1 5% (4-10)ml
43
Chapter 6
Conclusion and Future Works
6.1 Conclusion
The aim of this project was to design a calculator which could calculate
cost of consumption of fuel. It means that the amount of fuel consumed by the
engine will result in the cost calculation so that a well measured fare is charged
from the client. It is designed in such a way that two sensors are connected on
both the incoming and outgoing of the engine. The sensors are connected to an
Arduino. The Arduino are programmed which shows the amount of fuel
consumed. This done by finding the difference between the fuels passed from the
two sensors i.e. the inlet and outlet sensors. The Arduino is programmed in such a
way that it simultaneously shows the inlet reading, the outlet reading, the
difference between inlet and outlet reading which is the actual the fuel
consumption and the cost of fuel consumed. The reading noted by the arduino is
then registered on the LED connected to the arduino. The idea of the project was
conceived by the passengers. The hash conversation often seen between
passengers and cabs driver and the bargaining of both are disturb therefore to get
actual value of money we set the consumption cost calculators so that issue
related to bargaining of fare can be resolved.
44
Therefore in order to save the precious time of the passengers and avoid unnecessary
bargaining these calculators can be installed in the cabs with the help of ministry of
transport.
45
to which it bring changes in the reading .so some future work on the sensors to
make the reading accurate. Future works regarding sensors are
Less Vibration effect
We should choose such type of sensors which do not sense less vibration due to the error
are less and the reading most accurate.
Installation
Sensors are installed in the engine and tight well that is there should not be any vibration
plus you should take care of the horizontal and vertical positions of the sensors connected
in engine.
6.2.4 Synchronization
All the calculators installed in the cars should have a data base such that it
could be synchronized simultaneously. Mostly in Pakistan the prices of fuel
changes so we must have a data base from which could change the prices of the
calculators installed in the cars at a same time like we change the price in the data
base so it should be applied to all the calculators installed at the same time
46