Top Banner
Table of Contents 1.Introduction 2. Literature survey 3.Formation of the Problem 4.System specification 5.Design of solution 6.Implementation 7.Results and Discussions 8.System testing 9.Conclusion and future scope 10.References
150

Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Jul 27, 2015

Download

Documents

Sravan Kumar
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Table of Contents

1.Introduction

2. Literature survey

3.Formation of the Problem

4.System specification

5.Design of solution

6.Implementation

7.Results and Discussions

8.System testing

9.Conclusion and future scope

10.References

Page 2: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

INTELLIGENT AMBULANCE FOR CITY TRAFFIC AND GSM TO SENT THE STATUS OF THE PATIENT TO THE HOSPITALABSTRACT:The main aim of this project is develop an intelligent ambulance which will reach the hospitals without any problem in heavy traffics.INTRODUCTION:This particular project is designed for the cities with heavy traffic. Eg: In Bangalore the roads are full jammed every time. Most of the time the traffic will at least for 100meters .In this distance the traffics police can’t hear the siren form the ambulance .so he ignores this .Then the ambulance has to wait till the traffic is left. Some times to leave the traffic it takes at least 30 minutes .So by this time anything can happen to the patient .So this project avoid these disadvantages. According to this project, if any ambulance comes near or when the ambulance at emergency comes to any traffic post the traffic signals automatically stop the signals and give green signal for this ambulance.

COMPONENTSUSED:Power Supply - 12V/1A DC Micro controller – AT89C51 Buzzer - 5VdcLight Emitting Diode (LED)RF transmitter & receiverIR Transmitter and Receiver

SOFTWARES USED:Keil uVision3Embedded c

Page 3: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Power Supply

Trans former

Rectifier

Filter

Regulator(7805)

AT89C51 MCU

16X2 LCD

IR Rx

RF encoder

RF Tx

IR Tx

WORKING PRINCIPLE:

When the ambulance at emergency comes to any traffic post the traffic signals automatically stop the signals and

give green signal for this ambulance.

The ambulance carries an IR transmitter and IR receiver will be there some few meter before the signal. The

receiver will receive the signal and the module will send the command turn on green through the RF and every

traffic post will have an RF receiver. So whenever the ambulance comes near the traffic, the ambulance will transmit

a code say “emergency” the receiver will receive this signal .Then it immediately switch off the other signals that is

it make all the signals red and later make this particular direction signal green. So by doing this the ambulance can

go without any problem.

BLOCK DIAGRAM: Module in Ambulance

Page 4: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

RF Receiver RF Decoder

AT89C51 MCU

16X2 LCD

GREENLED

REDLED

Power Supply

Trans former

Rectifier Filter

Regulator(7805)

YELLOWLED

Block diagram: Traffic post

Page 5: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital
Page 6: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

CHAPTER 2

 Literature survey

2.1 Embedded Systems

An embedded system is a special-purpose computer system designed to perform one or a few dedicated

functions, often with real-time computing constraints. It is usually embedded as part of a complete device

including hardware and mechanical parts. In contrast, a general-purpose computer, such as a personal

computer, can do many different tasks depending on programming. Embedded systems control many of

the common devices in use today.

Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing the

size and cost of the product, or increasing the reliability and performance. Some embedded systems are

mass-produced, benefiting from economics of scale. Physically, embedded systems range from portable

devices such as digital watches and mp4 players, to large stationary installations like traffic lights, factory

controllers, or the systems controlling nuclear power stations. Complexity varies from low, with a single

microcontroller chip, to very high with multiple units, peripherals and networks mounted inside a large

chassis or enclosure.

In general, "embedded system" is not an exactly defined term, as many systems have some element of

programmability. For example, handheld computers share some elements with embedded systems — such

as the operating systems and microprocessors which power them — but are not truly embedded systems,

because they allow different applications to be loaded and peripherals to be connected

Page 7: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Every embedded system consists of custom-built hardware built around a Central Processing Unit (CPU).

This hardware also contains memory chips onto which the software is loaded. The software residing on

the memory chip is also called the ‘firmware’. The embedded system architecture can be represented

as a layered architecture as shown in Fig.

The operating system runs above the hardware, and the application software runs above the

operating system. The same architecture is applicable to any computer including a desktop

computer. However, there are significant differences. It is not compulsory to have an operating

system in every embedded system. For small appliances such as remote control units, air

conditioners, toys etc., there is no need for an operating system and you can write only the

software specific to that application. For applications involving complex processing, it is

advisable to have an operating system. In such a case, you need to integrate the application

software with the operating system and then transfer the entire software on to the memory chip.

Once the software is transferred to the memory chip, the software will continue to run for a long

time you don’t need to reload new software.

2.2 Characteristics

1. Embedded systems are designed to do some specific task, rather than be a general-purpose

computer for multiple tasks. Some also have real-time performance constraints that must be met,

Page 8: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

for reasons such as safety and usability; others may have low or no performance requirements,

allowing the system hardware to be simplified to reduce costs.

2. Embedded systems are not always standalone devices. Many embedded systems consist of small,

computerized parts within a larger device that serves a more general purpose. For example, the

features an embedded system for tuning the strings, but the overall purpose of the Robot Guitar

is, of course, to play music. Similarly, an embedded system in automobiles provides a specific

function as a subsystem of the car itself.

3. The program instructions written for embedded systems are referred to as firmware, and are

stored in read-only memory or flash memory chips. They run with limited computer hardware

resources: little memory, small or non-existent keyboard and/or screen.

Figure 2.1 A typical embedded system block diagram

2.3 Micro Controllers

The micro controller, nowadays, is an indispensable device for electrical/electronic engineers

and also for technicians in the area, because of its versatility and its enormous application. .Born

of parallel developments in computer architecture and integrated circuit fabrication ,the

microprocessor or computer on chip first becomes a commercial reality in 1971.with the

introduction of the 4 bit 4004 by a small, unknown company by the name of Intel corporation.

Other, well established, semiconductor firms soon followed Intel’s pioneering technology so that

by the late 1970’s we could choose from a half dozen or so micro processor typThe 1970s also

Page 9: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

saw the growth of the number of personal computer users from a Handful of hobbyists and

hackers to millions of business, industrial, governmental, defense, and educational and private

users now enjoying the advantages of inexpensive computing.

A bye product of microprocessor development was the micro controller. The same fabrication

techniques and programming concepts that make possible general-purpose microprocessor also

yielded the micro controller.

Among the applications of a micro controller we can mention industrial automation,

mobile telephones, radios, microwave ovens and VCRs. Besides, the present trend in digital

electronics is toward restricting to micro controllers and chips that concentrate a great quantity of

logical circuits, like PLDs (Programmable Logic Devices) and GALs (Gate Array Logic). In

dedicated systems, the micro controller is the best solution, because it is cheap and easy to

manage. Despite it’s relatively old age, the 8051 is one of the most popular micro controllers in

use today. Many derivative micro controllers have since been developed that are based on--and

compatible with--the 8051. Thus, the ability to program an 8051 is an important skill for anyone

who plans to develop products that will take advantage of micro controllers.In 8051 architecture

there are so many controllers developed by different semiconductor companies.Here we are

going to use the controller manufactured by Atmel semiconductors which is AT89C51.All the

controllers belongs to 8051 architecture follow harward architecture and CISC design.

2.3 Communication:

Communication refers to the sending, receiving and processing of information by electric

means. As such, it started with wire telegraphy in the early 80’s, developing with telephony and

radio some decades later. Radio communication became the most widely used and refined

through the invention of and use of transistor, integrated circuit, and other semi-conductor

devices. Most recently, the use of satellites and fiber optics has made communication even more

wide spread, with an increasing emphasis on computer and other data communications.

Page 10: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

A modern communications system is first concerned with the sorting, processing and

storing of information before its transmission. The actual transmission then follows, with further

processing and the filtering of noise. Finally we have reception, which may include processing

steps such as decoding, storage and interpretation. In this context, forms of communications

include radio, telephony and telegraphy, broadcast, point to point and mobile communications

(commercial and military), computer communications, radar, radio telemetry and radio aids to

navigation. It is also important to consider the human factors influencing a particular system,

since they can always affect its design, planning and use.

Wireless communication has become an important feature for commercial products and a

popular research topic within the last ten years. There are now more mobile phone subscriptions

than wired-line subscriptions. Lately, one area of commercial interest has been low-cost, low-

power, and short-distance wireless communication used for personal wireless networks."

Technology advancements are providing smaller and more cost effective devices for integrating

computational processing, wireless communication, and a host of other functionalities. These

embedded communications devices will be integrated into applications ranging from homeland

security to industry automation and monitoring. They will also enable custom tailored

engineering solutions, creating a revolutionary way of disseminating and processing information.

With new technologies and devices come new business activities, and the need for employees in

these technological areas. Engineers who have knowledge of embedded systems and wireless

communications will be in high demand. Unfortunately, there are few adorable environments

available for development and classroom use, so students often do not learn about these

technologies during hands-on lab exercises. The communication mediums were twisted pair,

optical fiber, infrared, and generally wireless radio.

2.4 IR Remote Theory

The cheapest way to remotely control a device within a visible range is via Infra-Red light. Almost all audio and video equipment can be controlled this way nowadays. Due to this wide spread use the required components are quite cheap, thus making it ideal for us hobbyists to use IR control for our own projects.

Page 11: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

IR sensor is the combination of IR LED with PHOTO DIODE. After this combination we are connecting the DARLINGTON PAIR TRANSISTOR. End of the IR sensor we have to connect a NOT gate for the inverting purpose means low input have corresponding low output. At last this entire connector is connected to any one external interrupt to generating the interruption of the main program.

Infra-Red actually is normal light with a particular colour. We humans can't see this

colour because its wave length of 950nm is below the visible spectrum. That's one of the reasons

why IR is chosen for remote control purposes, we want to use it but we're not interested in seeing

it. Another reason is because IR LEDs are quite easy to make, and therefore can be very cheap.

IR LED wave length range 1.6m to 2.4m. Materials used for IR LED are InSB, Ge,Si, GaAs, CdSe .

These IR s are not visible range for observation purpose we have to connect LED s are not.

2.5 RF Technology

Radio frequency (RF) is a frequency or rate of oscillation within the range of about 3 Hz to 300 GHz.

This range corresponds to frequency of alternating current electrical signals used to produce and detect

radio waves. Since most of this range is beyond the vibration rate that most mechanical systems can

respond to, RF usually refers to oscillations in electrical circuits or electromagnetic radiation

RF communication works by creating electromagnetic waves at a source and being able to pick up those

electromagnetic waves at a particular destination. These electromagnetic waves travel through the air at

near the speed of light. The wavelength of an electromagnetic signal is inversely proportional to the

frequency; the higher the frequency, the shorter the wavelength.

Frequency is measured in Hertz (cycles per second) and radio frequencies are measured in kilohertz (KHz

or thousands of cycles per second), megahertz (MHz or millions of cycles per second) and gigahertz

Page 12: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

(GHz or billions of cycles per second). Higher frequencies result in shorter wavelengths. The wavelength

for a 900 MHz device is longer than that of a 2.4 GHz device.

In general, signals with longer wavelengths travel a greater distance and penetrate through, and around

objects better than signals with shorter wavelengths.

Imagine an RF transmitter wiggling an electron in one location. This wiggling electron causes a ripple

effect, somewhat akin to dropping a pebble in a pond. The effect is an electromagnetic (EM) wave that

travels out from the initial location resulting in electrons wiggling in remote locations. An RF receiver

can detect this remote electron wiggling.

The RF communication system then utilizes this phenomenon by wiggling electrons in a specific pattern

to represent information. The receiver can make this same information available at a remote location;

communicating with no wires.

In most wireless systems, a designer has two overriding constraints: it must operate over a certain

distance (range) and transfer a certain amount of information within a time frame (data rate). Then the

economics of the system must work out (price) along with acquiring government agency approvals

(regulations and licensing).

In order to accurately compute range – it is essential to understand a few terms:

dB - Decibels

Decibels are logarithmic units that are often used to represent RF power. To convert from watts to dB:

Power in dB = 10* (log x) where x is the power in watts.

Another unit of measure that is encountered often is dBm (dB milliwatts). The conversion formula for it

is Power in dBm = 10* (log x) where x is the power in milliwatts.

Line-of-site (LOS)

Line-of-site when speaking of RF means more than just being able to see the receiving antenna from the

transmitting antenna. In, order to have true line-of-site no objects (including trees, houses or the ground)

can be in the Fresnel zone. The Fresnel zone is the area around the visual line-of-sight that radio waves

