0% found this document useful (1 vote)
640 views45 pages

Contact Less Digital Tachometer: Mini Project On

This document describes a contactless digital tachometer project created by three students. It uses an infrared proximity sensor to detect rotations and send pulses to a microcontroller which counts the pulses over one second to calculate and display the RPM on a LCD screen. The project was created for a class and guided by Professor Manisha Waje. It acknowledges those who provided support and guidance.

Uploaded by

Mayur Chandak
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
640 views45 pages

Contact Less Digital Tachometer: Mini Project On

This document describes a contactless digital tachometer project created by three students. It uses an infrared proximity sensor to detect rotations and send pulses to a microcontroller which counts the pulses over one second to calculate and display the RPM on a LCD screen. The project was created for a class and guided by Professor Manisha Waje. It acknowledges those who provided support and guidance.

Uploaded by

Mayur Chandak
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 45

G.H.

Raisoni College of Engineering & Management,


Wagholi, Pune.

Mini project on:

CONTACT LESS
DIGITAL
TACHOMETER
BY:
1) Mayur Chandak (Roll No. 03)
2) Ketan Kalantri (Roll No. 09)

3) Kapil Chandak (Roll No. 02)

T.E. Electronics (Academic Year 2009-2010)

Under the Guidance of:


1 Page
Prof. Manisha Waje.

ACKNOWLEDGMENT

We would take this opportunity to thank the almighty


who has endowed us with intelligence so as to be able to
undertake a project on Contact Less Digital Tachometer
At the outset we express our heartfelt gratitude to our
project guide Prof.Manisha Waje who, guided us with
her knowledge and experience our sole mean of guidance
is Prof. Manisha Waje and our respected H.O.D
Prof.Vijay Joshi. We also would like to thank our
honorable principle Dr. D.D.Shah for their support. It
would have been simply impossible for us to undertake
this project without their help.
We would also like to thank all staff members of our
department for their kind support.

-Mayur Chandak
-Ketan Kalantri
2 Page
-Kapil Chandak

3 Page
INDEX
1. Abstract………………………………………………….5
2. Introduction……………………………………………..6
3. Features………………………………………………….7
4. Specifications……………………………………………8
5. Principle of Operation…………………………………..9
6. Block Diagram & its Description………………………10
7. Module Wise Design…………………………………….12
a. Proximity Sensor………………………………….12
b. Microcontroller…………………………………...14
c. LCD………………………………………………..17
8. Circuit Diagram & Description………………………. 20
9. List of components…………………………………...…25
10. PCB Design……………………………………………26
11. Software Section………………………………………29
a. Algorithm…………………………………………..29
b. Flow Chart…………………………………………31
c. Code ………………………………………………33
12. Application…………………………………………….40
13. Bill of Materials.............................................................41
14. Results & Conclusions………………………………..42
15. References……………………………………………..43
16. Datasheets……………………………………………..44

4 Page
ABSTRACT

Counting revolutions per minute (RPM) of motors


determining the motor speed is essential in the field of industrial
automation. It is useful especially for closed loop systems where
proper action can be taken in case the actual RPM deviates from
the set RPM.
So we have designed a simple microcontroller based
system to measure RPM of any machine accurately without
actually touching it. This system measures the RPM and shows
on LCD the RPM of running motor or machine.
Using proper transducer, first the rotations of the
motor are converted into pulses. The generated pulses are
counted by microcontroller for a fixed time (one second). The
count is multiplied by factor to get the exact RPM and then
displayed on the LCD.

5 Page
INTRODUCTION

 TACHOMETER: Tachometer is a device which measures RPM


(Rotational speed) of any rotating element.
 This is a portable tachometer, which has battery and can measure
15,300rpms.
 As this is a digital tachometer, it displays the measured reading on
an alphanumeric LCD, in rpm’s (revolution per min.).
 As the name implies, what makes this device special, is that it can
very accurately measure the rotational speed of a shaft without
even touching it. This is very interesting when making direct
contact with the rotating shaft is not an option or will reduce the
velocity of the shaft, giving faulty readings.
 The sensor used in this tachometer is an IR Proximity sensor,
which produces pulses according to received IR rays & provides
them as input to the microcontroller.
 Microcontroller counts these pulses according to algorithm built in
as program and displays results on LCD.
 It can be used for speed measurements of various motors & shafts
where very precise measure of rotational speed is required.

6 Page
FEATURES

 Digital Readout.

 Speed displayed in rpm (Revolution per min.).

 Contactless measurement.

 Measures up to 15,300 rpm.

 Instantaneous measurement.

 Automatic DATA Hold Function.

 Portable, due to use of battery.

 Reliability due to use of microcontroller.

 No mechanical wear & tear, as no moving part.

 User friendly.

7 Page
SPECIFICATIONS

Measures up to 15,300 rpm.

9v Battery.

All IC’s require 6v supply.

Electrical & mechanical specifications of all


components are provided in the datasheets attached
Herewith at the end of the report.

