Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Microcontroller based TACHOMETER

INTRODUCTION

A tachometer (also called as revolution-counter or RPM gauge) is an

instrument that measures the rotation speed of a shaft or disk, as in

motor or other machines. The device displays the revolution per

minute (RPM) on a digital display. For example, there is an optimum

speed for drilling a particular-size hole in a particular metal piece;

there is an ideal sanding disk speed that depends on the material

being finished. You may also want to measure the speed of fans you

use. This easy-to-make photoelectric tachometer measures the rpm of

most shop-floor tools and many household machines without any

mechanical or electrical interface.

Mini Project Report


Page 1
Microcontroller based TACHOMETER

PROBLEM DEFINITION:

The traditional tachometer requires physical contact between the

instrument and the device being measured. In certain applications

this is not feasible for technical or safety reasons.

SOLUTION:
In a situation as mentioned above, it is possible to use a

microcontroller based tachometer which uses a light beam to take

measurements from a distance. This works by pulsation of a light

beam against the rotating element. The rotating element will have a

reflective spot, and the tachometer measures the rate at which the

light beam is reflected back.

Mini Project Report


Page 2
Microcontroller based TACHOMETER

Example: A common example is the tachometer found on

automobile dashboards. It is important to monitor engine RPMs, as

running the engine at excessively high rates can drastically shorten

engine life.

A tachometer can even find uses in medicine. By placing a small,

turbine-like device in an artery or vein, a doctor can use a tachometer

to infer the rate of blood flow from the speed at which the turbine

spins. This can be used to diagnose circulatory problems such as

clogged arteries. This device is known as a haematachometer.

Mini Project Report


Page 3
Microcontroller based TACHOMETER

Mini Project Report


Page 4
Microcontroller based TACHOMETER

Circuit Description

The main components of the tachometer are:

1. AT89C2051 microcontroller

2. ULN2003 high-current Darlington transistor array

3. CA3140 operational amplifier

4. Common-anode (KLQ564) 4-digit,7-segment display

5. L14F1 photo-transistor.

6. BC557 pnp transistors

7. 2N2222 npn transistor

8. 1N4007 rectifier diode

Fig. 1 shows the circuit of the microcontroller-based tachometer. The

AT89C2051 is a 20-pin, 8-bit microcontroller of Intel’s 8051 family made by

Atmel Corporation. Port-1 pins P1.7 through P1.2, and port-3 pin P3.7 are

connected to input pins 1 through 7 of ULN2003. Port-1 pins are pulled up with

10-kiloohm resistor network RNW1. They drive all the seven segments of the

display with the help of internal inverters.

Mini Project Report


Page 5
Microcontroller based TACHOMETER

Port-3 pins P3.0 through P3.3 of the microcontroller are connected to the base of

transistors T1 through T4, respectively, to select one digit out of the four at a

time and to supply anode-drive currents to the common anode pin of respective

digit. Pin configuration of transistor BC557.

When pin P3.0 of microcontroller IC1 goes low, it drives transistor T1 into

saturation, which provides the drive current to anode pin 6 of 4-digit, 7-segment,

common-anode display DIS1. Similarly, transistors T2 through T4, respectively,

provide supply to common-anode pins 8, 9 and 12 of DIS1. Thus

microcontroller IC1 drives the segment in multiplexed manner using its port

pins. This is timedivision multiplexing process. Segment data and display-enable

pulse for display are refreshed every 5ms. Thus, the display appears to be

continuous even though it lights up one by one. Switch S1 is used to manually

reset the microcontroller, while the poweron-reset signal for the microcontroller

is given by C1 and R6. A 12MHz crystal is connected to pins 4 and 5 of IC1 to

generate the basic clock frequency for the microcontroller. The circuit uses a 6V

battery for power supply or alternatively a mains derived low voltage supply.

Mini Project Report


Page 6
Microcontroller based TACHOMETER

Software:

The software is written in Assembly language and assembled using 8051

cross-assembler. It is well commented and easy to understand. It uses

AT89C2051’s internal timer for measuring the period of one cycle of the

rotation in units of 100 microseconds. Thus if the speed is 1500 rpm, it is

25rps, and the time taken for one cycle is 40 ms. The timer uses an

interrupt to count overflows every 100 microseconds and so the number

counted by the timer program in this case will be ‘400.’ This is divided by

‘600,000’ (so many 100/µs present in a minute), giving a result of ‘1500.’

This gives the rpm. These digits are displayed on the 4-digit, 7-segment

display. To perform the division, subroutine UDIV32 is employed, which

is a standard subroutine available for 8051 family for 32-bit number by

16-bit number division. It has an accuracy of 5 rpm in a 6000rpm count.

Mini Project Report


Page 7
Microcontroller based TACHOMETER

Figure 1 Circuit of microcontroller-based tachometer

Mini Project Report


Page 8
Microcontroller based TACHOMETER

WORKING:
When the light-sensitive probe tip is pointed towards a rotating shaft or disk (fixed

with a small reflector), the 4-digit, 7-segment displays the RPM of the shaft or disk.

Figure 2 Suitable arrangement of phototransistor

