15

ATmega328P Based Taxi Meter

using Arduino NANO Learning Kit

In this Chapter, we have documented step-by-step procedures for the development of a Taximeter. Most of the steps have been verified using Arduino NANO Learning Kit which is a breadboard type PCB containing TQFP ATmega328P Microcontroller. The program codes are presented in the form of Pseudo Code, Text Code, Line Diagram, Flow Chart, C Codes, and Arduino Code.

15.1 Introduction

A Taximeter is an electronic instrument (Fig-15.1) which is fitted with a rented Taxicab to record: (i) Distance Travelled, (ii) Waiting Time, and (iii) Fare. These are the minimum features that a simplest Taximeter should have.

Figure-15.: Pictorial view of a prototype 3-Window Taximeter


Apart from above mentioned three features, the Taximeter can have many other features of which the most important two are: a Real Time Clock to know the time of the day and a Printer to get the hard copy of the journey details. The other optional features that can be added with the meter are described below:


• Radio link for dispatching trip information to supervisor
• Interaction with GPS systems to receive security assistance during danger/accident
• Seat sensors that detect the presence of a passenger (s)
• Credit or prepaid card support
• Extra charge for luggage
• Speed of the Taxicab

15.2 The First Taximeter

Figure-15.2: Pictorial view of the first Mechanical Taximeter

The 1st Taximeter was a mechanical one, and it was fitted with an odometer type display unit. It was invented in 1891 by German inventor Friedrich Wilhelm Gustav Bruhn. The electronic versions of these meters were introduced in 1980s. At the present times, we have very sophisticated digital Taximeters based on microprocessor, microcontroller and DSP.

15.3 Duty Cycle of a Taximeter

During normal operation, a taximeter repeats cyclically through the following stages:

(1) FREE: The Taxicab is empty and available for hire. The roof top blinking light is switched on.

(2) HIRED: The Taximeter enters in this stage at the beginning of a journey when the driver presses the HIRED button. The roof top blinking light is switched off. The meter immediately enters into waiting state and then into running state when the driver releases the brake and accelerates the engine. The Digital Fare Meter (DFM) shows the initial Flat Fare (Tk 40.00 for Bangladesh) and Running Fare (Tk 12.00/Km and Tk 2.00/minute of waiting time for Bangladesh). The Digital Distance Meter (DDM) shows the distance travelled and the Digital Waiting Meter (DWM) keeps showing the elapsed waiting time.

(3) TO PAY: At the end of the trip, the Taximeter enters in this stage. The driver presses the ‘TO PAY’ switch. All processing activities of the meter are stopped. The meters show the Fare, distance travelled and the elapse waiting time. The driver may optionally print a receipt. The exterior roof top light may also blink to alert potential passengers.

15.4 Operational Features

Bangladesh Standards and Testing Institution in its draft specifications BDS xxx: 2004 has formulated that a Taximeter should include the following operational features of Table-15.1 in the form of front panel switches (Fig-15.3).

Figure-15.3: Conceptual View of a 3-Window Taximeter

Table – 15.1 : Operational Features of Taximeter
Switch / Full Name / Function
RST / Reset / To reset Taximeter. In response all display windows show 0s.
LED TST / Led Test / To check the functioning of the 7-Segment devices of the display unit. In response, the display digits cycle over 0,1,2,…,9 until the RST button is pressed.
HRD / Hired / To indicate that the Taxicab is hired. The fare field shows the flat fare. Taximeter is enabled to acquire distance, compute fare and waiting time.
TO PAY / Journey Ends
Make Payment / At the end of journey, the driver pushes this switch to freeze all the activities of the meter. The display unit shows: Total Fare, Distance and Waiting Time. This switch is only active in the waiting state of the Taxicab. The roof top light may also blink to alert passengers to hire the Taxicab.
K TST / K Factor Test
(Examine K Factor of Meter) / K-Factor is a value, which the transducer generated when it was first installed in the taximeter. The value is about 1600 pulses/1Km of travel.
W TST / W Factor Test
(Determine
Wheel Factor of Taximeter) / W TST switch allows an inspector for time to time check the functional conditions of the Taximeter itself, Speed pulse carrying cable, and Tire condition (Excessive Wear, Not Fully inflated). In this test, the Taxicab is moved over 1Km distance and the transducer counts are recorded.
W-K ERR / Determine Error between
W and K Factors / To certify that the Taximeter and the wheel of the vehicle are in operational condition, then the difference between W- and K-Factors must be less than 1%. Pressing of the W-K Error switch would compute the percentage of errors and display it.
ISP / In System Programming Port / Municipality Corporation may time to time change the fare rates. ISP Port allows entering new fare rates into the MCU chip of the Taximeter without removing it from the Taxicab.

