Vous êtes sur la page 1sur 92

A VERSATILE HIGHWAY MISHAP POSITIONING SYSTEM AND BIO-PARAMETRIC IDENTIFICATION USING NANO ID AND GLOBAL POSITIONING SYSTEM

A PROJECT REPORT Submitted by

RS.SENTHIL ARUN KUMAR S.THOTHATHIRI KALLAPIRAN G. LOKESHWARAN V.SURENDRAN

: : :

: 31106106065 31106106073 31106106307 31106106312

In partial fulfillment for the award of the degree Of

BACHELOR OF ENGINEERING
IN

ELECTRONICS AND COMMUNICATION ENGINEERING KCG COLLEGE OF TECHNOLOGY, CHENNAI 600 097

ANNA UNIVERSITY, CHENNAI 600 025


MAY 2010

BONAFIDE CERTIFICATE

Certified that this project report titled A VERSATILE HIGHWAY MISHAP POSITIONING SYSTEM AND BIO-PARAMETRIC IDENTIFICATION USING NANO ID AND GLOBAL POSITIONING SYSTEM is the bonafide work of RS.SENTHIL ARUN KUMAR S.THOTHATHIRI KALLAPIRAN G.LOKESHWARAN V.SURENDRAN : : : : 31106106065 31106106073 31106106307 31106106312

Who carried out the research under my supervision during the year 2009-10.

SIGNATURE HEAD OF THE DEPARTMENT


DR.RANGANATHAN VIJAYARAGHAVAN Department of Electronics and Communication Engineering KCG College of Technology Old Mahabalipuram Road Karapakkam, Chennai 600 097

SIGNATURE SUPERVISOR
MR.S.TAMIL SELVAN Department of Electronics and Communication Engineering KCG College of Technology Old Mahabalipuram Road Karapakkam, Chennai 600 097

INTERNAL EXAMINER DATE OF EXAM:

EXTERNAL EXAMINER

ACKNOWLEDGEMENT We wish to express our sincere gratitude to Mrs.ELIZABETH VERGHESE, Chairman, Hindustan Group of Institutions and our Director Mr.ANAND JACOB VERGHESE for providing us the facility required to carry out our project work. We thank our beloved Principal, Dr.T.RENGARAJA and Dr.SUMATHI POOBAL, Vice Principal Academic, K.C.G. College of Technology, Chennai for giving us an inspiring spirit for our project and for providing us all the necessary facilities to pursue our studies in our college. We would specially like to thank

Dr.RANGANATHAN VIJAYARAGHAVAN, Head of Electronics and Communication Engineering department who was instrumental in providing the vital encouragement for the successful completion of our project. We express sincere thanks to our mentor guide, Mr.S.TAMIL SELVAN, Lecturer, ECE Department for motivating in the right direction and for his guidance during the project works. We are extremely thankful to our External guide for providing us valuable guidance and useful suggestions for constant improvement of this project work. Finally, we thank our beloved parents, friends, teaching and nonteaching staffs of ECE department and others for their co-operation and valuable suggestions in bringing out this project in exact time.
3

ABSTRACT Automatic Crash Notification is a system designed to be used in a crash situation. When a crash occurs, the intelligent system is activated and automatically sends select crash details to the appropriate Emergency Medical Service Center. The position of the vehicle can be send to the rescue team using GPS technology. So the rescue team can easily found out the place of accident. And they can hurry to the accident spot. Wireless technology is used for collecting details about the person. According, to the collected details first-aid facilities are promptly and properly delivered to help the victims. Moreover, it would be a great advantage to include information about the passengers, such as the details of the persons health, mobile no, any specified prescription for his first aid, relatives no in the RFID tag in order to tackle the emergency situation. The project focuses on implementation of Radio Frequency Identification technology (RFID) to improve the Crash Notification System with First-aid Profile (FAP). First-aid active RFID tag is pre-coded with a unique serial number (FAP-ID) that can be used to gain access to the First-Aid profile of that tagged person. Compatible reader detects the presence of First-aid tags and reports their FAP-IDs to the control unit, so that in crash situation, all passengers FAP-IDs will be messaged to Emergency Medical Service Center. During the project, the possibilities and constraints of using RFID technology for identifying passengers in vehicle is investigated, based on given hardware technological solution. Several tests are designed and carried out to investigate communication between the active RFID tag and the reader.

CONTENTS
Chapters 1. Introduction Page no. 6 8 8 11 20 23 23 23 24 25 28 54 57 58 60 64 71 75 90 91

2. Block Diagrams 2.1. Person Section 2.2. Vehicle Section 2.3. Rescue Team Section 3. Circuit Diagrams 3.1. Person Section 3.2. Vehicle Section 3.3. Rescue Team Section 4. Power Supply 5. Microcontroller 6. RF Module 6.1. RF Transmitter 6.2. RF Receiver 7. GPS 8. GSM 9. Vibration Sensor 10. Coding 11. Conclusion 12. Reference

CHAPTER-1 INTRODUCTION EXISTING SYSTEM: The Existing system consist of many failures. Some of the failures are the lack of Intelligence in the detection systems, it fails to track the collision and pre-damage status, also the automatic collision information is impossible. And at last the way of monitoring people to be manual. PROPOSED SYSTEM: In Highway mishap positioning system accident can be easily detected using GSM and GPS Wireless technologies with medical free error.GPS is used to get the latitude and longitude value and send it as string message to the mobile.GSM is used to send the AT COMMANDS to the corresponding mobiles. In the Rescue section patients can be treated easily with medical free error. In this section we can implement effective way of web based design for medical Alert system and provides high efficiency while enhancing the level of patient care. The patients medicals details can be seen by the doctor globally through web. The project focuses on implementation of Radio Frequency Identification technology (RFID) to improve the Crash Notification System with First-aid Profile (FAP). First-aid active RFID tag is pre-coded with a unique serial number (FAP-ID) that can be used to gain access to the First-Aid profile of that tagged person. Compatible reader detects the presence of First-aid tags and reports their FAP-IDs to the control unit, so that in crash situation, all passengers FAP-IDs will be messaged to Emergency Medical Service
6

Center. During the project, the possibilities and constraints of using RFID technology for identifying passengers in vehicle is investigated, based on given hardware technological solution. Several tests are designed and carried out to investigate communication between the active RFID tag and there.

CHAPTER-2 BLOCK DIAGRAMS 2.1 PERSON SECTION:

DESCRIPTION: In person section each person has RF tag which transmits a unique ID. ENCODER: An encoder is a device used to change a signal (such as a bit stream) or data into a code. The code may serve any of a number of purposes such as compressing information for transmission or storage, encrypting or adding redundancies to the input code, or translating from one code to another. The 2^12 encoders are a series of CMOS LSIs for remote control system applications. They are capable of encoding information which consists of N address bits and 12N data bits.

Each address/data input can be set to one of the two logic states. The programmed addresses/data are transmitted together with the header bits via an RF transmission medium . Transmission is enabled by applying a low signal to the TE pin. FEATURES : Operating voltage:2.4V~12V for the HT12E Low power and high noise immunity CMOS technology Minimum transmission words of 4 words for the HT12E Built-in oscillator needs only 5% resistor Data code has positive polarity Minimal external components HT12E: 18-pin DIP/20-pin SOP package RF TRANSMITTER : It accepts both linear and digital inputs It can operate from 1.5 to 12 Volts-DC It is approximately the size of a standard postage stamp. The transmitter output is up to 8mW at 433.92MHz with a range of approximately few meters Transmitter Supply Current: At Logic High Input: 5.1 mA At Logic Low Input: 1.8 mA Low Power mode (PDN): 5 A

Amplitude-shift keying (ASK) It is a form of modulation which represents digital data as variations in the amplitude of a carrier wave. The simplest and most common form of ASK operates as a switch, using the presence of a carrier wave to indicate a binary one and its absence to indicate a binary zero. This type of modulation is called on-off keying, and is used at radio frequencies to transmit Morse code (referred to as continuous wave operation). More sophisticated encoding schemes have been developed which represent data in groups using additional amplitude levels. For instance, a four-level encoding scheme can represent two bits with each shift in amplitude; an eight-level scheme can represent three bits; and so on. These forms of amplitude-shift keying require a high signal-to-noise ratio for their recovery, as by their nature much of the signal is transmitted at reduced power. If L different symbols are to be sent, L different levels of amplitude will be necessary to achieve the communication. If the maximum amplitude of the carrier wave is A (with a peak-to-peak amplitude of 2A), putting the symbols at the same distance one from the other, this distance will be:

It is possible to show that the probability to make an error (i.e. a symbol is read that is different from the one that was sent) is:

10

where erfc (.) is the complementary error function, GT is the total gain of the system and N is the standard deviation of the noise. This relationship is valid when there is no intersymbolic interference. 2.2 VEHICLE SECTION:

CRASH NOTIFICATION SENSOR This sensor buffers a piezoelectric transducer. As the transducer is displaced from the mechanical neutral axis, bending creates strain within the piezoelectric element and generates voltages. If the assembly is supported by its mounting points and left to vibrate in free space the device will behave as a form of vibration sensor. The sensing element should not be treated as a flexible switch, and is not intended to be bent.

11

Sensor Value 500 roughly corresponds to 0g acceleration. Acceleration will deflect the sensing element up or down, causing Sensor Value to swing either way. This sensor is not meant to measure precise acceleration and vibration - use it to detect an acceleration impulse, or the presence of vibration. MICROCONTROLLER (DALLAS) The DS89C430, DS89C440, and DS89C450 offer the highest performance available in 8051-compatible microcontrollers. They feature newly designed processor cores that execute instructions up to 12 times faster than the original 8051 at the same crystal speed. Typical applications will experience a speed improvement up to 10x. At 1 million instructions per second (MIPS) per megahertz, the microcontrollers achieve 33 MIPS performance from a maximum 33MHz clock rate. POWER SUPPLY The ac voltage, typically 220V Rms is connected to a transformer, which steps that ac voltage down to the level of the desired dc output. A diode rectifier then provides a full-wave rectified voltage that is initially filtered by a simple capacitor filter to produce a dc voltage. This resulting dc voltage usually has some ripple or ac voltage variation. A regulator circuit removes the ripples and also remains the same dc value even if the input dc voltage varies, or the load connected to the output dc voltage changes. This voltage regulation is usually obtained using one of the popular voltage regulator IC units. The operation of power supply circuits built using filters, rectifiers, and then voltage regulators. Starting with an AC voltage, a steady DC voltage is obtained by rectifying the AC
12

