Anda di halaman 1dari 53

Declaration

I declare that this B.Sc. thesis is my original work, also the work in this thesis was carried out in
accordance with the regulations of Addis Ababa University (AAiT) and has not been presented
for fulfillment of a degree in this or the other University, and all sources and materials used for
this project have been acknowledged.
Acknowledgment
I take this opportunity to express my profound sense of gratitude and respect to all those who
helped me through the duration of this project work. First of all I express my profound gratitude
to the Almighty God, who gave me the opportunity, strength and support without his help this
task could have never been accomplished.

I am indebted to my Advisor, Zelalem Berehanu, Instructor at AAiT Department of Electrical


and Computer Engineering, for giving me an opportunity to work under his guidance. Like a true
mentor, he motivated and inspired me throughout the entire duration of my work. I also extend
my thanks to the supportive staff of ECE, Addis Ababa Institute of technology for providing me
all the necessary facilities to accomplish this project.

My greatest thanks are to my parents who bestowed ability and strength in me to complete this
work. I would also take this opportunity to express my gratitude and sincere thanks to
my brother Mr. Eyasu Yohannis his friend Mr. Abel and Dave Tiruneh for their valuable support
throughout the whole project. Last but not the least; I am also thankful to all 502B Dorm mates
and my friends for their encouragement and help
Contents
Acknowledgment .......................................................................................................................... II
Table of figures............................................................................................................................. V
Abstract ........................................................................................................................................ VI
Chapter One .................................................................................................................................. 1
Introduction ................................................................................................................................... 1
1.1. What is a taximeter? ......................................................................................................... 1
1.2. Current situation ............................................................................................................... 1
1.3. Problem statements .......................................................................................................... 1
1.4. Objectives ......................................................................................................................... 2
1.5. Significance of the project................................................................................................ 2
1.6. Scope of the project .......................................................................................................... 2
1.7. Methodology .................................................................................................................... 3
Chapter Two .................................................................................................................................. 4
Literature Review ......................................................................................................................... 4
2.1 Mechanical taximeters........................................................................................................... 5
2.2. Microprocessor taximeters ................................................................................................... 6
2.3. Microcontroller taximeters ................................................................................................... 6
2.4. Infrared Sensor ..................................................................................................................... 7
2.4.1. Operation of infrared sensor .......................................................................................... 7
2.5. Microcontroller..................................................................................................................... 9
2.5.1. ATmega32 Microcontroller Futures ............................................................................ 11
2.5.2. Pin Descriptions of ATmega32 ................................................................................... 13
2.6. Liquid Crystal Display (LCD)............................................................................................ 14
2.7. Odometer ............................................................................................................................ 14
2.8. Interrupts ............................................................................................................................ 15
Chapter Three ............................................................................................................................. 16
Design Methodology.................................................................................................................... 16
3.1. System Modeling................................................................................................................ 16
3.1.1. System Requirements .................................................................................................. 16
3.1.2. Block Diagram of the System ...................................................................................... 16
3.1.3. System flow chart ........................................................................................................ 18
3.2. Components selection ........................................................................................................ 19
3.2.1. Pushbutton switch ........................................................................................................ 19
3.2.2. ATmega32 ................................................................................................................... 19
3.2.3. JHD162A Display........................................................................................................ 20
3.3. Device configuration .......................................................................................................... 21
3.3.1. Interrupt Configuration: ............................................................................................... 21
3.3.2. Timer Subsystem: ........................................................................................................ 22
3.3.3. Timer0 Register Set: .................................................................................................... 22
3.3.4 Timer/Counter Control Register 0(TCCR0): ................................................................ 23
3.3.5 Timer/Counter Register 0 (TCNT0): ............................................................................ 24
Chapter four ................................................................................................................................ 27
Simulation and Implementation ................................................................................................ 27
4.1. Main program thread .......................................................................................................... 28
4.1.1 Initialization .................................................................................................................. 28
4.1.2 Update LCD display ..................................................................................................... 28
4.1.3. Distance cost ISR thread.............................................................................................. 29
4.1.4. Time cost ISR thread ................................................................................................... 29
4.2. Testing of ATMega32 ........................................................................................................ 29
4.3. Programming ...................................................................................................................... 30
4.4. System simulation .............................................................................................................. 30
4.5. Hardware Implementation .................................................................................................. 34
4.5.1. Mechanical Specifications ........................................................................................... 34
Chapter five ................................................................................................................................. 35
Result and Discussion ................................................................................................................. 35
Chapter six ................................................................................................................................... 36
Conclusion and Recommendation ............................................................................................. 36
Reference ..................................................................................................................................... 38
Appendix I: Source code ............................................................................................................ 39
Appendix II: Project costs .......................................................................................................... 47
Table of figures
Figure2.1:- Typical Tx/Rx ______________________________________________________ 7
Figure 2.2. A typical Transmitter circuit ___________________________________________ 7
Figure2.3: Tx - Rx Pair Circuitry _________________________________________________ 8
Figure2.4: Direct line of sight ____________________________________________________ 9
Figure 2.5: No line of sight ______________________________________________________ 9
Figure2.7:- ATMega32 PIN configuration _________________________________________ 12
Figure2.8: Atmega 32 microcontroller ____________________________________________ 12
Figure3.1: Block diagram of the system ___________________________________________ 17
Figure3.2. System Flow Chart __________________________________________________ 18
Figure3.3: Timer0 Registers ____________________________________________________ 23
Figure3.4. TCCR0 Register configuration _________________________________________ 24
Figure3.5: Modes of operation of Timer0__________________________________________ 25
Figure4.1: A sample of IDE windows ____________________________________________ 30
Figure 4.2: Shows the system is waiting to set cost per 100meter _______________________ 32
Figure4.3: Taxicab billing ______________________________________________________ 32
Figure4.4: Display bill ________________________________________________________ 33
Figure4.5: system working as Speedometer ________________________________________ 33
Figure 4.6: The positioning of the sensor on the wheel Axle [Drawn by solid work software] _ 34
Figure5.1. System prototype when functioning _____________________________________ 35
Abstract

Within our modern day towns and cities in Ethiopia, taxicabs are a common means of
transportation, but the billing of the taxicabs is currently done through negotiation between the
taxicab driver and a prospective customer. This situation can lead into several inconveniences to
both the taxicab driver and the customer. This design project proposes a prototype
microcontroller based system that will enable to implement a computerized billing mechanism to
be used to automate the billing in taxi cabs. In this design an external wheel revolution sensor is
used to generate an interrupt to a microcontroller each time the wheels make a single revolution;
and from this interrupt, distance travelled is deduced by using wheel dimensions
(circumference). Also time duration of the journey is obtained from an internal timer in the
microcontroller which is set to overflow after every one seconds; and from this interrupt, hiring
time of the journey is obtained for billing purposes. Then finally, the microcontroller by using
the predetermined billing rate which is based on parameters of cost per 100metres distance and
cost per 1minute time of the journey, calculates the cost (in birr) incurred by the customer and
displays it on an LCD screen. Also in some cases if the driver need a digital speedometer this
system can serve as a digital speedometer as well.
Distance Based Digital Taxi Service Charge Payment System

Chapter One
Introduction
Microcontroller based taxi billing system is a computerized electronic billing system for rented
personal transportation services of a taxicab, which are commonly found within our modern day
towns and cities as one of transportation means. Microcontrollers are virtually everywhere in our
modern society such that they can be found in practically every digital electronic device that
furnishes an independent functionality to its user be it at home, industry or office. For example
we can find microcontrollers in our televisions, fridges, microwave ovens, personal computers
and printers.

1.1. What is a taximeter?


A taximeter is a device that indicates the amount to be charged for use of a taxi by using
predetermined rate or rates based on distance travelled, time elapsed or a combination of both.
Taximeters arose out of a need to automate the taxi fare since in our present day society we tend
to seek efficiency and quality in our lives, with minimum resources in terms of cost and time
through the use of automatic or semi-automatic mechanization.

1.2. Current situation


