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.
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.
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.
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.
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
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.
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.
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.
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).
R2
270ohm
D1
LED
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
Case2: when IR is not incident upon the Rx, the output voltage of the sensor = 3.4V.
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
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.
VCC
Timer CPU
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.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.
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.
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.
16*2 LCD
MICRO- PUSH
IR - SENSOR CONTROL BUTTON
LER
POWER VOLTAGE
SUPPLY REGULATO
R
DC VOLTAGE
Initialize
Save main program Save main program
registers to be registers to be
affected affected
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
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.
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.
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.
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.
Normal CTC
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.
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.
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.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.
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.
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;
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.
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.
IR transmitter sensor
Tyre
placing hole
Sensor holder
Wheel Axle
Figure 4.6: The positioning of the sensor on the wheel Axle [Drawn by solid work software]
Chapter five
Result and Discussion
A full system as on functioning is show in the figure below
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
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
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/
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{
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
{
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)
{
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);
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;
}
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;
Total = 636:00