AUTOMATIC FARE CALCULATION SYSTEM

30
Netaji Subhas Institute of Technology AUTOMATIC FARE CALCULATION SYSTEM (An 8085 based Project) Presented by: Anirudh Vaid (023/EC/15) Arshiya Gahlot (033/EC/15)

Transcript of AUTOMATIC FARE CALCULATION SYSTEM

Page 1: AUTOMATIC FARE CALCULATION SYSTEM

Netaji Subhas Institute of Technology

AUTOMATIC FARE CALCULATION

SYSTEM

(An 8085 based Project)

Presented by:

Anirudh Vaid (023/EC/15)

Arshiya Gahlot (033/EC/15)

Page 2: AUTOMATIC FARE CALCULATION SYSTEM

ACKNOWLEDGEMENTS

The success of any project depends largely on the encouragement and guidelines of

many others. We take this opportunity to express our gratitude to the people who

have been instrumental in the successful completion of this project. We would like

to show our greatest gratitude to Prof. Dhananjay V. Gadre for his tremendous

support and help. Without his encouragement and guidance this project would not

have been materialized. The guidance and support received from all the CEDT

members who contributed and who are contributing to this project, was vital for the

success of this project. We are extremely grateful for their constant support and help.

Page 3: AUTOMATIC FARE CALCULATION SYSTEM

INTRODUCTION

This project aims to develop a prototype of an electronic meter that calculates the

fare according to the distance travelled & time elapsed in the entire journey using

8085. The system is based on a simple principle of counting the rotations of the

wheel/tyre using IR sensor. Whenever, the white piece of cardboard which is

attached to a fixed position on the wheel passes near the IR sensor, it generates

an output signal equals to 1 and counts it as one complete rotation incrementing

the count of the distance and calculation of fare is done accordingly. The main

building blocks of the circuit are 8085 microprocessor, Input/output interface,

LCD display, IR sensor circuit, push buttons to start, end & reset the system &

memory.

The prototype is developed in parallel to the original taxi/autorickshaw fare

meter. Conventionally used analog meters have many drawbacks like reading &

interpolation errors, parallax errors, has no provision for digital readout of final

value & no storage of readings for future reference. So, keeping in mind these

things and the advantages of a digital fare calculation mechanism using a

microprocessor provides an additional advantage of adding on a feature of time

elapsed in traffic, not causing any kind of financial loss to the service provider.

Moreover, the design of the digital meter makes it desirable for passengers as it

is accurate, direct, and tamper proof. Apart from this, other motivating factors

behind this project are learning the practical applicability of 8085 microprocessor

&how to implement it in the form of an integrated project that is dependent on

different functionalities that are offered by 8085.

Page 4: AUTOMATIC FARE CALCULATION SYSTEM

BASIC BUILDING BOCKS OF PROJECT

The entire project can be classified into functional blocks that work in

synchronization to achieve the final result of displaying the final fare in rupees &

total distance travelled. The blocks work as follows:

1. 8085 MICROPROCESSOR

When the system is powered ON, 8085 transfers the program control & starts

executing the main program stored in the ROM and activates the 8255 PPI & IR

sensor circuit & starts serial communication using SID/SOD.As the sensor gives

output HIGH, 8255 port A input is checked via a suitable program loop & suitable

result is displayed on the LCD display.

Figure 1: 8085 Integrated Chip Figure 2: 8085 pin diagram

Page 5: AUTOMATIC FARE CALCULATION SYSTEM

2. INPUT/OUTPUT INTERFACE (8255 PPI)

All the Input/output devices including the IR sensor circuit, push buttons to start,

end & reset the circuit & LCD display, all are interfaced to 8085 by PPI

(Programmable Peripheral Interface).8255 chip is used for this purpose depending

upon the requirement of ports in the project.

Figure 3:8255 PPI Integrated Chip Figure 4: 8255 pin diagram

3. LCD DISPLAY

At the beginning of the trip, when START button is pressed, the per unit distance

fare will be displayed on the 16X2 LCD display. During the journey, the rate of

Page 6: AUTOMATIC FARE CALCULATION SYSTEM

increment of fare corresponding to the distance travelled will be displayed. At the

end, net fare generated & total distance travelled will be displayed.

Figure 5:16X2 LCD Display

4. INFRA-RED SENSOR (IR SENSOR)

In order to measure the net distance travelled by the vehicle, it is practically