8 Page
PRINCIPLE OF OPERATION:

 The idea behind most digital counting device, frequency meters


and tachometers, is a micro-controller, used to count the pulses
coming from a sensor or any other electronic device.

 In the case of this tachometer, the counted pluses will come from
IR proximity sensor, which will detect any reflective element
passing in-front of it, and thus, will give an output pulse for each
and every rotation of the shaft, as show in the picture. Those pulses
will be fed to the microcontroller and counted.

BLOCK DIAGRAM:
9 Page
Reflective
strip
DIGITAL TACHOMETER

IR Microcontroller Alphanumeric
Proximity P89C51RD2Hxx LCD
sensor

Power Supply 6 V

DISCRIPTION:
IR Proximity Sensor:
 Here the proximity sensor used is IR proximity
sensor.

 Thus it works on the principle of IR transmission &


reception.

 When transmitted IR gets reflected back receiver


detects it & we get output.

Microcontroller(8051):
 It is the most important part of the design,
it processes the input obtained from IRproximity sensor
& produces output which
is displayed on the LCD.

 The P89C51RD2Hxx is a member of 8051 family,


produced by Phillips Semiconductor with 64Kb of on
chip ROM & 1Kb of on chip RAM & comes with ISP
10 P a g e
(In System Programming) mode for easy programming. It also has 3 Timers & 7
Interrupts.

 With a few support chips and a program stored in memory, one can use the
P89C51RD2Hxx-BASIC to sense, measure, and control processes, events, or
conditions.

LCD (Liquid Crystal Display):


 An alpha-numeric LCD module is used to
display the results.

 The LCD we used here is 2 line


alphanumeric Liquid Crystal Module that
can display 2 lines of 16 characters each.
Backlight is provided.

 It has ability to display numbers, characters & graphics .It displays speed &
distance even at night.

 The 14 pins needed for control, the main controller is built in the module.

POWER SUPPLY:
 As it is a portable device, power to the whole circuitry can be provided with
9V battery supply.

 The unregulated 9V power of battery is regulated using 7805


fixed IC regulator.

 The output of the regulator is then provided to each component of


main design.

11 P a g e
MODULE WISE DESIGN
1. LOW RANGE IR PROXIMITY SENSOR :

IR IR Pulse
Trans. Receiv Generator

Principle of Operation:
An IR proximity sensor works by applying a voltage to a pair of IR light emitting
diodes (LED’s) which in turn, emit infrared light. This light propagates through the air
and once it hits an object it is reflected back towards the sensor. If the object is close, the
reflected light will be stronger than if the object is further away. The sensing unit (for
this experiment a TSOP 1738 will be used), in the form of an integrated circuit (IC),
detects the reflected infrared light, and if its intensity is strong enough, the circuit
becomes active. When the sensing unit becomes active, it sends a corresponding signal
to the output terminal which can then be used to activate any number of devices. For the
purpose of this exercise, a small green LED will turn on when the sensor becomes active.
As shown in above block diagram Proximity sensor consist of three parts namely :
1) IR Transmitter
2) IR Receiver &
3) Pulse Generator

1) IR Transmitter:
It simply consist of an Simple IR Transmitter LED, which is biased
through a resistor R, which controls its intensity.

2) IR Receiver:
Similar to IR transmitter it also simply consist of an IR Receiver
Module i.e. TSOP 1738 which also biased similar to IR Transmitter.

3) Pulse Generator:
12 P a g e
The pulse generator consist of Timer IC NE555, which is
biased in monostable multivibrator mode & which is triggered
when –ve pulse is applied at pin2, which is pulled high with a
resistor. The IR Transmitter module is connected to the pin2 of
timer. When IR light falls on the Receiver module pin2 is shorted
to ground via the Receiver module & thus Timer is Triggered
generating a +ve pulse at the output (pin 3).

IC NE555 Pin Description

Nr. Name Purpose

1 GND Ground, low level (0 V)

2 TRIG A short pulse high-to-low on the trigger starts the timer

3 OUT During a timing interval, the output stays at +VCC

4 RESET A timing interval can be interrupted by applying a reset pulse to low (0 V)

5 CTRL Control voltage allows access to the internal voltage divider (2/3 VCC)

6 THR The threshold at which the interval ends (it ends if the voltage at THR is at least 2/3
VCC)
7 DIS Connected to a capacitor whose discharge time will influence the timing interval

8 V+, VCC The positive supply voltage which must be between 3 and 15 V

DESCRIPTION
 As the name implies, the sensor is always ON, meaning that the IR led is
constantly emitting light. this design of the circuit is suitable for counting

13 P a g e
objects, or counting revolutions of a rotating object, that may be of the order
of 15,300 rpm or much more. However this design is more power consuming
and is not optimized for high ranges. in this design, range can be from 1 to 10
cm, depending on the ambient light conditions.

Components positioning:
 The correct positioning of the sender LED, the receiver with regard to each