voltage, then filtering to a DC level, and finally, regulating to obtain a desired fixed DC voltage. The regulation is usually obtained from an IC voltage regulator Unit, which takes a DC voltage and provides a somewhat lower DC voltage, which remains the same even if the input DC voltage varies, or the output Load connected to the DC voltage changes. GLOBAL POSITIONING SYSTEM (GPS) GPS receiver determines just four variables: longitude, latitude, height and time. Additional information (e.g. speed, direction etc.) can be derived from these four components. This unit will receive all the coordinates needed from the GPS satellites. It will send the information to the microcontroller. We will be using the Garmin model GPS 12 XL. It has the capability to refresh its data once every second and therefore will be continuously updating the inputs for the microcontroller as the automobile changes location. Using GPS technology we can determine location, velocity and time, 24 hours a day in any weather conditions anywhere in the world for free. GSM MODEM A GSM modem is a wireless modem that works with a GSM wireless network. A wireless modem behaves like a dial-up modem. The main difference between them is that a dial-up modem sends and receives data through a fixed telephone line while a wireless modem sends and receives data through radio waves. A GSM modem can be an external device or a PC Card / PCMCIA Card. Typically, an external GSM modem is connected to a computer through a serial cable or a USB cable. A GSM modem in the form of a PC Card / PCMCIA Card is designed for use with a laptop computer. It should
13

be inserted into one of the PC Card / PCMCIA Card slots of a laptop computer. Like a GSM mobile phone, a GSM modem requires a SIM card from a wireless carrier in order to operate. As mentioned in earlier sections of this SMS tutorial, computers use AT commands to control modems. Both GSM modems and dial-up modems support a common set of standard AT commands. You can use a GSM modem just like a dial-up modem. In addition to the standard AT commands, GSM modems support an extended set of AT commands. These extended AT commands are defined in the GSM standards. With the extended AT commands, you can do things like: Reading, writing and deleting SMS messages. Sending SMS messages. Monitoring the signal strength. Monitoring the charging status and charge level of the battery. Reading, writing and searching phone book entries. The number of SMS messages that can be processed by a GSM modem per minute is very low -- only about six to ten SMS messages per minute. SERIAL COMMUNICATION Serial communication is basically the transmission or reception of data one bit at a time. Today's computers generally address data in bytes or some multiple thereof. A byte contains 8 bits. A bit is basically either a logical 1 or zero. Every character on this page is actually expressed internally as one byte. The serial port is used to convert each byte to a stream of ones and zeroes as well as to convert a streams of ones and zeroes to bytes. The serial port contains a electronic chip called a Universal Asynchronous Receiver/Transmitter (UART) that actually does the conversion.

14

The serial port has many pins. We will discuss the transmit and receive pin first. Electrically speaking, whenever the serial port sends a logical one (1) a negative voltage is effected on the transmit pin. Whenever the serial port sends a logical zero (0) a positive voltage is effected. When no data is being sent, the serial port's transmit pin's voltage is negative (1) and is said to be in a MARK state. Note that the serial port can also be forced to keep the transmit pin at a positive voltage (0) and is said to be the SPACE or BREAK state. (The terms MARK and SPACE are also used to simply denote a negative voltage (1) or a positive voltage(0) at the transmit pin respectively). When transmitting a byte, the UART (serial port) first sends a START BIT which is a positive voltage (0), followed by the data (general 8 bits, but could be 5, 6, 7, or 8 bits) followed by one or two STOP BITs which is a negative(1) voltage. The sequence is repeated for each byte sent. Figure 1 shows a diagram of a what a byte transmission would look like.

Figure 1 At this point you may want to know what is the duration of a bit. In other words, how long does the signal stay in a particular state to define a bit. The answer is simple. It is dependent on the baud rate. The baud rate is the number of times the signal can switch states in one second. Therefore, if the line is operating at 9600 baud, the line can switch states 9,600 times per second. This means each bit has the duration of 1/9600 of a second or about 100 sec.

15

MAX -232 MAX -232 is primary used for people building electronics with an RS-232 interface. Serial RS-232 communication works with voltages (15V ... -3V for high) and +3V ... +15V for low) which are not compatible with normal computer logic voltages. To receive serial data from an RS232 interface the voltage has to be reduced, and the low and high voltage level inverted. In the other direction (sending data from some logic over RS-232) the low logic voltage has to be "bumped up", and a negative voltage has to be generated, too.

Fig 5.11 Pin Diagram Of Max 232

16

RS232 COMMUNICATION

Fig 5.12 Circuit Diagram Of Serial Communication Introduction In telecommunications, RS-232 is a standard for serial binary data interconnection between a DTE (Data terminal equipment) and a DCE (Data Circuit-terminating Equipment). It is commonly used in computer serial ports. Scope of the Standard: The Electronic Industries Alliance (EIA) standard RS-232-C [3] as of 1969 defines: Electrical signal characteristics such as voltage levels, signaling rate, timing and slew-rate of signals, voltage withstand level, short-circuit behavior, maximum stray capacitance and cable length Interface mechanical characteristics, pluggable connectors and pin identification
17

Functions of each circuit in the interface connector Standard subsets of interface circuits for selected telecom applications The standard does not define such elements as character encoding (for example, ASCII, Baudot or EBCDIC), or the framing of characters in the data stream (bits per character, start/stop bits, parity). The standard does not define protocols for error detection or algorithms for data compression. The standard does not define bit rates for transmission, although the standard says it is intended for bit rates lower than 20,000 bits per second. Many modern devices can exceed this speed (38,400 and 57,600 bit/s being common, and 115,200 and 230,400 bit/s making occasional appearances) while still using RS-232 compatible signal levels. Details of character format and transmission bit rate are controlled by the serial port hardware, often a single integrated circuit called a UART that converts data from parallel to serial form. A typical serial port includes specialized driver and receiver integrated circuits to convert between internal logic levels and RS-232 compatible signal levels. Circuit Working Description In this circuit the MAX 232 IC used as level logic converter. The MAX232 is a dual driver/receiver that includes a capacitive voltage generator to supply EIA 232 voltage levels from a single 5v supply. Each receiver converts EIA-232 to 5v TTL/CMOS levels. Each driver converts TLL/CMOS input levels into EIA-232 levels.

18

In this circuit the microcontroller transmitter pin is connected in the MAX232 T2IN pin which converts input 5v TTL/CMOS level to RS232 level. Then T2OUT pin is connected to reviver pin of 9 pin D type serial connector which is directly connected to PC. In PC the transmitting data is given to R2IN of MAX232 through transmitting pin of 9 pin D type connector which converts the RS232 level to 5v TTL/CMOS level. The R2OUT pin is connected to receiver pin of the microcontroller. Likewise the data is transmitted and received between the microcontroller and PC or other device vice versa.

19

2.3 RESCUE TEAM SECTION

RF RECEIVER It also operates at 433.92MHz, and has a sensitivity of 3uV. It operates from 4.5 to 5.5 volts-DC. It has both linear and digital outputs Receiver Supply Current: During Operation (High or Low): 5.2 mA Low Power mode (PDN): 28 A DECODER A decoder is a device which does the reverse of an encoder, undoing the encoding so that the original information can be retrieved. The same method used to encode is usually just reversed in order to decode. 2^12 decoders are a series of CMOS LSIs for remote control system applications.

20

The decoders receive serial addresses and data from a programmed 2^12 series of encoders that are transmitted by a carrier using an RF transmission medium. They compare the serial input data three times continuously with their local addresses. If no error or unmatched codes are found, the input data codes are decoded and then transferred to the output pins. The VT pin also goes high to indicate a valid transmission. The 2^12 series of decoders are capable of decoding information's that consist of N bits of address and 12-N bits of data. MICROCONTROLLER ATMEL (AT89S51): The AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K bytes of In-System Programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industrystandard 80C51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with In-System Programmable Flash on a monolithic chip, the Atmel AT89S51 is a powerful microcontroller which provides a highly-flexible and costeffective solution to many embedded control applications. The AT89S51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, two 16-bit timer/counters, a five-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S51 is designed with static logic for
21

operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM contents but freezes the oscillator, disabling all other chip functions until the next external interrupt or hardware reset. TRANSFORMER Potential transformers are the most common devices used. These devices are conventional transformers with two or three windings (one primary with one or two secondary). They have an iron core and magnetically couple the primary and secondary. The high side winding is constructed with more copper turns than the secondary(ies), and any voltage impressed on the primary winding is reflected on the secondary windings in direct proportion to the turns ratio or PT ratio. A current transformer (CT) is a type of instrument transformer designed to provide a current in its secondary winding proportional to the alternating current flowing in its primary. They are commonly used in metering and protective relaying in the electrical power industry where they facilitate the safe measurement of large currents, often in the presence of high voltages. The current transformer safely isolates measurement and control circuitry from the high voltages typically present on the circuit being measured.

22

CHAPTER-3 CIRCUIT DIAGRAMS 3.1 PERSON SECTION


TRANSMITTER
DATA

433.92MHz
GND VCC VCC TE 750K ANT Antenna

1 2 3 4 5 6 7 8 9

U4 A0 A1 A2 A3 A4 A5 A6 A7 Vss HT-12E Vdd Dout Osc1 Osc2 /TE D11 D10 D9 D8 18 17 16 15 14 13 12 11 10 SW1 SW1 SW1