spread out into after they leave the antenna. This area must be clear or else signal strength will weaken.

Page 13: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

There are essentially two parameters to look at when trying to determine range.

Transmit Power

Transmit power refers to the amount of RF power that comes out of the antenna port of the radio.

Transmit power is usually measured in Watts, milliwatts or dBm. (For conversion between watts and dB

see below.)

Receiver sensitivity

Receiver sensitivity refers to the minimum level signal the radio can demodulate. It is convenient to use

an example with sound waves; Transmit power is how loud someone is yelling and receive sensitivity

would be how soft a voice someone can hear. Transmit power and receive sensitivity together constitute

what is know as “link budget”. The link budget is the total amount of signal attenuation you can have

between the transmitter and receiver and still have communication occur.

Example:

Maxstream 9XStream TX Power: 20dBm

Maxstream 9XStream RX Sensitivity: -110dBm

Total Link budget: 130dBm.

For line-of-site situations, a mathematical formula can be used to figure out the approximate range for a

given link budget. For non line-of-site applications range calculations are more complex because of the

various ways the signal can be attenuated.

Data rates are usually dictated by the system - how much data must be transferred and how often does the

transfer need to take place. Lower data rates, allow the radio module to have better receive sensitivity and

thus more range. In the XStream modules the 9600 baud module has 3dB more sensitivity than the 19200

baud module. This means about 30% more distance in line-of-sight conditions. Higher data rates allow

the communication to take place in less time, potentially using less power to transmit.

WHAT IS THE NEED FOR RF?

Page 14: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Radio frequency is a frequency or rate of oscillation within the range of about 3 Hz to 300 GHz. This

range corresponds to frequency of alternating current electrical signals used to produce and detect radio

waves Since most of this range is beyond the vibration rate that most mechanical systems can respond to,

RF usually refers to oscillations in electrical circuits. RF is widely used because it does not require any

line of sight, less distortions and no interference.

.

PROPERTIES OF RF:

Electrical currents that oscillate at RF have special properties not shared by direct current signals. One

such property is the ease with which it can ionize air to create a conductive path through air. This

property is exploited by 'high frequency' units used in electric arc welding. Another special property is an

electromagnetic force that drives the RF current to the surface of conductors, known as the skin effect.

Another property is the ability to appear to flow through paths that contain insulating material, like the

dielectric insulator of a capacitor. The degree of effect of these properties depends on the frequency of the

signals.

DIFFERENT RANGES PRESENT IN RF AND APPLICATIONS IN THEIR RANGES?

Extremely low frequency

ELF 3 to 30 Hz

10,000 km to 100,000 km

directly audible when converted to sound, communication with submarines

Super low frequency

SLF 30 to 300 Hz

1,000 km to 10,000 km

directly audible when converted to sound, AC power grids (50 hertz and 60 hertz)

Page 15: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Ultra low frequency

ULF 300 to 3000 Hz

100 km to 1,000 km

directly audible when converted to sound, communication with mines

Very low frequency

VLF 3 to 30 kHz

10 km to 100 km

directly audible when converted to sound (below ca. 18-20 kHz; or "ultrasound" 20-30+ kHz)

Low frequency

LF 30 to 300 kHz

1 km to 10 km

AM broadcasting, navigational beacons, lowFER

Medium frequency

MF 300 to 3000 kHz

100 m to 1 km

navigational beacons, AM broadcasting, maritime and aviation communication

High frequency

Page 16: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

HF 3 to 30 MHz

10 m to 100 m

Shortwave, amateur radio, citizens' band radio

Very high frequency

VHF 30 to 300 MHz

1 m to 10 m

FM broadcasting broadcast television, aviation, GPR

Ultra high frequency

UHF 300 to 3000 MHz

10 cm to 100 cm

Broadcast television, mobile telephones, cordless telephones, wireless networking, remote keyless entry

for automobiles, microwave ovens, GPR

Super high frequency

SHF 3 to 30 GHz

1 cm to 10 cm

Wireless networking, satellite links, microwave links, Satellite television, door openers.

Extremely high frequency

EHF 30 to 300 GHz

1 mm to 10 mm

Page 17: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Microwave data links, radio astronomy, remote sensing, advanced weapons systems, advanced security

scanning

WHY DO WE GO FOR RF COMMUNICATION?

RF Advantages:

1. No line of sight is needed.

2. Not blocked by common materials: It can penetrate most solids and pass through walls.

3. Longer range.

4. It is not sensitive to the light;.

5. It is not much sensitive to the environmental changes and weather conditions.

RF Disadvantages:

1. Interference: communication devices using similar frequencies - wireless phones, scanners, wrist

radios and personal locators can interfere with transmission

2. Lack of security: easier to "eavesdrop" on transmissions since signals are spread out in space

rather than confined to a wire

3. Higher cost than infrared

4. Federal Communications Commission(FCC) licenses required for some products

5. Lower speed: data rate transmission is lower than wired and infrared transmission

2.7 GSM Technology

GSM (Global System for Mobile Communications: originally from Groupe Spécial Mobile) is

the most popular standard for mobile telephony systems in the world. The GSM Association, its

promoting industry trade organization of mobile phone carriers and manufacturers, estimates that

80% of the global mobile market uses the standard.GSM is used by over 2 billion people across

more than 212 countries and territories.Its ubiquity enables international roaming arrangements

between mobile phone operators, providing subscribers the use of their phones in many parts of

the world. GSM differs from its predecessor technologies in that both signaling and speech

channels are digital, and thus GSM is considered a second generation (2G) mobile phone system.

Page 18: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

This also facilitates the wide-spread implementation of data communication applications into the

system.It is a globally accepted standard for digital cellular communication. GSM is the name of

standardization group established in 1982 to create a common European mobile telephone

standard that would formulate specifications for a pan-European mobile cellular radio system

operating at 900MHZ.

Throughout the evolution of cellular telecommunications, various systems have been

developed without the benefit of standardized specification. This presented many problems directly

related to compatibility, especially with the development of digital radio technology. The GSM

standard is intended to address these problems.

GSM-Introduction

• Architecture

• Technical Specifications

• Frame Structure

• Channels

Security

Characteristics and features

Applications

Definition:

Page 19: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Global System for Mobile (GSM) is a second generation cellular standard

developed to cater voice services and data delivery using digital modulation.

GSM-History

• Developed by Group Special Mobile (founded 1982) which was an initiative of

CEPT (Conference of European Post and Telecommunication)

• Aim : to replace the incompatible analog system

• Presently the responsibility of GSM standardization resides with special mobile

group under ETSI ( European telecommunication Standards Institute )

• Full set of specifications phase-I became available in 1990

• Under ETSI, GSM is named as “Global System for Mobile communication “

• Today many providers all over the world use GSM (more than 135

Countries in Asia, Africa, Europe, Australia, America)

• More than 1300 million subscribers in world and 45 million subscribers in India.

GSM IN WORLD

Figures: March, 2005

37%

1%4%43%

4%

3%3%

3% (INDIA)

3%

Arab World

Asia Pacific

Africa

East Central Asia

Europe

Russia

India

North America

South America

Page 20: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

GSM IN INDIA

Figures: March 2005

Bharti27%

BSNL22%

Spice 4%

IDEA13%

Hutch19%

BPL6%

Aircel4%

Reliance3%

MTNL2%

Bharti

BSNL

Hutch

IDEA

BPL

Aircel

Spice

Reliance

MTNL

Page 21: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

GSM SERVICES

Tele-services

Bearer or Data Services

Supplementary services

Tele-services

• Telecommunication services that enable voice communication

via mobile phones

• Offered services

- Mobile telephony

- Emergency calling

Bearer or Data Services

Include various data services for information transfer between GSM and other networks like

PSTN, ISDN etc at rates from 300 to 9600 bps

Short Message Service (SMS)

– up to 160 character alphanumeric data transmission to/from the mobile terminal

Unified Messaging Services(UMS)

Group 3 fax

Voice mailbox

Electronic mail

Supplementary services

Call related services :

• Call Waiting- Notification of an incoming call while on the handset

• Call Hold- Put a caller on hold to take another call

Page 22: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

• 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

• CLIP – Caller line identification presentation

• CLIR – Caller line identification restriction

• CUG – Closed user group

GSM System Architecture-I

Mobile Station (MS)

Mobile Equipment (ME)

Subscriber Identity Module (SIM)

Base Station Subsystem (BSS)

Base Transceiver Station (BTS)

Base Station Controller (BSC)

Network Switching Subsystem(NSS)

Mobile Switching Center (MSC)

Home Location Register (HLR)

Visitor Location Register (VLR)

Page 23: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Authentication Center (AUC)

Equipment Identity Register (EIR)

System Architecture Mobile Station (MS)

The Mobile Station is made up of two entities:

1. Mobile Equipment (ME)

2. Subscriber Identity Module (SIM)

Mobile Equipment

Portable,vehicle mounted, hand held device

Uniquely identified by an IMEI (International Mobile Equipment Identity)

Voice and data transmission

Monitoring power and signal quality of surrounding cells for optimum handover

Power level : 0.8W – 20 W

160 character long SMS.

Subscriber Identity Module (SIM)

Smart card contains the International Mobile Subscriber Identity (IMSI)

Allows user to send and receive calls and receive other subscribed services

Encoded network identification details

Page 24: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

- Key Ki,Kc and A3,A5 and A8 algorithms

Protected by a password or PIN

Can be moved from phone to phone – contains key information to activate the phone

System Architecture Base Station Subsystem (BSS)

Base Station Subsystem is composed of two parts that communicate across the standardized Abis

interface allowing operation between components made by different suppliers

1. Base Transceiver Station (BTS)

2. Base Station Controller (BSC)

System Architecture Base Station Subsystem (BSS)

Base Transceiver Station (BTS):

Encodes,encrypts,multiplexes,modulates and feeds the RF signals to the antenna.

Frequency hopping

Communicates with Mobile station and BSC

Consists of Transceivers (TRX) units

Base Station Controller (BSC)

Manages Radio resources for BTS

Assigns Frequency and time slots for all MS’s in its area

Handles call set up

Transcoding and rate adaptation functionality

Handover for each MS

Radio Power control

Page 25: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

It communicates with MSC and BTS

System Architecture Network Switching Subsystem(NSS)

Mobile Switching Center (MSC)

Heart of the network

Manages communication between GSM and other networks

Call setup function and basic switching

Call routing

Billing information and collection

Mobility management

- Registration

- Location Updating

- Inter BSS and inter MSC call handoff

MSC does gateway function while its customer roams to other network by using HLR/VLR.

System Architecture Network Switching Subsystem

Home Location Registers (HLR)

- Permanent database about mobile subscribers in a large service area (generally one per GSM network

operator)

Database contains IMSI, MS ISDN, prepaid/postpaid, roaming restrictions, and supplementary services.

Visitor Location Registers (VLR)

Page 26: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

- Temporary database which updates whenever new MS enters its area, by HLR

database

- Controls those mobiles roaming in its area

- Reduces number of queries to HLR

- Database contains IMSI, TMSI, MSISDN, MSRN, Location Area, authentication

key

Authentication Center (AUC)

- Protects against intruders in air interface

- Maintains authentication keys and algorithms and provides security triplets

( RAND, SRES, Kc)

- Generally associated with HLR

Equipment Identity Register (EIR)

- Database that is used to track handsets using the IMEI (International

Mobile Equipment Identity)

- Made up of three sub-classes: The White List, The Black List and the Gray List

- Only one EIR per PLMN

GSM Specifications-1

RF Spectrum

GSM 900

Mobile to BTS (uplink): 890-915 Mhz

BTS to Mobile(downlink):935-960 Mhz

Bandwidth : 2* 25 Mhz

GSM 1800

Page 27: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Mobile to BTS (uplink): 1710-1785 Mhz

BTS to Mobile(downlink) 1805-1880 Mhz

Bandwidth : 2* 75 Mhz

GSM Specification-II

Carrier Separation : 200 Khz

Duplex Distance : 45 Mhz

No. of RF carriers : 124

Access Method : TDMA/FDMA

Modulation Method : GMSK

Modulation data rate : 270.833 Kbps

OPERATION OF GSM

Page 28: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Call Routing

Call Originating from MS

Call termination to MS

Outgoing Call

Page 29: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

1. MS sends dialed number to BSS

2. BSS sends dialed number to MSC

3,4 MSC checks VLR if MS is allowed the requested service. If so, MSC asks BSS

to allocate resources for call.

5 MSC routes the call to GMSC

6 GMSC routes the call to local exchange of called use7, 8,