other. First, we need to adjust the position of the sender LED with respect to the
receiver , in such a way they are as near as possible to each others , while
preventing any IR light to be picked up by the receiver  before it hit and
object and returns back. The easiest way to do that is to put the sender(s)
LED(s) from one side of the PCB, and the receiver LED from the other side.

MICROCONTROLLER(8051):
The Intel 8051 is a Harvard architecture, single chip microcontroller (µC) which was
developed by Intel in 1980 for use in embedded systems. Intel's original versions were popular in
the 1980s and early 1990s, but has today largely been
superseded by a vast range of faster and/or functionally
enhanced 8051-compatible devices manufactured by more than
20 independent manufacturers including Atmel, Infineon
Technologies (formerly Siemens AG), Maxim Integrated
Products (via its Dallas Semiconductor subsidiary), NXP
(formerly Philips Semiconductor), Nuvoton (formerly
Winbond), ST Microelectronics, Silicon Laboratories (formerly
Cygnal), Texas Instruments and Cypress Semiconductor. Intel's
official designation for the 8051 family of µCs is MCS 51.
Intel's original 8051 family was developed using NMOS technology, but later versions,
identified by a letter C in their name (e.g., 80C51) used CMOS technology and were less power-
hungry than their NMOS predecessors. This made them more suitable for battery-powered
devices.
Important features and applications

 It provides many functions (CPU, RAM, ROM, I/O, interrupt logic, timer, etc.) in a


single package
 8-bit ALU, Accumulator and 8-bit Registers; hence it is an 8-
bit microcontroller
 8-bit data bus - It can access 8 bits of data in one operation
 16-bit address bus - It can access 216 memory locations - 64 KB (65536 locations)
each of RAM and ROM
 On-chip RAM – 128/256/512 bytes (data memory)

14 P a g e
 On-chip ROM - 4k/16k/32k/64k Byte (program memory)
 Four byte bi-directional input/output port
 UART (serial port)
 Two/Three 16-bit Counter/timers
 Two-level interrupt  priority
 Power saving mode

Common features included in modern 8051 based microcontrollers include built-in reset
timers with brown-out detection, on-chip oscillators, self-programmable Flash ROMprogram
memory, bootloader code in ROM, EEPROM non-volatile data storage, I²C, SPI, and USB host
interfaces, CAN or LIN bus, PWM generators, analog
comparators, A/Dand D/A converters, RTCs, extra counters and timers, in-circuit debugging
facilities, more interrupt sources, and extra power saving modes.

MEMORY ARCHITECTURE
The 8051 has four distinct types of memory - internal RAM, special function registers,
program memory, and external data memory.

Internal RAM (IRAM) is located from address 0 to address 0xFF. IRAM from 0x00 to
0x7F can be accessed directly, and the bytes from 0x20 to 0x3F are also bit-addressable. IRAM
from 0x80 to 0xFF must be accessed indirectly, using the @R0 or @R1 syntax, with the address
to access loaded in R0 or R1.

Special function registers (SFR) are located from address 0x80 to 0xFF, and are accessed
directly using the same instructions as for the lower half of IRAM. Some of the SFR's are also
bit-addressable.

Program memory (PMEM, though less common in usage than IRAM and XRAM) is
located starting at address 0. It may be on- or off-chip, depending on the particular model of chip
being used. Program memory is read-only, though some variants of the 8051 use on-chip flash
memory and provide a method of re-programming the memory in-system or in-application.
Aside from storing code, program memory can also store tables of constants that can be accessed
by MOVC A, @DPTR, using the 16-bit special function register DPTR.

External data memory (XRAM) also starts at address 0. It can also be on- or off-chip;
what makes it "external" is that it must be accessed using the MOVX (Move eXternal)
instruction. Many variants of the 8051 include the standard 256 bytes of IRAM plus a few KB of
XRAM on the chip. If more XRAM is required by an application, the internal XRAM can be
disabled, and all MOVX instructions will fetch from the external bus.
15 P a g e
Block diagram of internal architecture of
p89c51rd2hXX

Instruction set
The 8051 instruction set offers several addressing modes, including

 Direct register, using ACC (the accumulator) and R0-R7


16 P a g e
 Direct memory, which access the internal RAM or the SFR's, depending on
the address
 Indirect memory, using R0, R1, or DPTR to hold the memory address. The
instruction used may vary to access internal RAM, external RAM, or program
memory.
 Individual bits of a range of IRAM and some of the SFR's
Many of the operations allow any addressing mode for the source or the
destination, for example, MOV 020h, 03fh will copy the value in memory location
0x3f in the internal RAM to the memory location 0x20, also in internal RAM.
Because the 8051 is an accumulator-based architecture, all arithmetic
operations must use the accumulator, e.g. ADD A, 020h will add the value in
memory location 0x20 in the internal RAM to the accumulator.
It is important to note that one does not need to master these instructions in
order to program the 8051. With the availability of good quality C compilers,
including open sourceSDCC, virtually all programs can be written in C high-level
language.