achieved by attaching a white piece of cardboard to the wheel at a particular

position & accordingly the IR sensor shows an output voltage HIGH whenever the

white surface passes nearest to it & it is counted as one rotation till next time again

this happens. This process goes on till vehicle/wheel finally comes to rest.

Depending upon the number of revolutions, net distance is calculated as:

Total distance = No. of rotations x Circumference of wheel

Net Fare = Total Distance X Unit distance fare + Fare generated

due to stoppage (if any)

Page 7: AUTOMATIC FARE CALCULATION SYSTEM

Figure 6: IR sensor board

5. PUSH BUTTONS & THEIR FUNCTIONALITY

The system provides 3 functional push buttons indicating START, END &

RESET. START is used to indicate the start of journey & when it is pressed the

Microprocessor gets activated and starts to calculate the distance by activating IR

sensor circuit through Interrupt pin. END is used to indicate the end of journey &

directs the Microprocessor to deactivate the IR sensor circuit by disabling the

Interrupt pin of 8085 & thus displays final amount of fare generated. RESET

button is used to reset the entire system.

Figure 7:Push Buttons

Page 8: AUTOMATIC FARE CALCULATION SYSTEM

6. MEMORY

This block is used to store the main program that is being fetched by 8085 for

execution as well as storing the additional relevant data like value of readings that

have been recorded in the past trips etc. It consists of five functional blocks:

i. RAM

ii. ROM

iii. LATCH

iv. DECODER

v. NOT GATE IC (HEX INVERTER)

Figure 8: ROM IC Figure 9: RAM IC

Page 9: AUTOMATIC FARE CALCULATION SYSTEM

Figure 10: latch IC

Page 10: AUTOMATIC FARE CALCULATION SYSTEM

BLOCK DIAGRAM

Page 11: AUTOMATIC FARE CALCULATION SYSTEM

PROGRAM FLOWCHART

0

1

POWER ON

INITIALIZE LCD & MEMORY

CHECK

START

TURN ON TIMER COUNTER

UPDATE LCD, CHECK SENSOR, PUSH BUTTONS & TIMER

INCREMENT

“DIST” VARIABLE

INCREMENT “TIME”

VARIABLE

STOP CHECKING SENSORS

& DISPLAY FINAL FARE

RESET & START

TIMER COUNTER

CHECK

“END”

CHECK

“TIMER

COUNTER”

CHECK

“SENSOR

CHECK

“RESET”

Page 12: AUTOMATIC FARE CALCULATION SYSTEM
Page 13: AUTOMATIC FARE CALCULATION SYSTEM

BOARD LAYOUT

Page 14: AUTOMATIC FARE CALCULATION SYSTEM

BOM QTY DEVICE PACKAGE PARTS DESCRIPTION

1 16X2LCD 16X2_LCD LCD1 ALPHANUMERIC-LCD

1 58C256P DIL28-6 EEROM MEMORY

1 62256P DIL28-6 RAM MEMORY

1 8085A DIL40 8085A MICROCOMPUTER/PERIPHERAL DEVICE

1 8255A DIL40 8255A MICROCOMPUTER/PERIPHERAL DEVICE

1 CRYSTALHC49US HC49US Q1 Crystal

1 M03 03P SL1 AMP QUICK CONNECTOR

1 10u CPOL-EU C17 POLARIZED CAPACITOR

1 1k R-EU_0207/7 R13 RESISTOR

1 74HC04N 74HC04NDIL14 7404 DECODER Hex INVERTER

1 74HC138N 74HC138NDIL16 DECODER 3-line to 8-line DECODER/DEMULTIPLEXER

1 74HCT573N 74HCT573NDIL20 LATCH 8-bit D latch BUS DRIVER

1 LED3MM LED3MM LED3 LED3MM

1 LED5MM LED5MM LED1 LED5MM

1 PRESET_LR PRESET_LRU$3 PRESET_LR PRESET

1 USB(POWER) USB(POWER) USB(POWER)U$2 USB mini

4 M10 10P SL6, SL7, SL8, SL9 OMRON SWITCH

5 0.1u

C-EU025-

024X044 C025-

024X044 C5, C8, C11, C12, C18 CAPACITOR

5 10-XX B3F-10XX RESET, S1, S3, START, STOP AMP QUICK CONNECTOR

12 R-EU_0207/7 0207/7

R1, R2, R3, R4, R5, R6, R7, R8,