The current situation found in our countries towns and cities is that; billing for rented
transportation services is conducted through oral negotiation takes place between the taxicab
driver and the customer or by the commonly estimated distances known by the society. So only
until the cost has been agreed between the two parties the journey can begin. There is no clear
billing structure used to arrive at the cost rather billing is assumed depending on the case by case
basis and bargain power of the parties, this design project will address this problems by
proposing a microcontroller based billing system which uses billing structure based on the
measured distance and time to determine the cost.

1.3. Problem statements


Due to the use of negotiation caused by a lack of clear billing structure the present
situation has several problems which lead into inconveniences to both the taxicab
driver and the customer as well; Lack of clear billing structure for taxicabs which
cause price bargains between taxicab driver and customer causes wastage of time.
AAiT School Of Electrical And Computer Engineering | Chapter One 1
Distance Based Digital Taxi Service Charge Payment System

Difficulties might arise to people who are new into town since they can be caught
at a disadvantage in bargains, since they cannot estimate the destination distance
and thus reasonable cost.
Since current cars analog speedometer, uses worm gear inters connected with the
engine, sometimes due to bend or wear out of worm gear, there is failure on using
speedometer.
Difficulties to foreigners who cannot speak the local language that spoken in
Ethiopia like Amharic, Afaan Oromo, Tigrigna, etc. during price negotiation.

1.4. Objectives
Due to the aforementioned problems of the present situation this design project will address the
situation by proposing a microcontroller billing system whose main objective is to computerize
and thus automate the billing system of rented transportation services of the taxicab by achieving
the following specific objectives.

To design a microcontroller circuit that is capable of measuring time and distance.


To design a microcontroller circuit that calculates the cost by using time and
distance as the billing parameters.
To design a microcontroller circuit that is capable of being used as speedometer if
necessary.
To design a microcontroller circuit that displays the measured distance, time and
cost on the alphanumeric LCD screen.

1.5. Significance of the project


Upon its completion, the project will come up with the circuit that will be able to measure the
distance travelled and hiring time of the journey then system will automatically calculate the
fare. The circuit will provide a means of standardizing the taxicab billing so that it can be justly
to both the taxicab driver and to the customer.

1.6. Scope of the project


This project is undergraduate final year project performed in partial fulfillment for the award of
Bachelor of Science in Electrical and Computer Engineering. The project is a design-implement
based project that will use microcontroller, revolution sensor(IR sensor), and LCD display to
AAiT School Of Electrical And Computer Engineering | Introduction 2
Distance Based Digital Taxi Service Charge Payment System

build a system that will automatically measure distance covered and hiring time to calculate cost
and also In case of analog speedometer failure, this system serve as Digital speedometer. Only a
prototype will be accomplished, mainly for proof of concept purposes and its industrial
application may not be feasible at this stage because it need to add some slight modification to
the wheel.

1.7. Methodology
Since the system to be designed is an embedded electronics application then both principles of
hardware and software design methodologies are adopted in order to accomplish the intended
designed system then the following development approach will be used.

Literature review in design, interfacing and practical limitations and challenges


of microcontroller systems.
Functional requirements elicitation from the users of the proposed system.
System requirements identification.
System plan design and circuit simulation.
Implementation of system plan and circuit on to a breadboard prototype circuit.
Testing of prototype to ascertain that the requirements have been met and to account for
the subtle practical challenges.

The current situation has been outlined in this chapter together with its associated problems and a
design methodology has been identified as an approach to achieve the design goals and solve the
present problems. So the next chapter is about literature review on the different implementation
of taximeters together with associated technologies so as to achieve an efficient and useful
design in this project

AAiT School Of Electrical And Computer Engineering | 3


Distance Based Digital Taxi Service Charge Payment System

Chapter Two
Literature Review
This is the chapter that gives some information on various technologies to be used in the
construction of this design project.

A taximeter is used in a taxi cab to calculate how much the passengers owe the driver based on
how far the cab traveled and how long it took. The device, usually electronic, sits on the dash
inside the taxi cab and the driver starts it at the beginning of a trip. Upon reaching the
destination, the driver consults the meter to see how much to charge the customer. There are
many types of taxi meters depending on the manufacturer like CNG taxies, non-
air conditional and air conditional taxies are available through our the world. Taxi meter is a part
and parcel of these taxies. Currently, all the taxi meters in use are imported from abroad,
typically from Korea and India.

Wilhelm Bruhn invented the first taximeters in 1891. These taximeters were mechanically
powered and attached to the outside of the taxicab. As the car drove, the taximeter could be
heard clicking as the numbers on it changed to mark the miles traveled. Taximeters were
invented before the taxi cab itself, and the first taxis got their names from the taximeter.

Today taximeters are usually electronic and sit inside the taxicab where the driver and passengers
can read it. The taximeter goes through cycles over the course of a trip, each marking a different
stage. First, when the taxi is unoccupied, a sign Digital Taximeter is displayed on the taximeter
that says the taxi is free or for hire. Next, once passengers have entered the taxi, the meter starts
counting how far the taxi has traveled and displays the current amount owed to the taxi driver.

Basic futures of Taximeter that found on market currently are listed below.

Clearly displayed fare


Clearly Displayed Extras (separate from fare. At the end of the trip, a button will add the
two screens together for a few seconds to prevent math errors, then split them back apart
[per federal regulation].)
Indication of the status of the meter: hired or vacant, time off (when stopped but NOT
charging the client for the time).

AAiT School Of Electrical And Computer Engineering | Chapter Two 4


Distance Based Digital Taxi Service Charge Payment System

Statistics: permanent stats which the driver cannot reset or change, like your odometer in
the dash. [FYI: In certain cities like New York City, there are special conditions such as
rates which change with time of day or day of the week, special holiday rates and so
forth, all of which can be programmed into specially ordered meters.]
Taxi meters are capable of controlling via a relay, the lamps and indicators in or on the
top light or sign. This means a visual indication for the condition of the meter can be
placed in public view. In Palm Desert California, for instance, the top light is required to
display a "vacant" sign lighted when the meter is not hired, but the ignition switch is
turned on. Then the Vacant goes out and the ambers are lighted when the meter is hired.
This feature is not required in all places, but it is available on all meters we sell. Many
areas switch the top sign off when the meter is hired, and light it when vacant (available).

The other taxi meter is printing taxi meter has all the features of the basic meter plus a printing
function. This meter has a Built-In calculator sized printer, capable of printing a receipt for the
customer, and printing out stats for the operator. Apart from the microcontroller approach chosen
in this design there are other two more methods which can be used to provide a billing
mechanism of taxicabs.

2.1 Mechanical taximeters


These were the early means of constructing taximeters by using the mechanical computing gears
to transduce the distance covered into billing cost.
The mechanical taximeters have the following advantages
They have good temperature performance.
They are immune from electrical and electromagnetic interference.
The mechanical taximeters have the following disadvantages:
They are heavy and bulky.
They are difficulty to calibrate accurately on a timely basis.
They suffer from poor accuracy.
They lack adequate resolution.
They have limitations on the number of optional rates.
They have limited feature capability.
They do not take advantage of available electronic technology.

AAiT School Of Electrical And Computer Engineering | Literature Review 5


Distance Based Digital Taxi Service Charge Payment System

The process of calibrating mechanical taximeters to new fare rates is awkward and
expensive as it usually requires change in computing gears.
Mechanical computing gears with time are subject to corrosion and wear and this
introduces errors in fare calculations.
In general the use of mechanical taximeters does not provide much room for flexibility in the
billing requirements and it does not fit well with present day ubiquitous electronics technologies
which are much more efficient and cheap.

2.2. Microprocessor taximeters


These are taximeters which use the general purpose microprocessor as the computing engine of
the billing system of taximeter.
The advantages of microprocessor taximeters are
They have high performance.
They are easy to interface to other intelligent peripherals and systems.
However the microprocessor taximeters have the following disadvantages
They have poor temperature performance.
They have high cost.
They are susceptible from electrical and electromagnetic interference.
They have high power requirements.
In general the use of general purpose microprocessor in taximeters is uneconomical as the
microprocessors have so many capabilities (which must be paid for at a high cost), but which are
not normally needed in the operation of taximeters.