LCD (LIQUID CRYSTAL DISPLAY):

A liquid crystal display (LCD) is a thin,


flat panel used for electronically displaying
information such as text, images, and moving
pictures. Its uses include monitors for
computers, televisions, instrument panels, and other devices ranging from aircraft
cockpit displays, to every-day consumer devices such as video players, gaming
devices, clocks, watches, calculators, and telephones. Among its major features are
its lightweight construction, its portability, and its ability to be produced in much
larger screen sizes than are practical for the construction of cathode ray tube (CRT)
display technology. Its low electrical power consumption enables it to be used in
battery-powered electronic equipment. It is an electronically-modulated optical
device made up of any number of pixels filled with liquid crystals and arrayed in
front of a light source (backlight) or reflector to produce images in color or

17 P a g e
monochrome. The earliest discovery leading to the development of LCD
technology, the discovery of liquid crystals, dates from 1888.[1] By 2008,
worldwide sales of televisions with LCD screens had surpassed the sale of CRT
units.

1. Polarizing filter film with a vertical axis to polarize light as it enters.


2. Glass substrate with ITO electrodes. The shapes of these electrodes will
determine the shapes that will appear when the LCD is turned ON. Vertical
ridges etched on the surface are smooth.
3. Twisted nematic liquid crystal.
4. Glass substrate with common electrode film (ITO) with horizontal ridges to
line up with the horizontal filter.
5. Polarizing filter film with a horizontal axis to block/pass light.
6. Reflective surface to send light back to viewer. (In a backlit LCD, this layer
is replaced with a light source.)

Important factors to consider when evaluating an LCD


monitor:

Resolution: The horizontal and vertical screen size expressed in pixels (e.g.,
1024×768). Unlike CRT monitors, LCD monitors have a native-supported
resolution for best display effect.
Dot pitch: The distance between the centers of two adjacent pixels. The smaller
the dot pitch size, the less granularity is present, resulting in a sharper image.
Dot pitch may be the same both vertically and horizontally, or different (less
common).
Viewable size: The size of an LCD panel measured on the diagonal (more
specifically known as active
display area).
Response time: The minimum time
necessary to change a pixel's color
or brightness. Response time is also
divided into rise and fall time. For
LCD monitors, this is measured in

18 P a g e
btb (black to black) or gtg (gray to gray). These different types of
measurements make comparison difficult.[2]
Refresh rate: The number of times per second in which the monitor draws the
data it is being given. Since activated LCD pixels do not flash on/off between
frames, LCD monitors exhibit no refresh-induced flicker, no matter how low
the refresh rate.[3] High-end LCD televisions now feature up to 240 Hz refresh
rate, which allows advanced digital processing to insert additional interpolated
frames to smooth up motion, especially with lower-framerate 24p material like
the Blu-ray disc. However, such high refresh rates may not be supported by
pixel response times, and additional processing can introduce considerable
input lag.
Matrix type: Active TFT or Passive.
Viewing angle: (coll., more specifically known as viewing direction).
Color support: How many types of colors are supported (coll., more specifically
known as color gamut).
Brightness: The amount of light emitted from the display (coll., more
specifically known as luminance).
Contrast ratio: The ratio of the intensity of the brightest bright to the darkest
dark.

Display applications
The applications for the LCD’s are endless, Some of them are:

 Television and digital television
 Liquid crystal display television (LCD TV)
 Digital signage
 LCD projector
 Computer monitor
 Aircraft instrumentation displays (see glass cockpit)
 HD44780 Character LCD, a widely accepted protocol for small LCDs
 Various medical equipment.
 Mobile Phone Displays.

19 P a g e
CIRCUIT DIAGRAM
The circuit is divide into two parts :
1) MAIN CIRCUIT
2) SENSOR CIRCUIT
(Proximity sensor)

20 P a g e
MAIN CIRCUIT

21 P a g e
SENSOR CIRCUIT
22 P a g e
23 P a g e
CIRCUIT DIAGRAM DISCRIPTION
A) Main circuit:
MAIN CIRCUIT diagram given above shows the interfacing
of microcontroller with LCD, LED’s & the switch.
The microcontroller is P89C51RD2Hxx (Phillips
Semiconductor). P89C51RD2Hxx is a 40pin member of 8051
microcontroller family, with 64Kb of on chip ROM &1KB of on chip
RAM with 3 timers & 3 interrupt inputs. It is biased with 5V regulated
DC supply & 11.0592Mhz crystal. LCD is interfaced to the
microcontroller at ports 1 & port 3. Port 1 acts as 8bit input data bus to
the LCD & the RS, R\W & EN pins of LCD are Connected to P3.1, P3.7
& P3.6 respectively which in turn controls the LCD.
Switch SW is connected at P2.0 pin of port2., where as LED1 &
LED2 are connected to pin P2.1 & P2.6 respectively. LED2 remains on.
At P3.4(Timer0 input) the input from the sensor is connected.
When switch “Start_count” is pressed, P2.0 pin of port2 goes low &
Timer 0 starts which counts the pulses applied at P3.4 for 1 sec. In
duration when microcontroller counts the pulses, LED1 is turned on &
LED2 is turned off.

