Vehicle Speed Monitor Report
Vehicle Speed Monitor Report
By
ARJUN RK 18BEC1120
J KIRON 18BEC1150
B VISWESHWARAN 18BEC1152
BONAFIDE CERTIFICATE
Certified that this project report entitled “Vehicle speed monitoring using
8051” is a bonafide work of ARJUN RK (18BEC1120), J KIRON
(18BEC1150) and B VISWESHWARAN (18BEC1152) who carried out the
Project work under my supervision and guidance for ECE3003:
Microcontrollers and its applications
Dr. M JAGANNATH
Associate Professor
ABSTRACT
ACKNOWLEDGEMENT
We wish to express our sincere thanks and deep sense of gratitude to our project
guide, Dr. M Jagannath, Associate Professor, School of Electronics
Engineering, for her consistent encouragement and valuable guidance offered to
us in a pleasant manner throughout the course of the project work.
We express our thanks to our Head of the Department Dr. Vetrivelan. P for his
support throughout the course of this project. We also take this opportunity to
thank all the faculty of the School for their support and their wisdom imparted
to us throughout the course.
We thank our parents, family, and friends for bearing with us throughout the
course of our project and for the opportunity they provided us in undergoing
this course in such a prestigious institution.
ARJUN RK J KIRON
B VISWESHWARAN
5
TABLE OF CONTENTS
1 INTRODUCTION 6
2 DESIGN 7-11
2.1 BLOCK DIAGRAM 7
2.2 CIRCUIT DIAGRAM 8
2.3 HARDWARE ANALYSIS 8-11
REFERENCES 19
6
CHAPTER 1
INTRODUCTION
That measures and displays the speed of a vehicle accurately and instantly.
1.2 BENEFITS
1.3 FEATURES
CHAPTER 2
DESIGN
The three main features of the basic block diagram (given below) are
- IR Sensor
- LCD
- 8051Microcontroller
Each of the above units may consist of the sensory units, communication
modules, etc.
The circuit diagram of the system has been depicted in Figure 2. It was designed
using Proteus[1].
2.3.1 IR SENSOR
An infrared (IR) sensor is an electronic device that measures and detects infrared radiation in
its surrounding environment. There are two types of IR sensors namely active and passive.
The sensor we use is an Active sensor. Active infrared sensors both emit and detect infrared
radiation. Active IR sensors have two parts: a light emitting diode (LED) and a receiver.
When an object comes close to the sensor, the infrared light from the LED reflects off of the
object and is detected by the receiver. Active IR sensors act as proximity sensors, and they
are commonly used in obstacle detection systems. The module detects a distance of 2 ~
10cm, detection angle 35 °. The pin configuration of the IR Sensor is depicted in Table 1.
9
Pin Configuration
The output current of this IC can go up to 1.5A. But the IC suffers from heavy heat loss
hence a Heat sink is recommended for projects that consume more current. For example, if
the input voltage is 12V and you are consuming 1A, then (12-5) * 1 = 7W. This 7 Watts will
be dissipated as heat.
7805 IC Features
Minimum Input Voltage is 7V
Maximum Input Voltage is 25V
Operating current (IQ) is 5mA
Internal Thermal Overload and Short circuit current limiting protection is available.
2.3.3 LCD:
An LCD is an electronic display module which uses liquid crystal to produce a visible
image. The 16×2 LCD display is a very basic module commonly used in DIYs and
10
circuits. The 16×2 translates displays 16 characters per line in 2 such lines. In this
LCD each character is displayed in a 5×8 pixel matrix. The pin configuration of LCD
is mentioned in Table 3.
Pin Configuration
Pin
Name
No. Function
3 potentiometer. The output of the potentiometer is connected to this pin. Rotate the Vo / VEE
potentiometer knob forward and backwards to adjust the LCD contrast.
RS (Register
4 Selects command register when low, and data register when high
Select )
5 Low to write to the register; High to read from the register Read/write
Sends data to data pins when a high to low pulse is given; Extra voltage push is
required to execute the instruction and EN(enable) signal is used for this purpose.
6 Enable
Usually, we make it en=0 and when we want to execute the instruction we make it
high en=1 for some milliseconds. After this we again make it ground that is, en=0.
7 8-bit data pins DB0
11
8 DB1
9 DB2
10 DB3
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led-
Table 3: Pin configuration of LCD
Pin 31 − This is ALE pin which stands for Address Latch Enable. It is used to
demultiplex the address-data signal of port.
Pins 32 to 39 − These pins are known as Port 0. It serves as I/O port. Lower order
address and data bus signals are multiplexed using this port.
Pin 40 − This pin is used to provide power supply to the circuit [2].
CHAPTER 3
SOFTWARE IMPLEMENTATION
The software used is code compose studio. The concept of Timers and various
other features have been applied in the coding process [3].
Keil software was used to compile and run the code [4].
Program code
ASM CODE:
ORG 0000H
ACALL DELAY
INC DPTR
SJMP C1
SEND_DATA_1:
MOV DPTR, #MSG_ON_RST_1
D1:
CLR A
MOVC A, @A+DPTR
JZ SEND_DATA_2
ACALL DATAWRT
ACALL DELAY
INC DPTR
SJMP D1
SEND_DATA_2:
MOV A, #0C0H
ACALL COMNWRT
ACALL DELAY
MOV DPTR, #MSG_ON_RST_2
D2:
CLR A
MOVC A, @A+DPTR
JZ SEND_DATA_3
ACALL DATAWRT
ACALL DELAY
INC DPTR
SJMP D2
SEND_DATA_3:
ACALL DELAY_1S
MOV A, #01H
ACALL COMNWRT
ACALL DELAY
MOV DPTR, #MSG_ON_RST_3
D3:
CLR A
MOVC A, @A+DPTR
JZ SEND_DATA_4
ACALL DATAWRT
ACALL DELAY
INC DPTR
SJMP D3
SEND_DATA_4:
MOV A, #0C0H
ACALL COMNWRT
ACALL DELAY
MOV DPTR, #MSG_ON_RST_4
D4:
CLR A
MOVC A, @A+DPTR
JZ DELAY_4S
ACALL DATAWRT
ACALL DELAY
INC DPTR
SJMP D4
DELAY_4S:
MOV R7, #45
HERE3:
ACALL DELAY
DJNZ R7, HERE3
14
MAIN:
ACALL DELAY_1S
ACALL CLR_SCREEN
MOV A, #0FH
ACALL COMNWRT
ACALL DELAY
CONTINUE:
MOV R0, #00H
MOV P2, #0FFH
MOV TMOD, #01H
MOV TL0, #00H
MOV TH0, #00H
READ:
JNB P2.4, SPEED_PLUS
JNB P2.5, SPEED_MINUS
SJMP READ
SPEED_PLUS:
SETB TR0
RS_2:
JB TF0, PLUS_P
REPEAT_P:
JB P2.5, RS_2
CLR TR0
SEND_SPEED:
MOV DPTR, #SPEED_WORD
D5:
CLR A
MOVC A, @A+DPTR
JZ NEXT_LINE_P
ACALL DATAWRT
ACALL DELAY
INC DPTR
SJMP D5
NEXT_LINE_P:
MOV A, #0C0H
ACALL COMNWRT
ACALL DELAY
MOV A, #0FH
ACALL COMNWRT
ACALL DELAY
ACALL TIME
ACALL DIST_FIX
ACALL SPEED_INIT
ACALL SPEED_CALC
SEND_SPEED_UNIT:
MOV DPTR, #SPEED_UNIT
D7:
CLR A
MOVC A, @A+DPTR
JZ MAIN
ACALL DATAWRT
ACALL DELAY
INC DPTR
SJMP D7
SPEED_MINUS:
SETB TR0
RS_1:
15
JB TF0, PLUS_N
REPEAT_N:
JB P2.4, RS_1
CLR TR0
SEND_OPP:
MOV DPTR, #OPP_LANE_WORD
D6:
CLR A
MOVC A, @A+DPTR
JZ NEXT_LINE_N
ACALL DATAWRT
ACALL DELAY
INC DPTR
SJMP D6
NEXT_LINE_N:
MOV A, #0C0H
ACALL COMNWRT
ACALL DELAY
MOV A, #0FH
ACALL COMNWRT
ACALL DELAY
ACALL TIME
ACALL DIST_FIX
ACALL SPEED_INIT
ACALL SPEED_CALC
SEND_SPEED_VALUE:
MOV A, 48H
ACALL SPEED_DISP
MOV A, #"."
ACALL DATAWRT
ACALL DELAY
MOV A, 49H
ACALL SPEED_DISP
SJMP SEND_SPEED_UNIT
PLUS_P:
INC R0
CLR TF0
SJMP REPEAT_P
PLUS_N:
INC R0
CLR TF0
SJMP REPEAT_N
DELAY_1S:
MOV R7, #13
HERE4:
ACALL DELAY
DJNZ R7, HERE4
RET
TIME:
MOV A, #20H
MOV B, R0
MUL AB
MOV 43H, A
MOV 42H, B
MOV A, TH0
ADDC A, #18H
MOV 43H, A
16
RET
SPEED:
DEC R0
MOV 44H, R0
MOV A, R0
MOV B, #5
DIV AB
MOV 48H, A
MOV 49H, B
MOV A, #02H
MUL AB
MOV 49H, A
MOV B, #18
MUL AB
MOV 51H, A
MOV 50H, B
MOV A, 48H
MOV B, #18
MUL AB
MOV 48H, A
MOV 49H, B
MOV A, 51H
MOV B, #10
DIV AB
MOV 50H, A
MOV 51H, B
MOV A, 48H
ADD A, 50H
MOV 48H, A
MOV A, 49H
ADD A, 51H
MOV 49H, A
ACALL ACT_SPEED
JMP SEND_SPEED_VALUE
SPEED_CALC:
MOV A, R0
MOV B, 43H
MUL AB
MOV 47H, A
MOV 46H, B
MOV A, R0
MOV B, 42H
MUL AB
ADDC A, 46H
MOV 46H, A
SJMP SPEED_CHK
SPEED_CHK:
MOV A, 40H
MOV B, 46H
CJNE A, B, CHK1
MOV A, 41H
MOV B, 47H
CJNE A, B, CHK2
SJMP SPEED
CHK1:
JC SPEED
INC R0
SJMP SPEED_CALC
CHK2:
JC SPEED
17
INC R0
SJMP SPEED_CALC
DIST_FIX:
MOV 40H, #27H
MOV 41H, #10H
RET
SPEED_INIT:
MOV R0, #01H
RET
ACT_SPEED:
MOV A, 48H
MOV B, #10
DIV AB
MOV 50H, A
MOV A, #10
MUL AB
MOV 51H, A
ADD A, 49H
MOV 51H, A
MOV A, 49H
MOV B, #10
MUL AB
MOV 49H, A
ADD A, 51H
MOV 49H, A
MOV A, 48H
ADD A, 50H
MOV 48H, A
RET
SPEED_DISP:
MOV B, #100
DIV AB
JZ LESS_100
ADD A, #48
ACALL DATAWRT
ACALL DELAY
LESS_100:
MOV A, B
MOV B, #10
DIV AB
ADD A, #48
ACALL DATAWRT
ACALL DELAY
MOV A, B
ADD A, #48
ACALL DATAWRT
ACALL DELAY
RET
COMNWRT:
MOV P0, A
CLR P2.6
SETB P2.7
ACALL DELAY
CLR P2.7
RET
DATAWRT:
MOV P0, A
SETB P2.6
SETB P2.7
18
ACALL DELAY
CLR P2.7
RET
DELAY:
MOV R3, #200
HERE2:
MOV R4, #200
HERE:
DJNZ R4, HERE
DJNZ R3, HERE2
RET
CLR_SCREEN:
MOV A, #01H
ACALL COMNWRT
ACALL DELAY
MOV A, #80H
ACALL COMNWRT
ACALL DELAY
RET
ORG 300H
MY_COM1: DB 38H, 0EH, 01H, 06H, 80H,0
MSG_ON_RST_1: DB " VEHICLE SPEED",0
MSG_ON_RST_2: DB " DETECTION ",0
MSG_ON_RST_3: DB " USING 8051 ",0
MSG_ON_RST_4: DB " MICROCONTROLLER ",0
OPP_LANE_WORD: DB " Opposite Lane ",0
SPEED_WORD: DB "Speed = ",0
SPEED_UNIT: DB " kmph ",0
END
CHAPTER 4
CONCLUSION AND FUTURE WORK
4.1 CONCLUSION
19
- We find the speed by which a vehicle passes and that is displayed on the
LCD. This information can be used to assess the speed of vehicles on a
road and ticket over speeding vehicles. The working snapshot of the
simulation has been shown in Figure 4.
- The speed obtained is more accurate provided the vehicle is closer to the
sensor.
- The system has a drawback that the speed will not be detected even if one
of the IR sensors is covered by an obstruction like animals, plastics, etc.
- The vehicle speed checker can be fixed by using better quality sensors.
Better calibration between the sensor and vehicle can be used to measure
the precise speed and Data from these positions can be averaged to get a
more accurate speed reading.
1) The Infrared sensor can be used for mapping of the environment and
detect objects.
2) The sensor can be used for vehicles as parking sensors which can be
used for detecting walls and other vehicles.
3) The sensor can also be used as a radar of the environment to detect
movements and can also be placed in safe places of the pipelines to detect
any leaks in the pipeline.
4) Ships can use more accurate and bigger sensors to gain vision deep
inside the ocean. Enemy Submarines can also be detected using this
sensor.
5) It can also be used as a home theft alert system as the two sensors can
be used to detect a person entering the room and vice -versa.
20
5. REFERENCES
1. http://www.circuitstoday.com/proteus-software-introduction - Tutorial for using Proteus.
[ CITATION Pro2 \l 1033 ]
2. https://www.freebookcentre.net/electronics-ebooks-download/Microcontrollers-and-
Applications.html [ CITATION Mic \l 1033 ]
3. https://www.tutorialspoint.com/timers-of-8051 [ CITATION Tim \l 1033 ]