15.5 Authorized Tariffs

Bangladesh Road Transport Authority (BRTA) in a gazette notification on 20th October 2015 had fixed up the following tariffs of Table-15.2 for CNG-driven 3-wheeler Taxicabs. These are important data for the design of a Taximeter as we shall see in this paper.

Table-15.2 : Authorized Tariffs
Sn. / Parameters / Rate
1 / Fare for the 1st 2Km / Tk 40.00
2 / Fare for next each Km distance travelled after 1st 2Km / Tk 12.00
3 / Distance Update (Designer’s Option) / 10m
4 / Waiting Time Fare for each 1-min (60-Sec) waiting / Tk 2.00
5 / Fare Update for each 200m distance travelled after 1st 2Km (12.00/5 =2.40) / Tk 2.40
6 / Advance Fare (Fare Update) for 200m after 1st 2Km crossing (1/5th of 1Km fare) / Tk 2.40

15.6 Working Principle of a 3-Wheeler Taximeter

In this Section, we briefly describe the working mechanism of a typical Taximeter (Fig-15.1, 15.3) fitted with a 3-wheeler CNG powered Taxicab. This description would help a lot to understand the design principles of various electronic circuits and software routines of the Taximeter.

The journey of the Taxicab from a source point to a destination could be completed in one or more of the following ways:

(1) By travelling only (no waiting) called ‘Distance Drive or D-drive’,

(2) By spending waiting time (no travelling, the passenger cancels trip after waiting) called ‘Time Drive or T-drive’, and

(3) By travelling and waiting (real trip) called ‘Combined Distance-Time Drive or C-Drive’.


15.6.1 Distance Drive (D-drive) Journey

Figure-15.4: Line Diagram of a typical D-drive journey

(1) An electronic transducer (Fig-15.1, 15.2) is attached with the gearbox of the engine of the Taxicab, which produces about 16 electric pulses (called Wheel Turning Pulse, WTP) as the vehicle moves for 10m distance. The Digital Distance Meter updates the distance by 10m.

(2) At power up reset, the Taximeter shows 0.00 on the DFM, 0.00 on the DDM, and 0.00 on the DWM.

(3) After the Taxicab is hired by a passenger, the driver presses the HIRED button. The DFM show 40.00 Tk, the DDM shows 0.00 km, and DWM shows 0.00 Mn (0-min 00-sec = 0m00s = 0.00Mn).

(4) From the very start of the trip, Digital Fare Meter (DFM) shows Tk 40.00 as a Flat Fare for the 1st 2Km of distance. At the crossing of 1st 2Km, DFM advances by Tk 2.40 (Ponit-A, Fig-15.4) – an advance payment for the fare of 200m at the fare rate of Tk 12.00/Km.

(5) After the 1st 2Km zone, the DFM keeps adding Tk 1.50 for each 200m distance travelled by the Taxicab (Point-B, Fig-15.4).

(6) At the end of journey, the Taxicab arrives at the destination. The driver pushes TO PAY button. All processing activities of the meter are stopped. The DFM keeps showing the fare (44.80), Digital Distance Meter (DDM) shows distance covered (2.20) and Digital Waiting Meter (DWM) shows elapse waiting time (0.00). The passenger makes the payment and leaves the Taxicab. The Taxicab is ready for the next hire.

(7) The Line Diagram of Fig-15.4 describes a D-drive journey.

15.6.2 Time Drive (T-drive) Journey

Figure-15.5: Line Diagram of a typical T-drive journey

(1) Just after hiring, the driver may be asked to wait for other passengers to come down from house. DWM updates waiting time by 1-sec. Because, there is a charge for the waiting time as per Table-15.2; at the elapse of waiting time (WT) of 20.00 (20-m 0-sec), the DFM shows 40.00 + 2.40 = 42.40Tk, the DDM shows 0.00 km, and the DWM shows 20.00. This happens at Pont-B (Fig-15.5); it is equivalent to 1st 2km crossing point. For the 1st 2 km, Flat Fare is Tk 40.00; charge for waiting time Tk 2.00/minute; so, 40/2 = 20-min waiting time would be required to exhaust the Flat Fare of Tk 40.00. Tk 2.40 is paid to the driver as an advance for the next 200 m distance or equivalent waiting time of 1-min 12-sec.

(2) After Point-B, the Taximeter will wait for 1-min 12-sec to compensate Tk 2.40 paid as advance in Step-1. At Point-C, DFM shows 42.40 + 2.40 = 44.80 Tk; DDM shows 0.00 km; DWM shows 21.12.

