Professional Documents
Culture Documents
Submitted in partial fulfillment for the award of the Degree of Bachelor of Technology in Electrical and Electronics Engineering
by
Dr.K.S. Sivanandan
CERTIFICATE
This 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. R. SREERAM KUMAR (Head of the Department) Professor Dept. of Electrical Engineering
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.
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.
LIST OF ABBREVIATIONS
LCD RPM IR PCB - LIQUID CRYSTAL DISPLAY - ROTATIONS PER MINUTE - INFRA-RED - PRINTED CIRCUIT BOARD AMERICAN STANDARD CODE FOR INFORMATION
ASCII -
INTERCHANGE
LIST OF SYMBOLS
LIST OF FIGURES
FIGURE NO FIG 2.1 NAME EQUIVALENT CIRCUIT DIAGRAM OF CAPACITOR CHARGING IN IC555 EQUIVALENT CIRCUIT DIAGRAM OF CAPACITOR CHARGING IN IC555 INTERNAL BLOCK DIAGRAM OF IC555 PAGE NO 10
FIG 2.2
11
FIG 2.3
12
13 13
FIG 2.6
13
FIG 3.1
CIRCUIT OF IC555 TIMER CIRCUIT AS AN ASTABLE MULTIVIBRATOR INTERNAL BLOCK DIAGRAM OF TSOP 1738
16
FIG 3.2
17
FIG 3.3
18
FIG 3.4
19
FIG 3.5
20
FIG 5.1
23
FIG 5.2
24
FIG 5.3
25
1 2 2.1 2.2
8 10 10 14
COMPONENTS INFRA-RED TRANSMITTER INFRA-RED RECEIVER MODULE PIC MICROCONTROLLER: 16X2 LIQUID CRYSTAL DISPLAY: POWER SOURCE
15 15 17 18 19 20
CONCEPT AND CONSTRUCTION STAGES OF IMPLEMENTATION DESIGN DEVELOPMENT PROCUREMENT OF COMPONENTS CIRCUIT ASSEMBLY MICROCONTROLLER PROGRAMMING LCD SETUP
21 23 23 24 24 25 26
6 7 7.1 7.2 8 9
PROGRAM (CODE) IMPLEMENTATION OBSTACLES RESULTS AND DISCUSSIONS DRAWBACKS FUTURE ENHANCEMENTS REFERENCES
27 31 31 31 32 33
CHAPTER 1 INTRODUCTION
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 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 dont 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 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.
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
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
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
INTERNAL BLOCK DIAGRAM OF IC555
FIG 2.4
EXTERNAL CONNECTION DIAGRAM OF IC555
FIG 2.5
CAPACITANCE VS FREQUENCY GRAPH
FIG 2.6
OUTPUT & THRESHOLD PIN WAVEFORMS
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 doesnt provide that much reflected rays to the receiver module. So every time the reflective strip passes in front 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
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 R A, 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.C where 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.
FIG 3.1
CIRCUIT OF IC555 TIMER CIRCUIT AS AN ASTABLE MULTIVIBRATOR
FIG 3.2
INTERNAL BLOCK DIAGRAM OF TSOP 1738
FIG 3.3
PIN DIAGRAM OF PIC18F452 MICROCONTROLLER
FIG 3.4
PIN DIAGRAM OF 16x2 LCD
FIG 3.5
9V BATTERY AND CONNECTER
Step 1
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 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.
FIG 5.1
BLOCK DIAGRAM OF A CONTACTLESS IR TACHOMETER
FIG 5.2
POWER SUPPLY CONNECTION OF PIC18F452
FIG 5.3
SIMULATION 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.
CHAPTER 6 PROGRAM (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 port lcd_init(); //initializing function for lcd delay_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; } } 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 #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 pins output_bit(LCD_DB7, !!(nibble & 8)); delay_cycles(1); output_high(LCD_E); delay_us(2); 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) 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; default: lcd_send_byte(1,c); break; } }
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
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 9 REFERENCE
LM555 TIMER IC DATASHEET TSOP1738 IR SENSOR MODULE DATASHEET PIC MICROCONTROLLER AND PROGRAMMING
by Muhammad Ali Mazidi, Rolin D M, Danny Causey