24 P a g e
B) SENSOR CIRCUIT:
Sensor circuit comprises of three parts, Transmitter , Receiver &
pulse generator.
Transmitter circuit consist of an IR transmitter LED which is
simply forward biased through resistor R5. It emits IR beam of moderate
intensity continuously.
As shown in above the Receiver & Pulse Generator circuit
comprises of timer NE555, which is configured as a monostable
multiviabrator whose time period depends upon combination of resistor
R1 & capacitor C2, given by the equation:

Where we selected R1= 820ohm & C2 = 100nF

Therefore t = 1.1(820)(100 E-9)


= 0.902 μ sec. ≈ 1μ sec.
Thus we generate a pulse of 1μ sec. each time NE555 timer is
triggered.
Here the trigger pin 2 of timer 555 is pulled high through resistor
R6. The IR Receiver Module TSOP1738 is connected along with the
resistor R6 such that when the IR beam reflected by the refleactor falls
on IR Receiver, pin-2 goes low to trigger timer NE555. The output from
the pin-3 of timer 555 is inverted by the transitor Q1 and taken out as
output for the main circuit. This output is fed to the pin P3.4 of
microcontroller P89C51RD2Hxx for counting.

25 P a g e
LIST OF COMPONENTS
Sr no. Name of Component Quantity

1. Microcontroller P89C51RD2 1
2. 16 by 2 LCD 1
3. IR Receiver 1
4. IR Transmitter 1
5. Crystal-11.0592 MHz 1
6. Push Button 3
7. IC Regulator-7806, 7805 2
8. NE555 1
9. Transistor-2N2222 1
10. LED’s 3
11. Battery – 9Volt 1
12. Resistors -150 Ω, 220 Ω, 10
470Ω, 820Ω, 1k,10k.
13. 1K Resistor Bank 1
14. Capacitors – 33pF, 0.1uF, 10
1uF, 100uF
15. Connectors & wires 1m
16. IC ZIP 1
17. PCB’s 2

26 P a g e
PCB Design
The PCB for the above circuit is designed in
DIPTRACE software, because it has the following
features:
1. Dip-Trace software is basically used for designing of a circuit diagram and
generating PCB layout.

2. It has different device libraries , which is used for the designing of a schematics
of a circuit diagram.

E.g: AMD,ANALOG,ATMEL family etc

3. From this available component list, we choose the required component and
design the circuit on PC which we have already done on paper before
implementing.

4. After making the connections , we insert the ‘FOOTPRINT’ of each component


which is the actual dimension of the component stored as footprint name.

5. After that we update it, from it we find any error of wrong footprint given to
faulty connection.

6. In PCB layout , we arrange all components as we want and then we route it


manually or automatically.

7. Manual routing is useful when circuit is complex. For this circuit , we have to
use both first auto routing and then manual routing for modifying the tracks
which makes the layout simpler and easy for manufacturing.

 The circuit is divided into two parts: 1) Main Circuit


2) Sensor Circuit

27 P a g e
Main Circuit pcb

Main Circuit PCB Component Layout

28 P a g e
sensor Circuit pcb

Sensor Circuit PCB Component Layout

29 P a g e
SOFTWARE SECTION
The software i.e. program for counting RPM and displaying it on LCD is
written in Assembly Language of 8051 microcontroller. It is complied &
assembled in KEIL μVISION.3 compiler & hex file is created. The Hex file is
downloaded in the microcontroller IC with help of FLASH MAGIC software.

Algorithm & flow chart of the program is as given below:

ALGORITHM:
1. Equate (assign each pin of microcontroller the corresponding name.)

2. Start

3. Define interrupt routine

4. Start main program

5. Make LED2 on & LED2 off

6. Initialize LCD by proper commands

7. Display MSG0: ‘RPM counter’

8. Display MSG1: ‘TE Electronics’

9. Display MSG2: ‘Want to Count’

10.Make P2.0 input port i.e. set P2.0 for switch input

11.Set Timer-0 as counter in mode 2(set TMOD=00000110B)

12.Make P3.4 as input port for counter input from sensor

13.Scan the switch until it is pressed (low to high pulse at P2.0)

14.When switch is pressed, start counter (Timer 0), make LED1 on & LED2 off.

15.Display MSG3: ‘Counting RPM’

16.Wait for 1 sec.

17.Get contents of TL0 copied in Accumulator

18.Stop counter, make LED2 on & LED1 off.

30 P a g e
19.Display MSG4: ‘Counting Finished’

20.Check contents of Accu. , if A=0, display Jump to subroutine ‘OUT’ (Display


MSG6: ‘RPM out of range’) & again start execution from ‘MAIN’.

