Вы находитесь на странице: 1из 22

ABSTRACT

The digital speedometer measures the rotational speed of the wheel or how fast the wheel turns. Unlike with the old, analogue speedometers, this does not make use of moving pointer displays or the moving magnet designs. Instead, it makes use of digital screen readout to show the driver a more exact and accurate reading of the vehicles current speed using 89C51 microcontroller, hall-effect sensor, magnet and LCD display. In this mini project, wheel rotation of vehicle is sensed magnetically using Hall effect sensor. Total distance and distance per second is calculated using microcontroller and LCD module is used inorder to display them as KM (Kilo Metre) and KMPH (Kilo Metre Per Hour). This mini-project is designed such that, it can display speed upto 100KMPH and total distance up to10000KM.

i 1. INTRODUCTION
A digital speedometer is commonly found in land vehicles such as cars, trucks, vans, motorbikes, and other similar types of transportation. However, it can also be used for other means as well. It can be applied to anything wherein one is measuring the speed of a specific moving object. It is a vital instrument especially when it comes to land vehicles. With it, the driver or operator of the machine is able to track his or her movement and maintain a relatively safe speed while on the road. When it comes to racing performance vehicles, it is used by the driver and technicians to make vital decisions and measure the overall performance of the machine. Digital Speedometer can accurately determine the speed and uses digital display, not a pointer display. Digital Speedometer is easier to read than analogue meters. It avoids the risks. The most important advantage is that it can also be calibrated in such a way to show the speed reading in KPH and the distance in kilometres.

2. BLOCK DIAGRAM

Figure :2.0 Block Diagram

The block diagram consists of

microcontroller, Halleffect sensor, Liquid

crystal display.Halleffect sensor senses number of revolutions and sends this information to microcontroller unit through interrupt and displays distance and speed. AT137 is an 3 pin IC which provides output pulse when it crosses the magnet. In this 16 Character X 2 Line Liquid Crystal Display is used to display the speed and distance.

3. HARDWARE DESCRIPTION
3.1. Microcontroller AT89C51
The main function of microcontroller in this project is, it will get interrupted whenever sensor crosses magnet and displays distance travelled and speed on display. A Micro controller consists of a powerful CPU tightly coupled with memory, various I/O interfaces such as serial port, parallel port timer or counter, interrupt controller, data acquisition interfaces-Analog to Digital converter, Digital to Analog converter, integrated on to a single silicon chip.[1] If a system is developed with a microprocessor, the designer has to go for external memory such as RAM, ROM, EPROM and peripherals. But controller is provided all these facilities on a single chip. Development of a Micro controller reduces PCB size and cost of design.One of the major differences between a Microprocessor and a Micro controller is that a controller often deals with bits not bytes as in the real world application.

Fig. 3.1.1 Functional Block Diagram of AT89C51Micro Controller

The Major Features 1. Compatible with MCS-51 products. 2. 4k Bytes of in-system Reprogrammable flash memory. 3. Fully static operation: 0HZ to 24MHZ. 4. Three level programmable clock. 5. 128 * 8 bit timer/counters. 6. Six interrupt sources. 7. Programmable serial channel. 8. Low power, idle power-down modes. Purpose of AT89C51 The system requirements and control specifications clearly rule out the use of 16, 32 or 64 bit micro controllers or microprocessors. Systems using these may be earlier to implement due to large number of internal features. They are also faster and more reliable but, the above application is satisfactorily served by 8-bit micro controller. Coming to the question of why to use AT89C51 of all the 8-bit microcontroller available in the market the main answer would be because it has 4 Kb on chip flash memory which is just sufficient for our application. The on-chip Flash ROM allows the program memory to be reprogrammed in system or by conventional non-volatile memory Programmer. Moreover ATMEL is the leader in flash technology in todays market place and hence using AT 89C51 is the optimal solution.[2] The 89C51 architecture consists of these specific features: 1. Eight bit CPU with registers A (the accumulator) and B. 2. Sixteen-bit program counter (PC) and data pointer (DPTR). 3. Eight- bit Program Status Word (PSW). 4. Eight-bit stack pointer (Sp).