Each time the reflector spins past the probe, the momentary increase in reflected light

is detected by the phototransistor. The signal processor and microcontroller circuit

counts the increase in the number of such light reflections sensed by it and thereby

evaluates the rpm, which is displayed.

Mini Project Report


Page 9
Microcontroller based TACHOMETER

The detected signal is amplified by transistor 2N2222 (T5) and further amplified by

operational amplifier CA3140 (IC3). The reference voltage point for the operational

amplifier is obtained by resistor divider network comprising R2 and R3. The output

from pin 6 of IC3 is fed to pin 12 of microcontroller AT89C2051. Note that pins 12

and 13 of microcontroller AT89C2051 are the inputs (+ and -) of its internal analogue

comparator. Pin 13 is adjusted to nearly half the supply voltage using a potential

divider comprising resistor R7 and preset VR1 across the supply. The pulses picked

up by the phototransistor are sensed by the internal comparator of AT89C2051 and,

through software, each pulse representing one rotation of the object is detected. By

counting the number of such pulses, on an average per minute basis, the RPM is

evaluated. It is displayed by a software routine to light up the LED segments of the 4-

digit, 7-segment display.The detected signal is amplified by transistor 2N2222 (T5)

and further amplified by operational amplifier CA3140 (IC3). The reference voltage

point for the operational amplifier is obtained by resistor divider network comprising

R2 and R3. The output from pin 6 of IC3 is fed to pin 12 of microcontroller

AT89C2051. Note that pins 12 and 13 of microcontroller AT89C2051 are the inputs (+

and -) of its internal analogue comparator. Pin 13 is adjusted to nearly half the supply

voltage using a potential divider comprising resistor R7 and preset VR1 across the

supply. The pulses picked up by the phototransistor are sensed by the internal

comparator of AT89C2051 and, through software, each pulse representing one

rotation of the object is detected. By counting the number of such pulses, on an

average per minute basis, the RPM is evaluated. It is displayed by a software routine

to light up the LED segments of the 4-digit, 7-segment display.

$mod51 AJMP 30H


ORG 0H

Mini Project Report Page


10
Microcontroller based TACHOMETER