21.If A≠0 convert the contents of Accumulator to BCD format, Multiply each
number by 6 & adjust carry of next no.

22.Convert these BCD numbers to ASCII codes(add 30H to each) & save them in
registers from R0-R4.

23.Display MSG5: ‘RPM of machine is’

24.Display the results saved in registers R0-R4

25.Stop.

31 P a g e
FLOW CHART
Start

Define interrupt vector


If timer over flows call subroutine ‘OUT’

Start Main Program

Make LED1 off & LED2 on

Initialize LCD

Display Messages from MSG0 to MSG2

Make P2.0 & P3.4 as input port

Set Timer-0 as counter in Mode-2

Scan the switch at port P2.1

No Is
switch
pressed
? Yes

Start Counter (Timer0) A

32 P a g e
Make LED1 on & LED2 off A

Wait for 1sec

Copy contents of TL0(counter) to A

Make LED1 off & LED2 on

Is
A=0 Call subroutine ‘OUT’
?

Convert contents in A in BCD & save.

Multiply each digit by 6

Convert each digit in ASCII format & save.

Display MSG5 on LCD line 1

Display results saved on LCD line 2

Stop

33 P a g e
ASM CODE FOR COUNTING & DISPLAYING
RPM
DB0 BIT P1.0 ;Equate DB0 By P1.0
DB1 BIT P1.1 ;Equate DB1 By P1.1
DB2 BIT P1.2 ;Equate DB2 By P1.2
DB3 BIT P1.3 ;Equate DB3 By P1.3
DB4 BIT P1.4 ;Equate DB4 By P1.4
DB5 BIT P1.5 ;Equate DB5 By P1.5
DB6 BIT P1.6 ;Equate DB6 By P1.6
DB7 BIT P1.7 ;Equate DB7 By P1.7
EN BIT P3.1 ;Equate P3.1 By Enable of LCD
RS BIT P3.7 ;Equate RS By P3.7
RW BIT P3.6 ;Equate Write of LCD By P3.6
DAT EQU P1 ;Equate Port-1 By data I/p of LCD
SW BIT P2.0 ;Equate P2.0 by start button
LED1 BIT P2.1 ;Equate P2.1 by LED1
LED2 BIT P2.6 ;Equate P2.6 by LED2
TIM0 BIT P3.4 ;Equate P3.4 by T0(counter input)
ORG 0000H ;Start Execution
LJMP MAIN ;Jump to MAIN
ORG 000BH ;Timer 0 interrupt vector table
LJMP OUT ;Jump to OUT
RETI
ORG 0030H ;Main Program

MAIN:
SETB LED2 ;Make LED2 on
CLR LED1 ;Make LED1 off

;Initialize LCD
MOV DPTR,#MYCOM
C1: CLR A
34 P a g e
MOVC A,@A+DPTR
JZ NEXT0
LCALL COMMAND ;Call command subroutine
INC DPTR
SJMP C1

NEXT0: NOP

MOV DPTR,#MSG0 ; Point DPTR to MSG0


LCALL LCD_MSG ;Write MSG0 to LCD
LCALL DELAY1
LCALL CLEAR_LCD ;Clear LCD
MOV DPTR,#MSG1 ; Point DPTR to MSG1
LCALL LCD_MSG ;Write MSG1 to LCD
LCALL DELAY1
LCALL CLEAR_LCD ;Clear LCD
MOV DPTR,#MSG2 ; Point DPTR to MSG2
LCALL LCD_MSG ;Write MSG2 to LCD
LCALL DELAY1
SETB SW ;Make P2.0 as input bit(Switch)
MOV TMOD,#00000110B ;Set Timer 0 as counter in mode 2
SETB TIM0 ;Make TIM0 (P3.4) input port
MOV TH0,#00H
MOV TL0,#00H

SETB EA ;Enable interrupt control


SETB ET0 ;Enable Timer 0 overflow interrupt

START:
JB SW,START ;Stay in loop, until switch is pressed(SW=1)
SETB LED1 ;Make LED1 on
CLR LED2 ;Make LED2 off
MOV TL0,#00H ;Load TL0 with 00
SETB TR0 ;Turn on Counter
LCALL CLEAR_LCD ;Clear LCD
MOV DPTR,#MSG3 ; Point DPTR to MSG3
LCALL LCD_MSG ;Write MSG3 to LCD
LCALL DELAY1 ;Wait for 1 sec.
MOV A,TL0 ;Check counter & copy it into Acc.
JNZ NEXT5

DISP: CLR LED1 ;Display MSG 6 if A=0


LCALL OUT

35 P a g e
CLR TR0 ;Stop counter
SETB LED2 ;
LCALL DELAY1 ;
NOP ;
LCALL DELAY1 ;
NOP ;
LCALL DELAY1 ;Wait for 5 seconds
NOP ;
LCALL DELAY1 ;
NOP ;
LCALL DELAY1 ;
NOP ;
LJMP MAIN ;Jump to main again