5. Internal ROM or EPROM (8751) of 0(8031) to 4K (89C51). 6. Internal RAM of 128 bytes 6.1. Four register banks, each containing eight registers. 6.2. Sixteen bytes, which maybe addressed at the bit level. 6.3. Eighty bytes of general- purpose data memory. 7. Thirty two input/output pins arranged as four 8-bit ports:p0-p3 8. Two 16-bit timer/counters: T0 and T1 9. Full duplex serial data receiver/transmitter: SBUF 10. Control registers: TCON, TMOD, SCON, PCON, IP, and IE 11. Two external and three internal interrupts sources. 12. Oscillator and clock circuits. The 89C51 Oscillator and Clock The heart of the 89C51 circuitry that generates the clock pulses by which all the internal all internal operations are synchronized. Pins XTAL1 and XTAL2 is provided for connecting a resonant network to form an oscillator. Typically a quartz crystal and capacitors are employed. The crystal frequency is the basic internal clock frequency of the microcontroller. The manufacturers make 89C51 designs that run at specific minimum and maximum frequencies typically 1 to 16 MHz.

Fig. 3.1.2. Oscillator and Timing Circuit

Types of memory The 89C51 have three general types of memory. They are on-chip memory, external Code memory and external Ram. On-Chip memory refers to physically existing memory on the micro controller itself. External code memory is the code memory that resides off chip. This is often in the form of an external EPROM. External RAM is the Ram that resides off chip. This often is in the form of standard static RAM or flash RAM. Code memory Code memory is the memory that holds the actual 89C51 programs that is to be run. This memory is limited to 64K. Code memory may be found on-chip or offchip. It is possible to have 4K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA. Internal RAM The 89C51 have a bank of 128 of internal RAM. The internal RAM is found on-chip. So it is the fastest Ram available. And also it is most flexible in terms of reading and writing. Internal Ram is volatile, so when 89C51 is reset, this memory is 7

cleared. 128 bytes of internal memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains 8 registers. Internal RAM also contains 128 bits, which are addressed from 20h to 2Fh. These bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are numbered 00h to 7Fh. The user may make use of these variables with commands such as SETB and CLR.

Pin Description VCC: Supply voltage. GND: Ground. Port 0 Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pullups are required during program verification Pin Diagram

Fig 3.1.3 Pin diagram of AT89C51

Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 1 also receives the low-order address bytes during Flash programming and verification. Port 2 Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memories that use 16bit addresses (MOVX @DPTR). In this application, it uses strong internal pull-ups when emitting 1s. During accesses to external data memories that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-order address bits and some control signals during Flash programming and verification. Port 3 Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of various special features of the AT89C51 as listed below: Port 3 also receives some control signals for Flash programming and verification Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. Port pin P3.0 P3.1 P3.2 Alternate Functions RXD (Serial input port) TXD (Serial output port) INT0 (external interrupt 0)

P3.3 P3.4 P3.5 P3.6 P3.7

INT1 (external interrupt 1) T0 (Timer 0 external input) T1 (Timer1 external input) WR (external data memory write strobe) RD (external data memory read strobe)

Table. 3.1.0 Port pins and their alternate functions RST ALE/PROG Address Latch Enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation ALE is emitted at a constant rate of 1/6the oscillator frequency, and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external Data Memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode. PSEN Program Store Enable is the read strobe to external program memory. When the AT89C51 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming, for parts that require 12-volt VPP. XTAL1 Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 10

Output from the inverting oscillator amplifier. Oscillator Characteristics XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figs 6.2.3. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven as shown in Figure 6.2.4.There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.[3]

Fig 3.1.4 Oscillator Connections

3.2 Hall Effect Sensor


AH172 is a single digital output Hall-effect sensor with pull-up resistor which gives output pulse whenever the magnet crosses in every revolution of wheel. The device includes an on-chip Hall voltage generator for magnetic sensing, an amplifier to amplify Hall voltage, and a comparator to provide switching hysteresis for noise rejection, and an output driver with a pull-up resistor (Rpu). An internal band gap regulator is used to provide temperature compensated supply voltage for internal circuits and allows a wide operating supply range. While the magnetic flux density (B) is larger than operate point (Bop), the OUT pin turns on(low). If B removed toward release point (Brp), the OUT pin is latched on state prior to B < Brp. When B < Brp, the OUT pin go into off state.

11

AH 172

Fig 3.2.1 AH172

Fig 3.2.2 Blockdiagram of halleffect sensor

3.3 Liquid Crystal Display