9, 10 Answer back (ring back) tone is routed from called user to MS via

GMSC, MSC, BSS

Incoming Call

Page 30: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

1. Calling a GSM subscribers

2. Forwarding call to GSMC

3. Signal Setup to HLR

4. 5. Request MSRN from VLR

6. Forward responsible MSC to GMSC

7. Forward Call to current MSC

8. 9. Get current status of MS

10. 11. Paging of MS

12. 13. MS answers

14. 15. Security checks

16. 17. Set up connection

Page 31: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Handovers

Between 1 and 2 – Inter BTS / Intra BSC

Between 1 and 3 –

Inter BSC/ Intra MSC

Between 1 and 4 – Inter MSC

Security in GSM

On air interface, GSM uses encryption and TMSI instead of IMSI.

SIM is provided 4-8 digit PIN to validate the ownership of SIM

3 algorithms are specified :

- A3 algorithm for authentication

- A5 algorithm for encryption

Page 32: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

- A8 algorithm for key generation

Characteristics of GSM Standard

Fully digital system using 900,1800 MHz frequency band.

TDMA over radio carriers(200 KHz carrier spacing.

8 full rate or 16 half rate TDMA channels per carrier.

User/terminal authentication for fraud control.

Encryption of speech and data transmission over the radio path.

Full international roaming capability.

Low speed data services (upto 9.6 Kb/s).

Compatibility with ISDN.

Support of Short Message Service (SMS).

Advantages of GSM over Analog system:

Capacity increases

Reduced RF transmission power and longer battery life.

International roaming capability.

Better security against fraud (through terminal validation and user authentication).

Encryption capability for information security and privacy.

Compatibility with ISDN,leading to wider range of services

GSM Applications

Mobile telephony

GSM-R

Telemetry System

- Fleet management

Page 33: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

- Automatic meter reading

- Toll Collection

- Remote control and fault reporting of DG sets

Value Added Services

Future Of GSM

2nd Generation

GSM -9.6 Kbps (data rate)

2.5 Generation ( Future of GSM)

HSCSD (High Speed ckt Switched data)

Data rate : 76.8 Kbps (9.6 x 8 kbps)

GPRS (General Packet Radio service)

Data rate: 14.4 - 115.2 Kbps

EDGE (Enhanced data rate for GSM Evolution)

Data rate: 547.2 Kbps (max)

3 Generation

WCDMA(Wide band CDMA)

Data rate : 0.348 – 2.0 Mbps

Figure 2.2 The structure of a GSM network

CHAPTER 3

Problem formulation

Page 34: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

The problem with the traffic system is that for every minute the vehicles at the 4-way road will be heavy and the traffic lights shall be changed to each side for some fixed time. Even though there are no vehicles at particular side, the traffic signals will glow for given fixed time.Due to that there is time waste process. Due to this other side vehicles have to wait for the time to complete the process. If any ambulance comes near or when the ambulance at emergency comes to any traffic post the traffic signals automatically stop the other 3 sides with giving red signal and give green signal for this ambulance. So that for this implementation we using different technology such IR, RF and GSM communication.

Page 35: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

CHAPTER 4

System Specification

4.1 89S52 Micro Controller

Features:

• Compatible with MCS-51® Products

• 8K Bytes of In-System Programmable (ISP) Flash Memory

– Endurance: 1000 Write/Erase Cycles

• 4.0V to 5.5V Operating Range

• Fully Static Operation: 0 Hz to 33 MHz

• Three-level Program Memory Lock

• 256 x 8-bit Internal RAM

• 32 Programmable I/O Lines

• Three 16-bit Timer/Counters

• Eight 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

Page 36: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Description

The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K

bytes of in-system programmable Flash memory. The device is manufactured using Atmel’s

high-density nonvolatile memory technology and is compatible with the industry- standard

80C51 instruction set and pin out. 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

AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective

solution to many embedded control applications.

The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of

RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector

two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry.

In addition, the AT89S52 is designed with static logic for 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

Page 37: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

functions until the next interrupt or hardware reset.

Page 38: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital
Page 39: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Pin Description

VCC: Pin 40 provides supply voltage to the chip. The voltage source is + 5V.

GND: Pin 20 provides ground.

Port 0: Port 0 is an 8-bit open drain bidirectional 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 can 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 pull ups are required during program verification.

Port 1:Port 1 is an 8-bit bidirectional 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.

In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count

input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the

following table.

Port 1 also receives the low-order address bytes during Flash programming and

verification.

Page 40: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Port 2:Port 2 is an 8-bit bidirectional 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 memory that uses 16-bit addresses (MOVX @ DPTR). In

this application, Port 2 uses strong internal pull-ups when emitting 1s. During accesses to

external data memory that uses 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 bidirectional 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 AT89S52, as shown in

the following table.

Port 3 also receives some control signals for Flash programming and verification.

Page 41: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

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 96 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: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 ALE-disable 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

AT89S52 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.

Page 42: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

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.

XTAL1:Input to the inverting oscillator amplifier and input to the internal clock operating

circuit.

XTAL2:Output from the inverting oscillator amplifier.

Special Function Registers

A map of the on-chip memory area called the Special Function Register (SFR) space is

shown in Table 1. Note that not all of the addresses are occupied, and unoccupied addresses may

not be implemented on the chip. Read accesses to these addresses will in general return random

data, and write accesses will have an indeterminate effect.

User software should not write 1s to these unlisted locations, since they may be used in

future products to invoke new features. In that case, the reset or inactive values of the new bits

will always be 0.

Timer 2 Registers: Control and status bits are contained in registers T2CON (shown in Table 2)

and T2MOD (shown in Table 3) for Timer 2. The register pair (RCAP2H, RCAP2L) is the

Capture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.

Page 43: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Interrupt Registers: The individual interrupt enable bits are in the IE register. Two priorities can

be set for each of the six interrupt sources in the IP register.

Dual Data Pointer Registers: To facilitate accessing both internal and external data memory, two

banks of 16-bit Data Pointer Registers are provided: DP0 at SFR address locations 82H-83H and

DP1 at 84H-85H. Bit DPS = 0 in SFR AUXR1 selects DP0 and DPS = 1 selects DP1. The user

should always initialize the DPS bit to the appropriate value before accessing the respective Data

Pointer Register.

Power Off Flag: The Power Off Flag (POF) is located at bit 4 (PCON.4) in the PCON SFR. POF

is set to “1” during power up. It can be set and rest under software control and is not affected by

reset.

Memory Organization

Page 44: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

MCS-51 devices have a separate address space for Program and Data Memory. Up to

64K bytes each of external Program and Data Memory can be addressed.

Program Memory

If the EA pin is connected to GND, all program fetches are directed to external memory.

On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H through

1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are to

external memory.

Data Memory

The AT89S52 implements 256 bytes of on-chip RAM. The upper 128 bytes occupy a

parallel address space to the Special Function Registers. This means that the upper 128 bytes

have the same addresses as the SFR space but are physically separate from SFR space.

When an instruction accesses an internal location above address 7FH, the address mode

used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the

SFR space. Instructions which use direct addressing access of the SFR space.

For example, the following direct addressing instruction accesses the SFR at location

0A0H (which is P2).

MOV 0A0H, #data

Instructions that use indirect addressing access the upper 128 bytes of RAM. For

example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the

data byte at address 0A0H, rather than P2 (whose address is 0A0H).

MOV @R0, #data

Note that stack operations are examples of indirect addressing, so the upper 128 bytes of

data RAM are available as stack space.

Watchdog Timer

Page 45: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

(One-time Enabled with Reset-out)

The WDT is intended as a recovery method in situations where the CPU may be

subjected to software upsets. The WDT consists of a 13-bit counter and the Watchdog Timer

Reset (WDTRST) SFR. The WDT is defaulted to disable from exiting reset. To enable the WDT,

a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location 0A6H).

When the WDT is enabled, it will increment every machine cycle while the oscillator is running.

The WDT timeout period is dependent on the external clock frequency. There is no way to

disable the WDT except through reset (either hardware reset or WDT overflow (reset). When

WDT overflows, it will drive an output RESET HIGH pulse at the RST pin.

Using the WDT

To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST

register (SFR location 0A6H). When the WDT is enabled, the user needs to service it by writing

01EH and 0E1H to WDTRST to avoid a WDT overflow. The 13-bit counter overflows when it

reaches 8191 (1FFFH), and this will reset the device. When the WDT is enabled, it will

increment every machine cycle while the oscillator is running. This means the user must reset the

WDT at least every 8191 machine cycles. To reset the WDT the user must write 01EH and 0E1H

to WDTRST. DTRST is a write-only register. The WDT counter cannot be read or written.

When WDT overflows, it will generate an output RESET pulse at the RST pin. The RESET

pulse duration is 96xTOSC, where TOSC=1/FOSC. To make the best use of the WDT, it should

be serviced in those sections of code that will periodically be executed within the time required

to prevent a WDT reset.

WDT during Power-down and Idle

In Power-down mode the oscillator stops, which means the WDT also stops. While in

Power-down mode, the user does not need to service the WDT. There are two methods of exiting

Power-down mode: by a hardware reset or via a level-activated external interrupt which is

enabled prior to entering Power-down mode. When Power-down is exited with hardware reset,

servicing the WDT should occur as it normally does whenever the AT89S52 is reset. Exiting

Page 46: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Power-down with an interrupt is significantly different. The interrupt is held low long enough for

the oscillator to stabilize. When the interrupt is brought high, the interrupt is serviced. To prevent

the WDT from resetting the device while the interrupt pin is held low, the WDT is not started

until the interrupt is pulled high. It is suggested that the WDT be reset during the interrupt

service for the interrupt used to exit Power-down mode.

To ensure that the WDT does not overflow within a few states of exiting Power-down, it

is best to reset the WDT just before entering Power-down mode.

Before going into the IDLE mode, the WDIDLE bit in SFR AUXR is used to determine

whether the WDT continues to count if enabled. The WDT keeps counting during IDLE

WDIDLE bit = 0) as the default state. To prevent the WDT from resetting the AT89S52 while in

IDLE mode, the user should always set up a timer that will periodically exit IDLE, service the

WDT, and reenter IDLE mode. With WDIDLE bit enabled, the WDT will stop to count in IDLE

mode and resumes the count upon exit from IDLE.

UART

Serial data communication uses two methods, asynchronous and synchronous. The synchronous

method transfers a block of data (characters ) at a time, while the asynchronous method transfers

a single byte at a time. It is possible to write software to use either of these methods, but

programs can be tedious and long. For this reason, there are special IC chips made by the

manufacturers for the serial data communications. These chips are commonly referred to as

UART ( universal asynchronous receiver-transmitter) and USART ( universal synchronous

receiver-transmitter). The 8052 has built-in UART.

Timer 0

The 16-bit register of timer 0 is accessed as low byte and high byte. The low byte register is

called TL0 ( Timer 0 low byte) and the high byte register is referred to as TH0 ( Timer 0 high

Page 47: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

byte). These registers can be accessed like any other registers , such as A,B,R0,R1,R2 etc. for

example the instruction “MOV TL0,#4FH” moves the value 4FH into TL0, the low byte of

Timer 0. These registers can also be read like any other register. For example, “MOV R5,TH0”

saves TH0 ( high byte of Timer 0) in R5.

Timer1

Timer 1 is also 16 bits and its 16-bit register is split into two bytes, referred to as TL1 (Timer 1

low byte ) and TH1 ( Timer 1 high byte). These registers are accessible in the same way as the

registers of Timer 0.

Timer 2

Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter.

The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 2). Timer 2 has

three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The

modes are selected by bits in T2CON, as shown in Table 3. Timer 2 consists of two 8-bit

registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine

cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the

oscillator frequency.

In the Counter function, the register is incremented in esponse to a 1-to-0 transition at its

corresponding external input pin, T2. In this function, the external input is sampled during S5P2

of every machine cycle. When the samples show a high in one cycle and a low in the next cycle,

the count is incremented. The new count value appears in the register during S3P1 of the cycle