(3) Assume that the passenger cancels the journey after waiting for 1-min after Point-B. The driver pushes TO PAY button. All activities of the Taximeter are stopped. The DFM shows Tk 42.40, DDM shows 0.00 km, and DWM shows 21.00. The passenger makes the payment o Tk 42.40 (any way passenger leaves Tk 45.00 as round!). The question is: Does the driver lose money? The answer is No; because, the driver has already been paid an advance of Tk 2.40 at Point-B, which is yet to exhaust.

(4) The Line Diagram of a typical T-dive is shown on Fig-15.5.


15.6.3 Combined Distance-Time Drive (C-drive)

Figure-15.6: Line Diagram of a typical C-drive journey

(1) A practical journey is a combination of:

(a) Waiting for while

(b) Running for a while

(2) In a combined journey (C-drive), the fare is due to distance travelled and waiting time.

(3) To calculate fare in a C-drive, we will always take 10 m distance and 100 ms time as the references. In all calculations, we will use the following definitions:

(a) 10 m = 1-DQ (DQ = distance quanta)

(b) 100 ms = 1 –TQ (TQ = time quanta)

(c) Within 1st 2 km (2000 m) zone:

60-TQ = 1-DQ //means cost of 60*100 ms = cost of 10m

Calculations:

2000 m (2 km) cost: 4000 Ps

10 m cost: (4000/2000)*10 = 20 Ps

//------

200 Ps (Tk 2.00) cost: 1-min waiting time

20 Ps cost: ((60*1000)/200)*20 = 60*100 ms = 60-TQ

//------

60-TQ = 1-EQ (EQ = equivalent distance quanta = DQ)

(d) Outside 1st 2 km (2000 m) zone:

36-TQ = 1-DQ // cost of 36*100 ms = cost of 10m

Calculations:

1000 m (1 km) cost: 1200 Ps (Tk 12.00)

10 m cost: (1200/1000)*10 = 12 Ps

//------

200 Ps (Tk 2.00) cost: 1-min waiting time

12 Ps cost: ((60*1000)/200)*12 = 3600 ms = 36-tq

//------

36-TQ = 1-EQ (EQ = equivalent distance quanta = DQ)

(e) GQ = DQ + EQ (GQ = gross quanta)

(4) The 1st 2 km point will be marked when:

GQ = 200 (combination of DQ and EQ) marks 2 km crossing point: (200*10m = 2000 m)

Figure-15.7: Counting DQ and EQ to mark first 2 km point

Meaning of Fig-15.7:

(a)  In Waiting State, Taximeter will count the elapse of every 100 ms time period. This time period has been named as TQ. The TQ will be generated using TC1 of the MCU. The TQs will be accumulated in the variable counterTQ. After counting 10-TQ (10*100 = 1000 ms = 1 s), the DWM will be updated by 1 s.

(b)  After counting 60-TQ (60*100 = 6000 ms), the variable counterEQ will be incremented by 1. .

(c)  DQ is incremented by 1 when the Taxicab travels 10 m distance. DQ is accumulated in the variable bcounterDQ.

(d)  When the addition of DQ and EQ (of any combination) becomes equal to 200, the 2 km point is marked.

(5) 200 m point (outside 1st 2 km zone) will be marked when:

GQ = 20 (combination of DQ and EQ) marks 200 m crossing point: (20 * 10 m = 200 m)

Figure-15.8: Counting DQ and EQ to mark 200 m point outside 2 km zone

15.6.4 Manual Computation of Meter Readings at various Point of Fig-15.6 for C-drive

Let us find out DFM, DDM, and DWM readings at various points for the C-drive of Fig-15.6.

(1) A – B: T-drive (within 1st 2 km zone)

EQ: = ?

Waiting Time: 15.03 = (15x60 + 3)*1000 ms = 903000 ms = 9030-TQ

EQ: 9030/60 = 150 + 30-TQ

//------

New Quanta Balance at Point-B:

DQ: 0

EQ: 150

TQ: 30 (required 60)

GQ: DQ + EQ + GQ- = 0 + 150 + 0 = 150 (required 200)

//------

Meter Reading at Point-B

DFM = 40.00

DDM = 0.00

DWM = 15.03

//------

Final Quanta Balance at Point-B:

DQ: 0

EQ: 0

TQ: 30 (required 60)

GQ: 150

(2) B – C: D-drive (within 1st 2 km zone)

DQ: =?

Distance: 900 m

DQ: 900/10 = 90

//------

New Quanta Balance at Point-C:

DQ: 90

EQ: 0

TQ: 30 (required 60)

GQ: DQ + EQ + GQ- = 90 + 0 + 150 = 240 = 200 + 20*2

//------

Meter Readings at Point-C

DFM = (40.00 + 2.40) + 2.40*2 = 42.40 + 4.80 = 47.20