R9, R10, R11, R16 RESISTOR

Page 15: AUTOMATIC FARE CALCULATION SYSTEM

WORKING PROJECT

Figure 11: Soldered PCB of Fare Calculator (Bottom View)

Figure 12: Soldered PCB of Fare Calculator (Top View)

Page 16: AUTOMATIC FARE CALCULATION SYSTEM

Figure 13: Soldered PCB of Fare Calculator (Side View)

Figure 14: Fare Calculator during start of journey showing distance & fare

Page 17: AUTOMATIC FARE CALCULATION SYSTEM

Figure 15: IR Sensor Circuit used for measuring RPM

Page 18: AUTOMATIC FARE CALCULATION SYSTEM

PROGRAM

INITIALIZATION: This segment of code initializes & starts execution of main

program

.ORG 0000H

JMP BEGIN

BEGIN: LXI SP, 0000H

MVI A, 10010000B ; 8255 INITIALISATION A as Input Port B&C as output Ports

OUT 03H

MAIN PROGRAM:

RR: CALL INITIAL

CALL STARTER

XYZ: IN 00H

ANI 01H

JNZ XYZ

MVI E,00H

MVI A, 00H

STA 9C50H

STA 9C52H

LXI B, E38EH

MVI D,05H

MVI A,00H

STA 9C51H

CALL UPDATE_LCD

X: IN 00H

ANI 02H

JZ STOPPER

IN 00H

ANI 08H

JZ Y ;CALL DELAY

IN 00H

ANI 08H

JNZ X

LXI H, 9C50H

Page 19: AUTOMATIC FARE CALCULATION SYSTEM

INR M

INR E

LXI B, E38EH

MVI D, 05H

MOV A,E

SUI 04H

JNZ Y

MVI E,00H

LXI H,9C51H

INR M

CALL UPDATE_LCD

LXI H,9C50H

MOV A,M

SUI 04H

JNZ Y

LXI H, 9C52H

INR M

CALL UPDATE_LCD

Y: DCX B

MOV A,C

ORA B

JNZ X

DCR D

JNZ X

LXI H,9C51H

INR M

CALL UPDATE_LCD

LXI B,E38EH

MVI D,05H

JMP X

HLT

STARTER SUBROUTINE: This subroutine is executed as soon as START button is

pressed. It continuously displays the ‘Fare’ & the ‘Distance’ on LCD & side by side

checks the sensor circuit for measuring RPM

STARTER: MVI A, 83H ;Setting DDRAM TO address 83h on that is first line(starts

at 80h)

CALL CMDOUT

Page 20: AUTOMATIC FARE CALCULATION SYSTEM

here_1: MVI A, 46H ; Writing "FARE CALCULATOR"

CALL DTAOUT

MVI A, 41H

CALL DTAOUT

MVI A, 52H

CALL DTAOUT

MVI A, 45H

CALL DTAOUT ;CALL delay_1180ms

here_2: MVI A, C2H ; Setting DDRAM to C4H on second line(starts at C0h)

CALL CMDOUT

MVI A, 43H ; writing "TRIP OVER "

CALL DTAOUT

MVI A, 41H

CALL DTAOUT

MVI A, 4CH

CALL DTAOUT

MVI A, 43H

CALL DTAOUT

MVI A, 55H

CALL DTAOUT

MVI A, 4CH

CALL DTAOUT

MVI A, 41H

CALL DTAOUT

MVI A, 54H

CALL DTAOUT

MVI A, 4FH

CALL DTAOUT

MVI A, 52H

CALL DTAOUT

RET

FINAL FARE SUBROUTINE: This subroutine calculates & displays the final fare

generated according to the total RPMs as measured by the sensor circuit.

Page 21: AUTOMATIC FARE CALCULATION SYSTEM

FINAL_FARE:MVI A, 81H ; Setting DDRAM TO address 83h on that is first

line(starts at 80h)

CALL CMDOUT

MVI A, 46H

CALL DTAOUT

MVI A, 41H

CALL DTAOUT

MVI A, 52H

CALL DTAOUT

MVI A, 45H

CALL DTAOUT

MVI A,3AH

CALL DTAOUT

MVI A,52H

CALL DTAOUT

MVI A, 73H

CALL DTAOUT

LDA 9C40H

here_1:ADI 30H ; Writing "FARE CALCULATOR"

CALL DTAOUT