following the one in which the transition was detected. Since two machine cycles (24 oscillator

periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the

Page 48: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

oscillator frequency. To ensure that a given level is sampled at least once before it changes, the

level should be held for at least one full machine cycle.

Capture Mode

In the capture mode, two options are selected by bit EXEN2 in T2CON. If EXEN2 = 0,

Timer 2 is a 16-bit timer or counter which upon overflow sets bit TF2 in T2CON.

This bit can then be used to generate an interrupt. If EXEN2 = 1, Timer 2 performs the same

operation, but a 1- to-0 transition at external input T2EX also causes the current value in TH2

and TL2 to be captured into RCAP2H and RCAP2L, respectively. In addition, the transition at

T2EX causes bit EXF2 in T2CON to be set. The EXF2 bit, like TF2, can generate an interrupt.

The capture mode is illustrated in Figure 5.

Auto-reload (Up or Down Counter)

Timer 2 can be programmed to count up or down when configured in its 16-bit auto-

reload mode. This feature is invoked by the DCEN (Down Counter Enable) bit located in the

SFR T2MOD (see Table 4). Upon reset, the DCEN bit is set to 0 so that timer 2 will default to

count up. When DCEN is set, Timer 2 can count up or down, depending on the value of the

T2EX pin.

options are selected by bit EXEN2 in T2CON. If EXEN2 = 0, Timer 2 counts up to 0FFFFH and

then sets the TF2 bit upon overflow. The overflow also causes the timer registers to be reloaded

with the 16-bit value in RCAP2H and RCAP2L. The values in Timer in Capture ModeRCAP2H

and RCAP2L are preset by software. If EXEN2 = 1, a 16-bit reload can be Figure 6 shows Timer

Page 49: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

2 automatically counting up when DCEN=0. In this mode, two triggered either by an overflow or

by a 1-to-0 transition at external input T2EX. This transition also sets the EXF2 bit. Both the

TF2 and EXF2 bits can generate an interrupt if enabled.

Setting the DCEN bit enables Timer 2 to count up or down, as shown in Figure 6. In this

mode, the T2EX pin controls the direction of the count. A logic 1 at T2EX makes Timer 2 count

up. The timer will overflow at 0FFFFH and set the TF2 bit. This overflow also causes the 16-bit

value in RCAP2H and RCAP2L to be reloaded into the timer registers, TH2 and TL2,

respectively. A logic 0 at T2EX makes Timer 2 count down. The timer underflows when TH2

and TL2 equal the values stored in RCAP2H and RCAP2L. The underflow sets the TF2 bit and

causes 0FFFFH to be reloaded into the timer registers .The EXF2 bit toggles whenever Timer 2

overflows or underflows and can be used as a 17th bit of resolution. In this operating mode,

EXF2 does not flag an interrupt.

Page 50: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Timer 2 is selected as the baud rate generator by setting TCLK and/or RCLK in T2CON

(Table 2). Note that the baud rates for transmit and receive can be different if Timer 2 is used for

the receiver or transmitter and Timer 1 is used for the other function. Setting RCLK and/or

TCLK puts Timer 2 into its baud rate generator mode, as shown in Figure 8. The baud rate

generator mode is similar to the auto-reload mode, in that a rollover in TH2 causes the Timer 2

registers to be reloaded with the 16-bit value in registers RCAP2H and RCAP2L, which are

preset by software. The baud rates in Modes 1 and 3 are determined by Timer 2’s overflow rate

according to the following equation.

The Timer can be configured for either timer or counter operation. In most applications, it

is configured for timer operation (CP/T2 = 0). The timer operation is different for Timer 2 when

it is used as a baud rate generator. Normally, as a timer, it increments every machine cycle (at

Page 51: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

1/12 the oscillator frequency). As a baud rate generator, however, it increments every state time

(at 1/2 the oscillator frequency). The baud rate formula is given below.

Where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2L taken as a 16-bit

unsigned integer. Timer 2 as a baud rate generator is shown in Figure 8. This figure is valid only

if RCLK or TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2 and will not

generate an interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition in T2EX will set EXF2

but will not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus, when Timer 2 is in

use as a baud rate generator, T2EX can be used as an extra external interrupt. Note that when

Timer 2 is running (TR2 = 1) as a timer in the baud rate generator mode, TH2 or TL2 should not

be read from or written to. Under these conditions, the Timer is incremented every state time,

and the results of a read or write may not be accurate. The RCAP2 registers may be read but

should not be written to; because a write might overlap a reload and cause write and/or reload

errors. The timer should be turned off (clear TR2) before accessing the Timer 2 or RCAP2

registers.

Interrupts

The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and

INT1), three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. These interrupts

are all shown in Figure 10. Each of these interrupt sources can be individually enabled or

disabled by setting or clearing a bit in Special Function Register IE. IE also contains a global

disable bit, EA, which disables all interrupts at once. Note that Table 5 shows that bit position

IE.6 is unimplemented. In the AT89S52, bit position IE.5 is also unimplemented. User software

should not write 1s to these bit positions, since they may be used in future AT89 products. Timer

2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register T2CON. Neither of

these flags is cleared by hardware when the service routine is vectored to. In fact, the service

routine may have to determine whether it was TF2 or EXF2 that generated the interrupt, and that

bit will have to be cleared in software. The Timer 0 and Timer 1 flags, TF0 and TF1, are set at

S5P2 of the cycle in which the timers overflow. The values are then polled by the circuitry in the

Page 52: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

next cycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled in the same cycle in

which the timer overflows.

Oscillator Characteristics

XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be

configured for use as an on-chip oscillator, as shown in Figure 11. 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 12. 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

Page 53: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

and low time specifications must be observed. Oscillator connections

Note: C1, C2 = 30 pF ± 10 pF for Crystals

= 40 pF ± 10 pF for Ceramic Resonators

Asynchronous serial communication and data framing

The data coming in the receiving end of the data line in a serial data

transfer is all 0’s and 1’s; it is difficult to make sense of the data unless the sender and receiver

agree on a set of rules, a protocol, on how the data is packed, how many bits constitute the

character, and when the data begins and ends.

4.8.1 Start and Stop bits

Asynchronous serial data communication is widely used for character

orientation transmissions. In the asynchronous method, each character is placed between start

and stop bits. This is called the framing. In data framing for asynchronous communications, the

data, such as ASCII characters, are packed in between a start and stop bits. The start bit is always

one-bit but the stop bit can be one or two bits. The start bit is always a 0 and the stop bit is 1.

4.8.2. Parity Bit

In some systems in order to maintain data integrity, the parity bit of the character

byte is included in the data frame. This means that for each character we have a single parity bit

in addition to start and stop bits. The parity bit is odd or even. In case of odd parity bit the

number of data bits of a book of including the parity bit, is even.

Page 54: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

4.8.3 Data Transfer rate

The rate of data transfer in serial data communication is stated in bps or

it can be called as baud rate. Baud rate is defined as the number of signal changes per second. As

far as the conductor wire is concerned, the baud rates as bps are the same.

Figure 4.10: DATA FRAMING

Figure 4.11: Data Transfer between 89C51 and System

Page 55: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

4.9 Registers used for Communication

4.9.1. SBUF Register:

SBUF is an 8 bit register used solely for serial communication in the 8051. For

byte of data to be transfers via TxD line, it must be placed in SBUF register. SBUF also holds

the byte of data when it is received by the 8051’s RxD line.

The moment a byte is written into SBUF, it is framed with the start and stop

bits and transferred serially via TxD line. Similarly when bits are received serially via RxD, the

8051 defames it by eliminating a byte out of the received, and then placing it in the SBUF.

4.9 .2.SCON (Serial control register):

Bit addressable

Address location 98H

Figure 4.12: SCON register:

REN- Set or cleared by software to enable or disable reception.

TB8- Not widely used

RB8- Not widely used

TI- Transmits interrupt flag. Set by hardware at the beginning of the stop bit in mode 1.

It must be cleared by software

RI- Received interrupts flag. Set by hardware halfway through the stop bit mode 1. It must

be cleared by software.

Page 56: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

SM0 SM1 Serial mode 0

0 0 Synchronous mode

0 1 8-bit data, 1 start bit, 1 stop

bit, variable baud rate

1 0 9-bit data, 1 start bit, 1 stop

bit, fixed baud rate

1 1 9-bit data, 1 start bit, 1 stop

bit, variable baud rate

Figure 4.13: UART modes

4.10.MAX232 Driver/Receiver:

This module is primary of interest for people building their own electronics with an RS-232

interface. Off-the-shelf computers with RS-232 interfaces already contain the necessary

electronics, and there is no need to add the circuitry as described here.

Serial RS-232 (V.24) communication works with voltages (-15V ... -3V for high [sic]) and

+3V ... +15V for low [sic]) which are not compatible with normal computer logic voltages. On

the other hand, classic TTL computer logic operates between 0V ... +5V (roughly 0V ... +0.8V

for low, +2V ... +5V for high). Modern low-power logic operates in the range of 0V ... +3.3V or

even lower.

So, the maximum RS-232 signal levels are far too high for computer logic electronics, and the

negative RS-232 voltage for high can't be grokked at all by computer logic. Therefore, to receive

serial data from an RS-232 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.

RS-232 TTL Logic

-----------------------------------------------

-15V ... -3V <-> +2V ... +5V <-> high

Page 57: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

+3V ... +15V <-> 0V ... +0.8V <-> low

Figure 4.14 Voltage levels for RS232 and TTL

All this can be done with conventional analog electronics, e.g. a particular power supply and a

couple of transistors or the once popular 1488 (transmitter) and 1489 (receiver) ICs. However,

since more than a decade it has become standard in amateur electronics to do the necessary

signal level conversion with an integrated circuit (IC) from the MAX232 family (typically a

MAX232A or some clone). In fact, it is hard to find some RS-232 circuitry in amateur

electronics without a MAX232A or some clone.

The MAX232 from Maxim was the first IC which in one package contains the necessary drivers

(two) and receivers (also two), to adapt the RS-232 signal voltage levels to TTL logic. It became

popular, because it just needs one voltage (+5V) and generates the necessary RS-232 voltage

levels (approx. -10V and +10V) internally. This greatly simplified the design of circuitry.

Circuitry designers no longer need to design and build a power supply with three voltages (e.g. -

12V, +5V, and +12V), but could just provide one +5V power supply, e.g. with the help of a

simple 78x05 voltage converter.

The MAX232 has a successor, the MAX232A. The ICs are almost identical, however, the

MAX232A is much more often used (and easier to get) than the original MAX232, and the

MAX232A only needs external capacitors 1/10th the capacity of what the original MAX232

needs.

It should be noted that the MAX232(A) is just a driver/receiver. It does not generate the

necessary RS-232 sequence of marks and spaces with the right timing, it does not decode the RS-

232 signal, it does not provide a serial/parallel conversion. All it does is to convert signal voltage

levels. Generating serial data with the right timing and decoding serial data has to be done by

additional circuitry, e.g. by a 16550 UART or one of these small micro controllers (e.g. Atmel

AVR, Microchip PIC) getting more and more popular.

The MAX232 and MAX232A were once rather expensive ICs, but today they are cheap. It has

also helped that many companies now produce clones (ie. Sipex). These clones sometimes need

Page 58: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

different external circuitry, e.g. the capacities of the external capacitors vary. It is recommended

to check the data sheet of the particular manufacturer of an IC instead of relying on Maxim's

original data sheet.

The original manufacturer (and now some clone manufacturers, too) offers a large series of

similar ICs, with different numbers of receivers and drivers, voltages, built-in or external

capacitors, etc. E.g. The MAX232 and MAX232A need external capacitors for the internal

voltage pump, while the MAX233 has these capacitors built-in. The MAX233 is also between

three and ten times more expensive in electronic shops than the MAX232A because of its

internal capacitors. It is also more difficult to get the MAX233 than the garden variety

MAX232A.A similar IC, the MAX3232 is nowadays available for low-power 3V logic.

4.11 MAX232Application:

The MAX232(A) has two receivers (converts from RS-232 to TTL voltage levels) and two

drivers (converts from TTL logic to RS-232 voltage levels). This means only two of the RS-232

signals can be converted in each direction. The old MC1488/1498 combo provided four drivers

and receivers.

Typically a pair of a driver/receiver of the MAX232 is used for TX and RX and the second one

for CTS and RTS. There are not enough drivers/receivers in the MAX232 to also connect the

DTR, DSR, and DCD signals. Usually these signals can be omitted when e.g. communicating

with a PC's serial interface. If the DTE really requires these signals either a second MAX232 is

needed, or some other IC from the MAX232 family can be used (if it can be found in consumer

electronic shops at all). An alternative for DTR/DSR is also given below.Maxim's data sheet

explains the MAX232 family in great detail, including the pin configuration and how to connect

such an IC to external circuitry. Exactly to connect the RS-232 signals to the IC. So here is one

possible example:

MAX232 Pin Nbr. MAX232 Pin Name Signal Voltage DB9 Pin

Page 59: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

7 T2out CTS RS-232 7

8 R2in RTS RS-232 8