SW1

3.2 VEHICLE SECTION

23

GSM MODEM VEHICLE SECTION


V C C C 0 . 1 u F 40 20 1 U 1 V / / / / / / / / 3 A3 A3 A3 A3 A3 A3 A3 AS R 3 1 C 1 1C 0 k 1 3 C C V C C 16 U 1 1 1 1 0 T 1 I N T 2 I N 1 2 R 9 R 1 3 4 5 C C C C 1 O 2 O + M 1 2 + G N D 2 V 6 C 5 F 1 0 u A X 2 3 2 1 2 1 4 U7 T U T C 1 0 u F 5 9 4 8 3 7 2 6 1 P 1

T 1 O T 2 O R R

VC C

Sensor
O u t
1 1 1 1 1 1 1 1

G N D

Hurtle detection

1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7

P P P P P P P P P P P P P P P P

1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3

. . . . . . . . . . . . . . . .

0 P 1 P 2 / R XP D 3 / T X PD 4 P 5 P 6 P 7 P 0 1 2 3 4 5 6 7 / / / / / / / / R T I I T T W R

V SW 0

C C 2

C 1 1 . 0 X 1 C 4 3 3 P F 5 9 2 M

8K2

R ST

8 9

5 0

1 2 R 9 R C 1 3 1 3 4 5 C C C C

VC C

C 3 3 3 P

T 1 O T 2 O R R

1 4 U7 T U T

1 O 2 O + M 1 2 +

U U

T T

8 2 I N 3 1 1 I N

0 u F C 4

X 2 3 2 6 C 5 F 1 0 u

V G N D

POWER SUPPLY
1 D 1 2 9 V 1 2 A C 4 D B 1 + 2 1 0 6 C 3 5 u F / 2 5 V I N 7 8 0 5O U T G N D 1 0 0 u F /1 6 V C D 6 3 V C R 3 3 C 3 0 E

0 u F

2 -

4 7 0

- L X H

1 0 1

3.3 RESCUE TEAM SECTION

24

15

S E R IA L P O R T

X E D XA D L N T N T O 1 P RP DP P 9 R S T P P 1 8 X T A L 2 P P H1 9z X T A L 1

2 2 2 2 2 2

16

2 A 2 A 2 A 2 A 2 A 2 A 2 2 . 1 /2 A 2 . 0 / A . . . . . . 7 6 5 4 3 2 / / / / / /

8 71 61 51 41 31 21

1 9 8

5 4 3 2 1 0

GPS RECEIVER
V C C U 1 1 1 1 0 T 1 I N T 2 I N 1 2 C 1 0 u F 5 9 4 8 3 7 2 6 1 P 1

10uF

15

9 2 8D 0 3 7D 1 4 6D 2 5 5D 3 6 4D 4 7 3D 5 8 2D 6 9 DI P7 9 3 1 A0 / V 3 P 0 P E / P 2 9O G 0 R O S E N P 1 0 . 0 . 0 1. 01 . 0 . 0 . 0 . 0 . 0 1 2 3 4 5 6 7

U U

T T

8 2 I N 3 1 1 I N

0 u F C 4

0 u F

V+

S E R IA L P O R T

VC C

V+

HOSPITAL SECTION

SERVER
V V C C 1 2 3 4 5 6 7 8 R X D T X D 1 1 1 1 1 1 1 1 0 1 2 3 4 5 6 7 P P P P P P P P P P P P P P P P 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 . . . . . . . . . . . . . . . . C 0 40 1 . 1 u F U P P P P P P P P 0 0 0 0 0 0 0 0 . . . . . . . . 0 1 2 3 4 5 6 7 1 / / / / / / / / 3 A3 A3 A3 A3 A3 A3 A3 AS 9 D 8 D 7 D 6 D 5 D 4 D 3 D 2 DI 1 0P 9O 8 71 61 51 41 31 21 2 03 14 25 36 47 58 69 P7 G 1 5 4 3 2 1 0 V R 3 1 C C 1 1 1 9 1 3 4 5 C C 16 U 1 1 0 T 1 I N T 2 I N 2 R R C C C C 1 O 2 O + M 1 2 + G N D 2 V 6 C 1 5 0 u F A X 2 3 2 1 2 1 4 U7 T U T 8 I N 3 1 I N C 1 0 u F 5 9 4 8 3 7 2 6 1 P 1

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

T 1 T 2 R R

O O 2 1

U U

T T

C 1 9 1C 0 k C 0 0

3 u F 4 u F

V SW 0

C C 2

C 1 1 . 0 5 X 1 C 4 3 3 P F 9 2 M

R ST

10uF

8K2

X D A E XA D L E N T OP N T 1 O 1 P 2 RP 2 D P 2 P 2 9 R S T P 2 P 2 1 8 X T A L 2 P 2 P 2 H1 9z X T A L 1 F A T 8 9 S

/ / / / / / / /

R T I I T T W R

3 / V 3P / P R 2 S E N . . . . . . 7 6 5 4 3 2 / / / / / / 2 A 2 A 2 A 2 A 2 A 2 A 2

. 1 . 0

/2 A 1 9 / A 8

C 3 3 3 P

5 1 U 1 2 3 4 5 6 7 8 9 A A A A A A A A V 0 1 2 3 4 5 6 7 s H 1 1 d d1 T 1 c 11 c 12 D I N 1 D 1 11 D 1 01 D 9 1 D 8 V V s s 2 D

V 8 7 6 5 4 3 2 1 0

15

R F
GND DATA DATA VCC

4 3 3 . 9 2 M H z
VCC GND GND ANT C r

O O

T R 3 3

3 D A T A I N V C

T - 1

CHAPTER-4 POWER SUPPLY The ac voltage, typically 220V rms, is connected to a transformer, which steps that ac voltage down to the level of the desired dc output. A diode rectifier then provides a full-wave rectified voltage that is initially filtered

25

S E R IA L P O R T

20

VC C

G N D

VC C

V+

by a simple capacitor filter to produce a dc voltage. This resulting dc voltage usually has some ripple or ac voltage variation. A regulator circuit removes the ripples and also remains the same dc value even if the input dc voltage varies, or the load connected to the output dc voltage changes. This voltage regulation is usually obtained using one of the popular voltage regulator IC units.

TRANSFORMER

RECTIFIER

FILTER

IC REGULATOR

LOAD

Block Diagram of Power supply Working principle Transformer The potential transformer will step down the power supply voltage (0-230V) to (0-6V) level. Then the secondary of the potential transformer will be connected to the precision rectifier, which is constructed with the help of opamp. The advantages of using precision rectifier are it will give peak voltage output as DC, rest of the circuits will give only RMS output. Bridge rectifier When four diodes are connected as shown in figure, the circuit is called as bridge rectifier. The input to the circuit is applied to the diagonally opposite corners of the network, and the output is taken from the remaining two corners. Let us assume that the transformer is working properly and there is a positive potential, at point A and a negative potential at point B. the positive potential at point A will forward bias D3 and reverse bias D4. The negative potential at point B will forward bias D1 and reverse D2. At this time D3 and D1 are forward biased and will allow current flow to pass through them; D4 and D2 are reverse biased and will block current flow. The path for current flow is from point B through D1, up through RL, through D3, through the secondary of the transformer back
26

to point B. Waveforms (1) and (2) can be observed across D1 and D3.Onehalf cycle later the polarity across the secondary of the transformer reverse, forward biasing D2 and D4 and reverse biasing D1 and D3. Current flow will now be from point A through D4, up through RL, through D2, through the secondary of T1, and back to point A. This path is indicated by the broken arrows. Waveforms (3) and (4) can be observed across D2 and D4. The current flow through RL is always in the same direction. In flowing through RL this current develops a voltage corresponding to that shown waveform (5). Since current flows through the load (RL) during both half cycles of the applied voltage, this bridge rectifier is a full-wave rectifier. Advantage of a bridge rectifier over a conventional full-wave rectifier is that with a given transformer the bridge rectifier produces a voltage output that is nearly twice that of the conventional full-wave circuit. Since only one diode can conduct at any instant, the maximum voltage that can be rectified at any instant is 500 volts. The maximum voltage that appears across the load resistor is nearly-but never exceeds-500 v0lts, as result of the small voltage drop across the diode. In the bridge rectifier shown in view B, the maximum voltage that can be rectified is the full secondary voltage, which is 1000 volts. Therefore, the peak output voltage across the load resistor is nearly 1000 volts. With both circuits using the same transformer, the bridge rectifier circuit produces a higher output voltage than the conventional fullwave rectifier circuit. IC voltage regulators Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry for reference source, comparator amplifier, control device, and overload protection all in a single IC.. The regulators can be selected for operation with load currents from hundreds of milli

27

amperes to tens of amperes, corresponding to power ratings from milli

watts to tens of watts. A fixed three-terminal voltage regulator has an unregulated dc input voltage, Vi, applied to one input terminal, a regulated dc output voltage, Vo, from a second terminal. The series 78 regulators provide fixed positive regulated voltages from 5 to 24 volts. Similarly, the series 79 regulators provide fixed negative regulated voltages from 5 to 24 volts. For ICs, microcontroller, LCD --------- 5 volts For alarm circuit, op-amp, relay circuits ---------- 12 volts

CHAPTER-5 MICROCONTROLLER The generic 8031 architecture sports a Harvard architecture, which contains two separate buses for both program and data. So, it has two
28