2.3. Microcontroller taximeters


These are taximeters which use a dedicated processor of the microcontroller to provide
computing mechanism for billing system of taximeter.
This is the preferred choice in this design due to the following advantages:
They are cheap in cost.
They are flexible in providing the billing options.
They have adequate performance for taximeter application.
They have good resolution.

AAiT School Of Electrical And Computer Engineering | Literature Review 6


Distance Based Digital Taxi Service Charge Payment System

2.4. Infrared Sensor


Infrared sensors are in the form of diodes with 2 terminals. One can buy a pair of such diode (one
transmitter and one receiver) at a very low cost of about 30 birr only. Tx refers to a transmitter
and Rx refers to a receiver diode.

Figure2.1:- Typical Tx/Rx

Upon careful observation, one will notice that amongst the two legs, one has a much wider
base within the diode. This is normally the cathode (negative) whereas the leg having a
smaller base would be the anode (positive terminal).

2.4.1. Operation of infrared sensor


+5V

R2
270ohm

D1
LED

Figure 2.2. A typical Transmitter circuit

AAiT School Of Electrical And Computer Engineering | Literature Review 7


Distance Based Digital Taxi Service Charge Payment System

When the Tx is forward biased, it begins emitting infrared. Since it is not in visible spectrum,
you will not be able to see it through naked eyes but you will be able to view it through an
ordinary cell phone camera.

The resistance R1 in the above circuit can vary. It should not be a very high value (~ 1Kohm) as
then the current flowing through the diode would be very less and hence the intensity of emitted
IR would be lesser. By increasing the current flowing in the circuit, you can increase the
effective distance of your IR sensor. However, there are drawbacks of reducing the resistance.
Firstly, it would increase the current consumption of your circuit and hence drain the battery (one
of the few precious resources for any embedded system) faster. Secondly, increasing the
current might destroy the Tx. So, the final choice should be a calculated tradeoff between these
various factors.

One can also modulate the IR to achieve better distance and immunity. The receiver diode has a
very high resistance, typically of the order of mega Ohms when IR is not incident upon it.
However, when IR is incident upon it, the resistance decreases sharply to the order of a few kilo
Ohms or even lesser. This feature forms the basis of using IR as a sensor. You will need to
connect a resistance of the order of a few mega Ohm in series with the Rx. Then tap the output
voltage at the point of connectivity of these two resistors. A complete Tx-Rx circuit is given
below.
+5V

R2
37k

R2
270ohm
Output
IRL1

Demodulator

IRLINK

Figure2.3: Tx - Rx Pair Circuitry

AAiT School Of Electrical And Computer Engineering | Literature Review 8


Distance Based Digital Taxi Service Charge Payment System

Case1: when IR is incident upon the Rx.


When the IR Tx is above a black line, the black line will absorb all the IR. If you are making an
obstacle avoiding, then when there is no obstacle in front of the IR Tx, Rx will not receive the
transmitted IR. However, when an obstacle comes in front of the Tx, it will reflect the IR
incident upon it and hence Rx will receive the IR. In this case, the output voltage of the sensor =
0.12V.

Figure2.4: Direct line of sight

Case2: when IR is not incident upon the Rx, the output voltage of the sensor = 3.4V.

Figure 2.5: No line of sight

2.5. Microcontroller
A microcontroller is a single chip, self-contained computer which incorporates all the basic
components of a much familiar personal computer but on a much smaller scale. Thats why
microcontrollers are often referred to as single chip devices or single chip computers. The main
consequence of the microcontrollers small size is that its resources are far more limited than
those of a personal computer microprocessor. In functional terms, a microcontroller is a
programmable single chip which controls process or system. Microcontrollers are typically used

AAiT School Of Electrical And Computer Engineering | Literature Review 9


Distance Based Digital Taxi Service Charge Payment System

as embedded controllers where they control part of a larger system such as an appliance,
automobile device, scientific instrument or a computer peripheral to name a few. In this design a
microcontroller will be used to control a process that is the billing process. Physically, a
microcontroller is an integrated circuit with pins. The pins present on microcontroller are used
for power, ground, oscillator clock signals, I/O ports, interrupt request signals, reset and control
pins. In contrast the pins present on a microprocessor are most often memory bus signals (rather
than I/O ports).
A typical microcontroller has the following building parts
CPU: this is a part that does all the computing and supervisory functions within
microcontroller as it; fetches, decodes and executes program instructions and directs the
flow of data to and from memory. The CPU performs the calculations as required by
program instructions and places the results of these calculations into memory space.
ROM: this is a non-volatile memory used for storage of program codes and data in the
microcontroller. The microcontroller uses ROM memory space to store program
instructions so that they cannot be affected by loss of power.
RAM: this is the data memory used to store all of the program variables, thus it issued to
read and write data values as a program runs. RAM uses volatile memory (hence when
the power is off its contents are lost) type of technology whose access time does not
depend on the spatial locality of the given memory address.
I/O PORTS: these are the pins used to provide communication access to/from the
microcontroller and other electronic peripheral devices and systems.
Just as any other computer architecture microcontrollers are of two basic types;
Harvard architecture microcontroller: in this architecture the microcontroller uses
separate memory space for program instructions and data. This allows two or more
internal data buses which allow simultaneous access to both instructions and data. for
example the CPU fetches instruction on the program memory bus if fetched instruction
requires an operation on data memory the CPU can fetch the next program instruction
while it uses the data bus for its data operation this gives high throughput and speeds up
execution time, but at the cost of more hardware complexity as this architecture requires
much more internal buses for data and program instruction. In this design a
microcontroller with Harvard architecture will be used due to good performance.

AAiT School Of Electrical And Computer Engineering | Literature Review 10


Distance Based Digital Taxi Service Charge Payment System

Von Neumann architecture microcontroller: in this microcontroller architecture there is a


single common memory space where both program instructions and data are stored, thus
there is a single data bus which fetches both instructions and data. Each time the PU
fetches a program instruction it may have to perform one or more read/write operations to
data memory space. It must wait until these subsequent operations are complete before it
can fetch and decode the next program instruction. The advantage of this architecture lies
in its simplicity and economy.

2.5.1. ATmega32 Microcontroller Futures


Atmega32 has many features as stated in the datasheet. some of the futures used for this project
are listed below.
High-performance, Low-power AVR 8-bit Microcontroller
32 x 8 General Purpose Working Registers
1024 Bytes EEPROM
2Kbyte Internal SRAM
Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
Data retention: 20 years at 85C/100 years at 25C
Programming of Flash, EEPROM, Fuses, and Lock Bits through the JTAG Interface
Two 8-bit Timer/Counters with Separate Presales and Compare Modes
Real Time Counter with Separate Oscillator
External and Internal Interrupt Sources
32 Programmable I/O Lines
40-pin PDIP, 44-lead TQFP, and 44-pad QFN/MLF
Operating Voltages
4.5 - 5.5V for ATmega32

AAiT School Of Electrical And Computer Engineering | Literature Review 11


Distance Based Digital Taxi Service Charge Payment System

Figure2.7:- ATMega32 PIN configuration

VCC

Timer CPU

Watch dog Program


Oscillator Timer memory
Ground
UART (serial RAM
port port)
8 bit Data bus

Analog I/O Analog I/O


Port Port

Figure2.8: Atmega 32 microcontroller


AAiT School Of Electrical And Computer Engineering | Literature Review 12
Distance Based Digital Taxi Service Charge Payment System

2.5.2. Pin Descriptions of ATmega32