9 R2out RTS TTL n/a

10 T2in CTS TTL n/a

11 T1in TX TTL n/a

12 R1out RX TTL n/a

13 R1in RX RS-232 2

14 T1out TX RS-232 3

15 GND GND 0 5

Figure 4.15 RS232-DB9 pin Diagram

5.

LIQUID CRYSTAL DISPLAY:

LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing LEDs (seven

segment LEDs or other multi segment LEDs) because of the following reasons:

1. The declining prices of LCDs.

2. The ability to display numbers, characters and graphics. This is in contrast to LEDs,

which are limited to numbers and a few characters.

Page 60: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the

task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep

displaying the data.

4. Ease of programming for characters and graphics.

These components are “specialized” for being used with the microcontrollers, which means that

they cannot be activated by standard IC circuits. They are used for writing different messages on

a miniature LCD.

A model described here is for its low price and great possibilities most frequently

used in practice. It is based on the HD44780 microcontroller (Hitachi) and can display messages

in two lines with 16 characters each . It displays all the alphabets, Greek letters, punctuation

marks, mathematical symbols etc. In addition, it is possible to display symbols that user makes

up on its own. Automatic shifting message on display (shift left and right), appearance of the

pointer, backlight etc. are considered as useful characteristics.

Pins Functions

There are pins along one side of the small printed board used for connection to the

microcontroller. There are total of 14 pins marked with numbers (16 in case the background light

is built in). Their function is described in the table below:

Page 61: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Function Pin Number Name Logic State Description

Ground 1 Vss - 0V

Power supply 2 Vdd - +5V

Contrast 3 Vee - 0 - Vdd

Control of

operating

4 RS0

1

D0 – D7 are interpreted as

commands

D0 – D7 are interpreted as data

5 R/W0

1

Write data (from controller to LCD)

Read data (from LCD to controller)

6 E

0

1

From 1 to 0

Access to LCD disabled

Normal operating

Data/commands are transferred to

LCD

Data / commands

7 D0 0/1 Bit 0 LSB

8 D1 0/1 Bit 1

9 D2 0/1 Bit 2

10 D3 0/1 Bit 3

11 D4 0/1 Bit 4

12 D5 0/1 Bit 5

13 D6 0/1 Bit 6

14 D7 0/1 Bit 7 MSB

LCD screen:

Page 62: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

LCD screen consists of two lines with 16 characters each. Each character consists

of 5x7 dot matrix. Contrast on display depends on the power supply voltage and whether

messages are displayed in one or two lines. For that reason, variable voltage 0-Vdd is applied on

pin marked as Vee. Trimmer potentiometer is usually used for that purpose. Some versions of

displays have built in backlight (blue or green diodes). When used during operating, a resistor for

current limitation should be used (like with any LE diode).

LCD Basic Commands

All data transferred to LCD through outputs D0-D7 will be interpreted as commands or as data,

which depends on logic state on pin RS:

RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built in processor

addresses built in “map of characters” and displays corresponding symbols. Displaying position

is determined by DDRAM address. This address is either previously defined or the address of

previously transferred character is automatically incremented.

RS = 0 - Bits D0 - D7 are commands which determine display mode. List of commands which

LCD recognizes are given in the table below:

Command RS R D7 D6 D5 D4 D3 D2 D1 D0 Execution

Page 63: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

W Time

Clear display 0 0 0 0 0 0 0 0 0 1 1.64mS

Cursor home 0 0 0 0 0 0 0 0 1 x 1.64mS

Entry mode set 0 0 0 0 0 0 0 1 I/D S 40uS

Display on/off control 0 0 0 0 0 0 1 D U B 40uS

Cursor/Display Shift 0 0 0 0 0 1 D/C R/L x x 40uS

Function set 0 0 0 0 1 DL N F x x 40uS

Set CGRAM address 0 0 0 1 CGRAM address 40uS

Set DDRAM address 0 0 1 DDRAM address 40uS

Read “BUSY” flag (BF) 0 1 BF DDRAM address -

Write to CGRAM or

DDRAM1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS

Read from CGRAM or

DDRAM1 1 D7 D6 D5 D4 D3 D2 D1 D0 40uS

I/D 1 = Increment (by 1) R/L 1 = Shift right

0 = Decrement (by 1) 0 = Shift left

S 1 = Display shift on DL 1 = 8-bit interface

0 = Display shift off 0 = 4-bit interface

D 1 = Display on N 1 = Display in two lines

Page 64: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

0 = Display off 0 = Display in one line

U 1 = Cursor on F 1 = Character format 5x10 dots

0 = Cursor off 0 = Character format 5x7 dots

B 1 = Cursor blink on D/C 1 = Display shift

0 = Cursor blink off 0 = Cursor shift

LCD Connection

Depending on how many lines are used for connection to the microcontroller, there are 8-

bit and 4-bit LCD modes. The appropriate mode is determined at the beginning of the process in

a phase called “initialization”. In the first case, the data are transferred through outputs D0-D7 as

it has been already explained. In case of 4-bit LED mode, for the sake of saving valuable I/O

pins of the microcontroller, there are only 4 higher bits (D4-D7) used for communication, while

other may be left unconnected.

Consequently, each data is sent to LCD in two steps: four higher bits are sent first (that

normally would be sent through lines D4-D7), four lower bits are sent afterwards. With the help

of initialization, LCD will correctly connect and interpret each data received. Besides, with

regards to the fact that data are rarely read from LCD (data mainly are transferred from

microcontroller to LCD) one more I/O pin may be saved by simple connecting R/W pin to the

Ground. Such saving has its price. Even though message displaying will be normally performed,

it will not be possible to read from busy flag since it is not possible to read from display.

LCD Initialization

Once the power supply is turned on, LCD is automatically cleared. This process lasts for

approximately 15mS. After that, display is ready to operate. The mode of operating is set by

default. This means that:

1. Display is cleared

Page 65: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

2. Mode

DL = 1 Communication through 8-bit interface

N = 0 Messages are displayed in one line

F = 0 Character font 5 x 8 dots

3. Display/Cursor on/off

D = 0 Display off

U = 0 Cursor off

B = 0 Cursor blink off

4. Character entry

ID = 1 Addresses on display are automatically incremented by 1

S = 0 Display shift off

Automatic reset is mainly performed without any problems. Mainly but not always! If for

any reason power supply voltage does not reach full value in the course of 10mS, display will

start perform completely unpredictably. If voltage supply unit can not meet this condition or if it

is needed to provide completely safe operating, the process of initialization by which a new reset

enabling display to operate normally must be applied.

Algorithm according to the initialization is being performed depends on whether

connection to the microcontroller is through 4- or 8-bit interface. All left over to be done after

that is to give basic commands and of course- to display messages.

Page 66: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Fig: Procedure on 8-bit initialization.

CONTRAST CONTROL:

To have a clear view of the characters on the LCD, contrast should be adjusted. To adjust the

contrast, the voltage should be varied. For this, a preset is used which can behave like a variable

voltage device. As the voltage of this preset is varied, the contrast of the LCD can be adjusted.

Potentiometer

Variable resistors used as potentiometers have all three terminals connected.

This arrangement is normally used to vary voltage, for example to set the switching point of a

circuit with a sensor, or control the volume (loudness) in an amplifier circuit. If the terminals at

the ends of the track are connected across the power supply, then the wiper terminal will provide

a voltage which can be varied from zero up to the maximum of the supply.

Page 67: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

These are miniature versions of the standard variable resistor. They are designed to be mounted

directly onto the circuit board and adjusted only when the circuit is built. For example to set the

frequency of an alarm tone or the sensitivity of a light-sensitive circuit. A small screwdriver or

similar tool is required to adjust presets.

Presets are much cheaper than standard variable resistors so they are sometimes used in projects

where a standard variable resistor would normally be used.

Multiturn presets are used where very precise adjustments must be made. The screw must be

turned many times (10+) to move the slider from one end of the track to the other, giving very

fine control.

LCD INTERFACING WITH THE MICROCONTROLLER:

Potentiometer Symbol 

Preset Symbol

 

Page 68: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Vcc

Gnd

PRESET(CONTRAST CONTROL)

Vcc FOR BACKLIGHT PURPOSE

Infrared LED (IR LED)

P2.0

P2.1

P2.2

4 (RS) 1

5 (R/W) 2

6(EN) 3

LCD

D0

Gnd

Page 69: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

IR sensor is the combination of IR LED with PHOTO DIODE. After this combination

we are connecting the DARLINGTON PAIR TRANSISTOR. End of the IR sensor we have to

connect a NOT gate for the inverting purpose means low input have corresponding low

outputInfra-Red actually is normal light with a particular colour. We humans can't see this

colour because its wave length of 950nm is below the visible spectrum. That's one of the reasons

why IR is chosen for remote control purposes, we want to use it but we're not interested in seeing

it. Another reason is because IR LEDs are quite easy to make, and therefore can be very cheap.

Although we humans can't see the Infra-Red light emitted from a remote control doesn't

mean we can't make it visible. A video camera or digital photo camera can "see" the Infra-Red

light as you can see in this picture. If you own a web cam, point your remote to it, press

any button and you'll see the LED flicker. They do dozens of different jobs and are found in all

kinds of devices. Among other things, they form the numbers on digital clocks, transmit

information from remote controls, light up watches and tell you when your appliances are turned

on. Collected together, they can form images on a jumbo television screen or illuminate a traffic

light.

FIG.3.1 IR LED USED IN REMOTE CONTROL

DARLINGTON PAIR:

Page 70: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

An emitter follower offers high impedance of 500Kohms. For applications requiring still higher

input impedance, we may use what is called Darlington in place of conventional transistor. This

Darlington pair basically consists of two transistors cascaded in cc configuration. In the figure

shown below the input impedance of the second transistor

Constitutes the load impedance of the first.

We thus conclude that in comparison with a conventional single transistor emitter follower has in

higher current gain, higher input impedance and almost the same voltage gain lower out put

impedances.

Fig: Darlington Pair

Modulation

Modulation is the answer to make our signal stand out above the noise. With modulation we make the IR light source blink in a particular frequency. The IR receiver will be tuned to that frequency, so it can ignore everything else. You can think of this blinking as attracting the receiver's attention. We humans also notice the blinking of yellow lights at construction sites instantly, even in bright daylight.

Page 71: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

In the picture above you can see a modulated signal driving the IR LED of the transmitter on the left side. The detected signal is coming out of the receiver at the other side.

In serial communication we usually speak of 'marks' and 'spaces'. The 'space' is the default signal, which is the off state in the transmitter case. No light is emitted during the 'space' state. During the 'mark' state of the signal the IR light is pulsed on and off at a particular frequency. Frequencies between 30kHz and 60kHz are commonly used in consumer electronics. At the receiver side a 'space' is represented by a high level of the receiver's output. A 'mark' is then automatically represented by a low level.

Please note that the 'marks' and 'spaces' are not the 1-s and 0-s we want to transmit. The real relationship between the 'marks' and 'spaces' and the 1-s and 0-s depends on the protocol that's being used. More information about that can be found on the pages that describe the protocols.

TRANSMITTER:

In the picture below we can see a modulated signal driving the IR LED of the transmitter

on the left side. The detected signal is coming out of the receiver at the other side.

:

FIG.3.2 IR TRANSMITTER

The transmitter usually is a battery powered handset. It should consume as little power as

possible, and the IR signal should also be as strong as possible to achieve an acceptable control

distance. Preferably it should be shock proof as well.

Page 72: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Many chips are designed to be used as IR transmitters. The older chips were dedicated to

only one of the many protocols that were invented. Nowadays very low power microcontrollers

are used in IR transmitters for the simple reason that they are more flexible in their use. When no

button is pressed they are in a very low power sleep mode, in which hardly any current is

consumed. The processor when wakes up to transmit the appropriate IR command only a key is

pressed

FIG.3.3 TRANSISTOR CIRCUIT USED TO DRIVE IR LED

Quartz crystals are seldom used in such handsets. They are very fragile and tend to break

easily when the handset is dropped. Ceramic resonators are much more suitable here, because

they can withstand larger physical shocks. The fact that they are a little less accurate is not

important.

The current through the LED (or LEDs) can vary from 100mA to well over 1A! In order

to get an acceptable control distance the LED currents have to be as high as possible. A trade-off

should be made between LED parameters, battery lifetime and maximum control distance. LED

currents can be that high because the pulses driving the LEDs are very short. Average power

dissipation of the LED should not exceed the maximum value though. You should also see to it

Page 73: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

that the maximum peek current for the LED is not exceeded. All these parameters can be found