In this miniproject, a 16 X 2 LCD is used to display the temperature In 1968, RCA Laboratories developed the first liquid crystal display (LCD). Since then, LCDs have been implemented on almost all types of digital devices, from watches to computer to projection TVs .LCDs operate as a light valve, blocking light or allowing it to pass through. An image in an LCD is formed by applying an electric field to alter the chemical properties of each LCC (Liquid Crystal Cell) in the display in order to change a pixels light absorption properties. These LCCs modify the image produced by the backlight into the screen output requested by the controller. Through the end output may be in color, the LCCs are monochrome, and the color is added later through a filtering process. To understand the operation of an LCD, it is easiest to trace the path of a light ray from the backlight to the user. The light source is usually located directly behind the LCD, and can use either LED or conventional fluorescent technology. From this source, the light ray will pass through a light polarizer to uniformly polarize the light so it can be acted upon by the liquid crystal (LC) matrix. The light beam will then pass through the LC matrix, which will determine whether this pixel should be on or off. If the pixel is on, the liquid crystal cell is electrically activated, and the 12

molecules in the liquid will align in a single direction. This will allow the light to pass through unchanged. If the pixel is off, the electric field is removed from the liquid, and the molecules with in scatter. This dramatically reduces the light that will pass through the display at that pixel. In a color display, after the light passes through the liquid crystal matrix, it passes through a color filter (usually glass). This filter blocks all wavelengths of light except those within the range of that pixel. In a typical RGB display, the color filter is integrated into the upper glass colored microscopically to render each individual pixel red, green or blue. The areas in between the colored pixel filter areas are printed black to increase contrast. After a beam of light passes through the color filter, it passes through yet another polarizer to sharpen the image and eliminate glare. The image is then available for viewing. In an AMLCD, each LCC is stimulated individually by a dedicated transistor or diode. The two existing AMLCD technologies are Thin Film Transistor (TFT) and metal-insulator-metal (MIM). In an MIM display, dedicated diodes are fabricated at each pixel. 3.3.1. Interfacing LCD to microcontroller Here we are interfacing a 16 Character X 2 Line LCD Module to the Parallel Port. These LCD Modules are very common these days, and are quite simple to work with, as all the logic required running them is on board. Features Interface with either 4-bit or 8-bit microprocessor. Display data RAM Character generator ROM 160 different 5X7 dot-matrix character patterns. Character generator RAM 8 different user programmed 5X7 dot-matrix patterns. Display data RAM and character generator RAM may be accessed by the microprocessor. Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF, Blink Character, Cursor Shift, Display Shift.

13

Built-in reset circuit is triggered at power ON. 3.3.2.Pin Diagram of LCD

Figure:3.3.2:Pin Diagram of LCD In the above figure3.3.2 Vcc and Vss are supply pins and VEE (Pin no.3) is used for controlling LCD contrast. Pin No.4 is Rs pin for selecting the register, there are two very important registers are there in side the LCD. The RS pin is used for their selection as follows. If RS=0, the instruction command code register is selected, allowing the user to send data to be displayed on the LCD. R/W is a read or writes Pin, which allows the user to write information to the LCD or read information from it. R/W=1 when reading R/W=0 when writing. The LCD to latch information presented to its data pins uses the enable (E) pin. The 8-bit data pins, D0-D7, are used to send information to the LCD or read the contents of the LCDs internal registers. To display letters and numbers, we must send ASCII codes for the letters A-Z, and number 0 -9 to these pins while making RS=1.

3.4 Power Supply


3.4.1.Circuit diagram

14

1N4007 X 2

+12v

230v / 12v- 0 -12v 500mA Transformer

2200F/25 v

100F/25v

Figure: 3.4.1 Circuit Diagram of Power Supply The Power Supply is a Primary requirement for the project work. The required DC power supply for the base unit as well as for the recharging unit is derived from the mains line. For this purpose center tapped secondary of 12V-012V transformer is used. From this transformer we getting 5V power supply. In this +5V output is a regulated output and it is designed using 7805 positive voltage regulator. This is a 3 Pin voltage regulator, can deliver current up to 800 milliamps. Rectification is a process of rendering an alternating current or voltage into a unidirectional one. A rectifier permits current to flow only during positive half cycles of the applied AC voltage. Thus, pulsating DC is obtained to obtain smooth DC power additional filter circuits required.[4] A diode can be used as rectifier. There are various types of diodes. However, semiconductor diodes are very popularly used as rectifiers. A semiconductor diode is a solid-state device consisting of two elements is being an electron emitter or cathode, the other an electron collector or anode. Since electrons in a semiconductor diode can flow in one direction only-form emitter to collector-the diode provides the unilateral conduction necessary for rectification.[4] In figure 3.4.1, the rectified Output is filtered for smoothening the DC, for this purpose capacitor is used in the filter circuit. The filter capacitors are usually connected in parallel with the rectifier output and the load. The AC can pass through a capacitor but DC cannot, the ripples are thus limited and the output becomes

