Top Banner
DIGITAL CONTACTLESS TACHOMETER B. Tech. Mini Project Final Report Submitted in partial fulfillment for the award of the Degree of Bachelor of Technology in Electrical and Electronics Engineering by AVINESH VASUDEVAN B080307EE MANOJ M CHERIAN B080105EE RONY J KOONTHANAM B080048EE Under the guidance of Dr.K.S. Sivanandan
47
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Mini Report Final1

DIGITAL CONTACTLESS TACHOMETER

B. Tech. Mini Project Final Report

Submitted in partial fulfillment for the award of the Degree ofBachelor of Technology in Electrical and Electronics Engineering

by

AVINESH VASUDEVAN B080307EEMANOJ M CHERIAN B080105EERONY J KOONTHANAM B080048EE

Under the guidance of

Dr.K.S. Sivanandan

Department of Electrical Engineering

NATIONAL INSTITUTE OF TECHNOLOGY CALICUT NIT Campus P.O., Calicut - 673601, India

2011

Page 2: Mini Report Final1

CERTIFICATEThis is to certify that the report entitled “DIGITAL CONTACTLESS

TACHOMETER” is a bonafide record of the mini project done by AVINESH VASUDEVAN (Roll No.B080307EE), MANOJ M CHERIAN (Roll No. B080105EE) and RONY J KOONTHANAM (Roll No. B080048EE) under my supervision and guidance, in partial fulfillment of the requirements for the award of Degree of Bachelor of Technology in Electrical & Electronic Engineering from National Institute of Technology Calicut for the year 2010-11.

Dr.K.S. SIVANANDAN Dr. R. SREERAM KUMAR (Guide) (Head of the Department)Professor ProfessorDept. of Electrical Engineering Dept. of Electrical Engineering

Place: NIT CalicutDate:4/5/2011

Page 3: Mini Report Final1

ACKNOWLEDGEMENT

We would like to express our sincere gratitude to our guide, Dr. K S Sivanandan,

Professor, Department of Electrical Engineering, National Institute of Technology Calicut, for

allowing us to undertake this project and for his valuable suggestions, guidance and support

during the course of work.

We also want to thank Mr. Ananthakrishnan, Faculty in charge (mini projects- EED),

Dr. Jeevamma Jacob, our evaluator and Dr. Sreeram Kumar, HOD-EED for giving us a

chance to carry out this project.

Finally, we thank God for enabling us to carry out our work without hassles.

Page 4: Mini Report Final1

ABSTRACT

In the present era, control system is an area of utmost importance. Keeping

this in mind our mini-project aims to fabricate a device which can be used to measure

the rotating speed of a machine without coming in contact with the machine itself.

With this technique, sensing the speed of a machine becomes relatively easy.

Our aim is to create a device to sense a series of pulses sent by an infra-red

transmitter, making use of the output from the infra-red receiver, decoding it by using

a PIC Microcontroller to find the speed of the system, which can be used in numerous

programmed control applications. A secondary objective of this device is to reduce

the error sustained in sensing the speed by way of using an effective algorithm to

compute the speed.

The output from this device can be used as input for any process or can even

be used as a feedback for that machine itself. As the device is of non-contact type, we

can use it as a portable speed detector itself. Due to the output of the device being

digital it can be used in conjunction with digital control systems. We have made a

model of this concept, displaying the output on a Liquid Crystal Display.

Page 5: Mini Report Final1

LIST OF ABBREVIATIONS

LCD - LIQUID CRYSTAL DISPLAY

RPM - ROTATIONS PER MINUTE

IR - INFRA-RED

PCB - PRINTED CIRCUIT BOARD

ASCII - AMERICAN STANDARD CODE FOR INFORMATION

INTERCHANGE

LIST OF SYMBOLS

kHz - kilo Hertz

V - Volts

A - Ampere

mA - milli Ampere

µA - micro Ampere

µF - micro Farad

Ω - Ohm

Page 6: Mini Report Final1

LIST OF FIGURES

FIGURE NO NAME PAGE NO

FIG 2.1 EQUIVALENT CIRCUIT DIAGRAM OF CAPACITOR CHARGING IN IC555

10

FIG 2.2 EQUIVALENT CIRCUIT DIAGRAM OF CAPACITOR CHARGING IN IC555

11

FIG 2.3 INTERNAL BLOCK DIAGRAM OF IC555 12