VCC - Digital supply voltage.
GND - Ground.
PORTA (PA7...PA0) - PORTA serves as the analog inputs to the A/D Converter.
Port A also serves as an 8-bit bi -directional I/O port, if the A/D Converter is not used. Port pins
can provide internal pull-up resistors (selected for each bit). The Port A output buffers have
symmetrical drive characteristics with both high sink and source capability. When pins PA0 to
PA7 are used as inputs and are externally pulled low, they will source current if the internal pull-
up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active,
even if the clock is not running.
PORTB (PB7...PB0) - Port B is an 8-bit bi -directional I/O port with internal pull-up resistors
(selected for each bit). The Port B output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port B pins that are externally pulled low will
source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset
condition becomes active, even if the clock is not running.
PORTC (PC7...PC0) - Port C is an 8-bit bi -directional I/O port with internal pull-up resistors
(Selected for each bit). The Port C output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port C pins that are externally pulled low will
source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset
condition becomes active, even if the clock is not running. If the JTAG interface is enabled, the
pull -up resistors on pins PC5 (TDI), PC3 (TMS) and PC2 (TCK) will be activated even if a reset
occurs. The TD0 pin is tri-stated unless TAP states that shift out data are entered.
PORTD (PD7...PD0) - Port D is an 8-bit bi -directional I/O port with internal pull-up resistors
(Selected for each bit). The Port D output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port D pins that are externally pulled low will
source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset
condition becomes active, even if the clock is not running.
RESET - Reset Input. A low level on this pin for longer than the minimum pulse length will
generate a reset, even if the clock is not running. Shorter pulses are not guaranteed to generate a
reset.

AAiT School Of Electrical And Computer Engineering | Literature Review 13


Distance Based Digital Taxi Service Charge Payment System

XTAL1 - Input to the inverting Oscillator amplifier and input to the internal clock operating
circuit.
XTAL2 - Output from the inverting Oscillator amplifier.
AVCC - AVCC is the supply voltage pin for Port A and the A/D Converter. It should be
externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be
connected to VCC through a low-pass filter.
AREF - AREF is the analog reference pin for the A/D Converter.

2.6. Liquid Crystal Display (LCD)


LCDs are alphanumeric displays which are commonly used in microcontroller circuit
applications due to their advantages of low cost and low power consumption. And thus are ideal
in low power battery operated portable devices. There are basically two types of LCDs as far as
the interface technique is concerned namely parallel and serial LCDs. Parallel LCDs are
connected to the microcontroller I/O pins using four or eight data wires and data is transferred
from the microcontroller to the LCD in parallel form either one nibble at a time if four data wire
mode or one byte if eight data wire mode is used. This has the advantage of being economical
and with better performance. Serial LCDs are connected to the microcontroller using only one
data line and data is transferred to the LCD using the standard RS232 asynchronous data
communication protocols. Serial LCDs are easier to use but they usually cost more than the
parallel ones due to presence of serial controller chip such as RS232.however they have an
advantage that only one wire is used to interface them to a microcontroller, thus saving the
number of I/O pins required. In this design a parallel LCD with eight data wires will be used due
to better performance and relatively smaller cost as compared to serial LCD.

2.7. Odometer
Odometer is the technique of measuring distance travelled by a vehicle, generally by measuring
wheel revolutions. A IR sensor in this design will be used to measure angular displacement of a
wheel. By knowing the wheel dimensions (i.e. circumference)it is not difficult to calculate the
actual distance moved this is a simple technique but, it can take no account of wheel slippage, or
inaccuracies in wheel dimensions due to change in tire pressure or other parts of the
measurement chain.

AAiT School Of Electrical And Computer Engineering | Literature Review 14


Distance Based Digital Taxi Service Charge Payment System

2.8. Interrupts
Interrupts are a mechanism of a microcontroller which enables it to respond to some events at the
moment when they occur, regardless of what microcontroller is doing at the time. This is a very
important part in this design, because it provides connection between microcontroller and
environment which surrounds it. Generally, each interrupt changes the program flow, interrupts
it and after executing an interrupt subprogram (interrupt routine) it continues from that same
point onwards.
There are basically two types of interrupts namely;
Hardware interrupts these are interrupts that are initiated by a peripheral hardware
module event for example the timer module could issue an interrupt on overflow to the
central processing unit.
Software interrupts are software instructions that make calls to interrupt-handler routines.
Software interrupts are not often used in smaller microcontrollers, but they are very
common in microprocessor architectures as trap handlers.
In typical microcontroller architecture there are multiple hardware interrupt sources and when an
interrupt request is acknowledged the execution jumps to the handler, the address the program
jumps to is known as the interrupt vector.
Depending on the architecture of the microcontroller the interrupts can be either be vectored or
non-vectored interrupts. For vectored interrupts architectures this address is specified by the
application while for non-vectored architectures a specific address issued by the processor.

AAiT School Of Electrical And Computer Engineering | Literature Review 15


Distance Based Digital Taxi Service Charge Payment System

Chapter Three
Design Methodology
This chapter will give information about the modeled building blocks required by the system I
will also explain how different system parts and components are chosen as building components
of the design depending on their features and characteristics.

3.1. System Modeling


This section will elaborate on the model of the design, to implement a microcontroller circuit that
acts as a taximeter by taking into consideration the user requirements and the needed hardware

3.1.1. System Requirements


The following user general requirements have been identified
The user interface must be simple.
The contact area of push buttons should be at least 50 mm
The energy source must be provided by a car.
It must be able to show distance travelled, hiring time and cost.
The cost of production should be low.
The software architecture must be modular.
User needs to be able to reset the system to give a new billing instance.

3.1.2. Block Diagram of the System


The designed system will include the following building blocks
Push buttons: this is used to capture user settings.
Wheel revolution sensor: this is a digital switch that triggers a wheel revolution interrupt
to a microcontroller each time it is triggered by a wheel revolution.
LCD screen: this is the display used to show the measured distance, time and calculated
cost.
Microcontroller: this is the workhorse of the system and performs all the decision making
and computations.

AAiT School Of Electrical And Computer Engineering | Chapter Three 16


Distance Based Digital Taxi Service Charge Payment System

16*2 LCD

MICRO- PUSH
IR - SENSOR CONTROL BUTTON
LER

POWER VOLTAGE
SUPPLY REGULATO
R
DC VOLTAGE

Figure3.1: Block diagram of the system

AAiT School Of Electrical And Computer Engineering | Design Methodology 17


Distance Based Digital Taxi Service Charge Payment System

3.1.3. System flow chart

Start Disable sensor


Disable time
interrupt interrupt

Initialize
Save main program Save main program
registers to be registers to be
affected affected

Increment Wait for START Increment


seconds time key No distance meter
counter counter

Is the START
Is 60 Key Pressed?
seconds
reached?
Yes
Yes Yes
Increment Yes Increment cost
cost due to No due to 100 meter
distance
one minute
Update Display
No
Reset second Reset Hundred
counter meter counter
Check button status
for pressed key

No
Restore main Restore main
program registers program registers
Is the STOP
Key Pressed?
Enable sensor
Enable time
interrupt
counter interrupt

Return
Return
Figure3.2. System Flow Chart

AAiT School Of Electrical And Computer Engineering | Design Methodology 18


Distance Based Digital Taxi Service Charge Payment System

3.2. Components selection

3.2.1. Pushbutton switch


This is a device which enables the wheel revolution to be sensed by a microcontroller, the main
interest here is not to switch directly a voltage or current but rather to convert the switch position
in to a logic level that can be read by a microcontroller port. This is achieved in this design by
internally pulling up the PORTx to Vdd such that when this push button is pressed the PORTx
will go LOW and this will generate an external interrupt on the microcontroller. The pushbutton
switch is chosen in this design due its following features
It is simple to interface with the microcontroller since it is a passive sensor which means
it does not require any signal conditioning mechanism.
It does not require any analogue to digital conversion.

3.2.2. ATmega32
This is the preferred microcontroller choice in this design due to the following advantages of
Microchips ATmega microcontroller family products:
The availability of excellent low-cost and free development tools.
The largest and strongest user Internet based community of probably any silicon chip
family.
An outstanding distributor network with a wide variety of parts available in very short
notice.
A wide range of devices with various features that just about guarantees that there is a
microcontroller suitable for any application.
Microchip's efforts at continually improving and enhancing the Atmega MCU family
based on customer's needs.
High-Performance RISC CPU which means all instructions are single-cycle except for
program branches which needs two instruction cycles.
It has enhanced flash program memory (EEPROM) package with typical 100,000
erase/write cycle.
It has Data EEPROM memory with a typical 1,000,000 erase/write cycle.
Data EEPROM Retention time of at least 40 years.