distinctive memory spaces of 64K X 8 size for both program and data. It is based on an 8 bit central processing unit with an 8 bit Accumulator and another 8 bit B register as main processing blocks. Other portions of the architecture include few 8 bit and 16 bit registers and 8 bit memory locations. Each 8031 device has some amount of data RAM built in the device for internal processing. This area is used for stack operations and temporary storage of data. This base architecture is supported with on chip peripheral functions like I/O ports, timers/counters, versatile serial communication port. So it is clear that this 8031 architecture was designed to cater many real time embedded needs. The following list gives the features of the 8051 architecture: Optimized 8 bit CPU for control applications. Extensive Boolean processing capabilities. 64K Program Memory address space. 64K Data Memory address space. 128 bytes of on chip Data Memory. 32 Bi-directional and individually addressable I/O lines. Two 16 bit timer/counters. Full Duplex UART, On-chip clock oscillator. 6-source / 5-vector interrupt structure with priority levels. Now you may be wondering about the non mentioning of memory space meant for the program storage, the most important part of any embedded controller. Originally this 8031 architecture was introduced with on chip, one time programmable version of Program Memory of size 4K X 8. Intel delivered all these microcontrollers (8051) with users program fused inside the device. The memory portion was mapped at the lower end of the Program Memory area. But, after getting devices, customers couldnt

29

change any thing in their program code, which was already made available inside during device fabrication.

Figure5.1 - Block Diagram of the 8051 Core So, very soon Intel introduced the 8051 devices (8751) with reprogrammable type of Program Memory using built-in EPROM of size 4K X 8. Like a regular EPROM, this memory can be re-programmed many times. Later on Intel started manufacturing these 8051 devices without any on chip Program Memory. Now I go ahead giving more information on the important functional blocks of the 8051.

DIFFERENCES BETWEEN MICROCONTROLLER AND MICROPROCESSOR: Microprocessors have many instructions for moving data from external memory to internal memory. But microcontrollers have a few such instructions.
30

Microprocessors have less bit handling instructions, but microcontrollers have many such instructions. Microprocessors are concerned with rapid movement of code and data from external memory. But Microcontroller is concerned with that of bits within the chip. Of course Microprocessor needs additional chips for memory, parallel port, timer etc and microcontroller needs no such external ports.

8051

Figure 5.2 - 8051 Microcomputer Pinout Diagram

31

Figure 5.3 - 8051 Microcomputer logic symbol OSCILLATOR CHARACTERISTICS XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an onchip oscillator, as shown in Figure 1. 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 2. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divideby two flip-flop, but minimum and maximum voltage high and low time specifications must be observed. 8051 CLOCK 8051 has an on-chip oscillator It needs an external crystal

32

Crystal decides the operating frequency of the 8051

IDLE MODE In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hardware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory. POWER DOWN MODE In the power down mode the oscillator is stopped, and the instruction that invokes power down is the last instruction executed. The on-chip RAM and Special Function Registers retain their values until the power down mode is terminated. The only exit from power down is a hardware reset. Reset redefines the SFRs but does not change the on-chip RAM. The reset should not be activated before VCC is restored to its

33

normal operating level and must be held active long enough to allow the oscillator to restart and stabilize. 8051 RESET RESET is an active High input When RESET is set to High, 8051 goes back to the power on state Power-On Reset Push PB and active High on RST Release PB, Capacitor discharges and RST goes low RST must stay high for a min of 2 machine cycles

CENTRAL PROCESSING UNIT The CPU is the brain of the microcontrollers reading users programs and executing the expected task as per instructions stored there in. Its primary elements are an 8 bit Arithmetic Logic Unit (ALU), Accumulator (Acc), few more 8 bit registers, B register, Stack Pointer (SP), Program Status Word (PSW) and 16 bit registers, Program Counter (PC) and Data Pointer Register (DPTR).

34

THE ACCUMULATOR If worked with any other assembly language you will be familiar with the concept of an accumulator register. The Accumulator, as its name suggests, is used as a general register to accumulate the results of a large number of instructions. It can hold an 8-bit (1-byte) value and is the most versatile register the 8052 has due to the sheer number of instructions that make use of the accumulator. More than half of the 8052s 255 instructions manipulate or use the Accumulator in some way. For example, if you want to add the number 10 and 20, the resulting 30 will be stored in the Accumulator. Once you have a value in the Accumulator you may continue processing the value or you may store it in another register or in memory. THE "R" REGISTERS The "R" registers are sets of eight registers that are named R0, R1, through R7. These registers are used as auxiliary registers in many operations. To continue with the above example, perhaps you are adding 10 and 20. The original number 10 may be stored in the Accumulator whereas the value 20 may be stored in, say, register R4. To process the addition you would execute the command: As mentioned earlier, there are four sets of R registers, register bank 0, 1, 2, and 3. When the 8052 is first powered up, register bank 0 (addresses 00h through 07h) is used by default. In this case, for example, R4 is the same as Internal RAM address 04h. However, your program may instruct the 8052 to use one of the alternate register banks; i.e., register banks 1, 2, or 3. In this case, R4 will no longer be the same as Internal RAM address 04h. For example, if your program instructs the 8052 to use register bank 1, register R4 will now be synonymous with Internal RAM address 0Ch. If you select register bank 2, R4 is

35