15

smoothed. When the voltage across the capacitor plates tends to rise, it stores up energy back into voltage and current. Thus, the fluctuation in the output voltage is reduced considerable. 3.4.2. LM 7805 Voltage Regulator In this, LM7805 Voltage regulator is used to provide regulation. Designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents. The LM7805 series is available in aluminum to 3 packages which will allow over 1.5A load current if adequate heat sinking is provided. Current limiting is included to limit the peak output current to a safe value. The advantage of this type of regulator is, it is easy to use and minimize the number of external components.[4] The following are the features voltage regulators: a) Output current in excess of 1.5A for 78 and 78L series b) Internal thermal overload protection c) No external components required d) Output transistors age area protection e) Internal short circuit current limit. f) Available in aluminum 3 package.

4. CIRCUIT EXPLANATION
4.1 Circuit diagram

16

Figure: 4.0 Circuit Diagram

4.2 Operation
The required DC power supply for the base unit as well as for the recharging unit is derived from the mains line. For this purpose center tapped secondary of 12V012V transformer is used. From this transformer we getting 5V power supply. In this +5V output is a regulated output and it is designed using 7805 positive voltage regulator. This is a 3 Pin voltage regulator, can deliver current up to 800 milliamps. This forms the power section. After the application of power, the microcontroller initializes the LCD. The communication between microcontroller and AH172 is serial and between it and LCD is parallel communication. A magnet is then attached to one of the wheels of the vehicle. Whenever it rotates, it will pass by the halleffect sensor in each complete rotation, thus activating the component. Once this happens, it creates a small pulse, indicating one full revolution of the wheel. The pulse produced by hall effect sensor is then turned into a high priority interrupt to 89C51 microcontroller. The distance travelled by the vehicle is calculated using counters of 89C51 and the speed of the vehicle is then calculated by the based

17

on the time elapsed between two high priority interrupts. It then displays this on the LCD screen for the driver to recognize. By using this digital speedometer, speed and distance can be found and displayed on the LCD screen. Calculations We first need to know the radius of the bikes front wheel. The calculations here are based on Hero Hondas Splendor model. The radius of the front wheel is 30 cm. (This can vary with the brand or model.) Circumference of the wheel= 2r (where r is in cm) = 23.1430 = 188.4 cm or 1.884 metres Speed: Lets assume that in 1 second the wheel completes one revolution. In other words, in one second, the bike has covered 1.88 metres. Therefore the speed in km/hour: N1.883600/1000 = N6.784 or N6.8 where N is the number of revolutions per second. 6.8 is a constant and only N varies for example, if N is 5, the speed equals 5x6.8= 34 km/hour.

4.3 Algorithm
Step: 1 Initialize LCD. Step: 2 Display initial readings.

18

Step: 3 Configure the two Timers as 8-bit counters and enable time overflow interrupt. Step: 4 Write command for requesting temperature data by converting parallel commanding to serial. Step: 5 Get data from AH172 Step: 6 Convert output as interrupt to microcontroller. Step: 7 Convert hex data in to ASCII data with the help of lookup table. Step: 8 Write the same data in to the LCD display.

RESULT

19

Digital speedometer measures the vehicle speed upto 99km/hr and distance travelled upto 10,000 km and displays it on a LCD display. Therefore driver can know more exact and accurate reading of speed and distance.

CONCLUSION

20

Digital speedometer is the best choice for measuring speed and distance. It avoids errors caused by mechanical movements of indicators. Using this digital speedometer, it is easy-to-read the digital display. Because of this reason, digital speedometer has a wide range of applications. This can be extended to give alarm to user whenever vehicle exceeds certain speed by using buzzer and relay circuit. Thus, digital speedometer measures the vehicle speed, distance travelled and displays it on a LCD display accurately and cast effective.

REFERENCES
21

1. Microcontroller-based temperature monitoring and control by Dogan Ibrahim, September 2002. 2. The 8051 Microcontroller Architecture, Programming and Applications by Kenneth J Ayala, 2nd Edition.,1996. 3. PIC Basic programming by Dogan Ibrahim,First Edition, 2001. 4. Principles of electronic circuits by S.G.Burns and P.R.Bond ,Galgotia publications, 2nd edition, 1998.

22

Вам также может понравиться