AAiT School Of Electrical And Computer Engineering | Design Methodology 19


Distance Based Digital Taxi Service Charge Payment System

It has a Low-power CMOS Technology with a fully static design and a wide operating
voltage range (2.7V to 5.5V).
Programmable code protection capability.
Power saving Sleep mode ability.
Has internal oscillator.

3.2.3. JHD162A Display


This is a liquid crystal display with two rows (lines) and sixteen columns
(characters)alphanumeric characters display capability which will be used to provide the
graphical user interface to the users, by displaying visual information about available choices,
time, distance and cost of the journey.
JHD162A contains HD44780U internal display controller which is capable of accepting data sent
in either 4bit two operations or 8bit one operation ,so that it is capable of interfacing with both
4bit or 8bit microprocessor cores. Since in this design an 8bit mode will be used because the
Atmega32 microcontroller has an 8bit data processing core, in addition to that so as to achieve
better performance an 8bit mode is preferred as few operations will be needed which
consequently give short execution time as compared to 4bit mode which needs twice as much
operations and thus time to display the same number of characters.
When the JHD162A display is not enabled, data lines are in tri-state mode which means they are
in a state of high impedance (i.e. they appear as if they are disconnected) and this means they do
not interfere with the operation of the microcontroller when the display is not being addressed.
JHD162A display has 16pin connector for interfacing the display to a microcontroller
Vss this is the 0V grounding pin.
Vdd this is the pin which is connected to the positive power supply, the manufacturers
recommended supply is 5V,however the module can be operated as low as 3V or as high
as 6V.
Vee this is the pin used to control the contrast of the display and thus should be
connected to a variable voltage supply or it can be connected to ground if contrast
adjustment is not needed.

AAiT School Of Electrical And Computer Engineering | Design Methodology 20


Distance Based Digital Taxi Service Charge Payment System

RS this is the register select pin when it is low data transferred to the display is treated as
commands on the other hand when RS is high a character can be transferred to or from
the module.
R /W Pin this is the pin which is pulled low in order to write commands or character data
to the LCD module, also when this pin is high character data or status information can be
read from the module. This pin is usually connected to ground because we normally write
to the LCD module rather than read from it.
EN pin this is an enable pin which is used to initiate the transfer of commands or data
between LCD module and microcontroller. when writing to the display data is transferred
only on the high to low transition of this pin .when reading from the display data
becomes available after the low to high transition of the enable pin and this data remains
valid so long as the enable pin is high.
Pins 7 to 14 are eight data bus lines (D0 to D7) and will be used to transfer display
characters to the LCD module.
Pin 15 provides an anode connection pin for LED backlight.
Pin 16 provides a cathode for LED backlight.

3.3. Device configuration

3.3.1. Interrupt Configuration:


The interrupt system on board a microcontroller allows it to respond to higher-priority or
unscheduled events occurring during a program execution. These events may be planned, but we
do not know when they will occur. When an interrupt event occurs, the microcontroller will
normally complete the instruction it is currently executing and then transit the program control to
tasks related to the interrupt event. When one interrupt is being served, then no other interrupt
can occur as the microcontroller deactivates the interrupt system for preventing further
interrupts. The tasks, which correspond to the interrupt event, are organized in a function called
the interrupt service routine (ISR). Each interrupt will normally have its own ISR. Once the ISR
is complete, the microcontroller will resume processing where it left off before the interrupt
event occurred.
The ATmega32 can handle 21 interrupt sources. Three of the interrupts can be from external
interrupt sources, and the remaining 18 interrupts are for the peripheral subsystems of the

AAiT School Of Electrical And Computer Engineering | Design Methodology 21


Distance Based Digital Taxi Service Charge Payment System

microcontroller. The ATmega32 interrupt sources are shown in Figure 3.4. The interrupts are
listed in descending order of priority. RESET, INT0 (pin 16) and INT1 (pin 17) are external
interrupts and the remaining interrupt sources are internal to the ATmega32.
To program an interrupt, the user has to do the following actions:
Associate the ISR for a specific interrupt to the correct interrupt vector address, which
points to the starting address of the ISR.
Enable the interrupt system globally. This is accomplished with the assembly language
instruction SEI.
Enable the specific interrupt subsystem locally.
Configure the registers associated with the specific interrupt correctly.

3.3.2. Timer Subsystem:


The Atmel ATmega32 has a flexible and powerful three-channel timing system. The three timer
channels Timer 0(8-bit timer), Timer 1(16-bit timer), and Timer 2(8-bit timer). Timer0 is only
used in this project and so only that is explained in detail.

3.3.3. Timer0 Register Set:


The following figure shows the Timer0 Registers:

Timer/Counter Control Register (TCCR0)

Timer/counter Interrupt Mask Register (TIMSK)

Timer/counter interrupt Flag Register (TIFR)

AAiT School Of Electrical And Computer Engineering | Design Methodology 22


Distance Based Digital Taxi Service Charge Payment System

Figure3.3: Timer0 Registers

3.3.4 Timer/Counter Control Register 0(TCCR0):


The TCCR0 register bits are used to:
Select the operational mode of Timer 0 using the Waveform Mode Generation
(WGM0[1:0]) bits,
Determine the operation of the timer within a specific mode with the Compare Match
Output Mode (COM0[1:0]) bits, and
Select the source of the Timer 0 clock and the prescaler to subdivide the main clock
frequency down to timer system frequency (clkTn) using CS0 [2:0] bits. [3]
The bit settings for the TCCR0 register are summarized in the following figure:

AAiT School Of Electrical And Computer Engineering | Design Methodology 23


Distance Based Digital Taxi Service Charge Payment System

Wave generation mode

Normal CTC

Figure3.4. TCCR0 Register configuration


3.3.5 Timer/Counter Register 0 (TCNT0):
The TCNT0 is the 8-bit counter for Timer 0. The timer clock source (clkTn) is fed to the 8-bit
Timer/Counter Register (TCNT0). This register is incremented (or decremented) on every clock
pulse clkTn.

AAiT School Of Electrical And Computer Engineering | Design Methodology 24


Distance Based Digital Taxi Service Charge Payment System

Output Compare Register 0(OCR0):


The OCR0 register holds a user-defined 8-bit value that is continuously compared with the
TCNT0 register.
Timer/Counter Interrupt Mask Register (TIMSK):
The TIMSK register is used by all three timer channels. Timer0 uses the Timer/Counter0 Output
Compare Match Interrupt Enable (OCIE0) bit and the Timer/Counter0 Overflow Interrupt
Enable (TOIE0) bit. When the OCIE0 bit and the I-bit in the Status Register are both set to 1, the
Timer/Counter 0 Compare Match interrupt is enabled. When the TOIE0 bit and the I-bit in the
Status Register are both set to 1, the Timer/Counter 0 Overflow interrupt is enabled.
Timer/Counter Interrupt Flag Register (TIFR):
The TIMSK register is used by all three timer channels. Timer0 uses the OCF0 (Output compare
Flag), which sets for an output compare match. Timer 0 also uses the TOV0 (Timer/Counter
overflow flag), which sets when Timer/Counter 0 Overflows.
Modes of Operation:
The following diagram shows the modes of operation of the Timer0.

Figure3.5: Modes of operation of Timer0

AAiT School Of Electrical And Computer Engineering | Design Methodology 25


Distance Based Digital Taxi Service Charge Payment System

Mode 1 (i.e. Clear timer on compare match (CTC) mode) is used in this project .In this mode, the
TCNT0 timer register is reset to 0 every time the TCNT0 counter reaches the value set in OCR0.
The Output Compare Flag 0 (OCF0) is set when this event occurs. A 1 is written to this flag from
the program to clear it.

In this project Timer0 output compare match interrupt has been used. The OCR0 is assigned
decimal value 155 and TCCR0 is assigned 0X0B i.e. the timer is configured for CTC mode and
the inbuilt set main clock source frequency (1MHz) is divided by 64 to give timing system
frequency of 15.6 kHz so that the counter TCNT0 increments every 64 microseconds and it
would set the OCF0 in 156 ticks i.e. when the TCNT0 rolls over to 0 at the 156the clock tick
after becoming equal to 155 (at the 155th clock tick )which is the value stored in OCR0 and
hence cause the TIMER0 COMP interrupt to occur in 156 * 64s = 0.01s.