FIG 2.4 EXTERNAL CONNECTION DIAGRAM OF IC555 13

FIG 2.5 CAPACITANCE VS FREQUENCY GRAPH 13

FIG 2.6 OUTPUT & THRESHOLD PIN WAVEFORMS 13

FIG 3.1 CIRCUIT OF IC555 TIMER CIRCUIT AS AN ASTABLE MULTIVIBRATOR

16

FIG 3.2 INTERNAL BLOCK DIAGRAM OF TSOP 1738 17

FIG 3.3 PIN DIAGRAM OF PIC18F452 MICROCONTROLLER 18

FIG 3.4 PIN DIAGRAM OF 16x2 LCD 19

FIG 3.5 9V BATTERY AND CONNECTER 20

FIG 5.1 BLOCK DIAGRAM OF A CONTACTLESS IR

TACHOMETER

23

Page 7: Mini Report Final1

FIG 5.2 POWER SUPPLY CONNECTION OF PIC18F452 24

FIG 5.3 SIMULATION CIRCUIT OF DIGITAL TACHOMETER 25

CONTENTS

Chapter No Title Page No

1 INTRODUCTION 8

2 THEORY AND EQUATIONS 10

2.1 ASTABLE MULTIVIBRATOR OPERATION

10

2.2 INFRARED REFLECTION

14 3 COMPONENTS

15

3.1 INFRA-RED TRANSMITTER

15

3.2 INFRA-RED RECEIVER MODULE

17

3.3 PIC MICROCONTROLLER:

18

3.4 16X2 LIQUID CRYSTAL DISPLAY:

19 3.5 POWER SOURCE

20

4 CONCEPT AND CONSTRUCTION

21

5 STAGES OF IMPLEMENTATION 23

5.1 DESIGN DEVELOPMENT

Page 8: Mini Report Final1

23

5.2 PROCUREMENT OF COMPONENTS

24

5.3 CIRCUIT ASSEMBLY

24

5.4 MICROCONTROLLER PROGRAMMING

25

5.5 LCD SETUP

26

6 PROGRAM (CODE) 27

7 IMPLEMENTATION OBSTACLES 31

7.1 RESULTS AND DISCUSSIONS

31

7.2 DRAWBACKS 31

8 FUTURE ENHANCEMENTS 32

9 REFERENCES 33

CHAPTER 1INTRODUCTION

A tachometer also called a revolution-counter or RPM gauge is an instrument

that measures the rpm of a shaft or disk, as in a motor or other machine. The device

usually displays the revolutions per minute (RPM) on a calibrated analogue dial, but

digital displays are now being used.

A conventional tachometer works as a transducer which converts the

mechanical energy into proportional electrical energy. The tachometer shaft rotates

Page 9: Mini Report Final1

along with that of the machine and thereby generating a voltage which is calibrated in

terms of rpm of the machine.

With the advent of electronics it has become possible to scale down

tachometer into a small and portable device. These tachometers have the distinct

advantage that they don’t need to be in contact with the rotating body. The proposed

electronic digital tachometer works on the principle that the count is obtained from the

reflected rays of a strip pasted on the shaft or flywheel of the rotating device. The

reflected pulse is nothing but that of the reflection of the infrared rays (whose

emission is well controlled) transmitted from a transmitter mounted on the

tachometer.