LDA 9C41H

ADI 30H

CALL DTAOUT

LDA 9C42H

ADI 30H

CALL DTAOUT

MVI A, C0H

CALL CMDOUT

MVI A,54H

CALL DTAOUT

MVI A, 52H

CALL DTAOUT

MVI A, 49H

CALL DTAOUT

MVI A, 50H

CALL DTAOUT

Page 22: AUTOMATIC FARE CALCULATION SYSTEM

MVI A,20H

CALL DTAOUT

MVI A,4FH

CALL DTAOUT

MVI A, 56H

CALL DTAOUT

MVI A, 45H

CALL DTAOUT

MVI A, 52H

CALL DTAOUT

RET

UPDATE_LCD:PUSH B

PUSH D

LXI H, 9C52H

MOV D,M

CALL DGIT3

CALL DGIT2

CALL DGIT1

CALL INITIAL

CALL FFSCREEN

LXI H,9C51H

MOV D,M

CALL DGIT3

CALL DGIT2

CALL DGIT1

CALL FSCREEN

POP D

POP B

RET

DGIT3: MOV A,D

MVI E,00H

S: SUI 64H ;CPI 00H

JC F

INR E

JMP S

Page 23: AUTOMATIC FARE CALCULATION SYSTEM

F: MOV A,E

LXI H,9C40H

STA 9C40H

RET

DGIT2: MOV A,D

MVI E,00H

SS: SUI 0AH

;JZ FF

;CPI 00H

JC FF

INR E

JMP SS

FF: LDA 9C40H

MOV B,A

MVI A,00H

MVI C,0AH

AA: ADD B

DCR C

JNZ AA

MOV C,A

MOV A,E

SUB C

LXI H,9C41H

MOV M,A

RET

DGIT1: MOV A,D

MVI A,00H

MVI C,64H

LXI H,9C40H

AAA: ADD M

DCR C

JNZ AAA

MOV C,A

MOV A,D

SUB C

MOV E,A

MVI C,0AH

MVI A, 00H

LXI H,9C41H

BBB: ADD M

DCR C

Page 24: AUTOMATIC FARE CALCULATION SYSTEM

JNZ BBB

MOV C,A

MOV A,E

SUB C

STA 9C42H

RET

DELAY SUBROUTINE: This subroutine is used to introduce delay to the system.

DELAY: PUSH B

LXI B, 00FFH

DE: DCX B

MOV A,C

ORA B

JNZ DE

POP B

RET

INITIAL:MVI A, 00110000B ; 30H sent to check the necessary Power On

conditions

MOV B, A

CALL OUTPUT

CALL CMDOUT

CALL CMDOUT

MVI A, 00111000B ; Code 38H 8 BIT, 2 LINES, 5X7 DISP

CALL CMDOUT

MVI A, 00001000B ; DISPLAY OFF

CALL CMDOUT

MVI A, 00000001B ; CLEAR DISPLAY 01H

CALL CMDOUT

MVI A, 00000110B ; ENTRY MODE SET, SHIFT AND

INCREMENT CURSOR 06H

CALL CMDOUT

MVI A, 00001110B ; DISPLAY ON CURSOR, BLINKING OFF

0CH

CALL CMDOUT

RET

FFSCREEN: MVI A, C1H ; Setting DDRAM TO address 83h on that is first

line(starts at 80h)

CALL CMDOUT

Page 25: AUTOMATIC FARE CALCULATION SYSTEM

MVI A, 44H

CALL DTAOUT

MVI A, 49H

CALL DTAOUT

MVI A, 53H

CALL DTAOUT

MVI A, 54H

CALL DTAOUT

MVI A,2EH

CALL DTAOUT

MVI A,3AH

CALL DTAOUT

MVI A, 20H

CALL DTAOUT

LDA 9C40H

here_1: ADI 30H ; Writing "FARE CALCULATOR"

CALL DTAOUT

LDA 9C41H

ADI 30H

CALL DTAOUT

LDA 9C42H

ADI 30H

CALL DTAOUT

RET

FSCREEN: MVI A, 81H ; Setting DDRAM TO address 83h on that is first

line(starts at 80h)

CALL CMDOUT

MVI A, 46H

CALL DTAOUT

MVI A, 41H

CALL DTAOUT

MVI A, 52H

CALL DTAOUT

MVI A, 45H

CALL DTAOUT

MVI A,3AH