AAiT School Of Electrical And Computer Engineering | 26


Distance Based Digital Taxi Service Charge Payment System

Chapter four
Simulation and Implementation
Although microcontrollers have been traditionally been programmed using the assembly
language of the target device in this implementation a high level language will be used because
high-level languages offer several desirable advantages for this design project as compared to the
assembly language:
o It is easier to develop programs using a high-level language.
o Program maintenance is much easier if the program is developed using a high-level
language.
o Testing a program developed in a high-level language is much easier.
o High-level languages are more user-friendly and less prone to making errors.
It is easier to document a program developed using a high-level language. In addition to the
above advantages, high-level languages also have some disadvantages. For example, the length
of the code in memory is usually larger when a high-level language is used, and the programs
developed using the assembly language usually run faster than those developed using a high-
level language.
The application software code was implemented by using Atmel studio AVR C compiler for
Microchip Atmega32 microcontrollers version: 6.0. This high level language C compiler was
chosen for software implementation due to its following advantages:

The pseudo code derived from the modeled system flow chart in chapter3 has the following
sequence of activities.
1. Program initializes.
2. User prompted for choice from available options.
3. IF start key chosen continue to step4 ELSE go back to step2.
4. Update the display screen.
5. Check for Push button status.
6. IF stop key is pressed (the button is pressed again) stop and wait for start key press ELSE
go back to step4.

AAiT School Of Electrical And Computer Engineering | Chapter four 27


Distance Based Digital Taxi Service Charge Payment System

In this design the modeled system flow chart of the application program has three parallel
threads that implements the above pseudo code namely
Main program thread block.
TIMER1 overflow interrupt time cost ISR thread.
PD2 (INT0) external interrupt distance cost ISR thread.

4.1. Main program thread


The main program block has three functionalities
It initializes the microcontroller to an initial state by clearing executing the initialization
routine.
It updates the display screen by executing the update display routine.
It checks the push button for pressed key options and takes appropriate action according
to the captured user choice.

4.1.1 Initialization
In this stage the main program sets the configuration registers with appropriate values
and ensures that the microcontroller is within a desirable initial state for safe and reliable
operation of the microcontroller. In this routine the configuration registers are
programmed with the desired values and the program global variables are initialized to
their default values.

4.1.2 Update LCD display


In this stage the main program updates the alphanumeric display with the values of time,
distance and cost. To not interfere with the display controller (HD44780) operation
interrupts are temporarily disabled during this procedure and the numeric values are first
converted into string character buffer before being sent to the display, since the display
controller is character based.

AAiT School Of Electrical And Computer Engineering | Simulation and 28


Implementation
Distance Based Digital Taxi Service Charge Payment System

4.1.3. Distance cost ISR thread


This is the interrupt service routine for handling the PD2 /INT0 external interrupt; it
achieves this by adding the meters counter to itself and then checks to see this running
sum if it has reached 100metres (0.1km), so that the cost can be calculated (i.e. billing in
this design is by each 0.1km covered distance).Then the 100metres counter is checked if
it has reached 1000metres (1km) so that the kilometers distance counter can be updated
and 100metres counter reset.

4.1.4. Time cost ISR thread


This is the interrupt service routine for handling the TIMER1 overflow interrupt which
occurs after every 2 seconds. In this routine the seconds counter is monitored if it has
reached one minute so that the billing cost can be calculated. (I.e. billing is by each
elapsed minute).

4.2. Testing of ATMega32


Before using ATMega32 in real time, programs are written and simulated see if they execute as
desired or not and give the correct output or notary AVR Studio 6s simulator is used for this
purpose. This helps in easy debugging. If programs are directly used in real time then in case the
desired result is not obtained then it becomes difficult to trace where the fault lies. So it is
advisable to first simulate and then use the program in real time. So during the whole course of
project work, all programs were first tested by simulating in AVR Studio and then dumped into
the microcontroller for execution in real time.
The AVR Studio 4 is an Integrated Development Environment (IDE) for debugging AVR
software. The AVR Studio allows chip simulation and in-circuit emulation for the AVR family
of microcontrollers. The user interface is designed in such a way that it is easy to use and gives
complete information overview. The IDE has several windows that provide important
information to the user. The main windows of interest are the Workspace, Source Code, Output,
and Watch windows. These can be seen in the next page in figure 5.1.

AAiT School Of Electrical And Computer Engineering | Simulation and 29


Implementation
Distance Based Digital Taxi Service Charge Payment System
Work space
Source code

Output
Figure4.1: A sample of IDE windows

4.3. Programming
Taximeter is a small computer. It cannot do anything by itself until it is programmed with our
rates, charges, fees and information about how the money is to be calculated. You have to tell it
things like the Initial the interrupts, amount charge per 100 meter, what increment of coinage is
to be registered (like 0.05-cents per tenth of a 100meter), how much to charge for waiting time,
etc.. Programming also sets up such things as multiple rates if needed etc. the sample source
code are shown in Appendix I.

4.4. System simulation


This is the section which describes the hardware modules interconnection implementation
scheme so as to achieve a working system by using the Proteus professional version
7.2Labcenter electronics.

AAiT School Of Electrical And Computer Engineering | Simulation and 30


Implementation
Distance Based Digital Taxi Service Charge Payment System

Proteus VSM is an interactive electronic design package from Lab center Electronics that allows
analogue, digital, and microprocessor circuits to be subjected to virtual testing before the
creation of a PCB layout for the construction of real hardware. ISIS is the schematic capture
package, and ARES is the layout package. The circuit is entered directly onto the schematic by
selecting components from a library of parts, which have associated mathematical models (e.g.,
V= IR for a resistor). When completed, the wiring schematic is converted to a set of nodes
connected by components, represented by a set of simultaneous equations derived from the
model for each component. The network is solved for any given set of inputs and the outputs are
displayed via active on-screen components, virtual instruments, or charts. The microcontroller is
simulated on the basis of its internal architecture and the specific program being executed, which
must be attached to complete the model. In our case, the program is written in C and the HEX
byte file produced by the compiler is loaded to the MCU. This file contains the program machine
code and some additional information to help with debugging the program. ISIS allows the
source code and variables to be displayed so that the program operation can be studied step by
step and any functional errors corrected.

The design schematic was developed in ISIS professional release 7.1 and the applications
simulated here for a typical routine of steps that occurs in the system;

AAiT School Of Electrical And Computer Engineering | Simulation and 31


Implementation
Distance Based Digital Taxi Service Charge Payment System

Step1: User prompted for set the cost per 100 meter (i.e. the fee that was given by Ethiopian
Transportation Authority) and is shown below.

Figure 4.2: Shows the system is waiting to set cost per 100meter
Step 2: System goes in to continuous billing loop when start key is pressed to update display and
while checking for stop key.

Figure4.3: Taxicab billing

AAiT School Of Electrical And Computer Engineering | Simulation and 32


Implementation
Distance Based Digital Taxi Service Charge Payment System

Step3: When destination is reached and the user presses STOP button to stop billing here the cost
is displayed and the system waits for start key for new billing.

Figure4.4: Display bill


Optional step: when the system is going (the taxi is started to move towards to its destination) if
the driver need to use the system as a speedometer by pressing speedometer switch its shown
below.

Figure4.5: system working as Speedometer

AAiT School Of Electrical And Computer Engineering | Simulation and 33


Implementation
Distance Based Digital Taxi Service Charge Payment System

4.5. Hardware Implementation

4.5.1. Mechanical Specifications


The hardware layouts of the sensor part that is attached on the axle at the very near of one of the
wheel is shown below as drawn by design software.

IR transmitter sensor
Tyre
placing hole

Sensor holder

Wheel Axle

Metal attached to wheel to


block IR trans-receiver

Figure 4.6: The positioning of the sensor on the wheel Axle [Drawn by solid work software]