synonymous with 14h, and if you select register bank 3 it is synonymous with address 1Ch. The concept of register banks adds a great level of flexibility to the 8052, especially when dealing with interrupts (we'll talk about interrupts later). However, always remember that the register banks really reside in the first 32 bytes of Internal RAM. THE "B" REGISTER The "B" register is very similar to the Accumulator in the sense that it may hold an 8-bit (1-byte) value. The "B" register is only used implicitly by two 8052 instructions: MUL AB and DIV AB. Thus, if you want to quickly and easily multiply or divide A by another number, you may store the other number in "B" and make use of these two instructions. Aside from the MUL and DIV instructions, the "B" register is often used as yet another temporary storage register much like a ninth "R" register. THE PROGRAM COUNTER (PC) The Program Counter (PC) is a 2-byte address that tells the 8052 where the next instruction to execute is found in memory. When the 8052 is initialized PC always starts at 0000h and is incremented each time an instruction is executed. It is important to note that PC isnt always incremented by one. Since some instructions are 2 or 3 bytes in length the PC will be incremented by 2 or 3 in these cases. The Program Counter is special in that there is no way to directly modify its value. That is to say, you cant do something like PC=2430h. On the other hand, if you execute LJMP 2430h youve effectively accomplished the same thing.

36

It is also interesting to note that while you may change the value of PC (by executing a jump instruction, etc.) there is no way to read the value of PC. That is to say, there is no way to ask the 8052 "What address are you about to execute?" As it turns out, this is not completely true: There is one trick that may be used to determine the current value of PC. THE DATA POINTER (DPTR) The Data Pointer (DPTR) is the 8052s only user-accessible 16-bit (2-byte) register. The Accumulator, "R" registers, and "B" register are all 1-byte values. The PC just described is a 16-bit value but isnt directly user-accessible as a working register. DPTR, as the name suggests, is used to point to data. It is used by a number of commands that allow the 8052 to access external memory. When the 8052 accesses external memory it accesses the memory at the address indicated by DPTR. While DPTR is most often used to point to data in external memory or code memory, many developers take advantage of the fact that its the only true 16-bit register available. It is often used to store 2-byte values that have nothing to do with memory locations. THE STACK POINTER (SP) The Stack Pointer, like all registers except DPTR and PC, may hold an 8-bit (1-byte) value. The Stack Pointer is used to indicate where the next value to be removed from the stack should be taken from. When you push a value onto the stack, the 8052 first increments the value of SP and then stores the value at the resulting memory location. When you pop a value off the stack, the 8052 returns the value from the memory location indicated by SP, and then decrements the value of SP. This order of operation is important. When the 8052 is initialized SP will be initialized to 07h. If you immediately push a value onto the stack, the value will be stored in Internal RAM address 08h. This makes sense taking into account what was mentioned two paragraphs above: First
37

the 8051 will increment the value of SP (from 07h to 08h) and then will store the pushed value at that memory address (08h). SP is modified directly by the 8052 by six instructions: PUSH, POP, ACALL, LCALL, RET, and RETI. It is also used intrinsically whenever an interrupt is triggered (more on interrupts later. Dont worry about them for now!). INPUT / OUTPUT PORTS The 8031s I/O port structure is extremely versatile and flexible. The device has 32 I/O pins configured as four eight bit parallel ports (P0, P1, P2 and P3). Each pin can be used as an input or as an output under the software control. These I/O pins can be accessed directly by memory instructions during program execution to get required flexibility. These port lines can be operated in different modes and all the pins can be made to do many different tasks apart from their regular I/O function executions. Instructions, which access external memory, use port P0 as a multiplexed address/data bus. At the beginning of an external memory cycle, low order 8 bits of the address bus are output on P0. The same pins transfer data byte at the later stage of the instruction execution. Also, any instruction that accesses external Program Memory will output the higher order byte on P2 during read cycle. Remaining ports, P1 and P3 are available for standard I/O functions. But all the 8 lines of P3 support special functions: Two external interrupt lines, two counter inputs, serial ports two data lines and two timing control strobe lines are designed to use P3 port lines. When you dont use these special functions, you can use corresponding port lines as a standard I/O. Even within a single port, I/O operations may be combined in many ways. Different pins can be configured as input or outputs independent of each other or the same pin can be used as an input or as

38

output at different times. You can comfortably combine I/O operations and special operations for Port 3 lines. TIMERS / COUNTERS 8031 has two 16 bit Timers/Counters capable of working in different modes. Each consists of a High byte and a Low byte which can be accessed under software. There is a mode control register and a control register to configure these timers/counters in number of ways. These timers can be used to measure time intervals, determine pulse widths or initiate events with one microsecond resolution upto a maximum of 65 millisecond (corresponding to 65, 536 counts). Use software to get longer delays. Working as counter, they can accumulate occurrences of external events (from DC to 500KHz) with 16 bit precision.

39

INTERRUPTS The 8031 has five interrupt sources: one from the serial port when a transmission or reception operation is executed; two from the timers when overflow occurs and two come from the two input pins INT0, INT1. Each interrupt may be independently enabled or disabled to allow polling on same sources and each may be classified as high or low priority. A high priority source can override a low priority service routine. These options are selected by interrupt enable and priority control registers, IE and IP. When an interrupt is activated, then the program flow completes the execution of the current instruction and jumps to a particular program location where it finds the interrupt service routine. After finishing the interrupt service routine, the program flows return to back to the original place. The Program Memory address, 0003H is allotted to the first interrupt and next seven bytes can be used to do any task associated with that interrupt. Interrupt Source Service routine starting address External 0 0003H Timer/Counter 0 000BH External 1 0013H Timer/counter 1 001BH Serial port 0023H SERIAL PORT Each 8031 microcomputer contains a high speed full duplex (means you can simultaneously use the same port for both transmitting and receiving purposes) serial port which is software configurable in 4 basic

40

modes: 8 bit UART; 9 bit UART; Interprocessor Communications link or as shift register I/O expander. For the standard serial communication facility, 8031 can be programmed for UART operations and can be connected with regular personal computers, teletype writers, modem at data rates between 122 bauds and 31 kilo bauds. Getting this facility is made very simple using simple routines with option to select even or odd parity. You can also establish a kind of Interprocessor communication facility among many microcomputers in a distributed environment with automatic recognition of address/data. Apart from all above, you can also get super fast I/O lines using low cost simple TTL or CMOS shift registers. 8051 PIN FUNCTIONS I/O PORTS (P0, P1, P2, P3) Of the 40 pins of the typical 8052, 32 of them are dedicated to I/O lines that have a one-to-one relation with SFRs P0, P1, P2, and P3. The developer may raise and lower these lines by writing 1s or 0s to the corresponding bits in the SFRs. Likewise, the current state of these lines may be read by reading the corresponding bits of the SFRs. All of the ports have internal pull-up resistors except for port 0. PORT 0 Port 0 is dual-function in that it in some designs port 0s I/O lines are available to the developer to access external devices while in other designs it is used to access external memory. If the circuit requires external RAM or ROM, the microcontroller will automatically use port 0 to clock in/out the 8-bit data word as well as the low 8 bits of the address in response to a MOVX instruction and port 0 I/O lines may be used for other
41

functions as long as external RAM isnt being accessed at the same time. If the circuit requires external code memory, the microcontroller will automatically use the port 0 I/O lines to access each instruction that is to be executed. In this case, port 0 cannot be utilized for other purposes since the state of the I/O lines are constantly being modified to access external code memory. Note that there are no pull-up resistors on port 0, so it may be necessary to include your own pull-up resistors depending on the characteristics of the parts you will be driving via port 0. PORT 1 Port 1 consists of 8 I/O lines that you may use exclusively to interface to external parts. Unlike port 0, typical derivatives do not use port 1 for any functions themselves. Port 1 is commonly used to interface to external hardware such as LCDs, keypads, and other devices. With 8052 derivatives, two bits of port 1 are optionally used as described for extended timer 2 functions. These two lines are not assigned these special functions on 8051s since 8051s dont have a timer 2. Further, these lines can still be used for your own purposes if you dont need these features of timer 2. P1.0 (T2): If T2CON.1 is set (C/T2), then timer 2 will be incremented whenever there is a 1-0 transition on this line. With C/T2 set, P1.0 is the clock source for timer 2. P1.1 (T2EX): If timer 2 is in autoreload mode and T2CON.3 (EXEN2) is set, a 1-0 transition on this line will cause timer 2 to be reloaded with the auto-reload value. This will also cause the T2CON.6 (EXF2) external flag to be set, which may cause an interrupt if so enabled.

42

PORT 2 Like port 0, port 2 is dual-function. In some circuit designs it is available for accessing devices while in others it is used to address external RAM or external code memory. When the MOVX @DPTR instruction is used, port 2 is used to output the high byte of the memory address that is to be accessed. In these cases, port 2 may be used to access other devices as long as the devices are not being accessed at the same time a MOVX instruction is using port 2 to address external RAM. If the circuit requires external code memory, the microcontroller will automatically use the port 2 I/O lines to access each instruction that is to be executed. In this case, port 2 cannot be utilized for other purposes since the state of the I/O lines are constantly being modified to access external code memory. PORT 3 Port 3 consists entirely of dual-function I/O lines. While the developer may access all these lines from their software by reading/writing to the P3 SFR, each pin has a pre-defined function that the microcontroller handles automatically when configured to do so and/or when necessary. P3.0 (RXD): The UART/serial port uses P3.0 as the receive line. In circuit designs that will be using the microcontrollers internal serial port, this is the line into which serial data will be clocked. Note that when interfacing an 8052 to an RS-232 port that you may not connect this line directly to the RS-232 pin; rather, you must pass it through a part such as the MAX232 to obtain the correct voltage levels. This pin is available for any use the developer may assign it if the circuit has no need to receive data via the integrated serial port. P3.1 (TXD): The UART/serial port uses P3.1 as the transmit line. In circuit designs that will be using the microcontrollers internal serial port, this is the line that the microcontroller will clock out all data which is written to the SBUF SFR. Note that when interfacing an 8052 to
43

an RS-232 port that you may not connect this line directly to the RS-232 pin; rather, you must pass it through a part such as the MAX232 to obtain the correct voltage levels. This pin is available for any use the developer may assign it if the circuit has no need to transmit data via the integrated serial port. P3.2 (-INT0): When so configured, this line is used to trigger an External 0 Interrupt. This may either be low-level triggered or may be triggered on a 1-0 transition. Please see the chapter on interrupts for details. This pin is available for any use the developer may assign it if the circuit does not need to trigger an external 0 interrupt. P3.3 (-INT1): When so configured, this line is used to trigger an External 1 Interrupt. This may either be low-level triggered or may be triggered on a 1-0 transition. Please see the chapter on interrupts for details. This pin is available for any use the developer may assign it if the circuit does not need to trigger an external 1 interrupt. P3.4 (T0): When so configured, this line is used as the clock source for timer 0. Timer 0 will be incremented either every instruction cycle that T0 is high or every time there is a 1-0 transition on this line, depending on how the timer is configured. Please see the chapter on timers for details. This pin is available for any use the developer may assign it if the circuit does not to control timer 0 externally. P3.5 (T1): When so configured, this line is used as the clock source for timer 1. Timer 1 will be incremented either every instruction cycle that T1 is high or every time there is a 1-0 transition on this line, depending on how the timer is configured. Please see the chapter on timers for details. This pin is available for any use the developer may assign it if the circuit does not to control timer 1 externally. P3.6 (-WR): This is external memory write strobe line. This line will be asserted low by the microcontroller whenever a MOVX instruction
44

writes to external RAM. This line should be connected to the RAMs write (-W) line. This pin is available for any use the developer may assign it if the circuit does not write to external RAM using MOVX. P3.7 (-RD): This is external memory write strobe line. This line will be asserted low by the microcontroller whenever a MOVX instruction writes to external RAM. This line should be connected to the RAMs write (-W) line. This pin is available for any use the developer may assign it if the circuit does not read from external RAM using MOVX. OSCILLATOR INPUTS (XTAL1, XTAL2) The 8052 is typically driven by a crystal connected to pins 18 (XTAL2) and 19 (XTAL1). Common crystal frequencies are 11.0592Mhz as well as 12Mhz, although many newer derivatives are capable of accepting frequencies as high as 40Mhz. While a crystal is the normal clock source, this isnt necessarily the case. A TTL clock source may also be attached to XTAL1 and XTAL2 to provide the microcontrollers clock. RESET LINE (RST) Pin 9 is the master reset line for the microcontroller. When this pin is brought high for two instruction cycles, the microcontroller is effectively reset. SFRs, including the I/O ports, are restored to their default conditions and the program counter will be reset to 0000h. Keep in mind that Internal RAM is not affected by a reset. The microcontroller will begin executing code at 0000h when pin 9 returns to a low state. The reset line is often connected to a reset button/switch that the user may press to reset the circuit. It is also common to connect the reset line to a watchdog IC or a supervisor IC (such as MAX707). The latter is highly recommended for commercial and professional designs since
45

traditional resistor-capacitor networks attached to the reset line, while often sufficient for students or hobbyists, are not terribly reliable. ADDRESS LATCH ENABLE (ALE) The ALE at pin 30 is an output-only pin that is controlled entirely by the microcontroller and allows the microcontroller to multiplex the lowbyte of a memory address and the 8-bit data itself on port 0. This is because, while the high-byte of the memory address is sent on port 2, port 0 is used both to send the low byte of the memory address and the data itself. This is accomplished by placing the low-byte of the address on port 0, exerting ALE high to latch the low-byte of the address into a latch IC (such as the 74HC573), and then placing the 8 data-bits on port 0. In this way the 8052 is able to output a 16-bit address and an 8-bit data word with 16 I/O lines instead of 24. The ALE line is used in this fashion both for accessing external RAM with MOVX @DPTR as well as for accessing instructions in external code memory. When your program is executed from external code memory, ALE will pulse at a rate of 1/6th that of the oscillator frequency. Thus if the oscillator is operating at 11.0592Mhz, ALE will pulse at a rate of 1,843,200 times per second. The only exception is when the MOVX instruction is executed one ALE pulse is missed in lieu of a pulse on WR or RD. PROGRAM STORE ENABLE (-PSEN) The Program Store Enable (PSEN) line at pin 29 is exerted low automatically by the microcontroller whenever it accesses external code memory. This line should be attached to the Output Enable (-OE) pin of the EPROM that contains your code memory.

46

PSEN will not be exerted by the microcontroller and will remain in a high state if your program is being executed from internal code memory. EXTERNAL ACCESS (-EA) The External Access (-EA) line at pin 31 is used to determine whether the 8052 will execute your program from external code memory or from internal code memory. If EA is tied high (connected to +5V) then the microcontroller will execute the program it finds in internal/on-chip code memory. If EA is tied low (to ground) then it will attempt to execute the program it finds in the attached external code memory EPROM. Of course, your EPROM must be properly connected for the microcontroller to be able to access your program in external code memory. MEMORY ORGANIZATION The 8051 architecture provides both on chip memory as well as off chip memory expansion capabilities. It supports several distinctive physical address spaces, functionally separated at the hardware level by different addressing mechanisms, read and write controls signals or both: On chip Program Memory On chip Data Memory Off chip Program Memory Off chip Data Memory On chip Special Function Registers The Program Memory area (EPROM incase of external memory or Flash/EPROM incase of internal one) is extremely large and never lose information when the power is removed. Initialization values, Calibration data, Keyboard lookup tables etc along with the program itself. The Program Memory has a 16 bit address and any particular memory

47

location is addressed using the 16 bit Program Counter and instructions which generate a 16 bit address. On chip Data memory is smaller and therefore quicker than Program Memory and it goes into a random state when power is removed. On chip RAM is used for variables which are calculated when the program is executed. In contrast to the Program Memory, On chip Data Memory accesses need a single 8 bit value (may be a constant or another variable) to specify a unique location. Since 8 bits are more than sufficient to address 128 RAM locations, the on chip RAM address generating register is single byte wide. Different addressing mechanisms are used to access these different memory spaces and this greatly contributes to microcomputers operating efficiency. The 64K byte Program Memory space consists of an internal and an external memory portion. If the EA pin is held high, the 8051 executes out of internal Program Memory unless the address exceeds 0FFFH and locations 1000H through FFFFH are then fetched from external Program Memory. If the EA pin is held low, the 8031 fetches all instructions from the external Program Memory.

Figure5. 4 - Program Memory

48

The Data Memory address space consists of an internal and an external memory space. External Data Memory is accessed when a MOVX instruction is executed. Apart from on chip Data Memory of size 128/256 bytes, total size of Data Memory can be expanded upto 64K using external RAM devices. Total internal Data Memory is divided into three blocks: Lower 128 bytes. Higher 128 bytes Special Function Register space. Higher 128 bytes are available only in 8032/8052 devices.

Even though the upper RAM area and SFR area share same address locations, they are accessed through different addressing modes. Direct addresses higher than 7FH access SFR memory space and indirect addressing above 7FH access higher 128 bytes (in 8032/8052).

49

Figure 5.5 - Internal Data Memory The next figure indicates the layout of lower 128 bytes. The lowest 32 bytes (from address 00H to 1FH) are grouped into 4 banks of 8 registers. Program instructions refer these registers as R0 through R7. Program Status Word indicates which register bank is being used at any point of time.

Figure 5.7 - Lower 128 Bytes of Internal RAM The next 16 bytes above these register banks form a block of bit addressable memory space. The instruction set of 8031 contains a wide range of single bit processing instructions and these instructions can directly access the 128 bits of this area.
50

The SFR space includes port latches, timer and peripheral control registers. All the members of 8031 family have same SFR at the same SFR locations. There are some 16 unique locations which can be accessed as bytes and as bits. COMMON MEMORY SPACE The 8031s Data Memory may not be used for program storage. So it means you cant execute instructions out of this Data Memory. But, there is a way to have a single block of offchip memory acting as both Program and Data Memory. By gating together both memory read controls (RD and PSEN) using an AND gate, a common memory read control signal can be generated. In this arrangement, both memory spaces are tied together and total accessible memory is reduced from 128 Kbytes to 64 Kbytes. The 8031 can read and write into this common memory block and it can be used as Program and Data Memory. You can use this arrangement during program development and debugging phase. Without taking Microcontroller off the socket to program its internal ROM (EPROM/Flash ROM), you can use this common memory for frequent program storage and code modifications.

ATMEL FEATURES
51

4K Bytes of In-System Programmable (ISP) Flash Memory Endurance: 10,000 Write/Erase Cycles 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 128 x 8-bit Internal RAM 32 Programmable I/O Lines Two 16-bit Timer/Counters Six Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Interrupt Recovery from Power-down Mode Watchdog Timer Dual Data Pointer Power-off Flag Fast Programming Time Flexible ISP Programming (Byte and Page Mode)

52

RST Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives High for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled. ALE/PROG
53

Address Latch Enable (ALE) is an 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/6 the 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 ALEdisable bit has no effect if the microcontroller is in external execution mode. PSEN Program Store Enable (PSEN) is the read strobe to external program memory. When the AT89S51 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.

54

CHAPTER-6 RF MODULE Theory of Operation Short for Radio Frequency, RF refers to the frequencies that fall within the electromagnetic spectrum associated with radio wave propagation. When applied to an antenna, RF current creates electromagnetic fields that propagate the applied signal through space. Any RF field has a wavelength that is inversely proportional to the frequency. This means that the frequency of an RF signal is inversely proportional to the wavelength of the field. The Parallax RF modules utilize a frequency of 433.92 MHz, this works out to be a wavelength of approximately 0.69 meters (2.26 feet, or 7.3e-17 lightyears). 433.92 MHz falls into the Ultra High Frequency (UHF) designation, which is defined as the frequencies from 300 MHz ~ 3 GHz. UHF has free-space wavelengths of 1 m ~ 100 mm (3.28 ~ 0.33 feet or1.05e-16 ~ 1.05e-17 light-years). General Description The Parallax 433.92 MHz RF Transmitter allows users to easily send serial data, robot control, or other information wirelessly. When paired with the matched RF Receiver, reliable wireless communication is as effortless as sending serial data. The power-down (PDN) pin may be used to place the module into a low power state (active low), or left floating (it is tied high internally).

55

Features High-speed data transfer rates (1200 ~ 19.2k Baud depending on controller used) SIP header allows for ease of use with breadboards Compatible with all BASIC Stamp modules (including BS1 and Javelin Stamp) and SX chips As easy to use as simple SEROUT/SERIN PBASIC instructions Power-down mode for conservative energy usage (longer battery life) Line-of-sight range of 500 feet (or greater depending on conditions) Application Ideas Remote Controlled Boe-Bot robot Wireless data acquisition Remote sensors and triggers

56

PDN Pulling the power down (PDN) line low will place the transmitter/receiver into a low-current state. The module will not be able to transmit/receive a signal in this state.RSSI (receiver only).Received Signal Strength Indicator. This line will supply an analog voltage that is proportional to the strength of the received signal. CONNECTION DIAGRAM

57

6.1 RF TRASMITTER

The 2^12 encoders are a series of CMOS LSIs for remote control system applications. They are capable of encoding information which consists of N address bits and 12N data bits.

58

Each address/data input can be set to one of the two logic states. The programmed addresses/data are transmitted together with the header bits via an RF transmission medium . Transmission is enabled by applying a low signal to the TE pin 6.2 RF RECEIVER

59

2^12 decoders are a series of CMOS LSIs for remote control system applications.. The decoders receive serial addresses and data from a programmed 2^12 series of encoders that are transmitted by a carrier using an RF transmission medium. They compare the serial input data three times continuously with their local addresses. If no error or unmatched codes are found, the input data codes are decoded and then transferred to the output pins. The VT pin also goes high to indicate a valid transmission. The 2^12 series of decoders are capable of decoding information's that consist of N bits of address and 12-N bits of data

60

CHAPTER-7 GLOBAL POSITIONING SYSTEM EMBEDDED GPS RECEIVERS Trimble SK8/ACE GPS receiver ($60) Garmin GPS35 ($160) DeLorme Earthmate ($85) Have seen some as cheap as $50

61

Interface Single or dual serial port Protocols: NMEA-0183, TSIP, TAIP, Garmin, Rockwell Binary, others Power Typical requirements: 5V @ 200mA BLOCK DIAGRAM

Antenna: The antenna receives extremely weak satellite signals on a frequency of 1572.42MHz.Signal Output is around 163dBW. Some (passive) antennae have a 3dB gain.

62

LNA 1: This low noise amplifier (LNA) amplifies the signal by approx. 15 ... 20dB. HF filter: The GPS signal bandwidth is approx. 2MHZ. The HF filter reduces the affects of signal interference. The HF stage and signal processor actually represent the special circuits in a GPS receiver and are adjusted to each other. HF stage: The amplified GPS signal is mixed with the frequency of the local oscillator. The filtered IF signal is maintained at a constant level in respect of its amplitude and digitalized via Amplitude Gain Control (AGC) IF filter: The intermediate frequency is filtered out using a bandwidth of 2MHz. The image frequencies arising at the mixing stage are reduced to a permissible level. Signal processor: Up to 16 different satellite signals can be correlated and decoded at the same time. Correlation takes place by constant comparison with the C/A code. The HF stage and signal processor are simultaneously switched to synchronize with the signal. The signal processor has its own time base (Real Time Clock, RTC). All the data ascertained is broadcast (particularly signal transit time to the relevant satellites determined by the correlator), and this is referred to as source data. The signal processor can be

63

offset by the controller via the control line to function in various operating modes. Controller: Using the source data, the controller calculates position, time, speed and course etc. It controls the signal processor and relays the calculated values to the display. Important information (such as ephemeris, the most recent position etc.) are decoded and saved in RAM. The program and the calculation algorithms are saved in ROM. Keyboard: Using the keyboard, the user can select, which co-ordinate system he wishes to use and which parameters (e.g. number of visible satellites) should be displayed. Display: The position calculated (longitude, latitude and height) must be made available to the user. This can either be displayed using a 7segment display or shown on a screen using a projected map. The positions determined can be saved, whole routes being recorded. Current supply: The power supply delivers the necessary operational voltage to all levels of electronic componentry.

64

CHAPTER-8 GSM MODEM A GSM modem is a wireless modem that works with a GSM wireless network. A wireless modem behaves like a dial-up modem. The main difference between them is that a dial-up modem sends and receives data through a fixed telephone line while a wireless modem sends and receives data through radio waves. FACTS OF GSM/GPRS MODEM The GSM/GPRS Modem comes with a serial interface through which the modem can be controlled using AT command interface. An antenna and a power adapter are provided. The basic segregation of working of the modem is as under Voice calls SMS GSM Data calls GPRS Voice calls: Voice calls are not an application area to be targeted. In future if interfaces like a microphone and speaker are provided for some applications then this can be considered. SMS: SMS is an area where the modem can be used to provide features like: Pre-stored SMS transmission These SMS can be transmitted on certain trigger events in an automation system SMS can also be used in areas where small text information has to be sent. The transmitter can be an automation system or machines like vending machines, collection machines like positioning systems where navigator keeps on sending SMS at particular time intervals
65

SMS can be a solution where GSM data call or GPRS services are not available GSM Data Calls: Data calls can be made using this modem. Data calls can be made to a normal PSTN modem/phone line also (even received). Data calls are basically made to send/receive data streams between two units either PCs or embedded devices. The advantage of Data calls over SMS is that both parties are capable of sending/receiving data through their terminals. CHARACTERISTICS Dual-band 900 / 1800 MHz or 900 / 1900 MHz GSM / GPRS Modem Internet, Data, SMS, Voice (Optional Fax, TCP/IP Services Remote Control by AT Commands (according to GSM 07.07 and GSM 07.05) Maximum output power 2 W for GSM 900 : 1W for GSM 1800 or GSM 1900 Input voltage 5.5 V to 12 V DC Current 1.8A peak at 5.5 V, 330 mA average at 5.5 SIM Interface 3V / 5 V Weight 125 gram

66

FEATURES Call Waiting Notification of an incoming call while on the handset Call Hold Put a caller on hold to take another call Call Barring All calls, outgoing calls, or incoming calls Call Forwarding Calls can be sent to various numbers defined by the user Multi Party Call Conferencing Link multiple calls together ADVANCED FEATURE Calling Line ID incoming telephone number displayed Alternate Line Service one for personal calls one for business calls Closed User Group call by dialing last for numbers Advice of Charge tally of actual costs of phone calls Fax & Data Virtual Office / Professional Office Roaming services and features can follow customer from market to market NOTE: You need activated SIM card from GSM Mobile Telephony service provider in your city.You can also sue your existing Mobile phone SIM card.
67

In case GSM Mobile service is not available in your place, you cannot use GSM Modem. General behaviors SIM Insertion, SIM Removal: SIM card Insertion and Removal procedures are supported. There are software functions relying on positive reading of the hardware SIM detect pin. This pin state (open/closed) is permanently monitored. When the SIM detect pin indicates that a card is present in the SIM connector, the product tries to set up a logical SIM session. The logical SIM session will be set up or not depending on whether the detected card is a SIM Card or not. The AT+CPIN? Command delivers the following responses: . If the SIM detect pin indicates absent, the response to AT+CPIN? is +CME ERROR 10 (SIM not inserted). If the SIM detect pin indicates present, and the inserted Card is a SIM Card, the response to AT+CPIN? is +CPIN: xxx depending on SIM PIN state. If the SIM detect pin indicates present, and the inserted Card is not a SIM Card, the response to AT+CPIN? is CME ERROR 10. These last two states are not given immediately due to background initialization. Between the hardware SIM detect pin indicating present and the previous results the AT+CPIN? sends +CME ERROR: 515 (Please wait, init in progress). When the SIM detect pin indicates card absence, and if a SIM Card was previously inserted, an IMSI detach procedure is performed, all user data is removed from the product (Phonebooks, SMS etc.). The product then switches to emergency mode.

68

Background initialization After entering the PIN (Personal Identification Number), some SIM user data files are loaded into the product (Phonebooks, SMS status, etc.). Please be aware that it might take some time to read a large phonebook. The AT+CPIN? command response comes just after the PIN is checked. After this response user data is loaded (in background). This means that some data may not be available just after PIN entry is confirmed by OK. The reading of phonebooks will then be refused by +CME ERROR: 515 or +CMS ERROR: 515 meaning, Please wait, service is not available, init in progress. This type of answer may be sent by the product at several points: when trying to execute another AT command before the previous one is completed (before response), when switching from ADN to FDN (or FDN to ADN) and trying to read the relevant phonebook immediately, when asking for +CPIN? status immediately after SIM insertion and before the product has determined if the inserted card is a valid SIM Card. Advantages of GSM Crisper, cleaner quieter calls Security against fraud and eavesdropping International roaming capability in over 100 countries Improved battery life Efficient network design for less expensive system expansion Efficient use of spectrum Advanced features such as short messaging and caller ID A wide variety of handsets and accessories High stability mobile fax and data at up to 9600 baud

69

Ease of use with over the air activation, and all account information is held in a smart card which can be moved from handset to handset Applications Mobile telephony GSM-R Telemetry System - Fleet management - Automatic meter reading - Toll Collection - Remote control and fault reporting of DG sets Value Added Services What applications is suitable for GSM communication? If your application needs one or more of the following features, GSM will be more cost-effective then other communication systems. Short Data Size: You data size per transaction should be small like 1-3 lines. These small but important transaction data can be sent through SMS messaging which cost even less then a local telephone call or sometimes free of cost worldwide. Hence with negligible cost you are able to send critical information to your head office located anywhere in the world from multiple points. You can also transfer faxes, large data through GSM but this will be as or more costly compared to landline networks. Multiple remote data collection points: If you have multiple data collections points situated all over your city, state, country or worldwide you will benefit the most. Many a times some places like warehouses may be situated at remote location may not have landline or internet but you will have GSM network still available easily.

70

High uptime: If your business require high uptime and availability GSM is best suitable for you as GSM mobile networks have high uptime compared to landline, internet and other communication mediums. Also in situations where you expect that someone may sabotage your communication systems by cutting wires or taping landlines, you can depend on GSM wireless communication. Large transaction volumes: GSM SMS messaging can handle large number of transaction in a very short time. You can receive large number SMS messages on your server like e-mails without internet connectivity. E-mails normally get delayed a lot but SMS messages are almost instantaneous for instant transactions. consider situation like shop owners doing credit card transaction with GSM technology instead of conventional landlines. many a time you find local transaction servers busy as these servers use multiple telephone lines to take care of multiple transactions, whereas one GSM connection is enough to handle hundreds of transaction per minute. Mobility, Quick installation: GSM technology allow mobility, GSM terminals, modems can be just picked and installed at other location unlike telephone lines. Also you can be mobile with GSM terminals and can also communicate with server using your mobile phone. You can just purchase the GSM hardware like modems, terminals and mobile handsets, insert SIM cards, configure software and your are ready for GSM communication. GSM solutions can be implemented within few weeks whereas it may take many months to implement the infrastructure for other technologies.

71

CHAPTER-9 VIBRATION SENSOR This sensor buffers a piezoelectric transducer. As the transducer is displaced from the mechanical neutral axis, bending creates strain within the piezoelectric element and generates voltages. If the assembly is supported by its mounting points and left to vibrate in free space the device will behave as a form of vibration sensor. The sensing element should not be treated as a flexible switch, and is not intended to be bent. Sensor Value 500 roughly corresponds to 0g acceleration. Acceleration will deflect the sensing element up or down, causing Sensor Value to swing either way. This sensor is not meant to measure precise acceleration and vibration - use it to detect an acceleration impulse, or the presence of vibration.

72

FEATURES Simple to install and operate Easy to integrate in test rig applications and existing control systems Advanced digital signal electronics for lowest noise combined with highest sensitivity 0.5 Hz to 22 kHz frequency response Velocity up to 500 mm/s (3 ranges) Analog velocity output and digital S/P-DIF audio interface compatible with VIBSOFT-SP and other acquisition systems supporting the S/P-DIF standard CRYSTAL BUZZER A buzzer or beeper is a signaling device, usually electronic, typically used in automobiles, household appliances such as a microwave oven.

73

It most commonly consists of a number of switches or sensors connected to a control unit that determines if and which button was pushed or a preset time has lapsed, and usually illuminates a light on the appropriate button or control panel, and sounds a warning in the form of a continuous or intermittent buzzing or beeping sound. Initially this device was based on an electromechanical system which was identical to an electric bell without the metal gong (which makes the ringing noise). Often these units were anchored to a wall or ceiling and used the ceiling or wall as a sounding board. Another implementation with some AC-connected devices was to implement a circuit to make the AC current into a noise loud enough to drive a loudspeaker and hook this circuit up to a cheap 8-ohm speaker. Nowadays, it is more popular to use a ceramic-based piezoelectric sounder like a Sonalert which makes a high-pitched tone. Usually these were hooked up to "driver" circuits which varied the pitch of the sound or pulsed the sound on and off. In game shows it is also known as a "lockout system," because when one person signals ("buzzes in"), all others are locked out from signaling. Several game shows have large buzzer buttons which are identified as "plungers". The word "buzzer" comes from the rasping noise that buzzers made when they were electromechanical devices, operated from stepped-down AC line voltage at 50 or 60 cycles. Other sounds commonly used to indicate that a button has been pressed are a ring or a beep. Some systems, such as the one used on Jeopardy!, make no noise at all, instead using light. Nowadays some people use the word "buzzer" as to describe a person who's able to create a big buzz around a brand, an event or a company.[citation needed]

74

CRYSTAL 20.000 MHZ SER 49UA - ECS-200-S-1 Digi-Key Part Number Manufacturer Part Number Product Description X062-ND ECS-200-S-1 CRYSTAL 20.000 MHZ SER 49UA Price Break 1 10 100 500 1000 5000 Unit Price 0.28 0.253 0.2253 Extended Price 0.28 2.53 22.53

0.20114 100.57 0.18304 183.04 0.176 880.00

Quantity Available 969 All prices are in GBP

CRYSTAL 20.000 MHZ SER 49UA - ECS-200-S-1 Technical/Catalog Information ECS-200-S-1 Vendor Category Frequency Load Capacitance Package / Case Packaging Frequency Tolerance Mounting Type Operating Mode Operating Temperature Series ECS Inc Crystals and Oscillators 20MHz Series HC49/U Bulk 30ppm Through Hole Fundamental -10C ~ 70C
HC-49U

CHAPTER-10 CODING CODING FOR VECHILE SECTION

75

#include<REG420.h> #include<stdio.h> #include<string.h> #include <stdlib.h> sbit RS = P3^5; sbit RW = P3^6; sbit EN = P3^7; sbit DEV = P1^0; #define DATA P2 void lcdinit(void); void lcdclr(void); void lcdcomd(unsigned char); void lcddata(unsigned char); void lcd puts(const unsigned char *); void SBUF1 puts(unsigned char *); void Gets(unsigned char *, unsigned char); unsigned char Get USART char 1(void); unsigned char Get USART char 0(void); //***************Variable declaration**************// unsigned char temp=0, Count=0,Flag=0; unsigned char Str Array[30],y[45]; unsigned char *ptr; //***************Function declaration**************// void init comms(void); void Delay ms12M(unsigned int); void Transmit 0(unsigned char); void Transmit 1(unsigned char); void Send SMS(void);
76

code unsigned char *Send msg = "AT+CMGS= //Change the number here

9884078964\r";

//****************Main Function********************// void main() { Delay ms12M(100); init comms(); lcdinit(); lcdclr(); Delay ms12M(500); P1 = 0xff; P2 = 0x00; RS = RW = EN =0; lcdcomd(0x80); lcd puts("Crash Notificatn"); while(1){ if(DEV==0) Send SMS(); } } //**************Interrupt Function*************// void Receive(void)interrupt 4 { if(RI 0) { temp = SBUF0; //Receive the first character if (temp == 'L') { ES0 = 0; Gets(y,0); while(!(strchr(y,'L'))) Gets(y,0); ptr = strchr(y,'L')+ 2;
77

Flag = 1; } RI 0 = 0; } } void init comms(void) { EA = 1; ES0 = 0; ES1 = 0;

PCON |= 0x00; SCON0 = 0x50; //SERIAL CONN MODE 1 - SERIAL 0 (1 START, 8DATA, 1 STOP BIT) SCON1 = 0x50; //SERIAL CONN MODE 1 - SERIAL 1 (START, 8DATA, 1 STOP BIT) TMOD |= 0x21; TH1 rate. TCON = 0x50; } = 0xFD; //TIMER 1 MODE 2, 8-BIT AUTO RELOAD MODE //11.0592 Mhz at serial0(19200), serial1(9600) baud

void Delay ms12M(unsigned int del) { int j; while(del>0) { del--;


78

for(j=0;j<110;j++); } } void SBUF1 puts(const unsigned char *string) { while(*string) Transmit 1(*string++); } void Gets(unsigned char *string, unsigned char n) { unsigned char i=0,J=0; do { if(n==1) *(string+i)= Get USART char 1(); else *(string+i)= Get USART char 0(); J = *(string+i); //Transmit 0(J); i++; }while((J!='\n') && (J!='\r') && (J!=EOF)); i++; *(string+i) = NULL; } unsigned char Get USART char 1(void) { unsigned char c; while(!RI 1);
79

c = SBUF1; RI 1 = 0; return c; } unsigned char Get USART char 0(void) { unsigned char c; while(!RI 0); c = SBUF0; RI 0 = 0; return c; } void Transmit 0(unsigned char dat) { SBUF0 = dat; while(TI 0==0); TI 0 = 0; Delay ms12M(2); } void Transmit 1(unsigned char dat) { SBUF1 = dat; while(TI 1==0); TI 1 = 0; Delay ms12M(2); } void Send SMS(void) { ES0 = 1; while(Flag==0); Flag = 0; SBUF1 puts(Send msg);
80

SBUF1 puts(ptr); Transmit 1(0x1a); lcdcomd(0xc0); lcd puts("Vehicle Crashed "); while((P0&0x01)==0x00); lcdcomd(0xc0); lcd puts(" } void lcdinit(void) { char command[]={0x38,0x0c,0x06},i; for(i=0;i<3;i++) { lcdcomd(command[i]); Delay ms12M(2); } } ");

void lcdclr(void) { lcdcomd(0x01); Delay ms12M(5); } void lcd puts(const unsigned char *string) {
81

while(*string) lcddata(*string++); } void lcdcomd(unsigned char cmd) { RS=0;RW=0; EN=1; DATA=cmd; EN=0; } void lcddata(unsigned char byte) { RS=1;RW=0; EN=1; DATA=byte; EN=0; } Delay ms12M(2); Delay ms12M(3);

CODING FOR RESCUE TEAM SECTION #include<stdio.h> #include<reg51.h>

82

#define DATA P1 DATA as Port 0 for LCD #define IN P2 sbit RS Select sbit RW = P3^6; = P3^5;

//Define

//Register //LCD //LCD

Read/Write sbit lcd_e = P3^7; Enable sbit alarm = P0^7; sbit D0 = P2^0; sbit D1 = P2^1; sbit D2 = P2^2; sbit D3 = P2^3; sbit E = P2^7; //--------------------------------------- Declarations ------------------------------------------unsigned char title[] = " Monitoring ",title1[] = " System "; unsigned char Menu[] = "Press ScanButton"; unsigned char Stat[] = "Scanning......"; //unsigned char Info[5] [6]={"A00125","B00136","C00147","D00158","xxxxxx"}; //---------------------------------------Delay Routine-------------------------------------------void delay()
83

{ unsigned int s,t; for(s=0;s<200;s++) for(t=0;t<700;t++); } void DelayMs(unsigned int n) { unsigned int i,j; j=n; //for(j=0;j<n;j++) for(i=0;i<1500;i++); } //--------------------------------Serial Comm Initialization-------------------------------------void serial() { TMOD = 0x20; SCON = 0x50; TH1= 0xFD; TR1=1; TI=1; } //---------------------------------- LCD command Function -------------------------------------void lcd_cmd(unsigned char cmnd) { DATA = cmnd; RS = 0;
84

RW = 0; lcd_e = 1; DelayMs(35); lcd_e = 0; } //----------------------------------- LCD Data Function -------------------------------------void lcd_display(unsigned char dat) { DATA = dat; RS = 1; RW = 0; lcd_e = 1; DelayMs(35); lcd_e = 0; } //-----------------------------------LCD Initialization-------------------------------------------void lcd_init() { unsigned char i; lcd_cmd(0x38); //2x16 Character 5x7 dot DelayMs(15); //matrix LCD,8-bit format lcd_cmd(0x0c); DelayMs(15); lcd_cmd(0x06);
85

//Display On, cursor off //Shift Cursor to right

DelayMs(15); lcd_cmd(0x01); DelayMs(15); //First Line Display i=0; lcd_cmd(0x80); DelayMs(25); while(title[i]!='\0') { lcd_display(title[i++]); } lcd_cmd(0xC0); DelayMs(15); i=0; while(title1[i]!='\0') lcd_display(title1[i++]); } void Display(unsigned char *str) { //unsigned int x,y; lcd_cmd(0x01); lcd_cmd(0x84); while(*str!='\0') { lcd_display(*str++); DelayMs(25);
86

//Clear display screen

} } //----------------------------------- Main Program Starts -------------------------------------------void main() { unsigned char pos,k,p=4,q,ch; serial(); lcd_init(); DelayMs(250); P2=0xFF; //Configure Port 1 as input Port P0=0x00; delay(); delay(); while(1) { P2=0xFF; lcd_cmd(0x01); DelayMs(15); lcd_cmd(0x80); while(Menu[k]!='\0') { ch=Menu[k++]; lcd_display(ch); DelayMs(15); //SBUF = ch; DelayMs(15); }
87

while(E!=0); //while(E!=1); while(E==0){ pos=0xC0; lcd_cmd(0x80); DelayMs(25); k=0; while(Stat[k]!='\0') lcd_display(Stat[k++]); DelayMs(25); DelayMs(25); lcd_cmd(pos); for(k=0,pos=0xC0;k<16;k++) { lcd_cmd(pos++); DelayMs(25); lcd_display('>'); DelayMs(125); } DelayMs(50); if(D0==0) { SBUF = 'A'; DelayMs(15); alarm = 1; DelayMs(40); alarm = 0; Display("A00111"); while(E==0);
88

} else if(D1==0) { SBUF='B'; DelayMs(15); alarm = 1; DelayMs(40); alarm = 0; Display("B00255"); while(E==0); } else if(D2==0) { SBUF='C'; DelayMs(15); alarm = 1; DelayMs(40); alarm = 0; Display("C00666"); while(E==0); } else if(D3==0) { SBUF='D'; DelayMs(15); alarm = 1; DelayMs(40); alarm = 0; Display("D00888");
89

while(E==0); } q=0; DelayMs(200); P2=0xFF; while(E!=0); } }

CHAPTER-11 CONCLUSION

90

In the future, we can place verimid chip inside the human body,contains the ID which can be scanned and all the medical details of the person can be fetched with the help of the computer and it is universely connected through the internet . If the person meets with accident, using GPS the location of the spot where the accident took place is found.The message of the accident spotted is sent to members of the family or the near by hospital that we specify with the help of AT commands through GSM. The patient can be treated without any medical error. Hence with the help of this technique, we can treat the patient with precision using the history of medical records

REFERENCE

91

Fatality Analysis Reporting System PARS). National Highway Traffic Safety Administration, 1977-1996. Implantable Microchips for Drug Delivery Norman Sheppard, PhD, Director of Basic Research, Microchips, Inc Peter Jones, Colin Clarke-Hill, Peter Shears, Daphne Comfort, and David Hillier, "Radio Frequency Identification in the UK: opportunities and challenges," International Journal of Retail & Distribution Management, vol.32, no.2/3, 2004, pp.164- 171.

92

Vous aimerez peut-être aussi