in the LED's data sheet.

A simple transistor circuit can be used to drive the LED. A transistor with a suitable hfe

and switching speed should be selected for this purpose. The resistor values can simply be

calculated using Ohm's law. Remember that the nominal voltage drop over an IR LED is

approximately 1.1V. The normal driver, described above, has one disadvantage. As the battery

voltage drops, the current through the LED will decrease as well. This will result in a shorter

control distance that can be covered.

An emitter follower circuit can avoid this. The 2 diodes in series will limit the pulses on the base

of the transistor to 1.2V. The base-emitter voltage of the transistor subtracts 0.6V from that,

resulting in constant amplitude of 0.6V at the emitter. This constant amplitude across a constant

resistor results in current pulses of a constant magnitude. Calculating the current through the

LED is simply applying ohm’ law.

PHOTODIODES:

Unfortunately for us there are many more sources of Infrared light. The sun is the

brightest source of all, but there are many others, like: light bulbs, candles, central heating

system, and even our body radiates Infrared light. In fact everything that radiates heat, also

radiates Infrared light. Therefore we have to take some precautions to guarantee that our IR

message gets across to the receiver with out errors.

Photodiodes are used for the detection of optical power (UV, Visible, and IR) and for

the conversion of optical power to electrical power. The photodiode spectral response can be

measured in X-ray, UV, visible, or IR.  X-ray photodiodes are optimized for X-ray, gamma ray,

and beta radiation detection.

 UV enhanced photodiodes are optimized for the UV and blue spectral regions, Photodiodes are a

two-electrode, radiation-sensitive junction formed in a semiconductor material in which the

Page 74: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

reverse current varies with illumination. Photodiodes are used for the detection of optical power

and for the conversion of optical power to electrical power. Photodiodes can be PN, PIN, or

avalanche.  PN photodiodes feature a two-electrode, radiation-sensitive PN junction formed in a

semiconductor material in which the reverse current varies with illumination.  PIN photodiodes

are  diodes with a large intrinsic region sandwiched between P-doped and N-doped

semiconducting regions.  Photons absorbed in this region create electron-hole pairs that are then

separated by an electric field, thus generating an electric current in a load circuit

Page 75: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

4.12 RF Module:

Radio frequency (abbreviated RF) is a term that refers to alternating current (AC) having

characteristics such that, if the current is input to an antenna, an electromagnetic (EM) field is

generated suitable for wireless broadcasting and/or communications. These frequencies cover a

significant portion of the electromagnetic radiation spectrum, extending from nine kilohertz (9

kHz),the lowest allocated wireless communications frequency (it's within the range of human

hearing), to thousands of gigahertz(GHz).

When an RF current is supplied to an antenna, it gives rise to an electromagnetic field that

propagates through space. This field is sometimes called an RF field; in less technical jargon it is

a "radio wave." Any RF field has a wavelength that is inversely proportional to the frequency. In

the atmosphere or in outer space, if f is the frequency in megahertz and sis the wavelength in

meters, then

s = 300/f

The frequency of an RF signal is inversely proportional to the wavelength

of the EM field to which it corresponds. At 9 kHz, the free-space wavelength is approximately

33 kilometers (km) or 21 miles (mi). At the highest radio frequencies, the EM wavelengths

measure approximately one millimeter (1 mm). As the frequency is increased beyond that of the

RF spectrum, EM energy takes the form of infrared (IR), visible, ultraviolet (UV), X rays, and

gamma rays.

Many types of wireless devices make use of RF fields. Cordless and cellular telephone, radio and

television broadcast stations, satellite communications systems, and two-way radio services all

operate in the RF spectrum. Some wireless devices operate at IR or visible-light frequencies,

whose electromagnetic wavelengths are shorter than those of RF fields. Examples include most

television-set remote-control boxes Some cordless computer keyboards and mice, and a few

wireless hi-fi stereo headsets.

Page 76: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

The RF spectrum is divided into several ranges, or bands. With the exception of the lowest-

frequency segment, each band represents an increase of frequency corresponding to an order of

magnitude (power of 10). The table depicts the eight bands in the RF spectrum, showing

frequency and bandwidth ranges. The SHF and EHF bands are often referred to as the microwave

The main requirements for the communication using RF are:

RF Transmitter

RF Receiver

Encoder and Decoder

RF TRANSMITTER STT-433MHz:

The STT-433 is ideal for remote control applications where low cost and longer range is

required.

The transmitter operates from a1.5-12V supply, making it ideal for battery-powered

applications.

The transmitter employs a SAW-stabilized oscillator, ensuring accurate frequency control for

best range performance.

The manufacturing-friendly SIP style package and low-cost make the STT-433 suitable for high

volume applications.

Features:

433.92 MHz Frequency

Low Cost

Page 77: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

1.5-12V operation

Small size

PIN DESCRIPTION:

GND Transmitter ground. Connect to ground plane

DATA Digital data input. This input is CMOS compatible and should be driven with CMOS level inputs.

VCC Operating voltage for the transmitter. VCC should be bypassed with a .01uF ceramic capacitor and

filtered with a 4.7uF tantalum capacitor. Noise on the power supply will degrade transmitter noise

performance.

ANT 50 ohm antenna output. The antenna port impedance affects output power and harmonic

emissions. Antenna can be single core wire of approximately 17cm length or PCB trace antenna.

CONNECTION:

Page 78: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

The typical connection shown in the above figure cannot work exactly at all times because there will be

no proper synchronization between the transmitter and the microcontroller unit. i.e., whatever the

microcontroller sends the data to the transmitter, the transmitter is not able to accept this data as this

will be not in the radio frequency range. Thus, we need an intermediate device which can accept the

input from the microcontroller, process it in the range of radio frequency range and then send it to the

transmitter. Thus, an encoder is used. The encoder used here is HT640 from HOLTEK SEMICONDUCTORS

INC.

ENCODER HT640:

PIN DESCRIPTION:

The 318 (3 power of 18) series of encoders begins a three-word transmission cycle upon receipt of a

transmission enable (TE for the HT600/HT640/HT680 or D12~D17 for the HT6187/HT6207/HT6247,

Page 79: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

active high). This cycle will repeat itself as long as the transmission enable (TE or D12~D17) is held high.

Once the transmission enable falls low, the encoder output completes its final cycle and then stops as

shown below.

Address/data programming (preset)

The status of each address/data pin can be individually preset to logic high, logic low, or floating. If a

transmission enable signal is applied, the encoder scans and transmits the status of the 18 bits of

address/data serially in the order A0 to AD17.

Transmission enable

For the TE trigger type of encoders, transmission is enabled by applying a high signal to the TE pin. But

for the Data trigger type of encoders, it is enabled by applying a high signal to one of the data pins

D12~D17.

ASIC APPLICATION CIRCUIT OF HT640 ENCODER:

Page 80: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

DEMO CIRCUIT: Transmission Circuit

The data sent from the microcontroller is encoded and sent to RF transmitter. The data is transmitted on

the antenna pin. Thus, this data should be received on the destination i.e, on RF receiver.

RF RECEIVER STR-433 MHz:

Page 81: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

The data is received by the RF receiver from the antenna pin and this data is available on the data pins.

Two Data pins are provided in the receiver module. Thus, this data can be used for further applications

.

PINOUT:

ANT Antenna input.

GND Receiver Ground. Connect to ground plane.

VCC (5V) VCC pins are electrically connected and provide operating voltage for the receiver. VCC can be

applied to either or both. VCC should be bypassed with a .1μF ceramic capacitor. Noise on the power

supply will degrade receiver sensitivity.

DATA Digital data output. This output is capable of driving one TTL or CMOS load. It is a CMOS

compatible output.

CONNECTION:

Page 82: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

The decoder used is HT648L from HOLTEK SEMICONDUCTOR INC.

Page 83: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

PIN DESCRIPTION:

Features

Operating voltage: 2.4V~12V.

Low power and high noise immunity CMOS technology.

Low standby current.

Capable of decoding 18 bits of information.

Pairs with HOLTEK’s 318 series of encoders.

8~18 address pins.

0~8 data pins.

The 3^18 decoders are a series of CMOS LSIs for remote control system applications. They are

paired with the 3^18 series of encoders.

For proper operation, a pair of encoder/decoder pair with the same number of address and data

format should be selected.

The 3^18 series of decoders receives serial address and data from that series of encoders that

are transmitted by a carrier using an RF medium.

A signal on the DIN pin then activates the oscillator which in turns decodes the incoming

address and data.

It then compares the serial input data twice continuously with its local address.

Page 84: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

If no errors or unmatched codes are encountered, the input data codes are decoded and then

transferred to the output pins.

The VT pin also goes high to indicate a valid transmission. That will last until the address code is

incorrect or no signal has been received.

The 3^18 decoders are capable of decoding 18 bits of information that consists of N bits of

address and 18–N bits of data.

BASIC APPLICATION CIRCUIT OF HT648L DECODER:

DEMO CIRCUIT: Reception circuit

The data transmitted into the air is received by the receiver. The received data is taken from the data

line of the receiver and is fed to the decoder .The output of decoder is given to microcontroller and then

data is processed according to the applications.

GSM AT Commands:This AT command tutorial is written to support our Teltonika T-ModemUSB, a USB2.0 GSM modem based on the Nokia 12i GSM module - fast EDGE technology is supported. Some of the most popular applications are SMS based telemetry, security and news broadcasting.

Steps using AT commands to send and receive SMS using a GSM modem from a computer

1. Setting up GSM modem2. Using the HyperTerminal

Page 85: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

3. Initial setup AT commands4. Sending SMS using using AT commands5. Receiving SMS using using AT commands6. Using a computer program to send and receive SMS

After succesfully sending and receiving SMS using AT commands via the HyperTerminal, developers can 'port' the ASCII instructions over to their programming environment, eg. Visual Basic, C/C++ or Java and also programmically parse ASCII messages from modem.

1. Setting up your GSM modem

Most GSM modems comes with a simple manual and necessary drivers. To setup your T-ModemUSB, download the USB GSM Modem Quick Start ( Windows ) guide (460kB PDF). You would be able to send SMS from the Windows application and also setup GPRS connectivity. The GSM modem will map itself as a COM serial port on your computer.Most GSM modems comes with a simple manual and necessary drivers. To setup your T-ModemUSB, download the USB GSM Modem Quick Start ( Windows ) guide (460kB PDF). You would be able to send SMS from the Windows application and also setup GPRS connectivity. The GSM modem will map itself as a COM serial port on your computer.Hint :: By developing your AT commands using HyperTerminal, it will be easier for you to develop your actual program codes in VB, C, Java or other platforms.

Go to START\Programs\Accessories\Communications\HyperTerminal (Win 2000) to create a new connection, eg. "My USB GSM Modem". Suggested settings ::

- COM Port :: As indicated in the T-Modem Control Tool - Bits per second :: 230400 ( or slower ) - Data Bits : 8 - Parity : None - Stop Bits : 1 - Flow Control : Hardware

You are now ready to start working with AT commands. Type in "AT" and you should get a "OK", else you have not setup your HyperTerminal correctly. Check your port settings and also make sure your GSM modem is properly connected and the drivers installed. The Initial setup AT commands are

AT Returns a "OK" to confirm that modem is working

AT+CPIN="xxxx"   To enter the PIN for your SIM ( if enabled )

AT+CREG? A "0,1" Reply confirms your modem is connected to GSM network

AT+CSQ Indicates the signal strength, 31.99 is maximum.

AT+CMGF=1 To format SMS as a TEXT message

Page 86: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

AT+CSCA="+xxxxx"   Set your SMS center's number. Check with your provider.

AT+CMGS="+yyyyy" <Enter> > Your SMS text message here <Ctrl-Z>

The "+yyyyy" is your receipent's mobile number.

AT+CNMI=1,2,0,0,0   Set how the modem will response when a SMS is received

When a new SMS is received by the GSM modem, the DTE will receive the following

+CMT :  "+61xxxxxxxx" , , "04/08/30,23:20:00+40"

This the text SMS message sent to the modem

AT+CMGR=3 <Enter>  AT command to send read the received SMS from modem at 3rd slot.

+CMGR: "REC READ","+61xxxxxx",,"04/08/28,22:26:29+40"

This is the new SMS received by the GSM modem

AT+CMGD=3 <Enter>   To clear the SMS receive memory location in the GSM modem.

REGULATED POWER SUPPLY:

The power supplies are designed to convert high voltage AC mains electricity to a

suitable low voltage supply for electronic circuits and other devices. A RPS (Regulated Power

Supply) is the Power Supply with Rectification, Filtering and Regulation being done on the AC