NEXT5: NOP
CLR TR0 ;Stop counter

;Convert Counted result in ASCII Code


MOV B,#010
DIV AB
MOV R3,B ;Save least significant digit in R3
MOV B,#010
DIV AB
MOV R2,B ;Save second digit in R2
MOV R1,A ;Save most significant digit in R1

;Multiply by 6 & Store result in R0(MSB), R1(second digit), R2(third digit),--


; --R3(LSB)
;Multiply LSB by 6
MOV A,R3
MOV B,#06
MUL AB
MOV B,#010
DIV AB
MOV R3,B
MOV R4,A

;Multiply Second digit by 6


MOV A,R2
MOV B,#06
MUL AB
MOV B,#010
36 P a g e
DIV AB
MOV R5,A
MOV A,B
ADD A,R4
MOV R2,A
CJNE R2,#09, NOT_EQ1
SJMP NEXT

NOT_EQ1:
JC NEXT
MOV A,#01
ADD A,R5
MOV R5,A
MOV A,R2
SUBB A,#0AH
MOV R2,A

NEXT: NOP

;Multiply MSB by 6
MOV A,R1
MOV B,#06
MUL AB
MOV B,#010
DIV AB
MOV R0,A
MOV A,B
ADD A,R5
MOV R1,A
CJNE R1,#09, NOT_EQ2
SJMP NEXT1

NOT_EQ2: JC NEXT1

MOV A,#01
ADD A,R0
MOV R0,A
MOV A,R1
SUBB A,#0AH
MOV R1,A

NEXT1: NOP

37 P a g e
MOV A,R3
ADD A,#30H
MOV R3,A
MOV A,R2
ADD A,#30H
MOV R2,A
MOV A,R1
ADD A,#30H
MOV R1,A
MOV A,R0
ADD A,#30H
MOV R0,A

CLR LED1 ;Make LED1 off


SETB LED2 ;Make LED2 on again
LCALL CLEAR_LCD ;Clear LCD
MOV DPTR,#MSG4 ; Point DPTR to MSG4
LCALL LCD_MSG ;Write MSG4 to LCD
LCALL DELAY1
LCALL CLEAR_LCD
MOV DPTR,#MSG5 ;Display RPM of Machine
LCALL LCD_MSG
MOV A,#0C0H ;Force cursor to beginning of 2nd line
LCALL COMMAND
MOV A,R0
LCALL WRITE_DATA ;Display MSB
MOV A,R1
LCALL WRITE_DATA ;Display fourth digit
MOV A,R2
LCALL WRITE_DATA ;Display third digit
MOV A,R3
LCALL WRITE_DATA ;Display second digit
MOV A,#30H
LCALL WRITE_DATA ;Display LSB (LSB=0)

HERE: SJMP HERE

OUT:
LCALL CLEAR_LCD ;Clear LCD
MOV DPTR,#MSG6 ; Point DPTR to MSG6
LCALL LCD_MSG ;Write MSG6 to LCD
RET

38 P a g e
COMMAND:
LCALL WAIT_LCD
MOV DAT,A
CLR RS
CLR RW
SETB EN
LCALL DELAY
CLR EN
RET

WAIT_LCD:
SETB DB7 ; Make P1.7 input port
CLR RS ;It’s a command
SETB RW ;It’s a read command
;Read Command register and check busy flag
BACK: CLR EN
LCALL DELAY
SETB EN
JB DB7,BACK
LCALL DELAY
CLR EN
CLR RW
RET

WRITE_DATA:
LCALL WAIT_LCD
MOV DAT,A
SETB RS
CLR RW
SETB EN ;Clock out command to LCD
CLR EN ;Finish command
RET

LCD_MSG:
CLR A ;Clear Index
MOVC A,@A+DPTR ;Get byte pointed by DPTR
JZ LCD_MSG9 ;Return if found the zero (end of string)
LCALL WRITE_DATA ;It was data, write it to LCD
LCALL DELAY ;Give LCD some time
INC DPTR ;Point to the next byte
SJMP LCD_MSG ;Go get next byte from string
LCD_MSG9: RET ;Return to Caller
39 P a g e
CLEAR_LCD:
LCALL WAIT_LCD
MOV DAT,#01H
CLR RS
CLR RW
SETB EN
LCALL DELAY
CLR EN
RET

DELAY1: ;1 sec. delay subroutine


MOV R7,#20
L1: MOV R6,#180
L2: MOV R5,#255
L3: DJNZ R5,L3
DJNZ R6,L2
DJNZ R7,L1
RET

DELAY:
MOV R6,#10
D1: MOV R7,#255
D2: DJNZ R7,D2
DJNZ R6,D1
RET