CODE:
ORG 0BH ;TIMER 0 mov p3.5,c MOV B,#10 ; MOV 1AH,r5
INTERRUPT clr tr0 ;stop timer R7,R6,R5,R4,R3 MOV 1BH,R6 ; most
VECTOR clr et0 ;and interrupt DIV AB significant digit
AJMP TIMER0ISR by timer MOV R4,B (max:9999)
;Timer 0 Interrupt mov r3,#0 ;number MOV R5,A RET
service routine 600000 or 927c0 hex CJNE refresh1:
address as Dividend R1,#0H,HIGH_BYTE MOV R0,#1bh ;
ORG 30H mov r2,#09h ; 9 ; CHECK FOR HIGH 1b,1a,19,18, holds
MOV SP,#60H ;set mov r1,#27h ;27 BYTE values for 4 digits
stack pointer mov r0,#0c0h ; c0 SJMP ENDD MOV R4,#8 ; pin
MOV P3,#0FFH ;set mov r5,45h ;divisor HIGH_BYTE: MOV p3.3_ 0 made low
all port 3 bits high to is time for one cycle A,#6 one by one starts
enable inputs mov r4,44h ADD A,R3 wth 18
also call UDIV32 ;divide MOV B,#10 mov r7,#2 ; decimal
MOV P1,#03 ;set port 60000/t DIV AB pt.on 3rd digit from
1 to all zeros expect mov 40h,r0 MOV R3,B left (2 nd
bits 0,1 mov 41h,r1 ADD A,#5 fromright)
MOV mov r1,41h ADD A,R4 PQ2: CALL SEGDISP
TMOD,#01100001B ; mov r2,40h MOV B,#10 dec R0
TIMER 1 - MODE 2 CALL HEX2BCD DIV AB mov a,r4
COUNTER,TIMR-0 mov 50h,#0FFH MOV R4,B rrc a
TO 16 bit timer call refresh ADD A,#2 mov r4,a
BEG: MOV disp: call refresh1 ADD A,R5 jnc pQ2
TH0,#0ffH ;TIMER djnz 50h,disp ; so MOV B,#10 PV3:RET
REG.0 IS SET TO 0, many times for a DIV AB SEGDISP:mov
GIVES 64ms visible time limit MOV R5,B dptr,#ledcode
MOV TL0,#-99 ; jmp beg CJNE MOV A,@R0
timer low reg. is also ;16 Bit Hex to BCD R6,#00D,ADD_IT ANL A,#0FH
so Conversion for 8051 SJMP CONTINUE MOVC A,@A+dptr
setb et0 Microcontroller ADD_IT: ADD A,R6 segcode:MOV R5,A
setb ea ;This routine is for 16 CONTINUE: MOV ORL A,#03H ; WE
mov 44h,#0 bit Hex to BCD R6,A WANT TO USE
mov 45h,#0 conversion; DJNZ PORT 1 BITS 0
acall delay ;Accepts a 16 bit R1,HIGH_BYTE AND 1 FOR INPUT
ajmp lowsig binary number in MOV B, #10D ANLOG
delay: mov r2,#10 R1,R2 and returns 5 MOV A,R6 ; so retain them high
djnz r2,$ ;wait 20 us digit BCD in DIV AB S3: MOV P1,A ;
ret ;R7,R6,R5,R4,R3(upto MOV R6,B SEGMENT_PORT
lowsig: jb p3.6,lowsig 64K ) MOV R7,A MOV A,R5 ;we use
call delay Hex2BCD: ;r1=high ENDD: ret p3.7 for the segment
jnb p3.6,$ byte, r7 most DISP1: ‘a’ of display
setb tr0 ; start timer significant digit, R2 REFRESH:; content RRC A ;so get that
mov c,p3.6 ;high = LSByte of 18 to 1B memory bit D0into carry
begins MOV R3,#00D locations are rrc a
mov p3.5,c MOV R4,#00D output on LEDs mov p3.7,c ;segment
acall delay MOV R5,#00D ; only numbers 0 to 9 ‘a;
jb p3.6, $ MOV R6,#00D and A to F are valid S1: MOV A,R4 ; get
mov c,p3.6 ;low now MOV R7,#00D data in digit code from r4
mov p3.5,c MOV B,#10D these locations 00001000
acall delay MOV A,R2 MOV 18H,r3 ; least cpl a ;11110111
jnb p3.6,$ DIV AB significant digit rrc a ;11111011-1
mov c,p3.6 ;high MOV R3,B ; MOV 19H,r4 ; next
begins again significant digit

Mini Project Report Page


11
Microcontroller based TACHOMETER

mov p3.0,c ; output add a, 44h ;count mov a,r0 ;shift mov 07,a
to drive transsitors time btwn pulses highestbit of X cpl C
for digit lighting mov 44h,a rlc a jnc div_321
rrc a ;11111101-1 mov a,#0 mov r0,a mov r7,7
mov p3.1,c addc a,45h ;add carry mov a,r1 ;shift next mov r6,6
rrc a ;11111110-1 to most sign. byte bit of X mov r5,dph
mov p3.2,c mov 45h,a rlc a mov r4,dpl
rrc a ;1111111-0 yes pop acc mov r1,a div_321: mov a,r0
low makes left most reti mov a,r2 ;shift next rlc a
digit show subroutine UDIV32 bit of X mov r0,a ; shift result
msdigit 32 bit /16 bit to 32 bit rlc a bit into partial
mov p3.3,c quotient and mov r2,a quotient
S5: remainder unsigned mov a,r3 ;shift next mov a,r1
S4: ACALL input r3,r2,r1,r0 = bit of X rlc a
DELAY1 ; let it burn dividend X rlc a mov r1,a
for some time input r5,r4 = divisor mov r3,a mov a,r2
MOV A,#0ffH ; y setb rs0 ;reg. bank 1 rlc a
extinguish the digit output r3-r0 = mov a,r4 ;lowest bit mov r2,a
after that time quotient Q of X/Y of remainder mov a,r3
MOV P3,A ; to r7,r6,r5,r4 rlc a rlc a
prevent shadow =remainder mov r4,a mov r3,a
s6: RET alters acc, flags mov a,r5 ;shift next djnz B,div_lp32
ledcode:DB UDIV32: push 08 bit of rem mov 7,r7
7EH,0CH,0B6H,9EH, ;save reg. bank 1 rlc a mov 6,r6
0CCH,0DAH,0FAH push 09 mov r5,a mov 5,r5
;these are code for push 0AH mov a,r6 ;shift next mov 4,r4
the numbers 0 to 9 push 0BH bit of rem mov 3,r3
and A to F push 0CH rlc a mov 2,r2
DB push 0DH mov r6,a mov 1,r1
0EH,0FEH,0CEH,0E push 0EH mov a,r7 ;shift next mov 0,r0
EH,0F8H,72H,0BCH, push 0Fh bit of rem clr rs0
0F6H, push dpl rlc a pop B
0E2H push dph mov r7,a pop dph
DELAY1:MOV push B mov a,r4 pop dpl
55h,#0ffH ; 1ms setb RS0 ;select clr C pop 0Fh
N: NOP reg.bank 1 subb a,04 pop 0EH
DJNZ 55h,N mov r7,#0 mov dpl,a pop 0Dh
RET mov r6,#0 mov a,r5 pop 0Ch
TIMER0ISR:mov mov r5,#0 subb a,5 pop 0bh
th0,#0ffh mov r4,#0 mov dph,a pop 0ah
mov tl0,#-90 ; in 100 mov B,#32 ;set loop mov a, r6 pop 09
us steps count subb a,#0 pop 08
push acc div_lp32:clr RS0 mov 06,a ret
mov a,#1 ;selet reg.bank 0 mov a,r7 END
clr c clr C subb a,#0

Mini Project Report Page


12
Microcontroller based TACHOMETER

Advantages:
 This tachometer requires no physical contact between the

instrument and the device being measured. Hence less wear and

tear of the instrument.

 This type of tachometer can be a permanent part of the system, or it

can be handheld for occasional spot measurements.

Mini Project Report Page


13

You might also like