They have various applications like in Automobiles (shows the rate of

rotation of the engine's crankshaft by measuring the spark rate of the ignition system),

Light Rail Vehicles (the rotational speed of the axle), Analog audio recording

(measures the speed of audio tape as it passes across the head) etc. Tachometers fitted

to cars, aircraft, and other vehicles typically have markings indicating a safe range of

speeds at which the engine may be operated.

The transmitter circuit uses an IC555 timer circuit. The output of this circuit is

connected to an infra-red transmitter diode, the TSAL6200. The diode emits waves in

the infra-red spectrum at the pulse rate specifies by the timer circuit. This can be

suited to our preference by choosing appropriate resistance values in the timer circuit.

The pulses sent by the transmitter diode reflect off the surface of the machine.

The presence of a reflective strip helps as it would create a difference in the pattern of

reflection of the pulses from the surface. The strip being of lighter colour than the

surface of the machine will reflect more of the pulses than the surface. This change is

noticable to the infrared receiver.

The infrared receiver used in this device is the TSOP1738. It is a miniaturized

receiver that is used to detect frequencies near a certain range. The range of

frequencies for which each receiver works is different. The range for the receiver used

here, the TSOP1738 is 38 kHz with 5% tolerance either way. Therefore the timer

Page 10: Mini Report Final1

circuit has to be designed such that it oscillates inside the frequency range specified

by the receiver. The receiver gives a high output when it is not receiving pulses within

this range and gives a low output when it receives a pulse that is inside this range.

This output of this receiver is given to the microcontroller. The

microcontroller used here is the PIC18F452. The PIC processes the output from the

receiver and computes the speed of the machine by using a timer programming

algorithm. This value found is averaged for many time periods and is thus closer to

the real value of the speed. This averaging is done so that any errors that may have

appeared by way of the device may be negated.

The speed computed by the microcontroller is given to a 16x2 LCD system to

display the output.

CHAPTER 2

THEORY AND EQUATIONS

2.1 ASTABLE MULTIVIBRATOR OPERATION

Page 11: Mini Report Final1

An astable timer operation is achieved by setting up and configuring the

circuit as shown on Fig 2. In the astable operation, the trigger terminal and the

threshold terminal are connected so that a self-trigger is formed, operating as a

multivibrator. When the timer output is high, its internal discharging Transistor turns

off and the VC1 increases by exponential function with the time constant (RA+RB)*C.

When the VC1, or the threshold voltage, reaches 2Vcc/3, the comparator output

on the trigger terminal becomes high, resetting the Flip-flop and causing the timer

output to become low. This in turn turns on the discharging Transistor and the C1

through the discharging channel formed by RB and the discharging Transistor. When

the VC1 falls below Vcc/3, the comparator output on the trigger terminal becomes high

and the timer output becomes high again. The discharging Transistor turns off and the

VC1 rises again.

In the above process, the section where the timer output is high is the time it

takes for the VC1 to rise from Vcc/3 to 2Vcc/3, and the section where the timer output

is low is the time it takes for the VC1 to drop from 2Vcc/3 to Vcc/3. When timer

output is high, the equivalent circuit for charging capacitor C1 is as follows:

FIG 2.1 EQUIVALENT CIRCUIT DIAGRAM OF CAPACITOR CHARGING IN

IC555

Page 12: Mini Report Final1

The equivalent circuit for discharging capacitor C1, when timer output is low is, as

follows:

FIG 2.2 EQUIVALENT CIRCUIT DIAGRAM OF CAPACITOR CHARGING

IN IC555

Page 13: Mini Report Final1

Since the duration of the timer output low state (tL) is the amount of time it takes for

the VC1 (t) to reach Vcc/3,

Since RD is normally RB>>RD although related to the size of discharging

Transistor,

tL = 0.693RBC1 (10).

Consequently, if the timer operates in astable, the period is the same with

T= tH+tL = 0.693(RA+RB)C1 + 0.693RBC1=0.693(RA+2RB)C1

because the period is the sum of the charge time and discharge time. And since

frequency is the reciprocal of the period, the following applies.

FIG 2.3

Page 14: Mini Report Final1

INTERNAL BLOCK DIAGRAM OF IC555

FIG 2.4 FIG 2.5 EXTERNAL CONNECTION DIAGRAM CAPACITANCE VS

FREQUENCY OF IC555 GRAPH

FIG 2.6 OUTPUT & THRESHOLD PIN WAVEFORMS

Page 15: Mini Report Final1

2.2 Infrared reflection

It is common knowledge that darker colours are better absorbers of light and

thereby become better radiators of heat. So the reverse is applicable for lighter

colours. They turn out to be bad absorbers and bad radiators. Due to these properties it

is found that they are good reflectors.

The colour of an object depends on the wavelengths of colours reflected

from the object. A red apple is red because red wavelengths in white light are

reflected and other wavelengths are absorbed. In fact, if a red apple were to be

illuminated by light that had no red wavelengths, the apple would appear almost

black.

When a black object is illuminated by white light, all wavelengths are

absorbed and none are reflected. That is why the object appears black. So when light

is absorbed by a black object, the energy carried by the light doesn't just disappear.

Rather, it raises the energy of the object doing the absorbing. The object, in turn,

releases the absorbed energy by emitting longer wavelength, lower energy infrared

(heat). This transformation of light into heat is the key to understanding the process

because it accounts for the law of conservation of energy. Light just doesn't disappear

when it strikes a black object, it is transformed into another kind of radiation that is

either radiated from or retained within the black object.

The darker the object, the better its emission of heat because it is a better

absorber of light. So vice versa, the lighter the object the better reflector it is. This is

the principle which we use to find the revolutions per minute. As the white strip is a

better reflector, the receiver module gets more reflected rays when it passes through.

The darker surrounding surface is less of a reflector and so doesn’t provide that much

reflected rays to the receiver module. So every time the reflective strip passes in front

Page 16: Mini Report Final1

of the transmitter diode the receiver encounters an increase in rays incident upon it.

This sudden increase in infrared rays is used to detect the completion of one

revolution and the beginning of the next.

CHAPTER 3

COMPONENTS

1. IC 555

2. ASAL6200 IR transmitter diode

3. TSOP1738 IR receiver module

4. PIC18F452 Microcontroller

5. 16x2 LCD display

6. IN4148 Diode

7. LM 7805 Voltage Regulator

8. Power Source

9. PCB, Resistors, capacitors and oscillators of required ratings

3.1 Infra-red Transmitter:

The transmitter consists of an IC 555 timer circuit (astable multivibrator) with

an IR LED at the output. The IC 555 timer circuit is designed to produce a pulse of

frequency 33 kHz .The pulse produced triggers ‘on’ the transistor which in turn

forward biases the IR diode. A resistor is kept in series to limit the current through the

semiconductor devices. When the IR diode is forward biased during the on-time of the

pulse, it emits infra-red rays.

IC 555 and Astable Multivibrator circuit:

Page 17: Mini Report Final1

The 555 Timer IC is an integrated circuit (chip) used in a variety of timer,

pulse generation and oscillator applications. The IC was designed by Hans R.

Camenzind in 1970.The LM555 is a highly stable controller capable of producing

accurate timing pulses. With an astable operation, the frequency and duty cycle are

accurately controlled by two external resistors and one capacitor.

In astable mode, the 555 timer puts out a continuous stream of rectangular

pulses having a specified frequency. Resistor RA is connected between VCC and the

discharge pin (pin 7) and another resistor (RB) is connected between the discharge pin

(pin 7), and the trigger (pin 2) and threshold (pin 6) pins that share a common node.

Hence the capacitor C is charged through RA and RB, and discharged only through RB,

since pin 7 has low impedance

to ground during output low intervals of the cycle, therefore discharging the capacitor.

In the astable mode, the frequency of the pulse stream depends on the values

of RA, RB &C:

The high time from each pulse is given by High =ln(2).(RA+RB).C

and the low time from each pulse is given by Low =ln(2).RB.Cwhere RA and RB are the values of the resistors in ohms and C is the value of the

capacitor in farads.

To achieve a duty cycle of less than or equal to 50% ,a diode can be added in

parallel with RB towards the capacitor. This bypasses RB during the high part of the

cycle so that the high interval depends only on RA and C.

Page 18: Mini Report Final1

FIG 3.1CIRCUIT OF IC555 TIMER CIRCUIT AS AN ASTABLE MULTIVIBRATOR

3.2 Infra-red Receiver Module:

For detection purposes a commercially available infra-red receiver module is

used. The receiver module we use is TSOP1738 which has a carrier frequency of 38

kHz (This is the reason for creating an astable multivibrator at the emitter side). This

module consists of photo-detector, amplifier and band pass filter, which convert the

electro-magnetic input into a measurable potential difference. Band pass filter is to

filters out the noise due to diffused infra-red rays from the surrounding light sources,

as it only allows only the transmitted 38 kHz to pass. The reflective strip on the

machine reflects more of the infra-red rays than the surrounding areas of the machine.

The receiver module will be triggered only if the rays from the reflective strip fall on

it.

This module has three pins –

Vcc pin- The supply voltage is provided to the module through this pin. The

supply voltage provided is usually 5 volts.

Ground pin- The grounding for the device is provided using this pin.

Page 19: Mini Report Final1

Vout pin- In most cases this pin gives high level output when it is not

triggered. Low level output is given when it is triggered by the infra-red rays

from the reflective strip.

FIG 3.2INTERNAL BLOCK DIAGRAM OF TSOP 1738

3.3 PIC Microcontroller:

The microcontroller used is the PIC18F452. The Vout pin of the receiver

module is connected to an analog pin of the microcontroller. The high and low inputs

of the receiver module are detected by the microcontroller through this analog pin. To

deduce an RPM reading in less than second, while constantly refining the reading's

accuracy, a timer is used. They are part of the internal features of a microcontroller

and they can be easily configured through programming.

The timer is used to precisely feed the timer value that occurs between two

consecutive detections of reflected pulses from the machine surface. Therefore now

we know the time taken between two consecutive reflected pulses from the machine

surface. From this value the frequency of rotation can be computed. Then all that

remains is to convert the frequency value into a rotation per minute value.

Page 20: Mini Report Final1

FIG 3.3PIN DIAGRAM OF PIC18F452 MICROCONTROLLER

3.4 16x2 Liquid Crystal Display:

The LCD is used to display the rpm reading of the machine. It consists of 16 pins-

Vss- This is the Ground pin of the display.

Vdd- The supply voltage is provided to this pin

VEE- This pin is used to adjust the contrast of the LCD by changing the input

voltage at this pin. This is done by using a potential divider.

RS(Register Select)pin-There are 2 very important registers in LCD

1. Command Code register

2. Data Register

If RS=0, Instruction command Code register is selected, allowing user to send

command. If RS=1, Data register is selected allowing to send data that has to

be displayed.

Page 21: Mini Report Final1

R/W (Read/Write) pin-R/W input allows the user to write information to LCD

or read information from it. The data that is being currently displayed will be

stored in a buffer memory DDRAM. This data could be read if necessary. If

R/W=0, it is in Reading mode and if R/W=1, it is in Writing mode.

E (Enable) pin-The enable Pin is used by the LCD to latch information at its

data pins. When data is supplied to data pins, a high to low pulse must be

applied to this pin in order for the LCD to latch the data present in the data

pins.

Data Bus- D0-D7- the data or command from the microcontroller is sent to

these pins.

FIG 3.4PIN DIAGRAM OF 16x2 LCD

3.5 Power Source:

A DC power source was used in the project - 9V battery with 900mAh

capacity. The 9V source is used for the working of IC’s. As all the IC’s required 5V

for working, a 5V linear regulator LM7805 was used to supply the regulated power.

Page 22: Mini Report Final1

FIG 3.59V BATTERY AND CONNECTER

CHAPTER 4

Concept and Construction

Step 1

Page 23: Mini Report Final1

The suitable resistances are selected for the IC555 circuit such that the output

oscillates at a frequency of 33 kHz. The output of this circuit is connected to the

infrared transmitter diode. Therefore the diode transmits infrared rays at the rate at

which the circuit output oscillates.

Step 2

The pulse reflects off the surface of the machine. The machine surface has a

white reflective strip. The reflective strip being white in colour reflects more than the

surrounding areas. Since the reflective strip reflects more, a change in reflective

pattern occurs whenever the incident infrared rays strike upon this strip. Due to this

change in pattern we can understand that it is this strip that is reflecting and not the

surrounding areas. As this change in pattern can occur only once in one revolution we

can keep this as a count for how many revolutions take place in a given time period.

Step 3

The receiver module is kept in such a position so that the reflected infrared

rays from the surface are incident upon the receiver module. When the receiver

module detects a signal with pulse rate within its frequency range (33 kHz + 5%), its

normal high output goes to a low state.

Step 4

The output pin from the receiver module is connected to the PIC

microcontroller. This change of state is detected by the microcontroller. Now we

know that the reflective strip has passed by once. This change of output from high to

Page 24: Mini Report Final1

low is used to trigger a timer. Now the microcontroller checks whether the output of

the receiver module has gone from low state to high state. In this way we can make

sure that it is the surrounding surface that is now reflecting. When the output changes

from high to low it will be due to the appearance of the reflective strip. At this point

the timer is stopped and the value inside the timer is stored. This value is the time that

has elapsed between two appearances of the reflective strip, ie. the time taken for one

revolution. From this we can find the frequency of rotation of the machine and hence

find the rpm value of the machine.

Step 5

This value is sent to the LCD so that it can be displayed.

CHAPTER 5

STAGES OF IMPLEMENTATION

Page 25: Mini Report Final1

5.1 Design Development

The functional block diagram of the basic design is shown in figure given

below. The infra-red signal from the transmitter is reflected from the rotating machine

and is received by a sensor circuit which, in turn sends the corresponding output to a

microcontroller. The microcontroller processes the signal and sends the rpm value to

the LCD display.

FIG 5.1BLOCK DIAGRAM OF A CONTACTLESS IR TACHOMETER

5.2 Procurement of components

Page 26: Mini Report Final1

The IC555, a bread board, a plain circuit board, LM7805 and the other

components for the microcontroller circuit were procured from Calicut. A receiver

module and an LCD display were purchased from Chennai. The transmitter-receiver

module was obtained from a senior.

5.3 Circuit Assembly

The above figure shows the power supply circuit for the PIC18F4520. Also

shown is the external oscillator circuit for the microcontroller. A 9V battery is

connected to a LM7805 voltage regulator which steps down the voltage to 5V. This

5V is given to the supply and MCLR (reset) pins of the PIC. The external oscillator

crystal decides the time taken per instruction and so determines the speed of the

microcontroller processes.

FIG 5.2

POWER SUPPLY CONNECTION OF PIC18F452

Page 27: Mini Report Final1

FIG 5.3SIMULATION CIRCUIT OF DIGITAL TACHOMETER

The exact pin configuration is shown in the above figure. The input from the

infrared receiver is given to pin 15. The LCD is connected to the port B of the PIC.

The data is sent to the LCD using parallel connection. This means that each of the 4

data pins in the LCD is connected to one pin of the PIC.

5.4 Microcontroller programming

The microcontroller used for this project is PIC18F452.The microcontroller

was programmed to detect the pulse from the IR receiver and to count the time

between two pulses. The microcontroller code was written in C/C++ language in

PICC compiler and converted to HEX file. The code was burned to the

microcontroller using universal programmer.

Six pins of microcontroller are used to give input to the LCD display. The data

to LCD display is given in ASCII code.

Page 28: Mini Report Final1

5.5 LCD setup

The output from the PIC18F4250 microcontroller goes to the LCD. The data

pins of the LCD are connected to pins 34 to 37. The RS and E pins of the LCD are

connected to the pins 40 and 39 respectively. The RW pin of the LCD is grounded as

we always write to the LCD. There is no situation in which we will need to read from

the LCD. The commands to the LCD are given via the PIC microcontroller. This is

possible due to the LCD interfacing which is a highly useful feature of the

microcontroller.

Page 29: Mini Report Final1

CHAPTER 6PROGRAM (CODE)

#include "E:\Studies\national institute of technology calicut\sixth\mini project\piccproj\main.h" //file containing microcontroller information #include "lcddisp.c" // file for lcd display int16 k=0, p;int h, m, n, o;void main () setup_adc_ports (NO_ANALOGS|VSS_VDD); //initial states setup_adc (ADC_OFF|ADC_TAD_MUL_0); setup_psp (PSP_DISABLED); setup_spi (SPI_SS_DISABLED); setup_wdt (WDT_OFF); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_256); //initializing timer 0 setup_timer_1(T1_DISABLED); setup_timer_2(T2_DISABLED,0,1); setup_timer_3(T3_DISABLED|T3_DIV_BY_1); setup_comparator(NC_NC_NC_NC); setup_vref(FALSE);set_tris_c(1); //portc as input portlcd_init(); //initializing function for lcddelay_ms(1000);while(1) while(1) if(!input(PIN_C0)) //checking for a low in input set_timer0(0); //starting timer with value zero break;

Page 30: Mini Report Final1

while(!input(PIN_C0)) //if input high it exits this loop

while(1) if(!input(PIN_C0)) //if input again low k=get_timer0(); //getting timer count for one revolution break; p=234360/k; //constant divided by value to get directly rpm h=p%10; p=p/10; //extracting digits from units place m=p%10; p=p/10; n=p%10; p=p/10; o=p%10; p=p/10; n=n-o; printf(lcd_putc,"%u",o); //displaying it in the correct order printf(lcd_putc,"%u",n); printf(lcd_putc,"%u",m); printf(lcd_putc,"%u",h); delay_ms(1000); lcd_putc('\f');

//lcddisp.c (external file written only for lcd display)

#define LCD_DB4 PIN_B4

Page 31: Mini Report Final1

#define LCD_DB5 PIN_B3 #define LCD_DB6 PIN_B2 #define LCD_DB7 PIN_B1 #define LCD_E PIN_B6 #define LCD_RS PIN_B7 #define LCD_RW PIN_B0 #define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines #define lcd_line_two 0x40 // LCD RAM address for the 2nd line

int8 const LCD_INIT_STRING[4] = 0x20 | (lcd_type << 2), // Func set: 4-bit, 2 lines, 5x8 dots 0xc, // Display on 1, // Clear display 6 // Increment cursor ; void lcd_send_nibble(int8 nibble) // Note: !! converts an integer expression to a boolean (1 or 0). output_bit(LCD_DB4, !!(nibble & 1)); output_bit(LCD_DB5, !!(nibble & 2)); output_bit(LCD_DB6, !!(nibble & 4)); //sending data through output pinsoutput_bit(LCD_DB7, !!(nibble & 8));

delay_cycles(1); output_high(LCD_E); delay_us(2); //latching the input of lcd output_low(LCD_E);

// Send a byte to the LCD. void lcd_send_byte(int8 address, int8 n) output_low(LCD_RS); delay_us(60);if(address)

Page 32: Mini Report Final1

output_high(LCD_RS); else output_low(LCD_RS); delay_cycles(1); output_low(LCD_E); lcd_send_nibble(n >> 4); lcd_send_nibble(n & 0xf);

void lcd_init(void) int8 i; output_low(LCD_RS); output_low(LCD_E); delay_ms(15);

for(i=0 ;i < 3; i++) lcd_send_nibble(0x03); delay_ms(5); lcd_send_nibble(0x02);

for(i=0; i < sizeof(LCD_INIT_STRING); i++) lcd_send_byte(0, LCD_INIT_STRING[i]);

void lcd_putc(char c) switch(c) case '\f': lcd_send_byte(0,1); delay_ms(2); break;

Page 33: Mini Report Final1

default: lcd_send_byte(1,c); break;

CHAPTER 7IMPLEMENTATION OBSTACLES

7.1 RESULTS AND DISCUSSIONS

The main difficulties encountered during the design process were-

1. Not practically possible to make the astable multivibrator circuit oscillate at

the exact frequency of the receiver module. This is mainly due to the fact that this

frequency cannot be obtained by using commercially available standard resistance

values.

2. The algorithm used has within it the division of two integer values. This

creates two problems. One is the fact that this is very hard to implement in assembly

language. It can only be done using multiple subtraction which takes up a lot of

processing time and resources. The other problem encountered here is that this

division creates loss of precision. This is due to the fact that the PIC microcontroller

cannot perform floating point arithmetic calculations. This loss of precision ultimately

results in error induced in the final rpm value calculated.

3. The values calculated from the PIC microcontroller are all of hexadecimal

type. The values to be sent to the LCD can only be in ASCII format. This requires

conversion from one format to the other which again uses up processing time and

resources.

4. The LCD system as such is a very slow one. This requires a lot of delays to be

implemented in the algorithm. If these were not incorporated into the algorithm the

LCD system would not be able to keep pace with the microcontroller system.

7.2 DRAWBACKS

Page 34: Mini Report Final1

The main drawback of this system is the error encountered during calculation.

This is mainly due to the fact that the microcontroller may not detect the low output

immediately after it occurs. The division process in the algorithm creates loss of much

precision. This loss of precision could have been avoided if floating point arithmetic

operations were possible in PIC microcontroller. The value of rpm displayed is not the

exact value of rpm that the machine has at present. There is always a delay

encountered during the calculation process. That delay ensures that the present value

of rpm is never displayed as the output.

CHAPTER 8

FUTURE ENHANCEMENTS

Numerous future enhancements suggested to the machine can be-

1. The display of the rpm in numerous dimensions i.e. Hz and rps. An inter-

conversion process can be incorporated into the algorithm. This would be

convenient as we would not have to carry out the calculation manually.

2. Faster LCD system can be used. This would lessen the delay in the whole

process.

3. The implementation of a HOLD feature. This feature would allow the user to

freeze the value of rpm displayed so that we would be able to read the value

that we need. This can be done by using a dedicated button for this feature.

The pressing of this button would result in the freezing of the display.

Page 35: Mini Report Final1

CHAPTER 9REFERENCE

LM555 TIMER IC DATASHEET

TSOP1738 IR SENSOR MODULE DATASHEET

PIC MICROCONTROLLER AND PROGRAMMING

by Muhammad Ali Mazidi, Rolin D M, Danny Causey

LCD display module datasheet