mains to get a Regulated power supply for Microcontroller and for the other devices being

interfaced to it.

A power supply can by broken down into a series of blocks, each of which performs a

particular function. A d.c power supply which maintains the output voltage constant irrespective

of a.c mains fluctuations or load variations is known as “Regulated D.C Power Supply”

For example a 5V regulated power supply system as shown below:

Page 87: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Transformer:

A transformer is an electrical device which is used to convert electrical power from one

Electrical circuit to another without change in frequency.

Transformers convert AC electricity from one voltage to another with little loss of

power. Transformers work only with AC and this is one of the reasons why mains electricity is

AC. Step-up transformers increase in output voltage, step-down transformers decrease in output

voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains

voltage to a safer low voltage. The input coil is called the primary and the output coil is called

the secondary. There is no electrical connection between the two coils; instead they are linked by

an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the

middle of the circuit symbol represent the core. Transformers waste very little power so the

power out is (almost) equal to the power in. Note that as voltage is stepped down current is

stepped up. The ratio of the number of turns on each coil, called the turn’s ratio, determines the

ratio of the voltages. A step-down transformer has a large number of turns on its primary (input)

Page 88: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

coil which is connected to the high voltage mains supply, and a small number of turns on its

secondary (output) coil to give a low output voltage.

An Electrical Transformer

Turns ratio = Vp/ VS = Np/NS

Power Out= Power In

VS X IS=VP X IP

Vp = primary (input) voltage

Np = number of turns on primary coil

Ip  = primary (input) current    

Page 89: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

RECTIFIER:

A circuit which is used to convert ac to dc is known as RECTIFIER. The process of

conversion ac to dc is called “rectification”

TYPES OF RECTIFIERS:

Half wave Rectifier

Full wave Rectifier

1. Centre tap full wave rectifier.

2. Bridge type full bridge rectifier.

Page 90: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Full-wave Rectifier:

From the above comparison we came to know that full wave bridge

rectifier as more advantages than the other two rectifiers. So, in our project we are using full

wave bridge rectifier circuit.

Bridge Rectifier:

A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-

wave rectification. This is a widely used configuration, both with individual diodes wired as

shown and with single component bridges where the diode bridge is wired internally.

A bridge rectifier makes use of four diodes in a bridge arrangement as shown in fig (a) to

achieve full-wave rectification. This is a widely used configuration, both with individual diodes

wired as shown and with single component bridges where the diode bridge is wired internally.

Fig (A)

Operation: During positive half cycle of secondary, the diodes D2 and D3 are in forward biased

while D1 and D4 are in reverse biased as shown in the fig(b). The current flow direction is

shown in the fig (b) with dotted arrows.

Page 91: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

Fig (B)

During negative half cycle of secondary voltage, the diodes D1 and D4 are in forward

biased while D2 and D3 are in reverse biased as shown in the fig(c). The current flow direction is

shown in the fig (c) with dotted arrows.

Fig(C)

Filter:

A Filter is a device which removes the ac component of rectifier output but allows the

dc component to reach the load.

Capacitor Filter:

Page 92: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

We have seen that the ripple content in the rectified output of half wave rectifier is

121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of

ripples is not acceptable for most of the applications. Ripples can be removed by one of the

following methods of filtering.

(a) A capacitor, in parallel to the load, provides an easier by –pass for the ripples voltage though

it due to low impedance. At ripple frequency and leave the D.C. to appear at the load.

(b) An inductor, in series with the load, prevents the passage of the ripple current (due to high

impedance at ripple frequency) while allowing the dc (due to low resistance to dc).

(c) Various combinations of capacitor and inductor, such as L-section filter section filter,

multiple section filter etc. which make use of both the properties mentioned in (a) and (b) above.

Two cases of capacitor filter, one applied on half wave rectifier and another with full wave

rectifier.

Filtering is performed by a large value electrolytic capacitor connected across the DC

supply to act as a reservoir, supplying current to the output when the varying DC voltage from

the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then

discharges as it supplies current to the output. Filtering significantly increases the average DC

voltage to almost the peak value (1.4 × RMS value).

To calculate the value of capacitor(C),

C = ¼*√3*f*r*Rl

Where,

f = supply frequency,

r = ripple factor,

Rl = load resistance

Note: In our circuit we are using 1000µF hence large value of capacitor is placed to

reduce ripples and to improve the DC component.

Regulator:

Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable

output voltages. The maximum current they can pass also rates them. Negative voltage regulators

Page 93: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

are available, mainly for use in dual supplies. Most regulators include some automatic protection

from excessive current ('overload protection') and overheating ('thermal protection'). Many of

the fixed voltage regulators ICs have 3 leads and look like power transistors, such as the 7805

+5V 1A regulator shown on the right. The LM7805 is simple to use. You simply connect the

positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the

Input pin, connect the negative lead to the Common pin and then when you turn on the power,

you get a 5 volt supply from the output pin.

Fig 6.1.6 A Three Terminal Voltage Regulator

78XX:

The Bay Linear LM78XX is integrated linear positive regulator with three terminals. The

LM78XX offer several fixed output voltages making them useful in wide range of applications.

When used as a zener diode/resistor combination replacement, the LM78XX usually results in an

effective output impedance improvement of two orders of magnitude, lower quiescent current.

The LM78XX is available in the TO-252, TO-220 & TO-263packages,

Features:

• Output Current of 1.5A

• Output Voltage Tolerance of 5%

• Internal thermal overload protection

• Internal Short-Circuit Limited

• Output Voltage 5.0V, 6V, 8V, 9V, 10V, 12V, 15V, 18V, 24V.

Page 94: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

CHAPTER 5

System Design

Designing of this system is possible when you select the specific controller to suite. For this we selected 89S52 controller. With the help of 89S52 controller, intelligent ambulance which will reach the hospitals without any problem in heavy traffics.The system can be implemented successfully with the help IR, RF and GSM technology. To the ambulance system, we shall connect IR receiver to receive the signal from IR transmitter which shall be connected near to the traffic post. And also connect the RF transmitter and GSM modem to ambulance system. And at traffic post, we shall connect another system, which shall be used to control the traffic signals. When ambulance comes nearby (for example 100 mts) the traffic post, the IR transmitter sents a signal to ambulance indicating that ambulance is nearby the traffic post. IR receiver receives that signals and amubalance system shall send the signal to traffic post system mentioning that ambulance has arrived at the post using Rf transmitter. Immediately traffic post system receives the signal by using RF receiver, give green signal to ambulance to cross the traffic post. GSM modem is used to communicate with hospital for informing the status of the patient in ambulance.

Page 95: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

5.1 Hardware Design:

5.1.1 Schematic

V C C

R 5R

J 3

C O N 8

12345678

U 5

L M 7 8 0 5 / TO

1

3

2V I N

GN

D V O U T

C 2

C A P

D 4D I O D E

U 1

A T8 9 S 5 2

5678

9

1 01 11 21 31 41 51 61 7

1 8

1 9

2 0

4 0

3 93 83 73 63 53 43 33 2

3 1

3 02 9

2 82 72 62 52 42 32 22 1

1234

P 1 . 4P 1 . 5P 1 . 6P 1 . 7

R S T

P 3 . 0 / R XDP 3 . 1 / TXDP 3 . 2 / I N T0P 3 . 3 / I N T1P 3 . 4 / T0P 3 . 5 / T1P 3 . 6 / W RP 3 . 7 / R D

XTA L 2

XTA L 1

G N D

V C C

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

E A / V P P

A L E / P R O GP S E N

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

P 2 . 1 / A 9P 2 . 0 / A 8

P 1 . 0P 1 . 1P 1 . 2P 1 . 3

S W 1

J 2

C O N 8

12345678

C 5

C A P

V C C

J 4

C O N 8

12345678

D 1D I O D E

R 4R

J 3

L C D

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

gnd

vcc

3 RS

W EN

P0.

0P

0.1

P0.

2P

0.3

P0.

4P

0.5

P0.

6P

0.7

VC

CG

ND

C 4

C A P

C 1C

P 2

C O N N E C TO R D B 9

594837261

C 6

C A P

V C C

R XD

R 6

P O T

J 2

C O N 8

12345678

D 6D I O D E

TXD

TXD

C 7C A P

U 6t / f (4 p in )

1 2

3 4

1 2

3 4

C 3

C A P

D 2D I O D E

<D o c > <R e v C o d e >

<Tit le >

A

1 1Th u rs d a y , J u ly 1 5 , 2 0 1 0

Tit le

S ize D o c u m e n t N u m b e r R e v

D a t e : S h e e t o f

Y 1C R Y S TA L

D 5L E D

R XD

J 7C O N 2

1 2

+5 V

C 9

C

= 1 0 0 0 U F / 2 5 V

U 3

M A X2 3 2

13

45

2

6

1 2

9

1 1

1 0

1 3

8

1 4

7

C 1 +C 1 -

C 2 +C 2 -

V +

V -

R 1 O U T

R 2 O U T

T1 I N

T2 I N

R 1 I N

R 2 I N

T1 O U T

T2 O U T

C 81 0 4

Page 96: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

5.1.2. Schematic Description

The main aim of this power supply is to convert the 230V AC into 5V DC in order to give supply

for the TTL. This schematic explanation includes the detailed pin connections of every device with the

microcontroller.

This schematic explanation includes the detailed pin connections of every device with the

microcontroller.

Let us see the pin connections of each and every device with the microcontroller in detail.

Power Supply: In this process we are using a step down transformer, a bridge rectifier, a smoothing

circuit and the RPS. At the primary of the transformer we are giving the 230V AC supply. The secondary

is connected to the opposite terminals of the Bridge rectifier as the input. From other set of opposite

terminals we are taking the output to the rectifier.

The bridge rectifier converts the AC coming from the secondary of the transformer into

pulsating DC. The output of this rectifier is further given to the smoother circuit which is capacitor in our

project. The smoothing circuit eliminates the ripples from the pulsating DC and gives the pure DC to the

RPS to get a constant output DC voltage. The RPS regulates the voltage as per our requirement.

Microcontroller: The microcontroller AT89S52 with Pull up resistors at Port0 and crystal oscillator

of 11.0592 MHz crystal in conjunction with couple of capacitors of is placed at 18 th & 19th pins of 89S51

to make it work (execute) properly.

RF Module: The RF transmitter and receiver are input and output devices. This is connected to the

port P2 of the Microcontroller through the decoder and encoder for transmitter and receiver circuit

respectively

LCD: The LCD data lines are connected to port 0 of the microcontroller in the schematic and

the control signals like RS, EN are connected to pin2,3 of port 1.

Page 97: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

IR Module: The IR transmitter and receiver are input and output devices. This is

connected to the port P3 of the Microcontroller.

GSM module: Here the modem is connected to microcontroller by using serial port of 89S52. i.e., Tx

and Rx signals (pin 10, 11)

5.2.SOFTWARE Components

5.2.1. ABOUT SOFTWARE

Software used is:

*Keil software for C programming

*Express PCB for lay out design

*Express SCH for schematic design

KEIL µVision3

µVision3 is an IDE (Integrated Development Environment) that helps you write, compile, and

debug embedded programs. It encapsulates the following components:

A project manager.

A make facility.

Tool configuration.

Editor.

A powerful debugger.

This software is used for execution of microcontroller programs.

Keil development tools for the MC architecture support every level of software developer from

the professional applications engineer to the student just learning about embedded software

development.

The industry-standard keil C compilers, macro assemblers, debuggers,real, time Kernels, Single-board

computers and emulators support all avr derive--atives and help you to get more projects completed on

Page 98: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

schedule. The keil software development tools are designed to solve the complex problems facing

embedded software developers.

When starting a new project, simply select the microcontroller you the device database

and the µvision IDE sets all compiler, assembler, linker, and memory options for you.

Numerous example programs are included to help you get started with the most

popular embedded avr devices.

The keil µ Vision debugger accurately simulates on-chip peripherals(PC, CAN, UART,

SPI,Interrupts,I/O ports, A/D converter, D/A converter and PWM modules)of your avr device. Simulation

helps you understand h/w configurations and avoids time wasted on setup problems. Additionally,

with simulation, you can write and test applications before target h/w is available.

When you are ready to begin testing your s/w application with target h/w, use the

MON51, MON390, MONADI, or flash MON51 target monitors, the ISD51 In-System Debugger, or the

ULINK USB-JTAG adapter to download and test program code on your target system.

Express PCB Express PCB is a Circuit Design Software and PCB manufacturing service. One can learn

almost everything you need to know about Express PCB from the help topics included with the programs