AAiT School Of Electrical And Computer Engineering | Simulation and 34


Implementation
Distance Based Digital Taxi Service Charge Payment System

Chapter five
Result and Discussion
A full system as on functioning is show in the figure below

Figure5.1. System prototype when functioning


When the meter is turned on, the IR sensor close to the wheel starts measuring the number of
revolutions of the wheel by using a base point on the wheel. Once the taxi covers the intended
distance of the journey, the meter is switched off to stop counting the revolutions now. Now,
based on the no of revolutions, the distance is calculated by using the formula: number Of
Revolutions X circumference Of Wheel. Now, based on the distance, the fare is calculated and
displayed on the LCD screen.
As seen from the figure, software simulated result and the experimental result are the same hence
we have successfully designed an automated digital taxi service charge payment system. But in
some cases there is the difference that since the buttons are manually pressed if the user pressed
it for long time than around 2-3 msec the system work the next instruction for that button. Also
for the counting the rotation of the tyre, as the car goes faster, 147 160km/hr. the sensor cant
recognize the interrupts. But as known this system was designed for city taxi that means the
speed of the cars are limited (maximum of 50km/hr. in Addis Ababa) thus the system works
well.

AAiT School Of Electrical And Computer Engineering | Chapter five 35


Distance Based Digital Taxi Service Charge Payment System

Chapter six
Conclusion and Recommendation
This project tries to solve those problems that are related to payment system for service charge
while using taxi for transportation. Since the system uses embedded electronics to compute the
service charge depending on the distance moved, measured by using IR sensor, and the time it
takes to cover the journey, by using internal Timer0 of microcontroller. Thus the system is fair
for all user and taxicabs.
Generally the system plan was successfully designed, simulated and then tested on the
breadboard hardware prototyping circuit and then printed on PCB, so I could claim that my
project objectives have been duly met.
While working on this project many things came up, both positive and negative, however to a
good extent things have been under control and the system was successfully designed. The
design worked fine under the emulation environment. However during implementation several
challenges were encountered such us hardware component availability, because initially I had
planned to use a four line display screen but had to settle with two line displays. Secondly, parts
cost affordability. Thirdly, was the difficulty of obtaining the AVR Atmel programmer(STK500)
since there was not enough to use the independently then I had to borrow the from my friends
and teachers this caused many unnecessary hustles and wasted much valuable time during design
testing.
Failures of the project
Although I have been able to model and finally design the prototype; I have failed to come up
with quantifiable data and/or mathematical model that justifies by how much my proposed
system will reduce the inconveniences suffered by the customers and taxicab drivers due to the
present situation.
Recommendations for future work
The following are will be the recommendations for the improvement of the proposed
microcontroller based taxi billing system for future works.
1. Statistical records: Keeping statistical records by the microcontroller could improve the
financial management usefulness of the system to the users; this could be achieved by

AAiT School Of Electrical And Computer Engineering | Chapter six 36


Distance Based Digital Taxi Service Charge Payment System

attaching to the microcontroller retrievable special flash memory to be used to store a


billing log file so that it can be used for later auditing and printing.
2. Improving the way cost per 100m was set by making first when the system starts it its
connected to central database wirelessly by using RF trans-receiver and read the cost per
100m from there and this decrease the inconvenience and no need to broadcast the
current taxi service charge by TV or Radio.
3. The government revenue authority (i.e. Ethiopian Revenues and Costumes Authority) can
use taximeters to increase the source of revenues from taxi businesses by charging value
added tax (VAT) on taxicab business transactions.

AAiT School Of Electrical And Computer Engineering | Conclusion and 37


Recommendation
Distance Based Digital Taxi Service Charge Payment System

Reference

[1] Barrett Steven F. and Pack Daniel J. Atmel AVR Microcontroller Primer:
Programming and Interfacing. Morgan & Claypool, 2008

[2] Mazidi Muhammad Ali, Naimi Sarmad, Naimi Sepher.The AVR Microcontroller and
embedded and embedded systems using assemble and C. Upper Saddle River: Prentice
Hall, 2011

[3] ATMEL (2001) ATmega32datasheet.

www.atmel.com/dyn/resources/prod_documents/doc2503.pdf

[4] AVR Simulation with the ATMEL AVR Studio 6 , Purdue university , 2005, Huang
[5] Han-Way. MC68HC12 an introduction: software and hardware interfacing. New
York : Thomson Learning , 2003

[6] http://www.avrfreaks.net/

[7] http://www.extremeelectronics.co.in/

[8] http://taxicabelectronics.com

[9] http://www.newbiehack.com/MicrocontrollerAddingabutton.aspx

[10] https://sites.google.com/site/qeewiki/books/avr-guide

[11] http://www.mbed.org/

AAiT School Of Electrical And Computer Engineering | Reference 38


Distance Based Digital Taxi Service Charge Payment System

Appendix I: Source code