CALL DTAOUT

MVI A,52H

CALL DTAOUT

MVI A, 73H

CALL DTAOUT

Page 26: AUTOMATIC FARE CALCULATION SYSTEM

MVI A, 20H

CALL DTAOUT

LDA 9C40H

here_1: ADI 30H ; Writing "FARE CALCULATOR"

CALL DTAOUT

LDA 9C41H

ADI 30H

CALL DTAOUT

LDA 9C42H

ADI 30H

CALL DTAOUT

RET ;CALL delay_1180ms

STARTER: MVI A, 83H ; Setting DDRAM TO address 83h on that is first

line(starts at 80h)

CALL CMDOUT

here_1: MVI A, 46H ; Writing "FARE CALCULATOR"

CALL DTAOUT

MVI A, 41H

CALL DTAOUT

MVI A, 52H

CALL DTAOUT

MVI A, 45H

CALL DTAOUT

;CALL delay_1180ms

here_2: MVI A, C2H ; Setting DDRAM to C4H on second

line(starts at C0h)

CALL CMDOUT

MVI A, 43H ; writing "TRIP OVER"

CALL DTAOUT

MVI A, 41H

CALL DTAOUT

MVI A, 4CH

CALL DTAOUT

MVI A, 43H

CALL DTAOUT

MVI A, 55H

CALL DTAOUT

MVI A, 4CH

CALL DTAOUT

MVI A, 41H

CALL DTAOUT

Page 27: AUTOMATIC FARE CALCULATION SYSTEM

MVI A, 54H

CALL DTAOUT

MVI A, 4FH

CALL DTAOUT

MVI A, 52H

CALL DTAOUT

RET

CMDOUT: MOV B,A

CALL CHKDB7

OUTPUT: MVI A, 00000000B ; Select PC1=RS=0

OUT 03H

MVI A, 000000010B ; Select PC0 RW=0 Enable Write

OUT 03H

MVI A, 00000101B ; Set EN High

OUT 03H

MOV A,B

OUT 01H

MVI A, 00000100B ; Set EN Low

OUT 03H

RET

DTAOUT: MOV B,A

CALL CHKDB7

MVI A, 00000001B ; Select PC1=RS=1

OUT 03H

MVI A, 00000010B ; Select PC0 RW=0 Enable Write

OUT 03H

MVI A, 00000101B ; SET EN High

OUT 03H

MOV A,B

OUT 01H

MVI A, 00000100B ; Set EN Low

OUT 03H

RET

CHKDB7: MVI A, 10010010B ; Set up Port B as Input

OUT 03H

MVI A, 00000000B ; Select PC1=RS=0

OUT 03H

MVI A, 00000011B ; Select PC0 RW=1 Enable Read

OUT 03H

READ: MVI A, 00000101B ; Set EN High

Page 28: AUTOMATIC FARE CALCULATION SYSTEM

OUT 03H

IN 01H ; Read 01H and CHKDB7

RLC

MVI A, 00000100B ; Set EN Low

OUT 03H

JC READ ; If DB7=1 jump and read again

MVI A, 10010000B ; Set up B again as ouput

OUT 03H

RET

The major subroutines comprising the program are given below with their functions:

• Mainprogram: timer loop and check pushbuttons and input from sensor

• Stopper- displays final fare when stop button is pressed and resets the program

when reset button is press

• Reset- displays final fare when stop button is pressed and resets the program

when reset button is press

• Update_lcd- updates lcd during the trip & shows the distance and fare

• Digit 3,digit2,digit1- converts binary number into decimal digits

• Delay-for debouncingDelay-for debouncing

• Fscreen,ffscreen-for displaying distance and fare while updating lcd

• Starter-for displaying welcome msg(fare calculator)

• Initial,cmdout,output,dtaout,chkdb7,read- for LCD

Page 29: AUTOMATIC FARE CALCULATION SYSTEM

GANTT CHART

1. EXPECTED GANTT CHART

2. ACTUAL GANTT CHART

Page 30: AUTOMATIC FARE CALCULATION SYSTEM

REFERENCES

[1] Gaonkar, R.S. “Microprocessor Architecture, Programming,

and Applications with the 8085”. Prentice Hall, 2002. isbn:

9780130195708.

[2]www.8085projects.in

[3]https://www.tutorialspoint.com/microprocessor/microprocessor_8279_

programmable_keyboard.htm