given.

Details: Express PCB, Version 5.6.0

Express SCH The Express SCH schematic design program is very easy to use. This software enables

the user to draw the Schematics with drag and drop options. A Quick Start Guide is provided by which

the user can learn how to use it.

Details: Express SCH, Version 5.6.0

EMBEDDED C: The programming Language used here in this project is an Embedded C Language. This

Embedded C Language is different from the generic C language in few things like

a) Data types

b) Access over the architecture addresses.

The Embedded C Programming Language forms the user friendly language with access over Port

addresses, SFR Register addresses etc.

Signed char:

Page 99: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

o Used to represent the – or + values.

o As a result, we have only 7 bits for the magnitude of the signed number, giving us values from -

128 to +127.

Embedded C Data types:

Data Types Size in Bits Data Range/Usage

unsigned char 8-bit 0-255

signed char 8-bit -128 to +127

unsigned int 16-bit 0 to 65535

signed int 16-bit -32,768 to +32,767

sbit 1-bit SFR bit addressable only

Bit 1-bit RAM bit addressable only

sfr 8-bit RAM addresses 80-FFH only

Page 100: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

CHAPTER 6

Implementation

The applications as discussed in the design are implemented and the source code related to the current work is pasted in the appendix.

SOFTWARE

µVision3

µVision3 is an IDE (Integrated Development Environment) that helps you write, compile, and debug

embedded programs. It encapsulates the following components:

A project manager.

A make facility.

Tool configuration.

Editor.

A powerful debugger.

To help you get started, several example programs (located in the \C51\Examples, \C251\Examples, \

C166\Examples, and \ARM\...\Examples) are provided.

HELLO is a simple program that prints the string "Hello World" using the Serial Interface.

Building an Application in µVision2:

To build (compile, assemble, and link) an application in µVision2, you must:

1. Select Project - (for example, 166\EXAMPLES\HELLO\HELLO.UV2).

2. Select Project - Rebuild all target files or Build target.

µVision2 compiles, assembles, and links the files in your project.

Creating Your Own Application in µVision2

To create a new project in µVision2, you must:

Page 101: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

1. Select Project - New Project.

2. Select a directory and enter the name of the project file.

3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device

Database™.

4. Create source files to add to the project.

5. Select Project - Targets, Groups, Files, Add/Files, select Source Group1, and add the source files

to the project.

6. Select Project - Options and set the tool options. Note when you select the target device from

the Device Database™ all special options are set automatically. You typically only need to

configure the memory map of your target hardware. Default memory model settings are optimal

for most applications.

7. Select Project - Rebuild all target files or Build target.

Debugging an Application in µVision2

To debug an application created using µVision2, you must:

1. Select Debug - Start/Stop Debug Session.

2. Use the Step toolbar buttons to single-step through your program. You may enter G, main in the

Output Window to execute to the main C function.

3. Open the Serial Window using the Serial #1 button on the toolbar.

Debug your program using standard options like Step, Go, Break, and so on.

Starting µVision2 and creating a Project

µVision2 is a standard Windows application and started by clicking on the program icon. To

create a new project file select from the µVision2 menu

Project – New Project…. This opens a standard Windows dialog that asks you for the new project file

name.

We suggest that you use a separate folder for each project. You can simply use the icon Create

New Folder in this dialog to get a new empty folder. Then select this folder and enter the file name for

the new project, i.e. Project1.

Page 102: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

µVision2 creates a new project file with the name PROJECT1.UV2 which contains a default target

and file group name. You can see these names in the Project

Window – Files.

Now use from the menu Project – Select Device for Target and select a CPU for your project. The

Select Device dialog box shows the µVision2 device database. Just select the microcontroller you use.

We are using for our examples the Philips 80C51RD+ CPU. This selection sets necessary tool options for

the 80C51RD+ device and simplifies in this way the tool Configuration

Building Projects and Creating a HEX Files

Typical, the tool settings under Options – Target are all you need to start a new application. You

may translate all source files and line the application with a click on the Build Target toolbar icon. When

you build an application with syntax errors, µVision2 will display errors and warning messages in the

Output

Window – Build page. A double click on a message line opens the source file on the correct location in a

µVision2 editor window.

Once you have successfully generated your application you can start debugging.

After you have tested your application, it is required to create an Intel HEX file to download the

software into an EPROM programmer or simulator. µVision2 creates HEX files with each build process

when Create HEX files under Options for Target – Output is enabled. You may start your PROM

programming utility after the make process when you specify the program under the option Run User

Program #1.

CPU Simulation

Page 103: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

µVision2 simulates up to 16 Mbytes of memory from which areas can be mapped for read,

write, or code execution access. The µVision2 simulator traps and reports illegal memory accesses being

done.

In addition to memory mapping, the simulator also provides support for the integrated peripherals of

the various 8051 derivatives. The on-chip peripherals of the CPU you have selected are configured from

the Device

Database selection

You have made when you create your project target. Refer to page 58 for more Information

about selecting a device. You may select and display the on-chip peripheral components using the

Debug menu. You can also change the aspects of each peripheral using the controls in the dialog boxes.

Start Debugging

You start the debug mode of µVision2 with the Debug – Start/Stop Debug Session command.

Depending on the Options for Target – Debug Configuration, µVision2 will load the application program

and run the startup code µVision2 saves the editor screen layout and restores the screen layout of the

last debug session. If the program execution stops, µVision2 opens an editor window with the source

text or shows CPU instructions in the disassembly window. The next executable statement is marked

with a yellow arrow. During debugging, most editor features are still available.

For example, you can use the find command or correct program errors. Program source text of

your application is shown in the same windows. The µVision2 debug mode differs from the edit mode in

the following aspects:

_ The “Debug Menu and Debug Commands” described on page 28 are Available. The additional debug

windows are discussed in the following.

_ The project structure or tool parameters cannot be modified. All build Commands are disabled.

Disassembly Window

Page 104: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

The Disassembly window shows your target program as mixed source and assembly program or

just assembly code. A trace history of previously executed instructions may be displayed with Debug –

View Trace Records. To enable the trace history, set Debug – Enable/Disable Trace Recording.

If you select the Disassembly Window as the active window all program step commands work on CPU

instruction level rather than program source lines. You can select a text line and set or modify code

breakpoints using toolbar buttons or the context menu commands.

You may use the dialog Debug – Inline Assembly… to modify the CPU instructions. That allows

you to correct mistakes or to make temporary changes to the target program you are debugging.

CHAPTER 7

System Testing

The system can be tested with the use of KEIL compiler. This one we are using to write

programs for 8051 controller. After writing programs using 8051 programmer we can dump code

in to the controller. RF encoder and decoders we will connect to port pins at transmitting and

receiving sides. First we shall write diagnostic code to test the basic functionality of the each

device connected to the system. Then we write our application and test it.

CHAPTER 8

Results and Evaluation

This chpater lists down the results realized from the practical work and examines whether

ideas/solution approaches recommended in research are met by the practical implementation.

Because now a days IR, RF and GSM technology became very popular,here its very easy to use

for any applications with the help of 8051 controller.In all low end applications now a days we

are using 8051 controllers like industrial automation and data acquisition.

Page 105: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

.

Page 106: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

CHAPTER 9

Conclusion

With this we can conclude that the system which has developed by using controller having the

following features like 8 bit 8051 architecture in a tiny 40 pin DIP package,128B RAM and 4kB

on-chip Flash Program Memory, can be really used in real time environment. But there may be

some limitations and constraits which we have to look into it.

For low end applications this controller is very easy to use and at the same time RF also

widely accepted protocol for mobile communication.

References

[1] 8051 Architecture and Programming by Mazidi

[2] 8051 Programming by Ayala [3] MAX232 user guide by MAXIM semiconductors

[4] Wikipedia

[5] RF Technology

[6] GSM AT commands user manual

Appendix

Source code.

Traffic post system

#include<reg51.h>

#include"lcd.h"

Page 107: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

sbit gl= P3^4;

sbit rl= P3^5;

sbit rf=P3^7;

void main()

{

unsigned char ch;

lcd_init();

msgdisplay(" INTELLIGENT AMBULANCE ");

delay(600);

delay(600);

while(1)

{

lcdcmd(0x01);

lcdcmd(0x80);

while(rf==1); // wait to rceive data (VT monitor)

while(rf==0);

ch=P2;

if(ch=='A')

{

lcdcmd(0x80);

msgdisplay(" NO AMBULANCE ");

Page 108: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

gl=1;

rl=0;

delay(100);

}

if(ch=='B')

{

lcdcmd(0x80);

msgdisplay(" AMBULANCE ARRIVED ");

gl=0;;

rl=1;

delay(100);

}

if(ch=='*')

{

lcdcmd(0x80);

msgdisplay(" NO AMBULANCE ");

gl=1;

rl=0;

delay(100);

Page 109: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

}

if(ch=='#')

{

lcdcmd(0x80);

msgdisplay(" AMBULANCE ARRIVED ");

gl=0;;

rl=1;

delay(100);

}

}

}

Ambulance system:

#include<reg51.h>

#include"lcd.h"

void Enter(void);

void GSM_Init(void);

void Modem_send(unsigned char *);

Page 110: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

void send_sms(unsigned char *,unsigned char *);

void Delay1(unsigned int);

sbit ld= P3^3;

sbit ir= P3^4;

sbit rf=P3^7;

void main()

{

SCON = 0x50; //Mode 1..8 bit data,..1 stop bit,..1 start bit

TMOD = 0x20; //Timer 1....Mode 2...8 bit Auto Reload

TH1 = 0xFD; //Baud Rate 9600

TR1 = 1;

ld=0;

delay(500);

ld=1;

lcd_init();

msgdisplay(" INTELLIGENT AMBULANCE ");

delay(500);

GSM_Init();

ld=0;

delay(500);

ld=1;

while(1)

Page 111: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

{

while(ir==1) // no ambulance

{

lcdcmd(0x01);

lcdcmd(0x80);

msgdisplay(" NO AMBULANCE ");

ld=1;

rf=1;

P2='*';

delay(50);

rf=0;

rf=1;

P2='A';

delay(50);

rf=0;

}

while(ir==0) //ambulance arrived

Page 112: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

{

lcdcmd(0x01);

lcdcmd(0x80);

msgdisplay(" AMBULANCE ARRIVED ");

ld=0;

rf=1;

P2='B';

delay(50);

rf=0;

rf=1;

P2='#';

delay(50);

rf=0;

send_sms("AT+CMGS=\"8142154992\"","PATIENT UNDER CRICITAL CONDITION");

//send_sms("AT+CMGS=\"8978987877\"","PATIENT UNDER CRICITAL CONDITION");

delay(50);

}

Page 113: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

}

}

void GSM_Init(void)

{

lcdcmd(0x01);

msgdisplay("GSM Initializing");

Delay1(100);

Modem_send("AT");

Modem_send("ATE0");

Modem_send("AT+CSMS=0");

Modem_send("AT+IPR=9600");

Modem_send("AT+CMGF=1");

Modem_send("AT&W");

Modem_send("AT+CNMI=2,1,0,0,0");

lcdcmd(0x01);

msgdisplay("GSM Initialized");

Delay1(100);

}

Page 114: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

void Modem_send(unsigned char *ch)

{

unsigned char cha;

while(*ch)

{

SBUF = *ch;

while(TI == 0);

TI = 0;

ch++;

}

Enter();

TI = 0;

RI = 0;

while(1)

{

while(RI == 0);

RI = 0;

cha = SBUF;

if(cha == 'O');

while(RI == 0);

RI = 0;

cha = SBUF;

if(cha == 'K')

Page 115: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

break;

SBUF = 'A';

while(TI == 0);

TI = 0;

SBUF = '/';

while(TI == 0);

TI = 0;

}

TI = 0;

RI = 0;

}

void send_sms(unsigned char *No,unsigned char *v)

{

unsigned char ch1='X';

while(*No)

{

SBUF=*No;

while(TI==0);

TI=0;

No++;

}

Enter();

Page 116: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

while(ch1!='>')

{

while(RI==0);

ch1=SBUF;

RI=0;

}

while(*v)

{

SBUF=*v;

while(TI==0);

TI=0;

v++;

}

RI=0;

TI=0;

SBUF=0x1A;

while(TI==0);

TI=0;

RI=0;

}

Page 117: Intelligent Ambulance for City Traffic and Gsm to Sent the Status of the Patient to the Hospital

void Delay1(unsigned int itime)

{

unsigned int i,k=0;

for(i=0;i<itime;i++)

for(k=0;k<1000;k++);

}