ORG 400H
MYCOM: DB 38H, 0EH, 01, 06, 84H, 0 ;Commands & Null
MSG0: DB "RPM Counter", 0 ; data and null
MSG1: DB "TE Electronics", 0 ; data and null
MSG2: DB "Want To Count ", 0 ; data and null
MSG3: DB "Counting RPM", 0 ; data and null
MSG4: DB "Counting Finished", 0 ; data and null
MSG5: DB "RPM of Machine is", 0 ; data and null
MSG6: DB "RPM out of range", 0 ; data and null

END

40 P a g e
APPLICATIONS:

1. In automobiles, trucks, tractors and aircraft:


Tachometers or rev counters on automobiles, aircraft, and other vehicles show
the rate of rotation of the engine's crankshaft, and typically have markings
indicating a safe range of rotation speeds. This can assist the driver in selecting
appropriate throttle and gear settings for the driving conditions. Prolonged use at
high speeds may cause inadequate lubrication, overheating (exceeding capability
of the cooling system), exceeding speed capability of sub-parts of the engine (for
example spring retracted valves) thus causing excessive wear or permanent
damage or failure of engines. This is more applicable to manual transmissions than
to automatics. On analogue tachometers, speeds above maximum safe operating
speed are typically indicated by an area of the gauge marked in red, giving rise to
the expression of "redlining" an engine — revving the engine up to the maximum
safe limit.
2. Hours meters:
When used in stationary engines or vehicles where an odometer would not give
an accurate reading of the vehicle's use (such as in aircraft, boats or tractors),
tachometers frequently incorporate a display showing the total number of hours the
engine has run. Service intervals are given and measured in hours.
3. Traffic Engineering:
Tachometers are used to estimate traffic speed and volume (flow). A vehicle
is equipped with the sensor and conducts "tach runs" which record the traffic data.
These data are a substitute or complement to loop detector data. To get statistically
significant results usually requires a fairly high number of runs, and bias is
introduced by the time of day, day of week, and the season. However, because of
the expense, spacing (a lower density of loop detectors diminishes data accuracy),
and relatively low reliability of loop detectors (often 30% or more are out of
service at any give time), tach runs remain a common practice.
4. In trains and light rail vehicles:
Speed sensing devices, termed variously "wheel impulse generators" (WIG),
speed probes, or tachometers are used extensively in rail vehicles. Common types
include opto-isolator slotted disk sensors[1] and Hall effect sensors.
5. In analogue audio recording:
In analogue audio recording, a tachometer is a device that measures the speed
of audiotape as it passes across the head. On most audio tape recorders the
tachometer (or simply "tach") is a relatively large spindle near the ERP head stack,
isolated from the feed and take-up spindles by tension idlers.
41 P a g e
RESULTS AND CONCLUSION
Thus we successfully implemented CONTACT
LESS DIGITAL TACHOMETER using
microcontroller P89C51RD2Hxx.
As far as hardware testing is concerned, PCB is
working properly. Each IC is performing the functions
properly.
The assembly language program written for the
project is working without errors. RPM are counted
properly & are displayed on the display within the range
given for each as per the specification. The RPM are
counted precisely with resolution of 60/1 RPM. The most
accurate measurements are taken when the sensor is
placed at proper distance from the motor shaft.
During actual implementation of the project on the
motor, proper mounting of sensors on the bike is very
important without causing damage to the circuit.

In our testing we discovered how hard it is to design


a tachometer that would be effective for a wide range of
machines with wide range of RPMs.

42 P a g e
Bill OF Materials

Sr no. Quantity Cost Per Total Cost


Name of Component Unit (Rs) (Rs)
1. Microcontroller P89C51RD2 1 450 450
2. 16 by 2 LCD 1 120 120
3. IR Receiver 1 25 25
4. IR Transmitter 1 12 12
5. Crystal-11.0592 MHz 1 6 6
6. Push Button 3 5 15
7. IC Regulator-7806, 7805 2 7 14
8. NE555 1 10 10
9. Transistor-2N2222 1 3 3
10. LED’s 3 3 9
11. Battery – 9Volt 1 25 25
12. Resistors -150 Ω, 220 Ω, 10 0.20 2
470Ω, 820Ω, 1k,10k.
13. 1K Resistor Bank 1 5 5
14. Capacitors – 33pF, 0.1uF, 10 2 20
1uF, 100uF
15. Connectors & wires 1m 4 4
16. IC ZIP 1 45 45
17. PCB’s 2 75 150
TOTAL COST 932

43 P a g e
REFRENCES

1. 8051 microcontroller - Kenneth Ayala


2. 89C51 data book - ATMEL manual
3. 8051 microcontroller - Mazidi
4. Magazines - Electronics For You
- Nut & Volts
5. Datasheets - Atmel ,Fairchild
6. Internet
a. www.electronicsforyou.com
b.www.alldatasheets.com
c. www.ustr.net
d.www.iplogic.com

44 P a g e
DATASHEETS
1) NE555N
2) 2N2222A
3) TSOP1738
4) P89C51RD2Hxx
5) 16 by 2 LCD (Hitachi)
6) LM7805

45 P a g e

You might also like