#define set bit_is_clear(PINA, 0)
#define ST1 bit_is_clear(PINA, 1)
#define sw4 bit_is_clear(PINA, 5)
#define birr bit_is_clear(PINA, 6)
#define cent bit_is_clear(PINA, 7)
int cost1;
int pressed_confidentB;
int noOfRevolutions;
unsigned short hour_counter;
unsigned short minutes_counter;
unsigned short kilometers_counter;
unsigned short meters_counter;
unsigned short hundred_meters_counter;
unsigned short distance_cost;//billing cost per 100 meter
0.046285 birr
unsigned short time_cost = 1; //billing cost per 1 minute
unsigned short seconds_counter;
unsigned short button;
int RPS;//Rotation per second(m/s)
int KPH;//killometer per hour
bool ST11 = false;
unsigned short distancebirr,coin;
//************************************
unsigned short i, NUM ;
unsigned int ADD = 0x00, temp; // Start EEPROM Location
// ------------------------------------------------
int main(void)
{
DDRA= 0b00000000;
PORTA=0b11111111;
DDRB=0xFF;
DDRC=0xFF;
PORTC = 0;
LCDInit(0|0);
LCDClear();
LCDWriteString("Welcome...");
LCDGotoXY(0,1);
LCDWriteString("Digital TaxiMeter");
_delay_ms(2000);
LCDClear();
LCDWriteString("Press SET button");
LCDGotoXY(1,1);
LCDWriteString("set cost/100m");

AAiT School Of Electrical And Computer Engineering | Appendix I: Source code 39


Distance Based Digital Taxi Service Charge Payment System

while(set) { _delay_ms(500);}
while(!set) {_delay_ms(500);}
SETTING:
distancebirr= (int)eeprom_read_word(0x01);
coin = (int)eeprom_read_word(0x08);
_delay_ms(200);
LCDClear();
LCDWriteString("SETTING");
_delay_ms(500);
do
{
LCDWriteIntXY(1,1,distancebirr,1);
LCDGotoXY(3,1);
LCDWriteString("birr");
LCDWriteIntXY(8,1,coin,2);
LCDGotoXY(10,1);
LCDWriteString("cents");
if (birr)
{
pressed_confidentB++;
released_confidentB = 0;
if (pressed_confidentB>50)
{
distancebirr++;
pressed_confidentB = 0;
}
}
else{
released_confidentB++;
pressed_confidentB = 0;
if (released_confidentB >50)
{
pressedB = 0;
released_confidentB =0;
}
}
if (cent)
{
pressed_confidentC++;
released_confidentC = 0;
if (pressed_confidentC>50)
{
coin++;
pressed_confidentC = 0;
}
}
else{

AAiT School Of Electrical And Computer Engineering | Appendix I: Source code 40


Distance Based Digital Taxi Service Charge Payment System

released_confidentC++;
pressed_confidentC = 0;
if (released_confidentC >50)
{
pressedC = 0;
released_confidentC =0;
}
}
} while (!set);
//******writing to EEPROM
eeprom_write_word(0x01,(int)distancebirr);
eeprom_write_word(0x08,coin);
coin = coin/100;
distance_cost = distancebirr + coin;
LCDClear();
LCDWriteString("INITIALIZING....");

//**********************************************
int UBBRValue = 25;
//Put the upper part of the baud number here (bits 8 to 11)
UBRRH = (unsigned char) (UBBRValue >> 8);
//Put the remaining part of the baud number here
UBRRL = (unsigned char) UBBRValue;
//Enable the receiver and transmitter
UCSRB = (1 << RXEN) | (1 << TXEN);
//Set 2 stop bits and data bit length is 8-bit
UCSRC = (1 << USBS) | (3 << UCSZ0);
//*********************************************
//Init INT0
MCUCR|=(1<<ISC01);//Falling edge on INT0 triggers interrupt.
GICR|=(1<<INT0); //Enable INT0 interrupt
//Timer1 is used as 1 sec time base
//Timer Clock = 1/1024 of sys clock
//Mode = CTC (Clear Timer On Compare)
TCCR1B|=((1<<WGM12)|(1<<CS12)|(1<<CS10));
//Compare value=976
OCR1A=976;
TIMSK|=(1<<OCIE1A); //Output compare 1A interrupt enable
//Enable interrupts globaly
sei();
int pressed_confident1;
int released_confident1;
int pressed1;
//-----------------------------------------------------------
initializesystem();
do
{

AAiT School Of Electrical And Computer Engineering | Appendix I: Source code 41


Distance Based Digital Taxi Service Charge Payment System

if (set)
{
pressed_confidentS++;
released_confidentS = 0;
if (pressed_confidentS>50)
{
pressed_confidentS = 0;
goto SETTING;
}
}
else{
released_confidentS++;
pressed_confidentS = 0;
if (released_confidentS >50)
{
pressedS = 0;
released_confidentS =0;
}
}
_delay_ms(50);
} while (set);
START:
cost1,cost2,cost3,cost4 =0 ;
do
{
LCDClear();
_delay_ms(700);
LCDGotoXY(5,0);
LCDWriteString("DIGITAL");
LCDGotoXY(3,1);
LCDWriteString("TAXI-METER");
_delay_ms(700);

} while (!ST1 && !ST2 && !ST3 && !ST4 && !set);
if (set)
{
goto SETTING;
}
subSTART:
// Sample code for button1 and the other three buttons are
// implemented the same way
while (1)
{
updateDisplay();
PORTC |= 1 << PINC2;
if (ST1)
{

AAiT School Of Electrical And Computer Engineering | Appendix I: Source code 42


Distance Based Digital Taxi Service Charge Payment System

pressed_confident1++;
released_confident1 = 0;
if (pressed_confident1>50)
{
if (pressed1 == 0)
{
pressed1 = 1;
PORTC ^=(1 << PINC4);
if (bit_is_set(PINC, 4) )
{
ST11 = true;
LCDClear();
LCDWriteString("Welcome 1");
_delay_ms(1000);
cost1 = cost;
dist1Km = kilometers_counter;
dist1m= meters_counter;
}
if (!(bit_is_set(PINC, 4)))
{
goto STOP1;
}
}
pressed_confident1 = 0;
}
}
else{
released_confident1++;
pressed_confident1 = 0;
if (released_confident1 >50)
{
pressed1 = 0;
released_confident1 =0;
}
}

if (sw4)
{
LCDClear();
LCDGotoXY(2,0);
LCDWriteString("Speed Meter:");
LCDGotoXY(4,1);
LCDWriteString(" Km/hr");
do {
PORTC |= 1 << PINC1;
KPH = RPS*3.6;
LCDWriteIntXY(1,1,KPH,3);

AAiT School Of Electrical And Computer Engineering | Appendix I: Source code 43


Distance Based Digital Taxi Service Charge Payment System

pressed_confidentSPeed = 0;
} while (sw4);
PORTC ^= 1 << PINC1;
}
}
STOP1:
PORTC ^= 1 << PINC2;
PORTC |= 1 << PINC3;
LCDClear();
LCDGotoXY(1,0);
LCDWriteString("Cost:");
cost1 = cost - cost1;
LCDWriteIntXY(6,0,cost1,2);
UDR = cost1;
LCDGotoXY(8,0);
LCDWriteString(" birr");
LCDGotoXY(1,1);
LCDWriteString("Welcome again!");
_delay_ms(3000);
ST11 = false;
if (ST11 || ST22 || ST33 || ST44)
{
goto subSTART;
}
goto START;
goto START;
return 0;
}
//------------------------------------------------
ISR(INT0_vect)
{
//CPU Jumps here automatically when INT0 pin detect a
falling edge
noOfRevolutions++;
PORTC |= 1 << PINC0;
distancecost();
_delay_ms(50);
PORTC ^= 1 << PINC0;
}

ISR(TIMER1_COMPA_vect)
{
//CPU Jumps here every 1 sec exactly!
timecost();
RPS = noOfRevolutions;
noOfRevolutions = 0;
}

AAiT School Of Electrical And Computer Engineering | Appendix I: Source code 44


Distance Based Digital Taxi Service Charge Payment System

void timecost(){
seconds_counter = seconds_counter+1;
if (seconds_counter == 60)
{
seconds_counter = 0;
minutes_counter = minutes_counter + 1;
cost = cost+time_cost;
if (minutes_counter == 60)
{
minutes_counter = 0;
hour_counter = hour_counter+1;
}
}
}
void distancecost(){
meters_counter = meters_counter + 1;

if (meters_counter == 100)
{
meters_counter = 0;
hundred_meters_counter = hundred_meters_counter+1;
cost = cost +distance_cost;
if (hundred_meters_counter ==10)
{
hundred_meters_counter = 0;
kilometers_counter = kilometers_counter + 1;
}
}
}
void initializesystem(){
ST11 = false;// for pressing start for already started user
hour_counter = 0;
minutes_counter = 0;
kilometers_counter = 0;
hundred_meters_counter = 0;
cost = 0;
meters_counter = 0;
seconds_counter = 0;
button = 0;
RPS = 0;
KPH = 0;
cost1 = 0 ;
dist1Km =0 ;
dist1m = 0;
for (int x = 0;x<4;x++)
{
PORTC |= 1 << PINC0;

AAiT School Of Electrical And Computer Engineering | Appendix I: Source code 45


Distance Based Digital Taxi Service Charge Payment System

PORTA |= 1 << PINA0;


_delay_ms(100);
PORTC ^= 1 << PINC0;
PORTC |= 1 << PINC1;
_delay_ms(100);
PORTC ^= 1 << PINC1;
PORTC |= 1 << PINC2;
_delay_ms(100);
PORTC ^= 1 << PINC2;
PORTC |= 1 << PINC3;
_delay_ms(100);
PORTC ^= 1 << PINC3;
}
LCDClear();
}
void updateDisplay(){
LCDGotoXY(0,0);
LCDWriteString("Time:");
LCDWriteIntXY(5,0,hour_counter,2);
LCDGotoXY(7,0);
LCDWriteString("hr");
LCDWriteIntXY(9,0,minutes_counter,2);
LCDGotoXY(11,0);
LCDWriteString("mn");
LCDWriteIntXY(13,0,seconds_counter,2);
LCDGotoXY(15,0);
LCDWriteString("s");
LCDGotoXY(0,1);
LCDWriteString("Dist:");
LCDWriteIntXY(5,1,kilometers_counter,3);
LCDGotoXY(8,1);
LCDWriteString("km");
LCDWriteIntXY(11,1,meters_counter,3);
LCDGotoXY(14,1);
LCDWriteString("mtr");
}

AAiT School Of Electrical And Computer Engineering | Appendix II: Project 46


costs
Distance Based Digital Taxi Service Charge Payment System

Appendix II: Project costs


Number Description Quantity Unit price Total cost
(birr)
(birr)
1 Resistor 9 3:00 27:00

2 LCD Protection resistor 1 3:00 3:00

3 Push button switch 8 4:00 32:00

4 LCD Display 1 180:00 180:00

5 Microcontroller 1 330:00 330:00

6 switch 1 4:00 4:00

7 Photodiode 1 30:00 30:00

8 Infrared transmitter 1 30:00 30:00

Total = 636:00

AAiT School Of Electrical And Computer Engineering | Appendix II: Project 47


costs

Anda mungkin juga menyukai