Sunteți pe pagina 1din 46

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

List of Figures

Figure 2.1 A typical embedded system block diagram

Figure 2.2 The structure of a GSM network

Figure 4.1: AT89C51 Pin Diagram

Figure 4.2 Oscillator and timing circuit

Figure 4.3 SMOD Register

Figure 4.4 TCON Register


Figure 4.5 TMOD Register

Figure 4.6 IE Register

Figure 4.7 IP Register

Figure 4.8 PSW Register

Figure 4.9 PORT3 Alternate Use

Figure 4.10 Data framing

Figure 4.11 Data transfer

Figure 4.12 SCON Register

Figure 4.13 UART modes


Figure 4.14Voltage levels for RS232 and TTL
Figure 4.15 RS232 Pin Diagram
Figure 4.16 LM35
Figure 4.17 Gas sensor

Figure 4.18 Gas sensor circuit.


Figure 4.19 PIR sensor
Figure 4.20 ADC0808
Abstract

Intelligent system for Gas, Human detection and Temperature Monitor control using GSM

Aim: The main aim of this project is to develop intelligent system for gas, Human detection and
Temperature Monitor control using GSM

Project Description:

In this project we are connecting different sensors like Temperature, gas and PIR sensor to the
controller. The Controller continuously monitors the values from all the sensors. If the values are not with
in the range it will take decision and indicates using GSM network. Any person can receive the SMS sent
by GSM modem and further can decide what to do.In this project we are implementing safety and at the
same time security also.The safety is against gas and temperature and security is like to detect human
being in prohibited areas.This kind of system is useful in areas like industries where we should avoid the
existence of gas and fire at any cost.

Block diagram:

CONTROLLING
LM35
AT89C51 PART

GAS GSM
MODEM

PIR

SENSOR

Hardware :

AT89C51

GSM Modem

LM35

Gas and PIR sensors

Software:

Keil uVision 2

8051 programmer

Application Areas:

Industrial safety systems

Security systems
CHAPTER 1

Introduction

1.1Overview

The overview of this project is to implement intelligent system which can detect temperature,gas
and humanbeings using 8051 controller.8051 is very efficient architechture which can be used
for low end security systems and GSM is widely adapted technology for communication.

1.2Purpose

Purpose of the current work is to study and analyse the design of intelligent system with the help
of 8051 controller and GSM technology..

1.3 Scope

Current work focuses on how to effectively use GSM technology and 8051 controller for
intelligent security systems.

1.4 Organization of the document


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

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

2.4 8051 Micro Controller

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.5 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.
This also facilitates the wide-spread implementation of data communication applications into the
system.The ubiquity of implementation of the GSM standard has been an advantage to both
consumers, who may benefit from the ability to roam and switch carriers without replacing
phones, and also to network operators, who can choose equipment from many GSM equipment
vendors. GSM also pioneered low-cost implementation of the short message service (SMS), also
called text messaging, which has since been supported on other mobile phone standards as well.
The standard includes a worldwide emergency telephone number feature.

Newer versions of the standard were backward-compatible with the original GSM system. For
example, Release '97 of the standard added packet data capabilities by means of General Packet
Radio Service(GPRS). Release '99 introduced higher speed data transmission using Enhanced
Data Rates for GSM Evolution(EDGE).

In 1982, the European Conference of Postal and Telecommunications Administrations (CEPT)


created the Groupe Spécial Mobile(GSM) to develop a standard for a mobile telephone system
that could be used across Europe. In 1987, a memorandum of understanding was signed by 13
countries to develop a common cellular telephone system across Europe.Finally the system
created by SINTEF led by Torleiv Maseng was selected.

In 1989, GSM responsibility was transferred to the European Telecommunications Standards


Institute (ETSI) and phase I of the GSM specifications were published in 1990. The first GSM
network was launched in 1991 by Radiolinja in Finland with joint technical infrastructure
maintenance from Ericsson.By the end of 1993, over a million subscribers were using GSM
phone networks being operated by 70 carriers across 48 countries.
GSM is a cellular network, which means that mobile phones connect to it by searching for cells
in the immediate vicinity. There are five different cell sizes in a GSM network—macro, micro,
pico, femto and umbrella cells. The coverage area of each cell varies according to the
implementation environment. Macro cells can be regarded as cells where the base station antenna
is installed on a mast or a building above average roof top level. Micro cells are cells whose
antenna height is under average roof top level; they are typically used in urban areas. Picocells
are small cells whose coverage diameter is a few dozen metres; they are mainly used indoors.
Femtocells are cells designed for use in residential or small business environments and connect
to the service provider’s network via a broadband internet connection. Umbrella cells are used to
cover shadowed regions of smaller cells and fill in gaps in coverage between those cells.

GSM networks operate in a number of different carrier frequency ranges (separated into GSM
frequency ranges for 2G and UMTS frequency bands for 3G), with most 2G GSM networks
operating in the 900 MHz or 1800 MHz bands. Where these bands were already allocated, the
850 MHz and 1900 MHz bands were used instead (for example in Canada and the United
States). In rare cases the 400 and 450 MHz frequency bands are assigned in some countries
because they were previously used for first-generation systems.

Most 3G GSM EDGE networks in Europe operate in the 2100 MHz frequency band.

Figure 2.2 The structure of a GSM network


2.6 Intelligent systems

Now a days intelligent systems became very serious issue at any where.To get good results at
any time, we need a system which can work at any circumstances.In this project we are going to
use GSM technology which is widely accepted technology for mobile communications.With the
use of 8051 controller and GSM technogy we are going to implement an intelligent system.

CHAPTER 3

Problem formulation

The problem with the intelligent systems is they should work at any time without any fail.Here in
this project we are going to implement safety against temperature and gas.Along with this human
detection also we are implementing.These things are very important in areas like industries
where we should monitor the status of temperature and gas at the same time if it ios restricted
area we need to monitor the presense of human beings also.

CHAPTER 4

System Specification

4.1 8051 Micro Controller

The features of the micro controller are as follows:

• Compatible with MCS-51 ™ Products

• 4K Bytes of In-System Reprogrammable Flash Memory

• Fully Static Operation: 0 Hz to 24 MHz

• Three-level Program Memory Lock

• 128 x 8-bit Internal RAM


• 32 Programmable I/O Lines

• Two 16-bit Timer/Counters

• Programmable Serial Channel

• Low-power Idle and Power-down Modes Six Interrupt Sources

4.2 8051 Description


The 8051 microcontroller unit is a fast, single-chip, and is a derivative of the 80C51
microcontroller family. It is a fully functional 8-bit embedded controller that executes all ASM51
instructions and has the same instruction set as the 80C51. The 8051 accesses instructions from
two kinds of program memory, serves software and hardware interrupt, and provide serial
communications interface and timer systems.

The 8051 micro controller unit is a high-performance, synthesizable 80C51 function specifically
designed for reusability. It can operate at frequencies up to 14 MHz in FLEX® devices.

The 8051 consist of the following modules:

Functional core—8051 mega function

Program memory—Internal_Program_Memory

Data memory—Internal_Data_Memory

Open-drain I/O pins—OPNDRN

The 8051 is an 8-bit microprocessor originally designed in the 1980's by Intel that has gained
great popularity since its introduction. Its standard form includes several standard on-chip
peripherals, including timers, counters, and UART's, plus 4kbytes of on-chip program memory
and 128 bytes (note: bytes, not Kbytes) of data memory, making single-chip implementations
possible. Its hundreds of derivatives, manufactured by several different companies (like Philips)
include even more on-chip peripherals, such as analog-digital converters, pulse-width
modulators, I2C bus interfaces, etc. Costing only a few dollars per IC, the 8051 is estimated to be
used in a large percentage (maybe 1/2?) all embedded system products. The 8051 memory
architecture includes 128 bytes of data memory that are accessible directly by its instructions. A
32-byte segment of this 128-byte memory block is bit addressable by a subset of the 8051
instructions, namely the bit-instructions. External memory of up to 64 Kbytes is accessable by a
special "movx" instruction. Up to 4 Kbytes of program instructions can be stored in the internal
memory of the 8051, or the 8051 can be configured to use up to 64 Kbytes of external program
memory The majority of the 8051's instructions are executed within 12 clock cycles.

1 A T89C 51 40
2 P 1 .0 V C C 39
3 P 1 .1 P 0 .0 /A D 0 38
4 P 1 .2 P 0 .1 /A D 1 37
5 P 1 .3 P 0 .2 /A D 2 36
6 P 1 .4 P 0 .3 /A D 3 35
7 P 1 .5 P 0 .4 /A D 4 34
8 P 1 .6 P 0 .5 /A D 5 33
9 P 1 .7 P 0 .6 /A D 6 32
10 R S T P 0 .7 /A D 7 31
11 P 3 .0 /R X D E A /V P P 30
12 P 3 .1 /T X D A L E /P R O G 29
13 P 3 .2 /IN T 0 P S E N 28
14 P 3 .3 /IN T 1 P 2 .7 /A 1 5 27
15 P 3 .4 /T 0 P 2 .6 /A 1 4 26
16 P 3 .5 /T 1 P 2 .5 /A 1 3 25
17 P 3 .6 /W R P 2 .4 /A 1 2 24
18 P 3 .7 /R D P 2 .3 /A 1 1 23
19 X TA L2 P 2 .2 /A 1 0 22
20 X TA L1 P 2 .1 /A 9 21
G N D P 2 .0 /A 8
Figure 4.1: AT89C51 Pin Diagram

A typical 8051 contains CPU with Boolean processor, 5 or 6 interrupts, 16-bit


timer/counters,programmable full-duplex serial port, 32 I/O lines (four 8-bit ports),RAM and
ROM. The 8051 architecture is a tad bizarre, but then so are the architectures of most micro
controllers due to their specialization. One vexing problem with the 8051 is its very non-
orthogonal instruction set - especially the restrictions on accessing the different address spaces.
However, after some time programming the chip, you can get used to it - maybe even appreciate.

8051 has four I/O port (P0, P1, P2, and P3), ored in an external ROM or EPROM chip or if
you are using external RAM chips) you may not use P0 or P2. This is because the 8051 uses
ports P0 and P2 to address the external memory. Thus if you are using external RAM or code
memory you may only use ports P1 and P3 for your own use. One strong point of the 8051 is the
way it handles interrupts. Most interrupt routines are very short, and generally can fit into the 8-
byte area. Of course if your interrupt routine is longer, you can still jump to the appropriate
routine from within the 8 byte interrupt region. The 8051 instruction set is optimized for the one-
bit operations so often desired in real-world, real-time control applications. The Boolean
processor provides direct support for bit manipulation. This leads to more efficient programs
that need to deal with binary input and output conditions inherent in digital-control problems.
Bit addressing can be used for test pin monitoring or program control flags.

4.3 The 8051 Oscillator and Clock:


The heart of the 8051 circuitry that generates the clock pulses by
which all the internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is
provided for connecting a resonant network to form an oscillator. Typically a quartz crystal and
capacitors are employed. The crystal frequency is the basic internal clock frequency of the
microcontroller. The manufacturers make 8051 designs that run at specific minimum and
maximum frequencies typically 1 to 16 MHz
Figure 4.2 Oscillator and timing circuit
4.4 Types of memory:
The 8051 have three general types of memory. They are on-chip memory,
external Code memory and external Ram. On-Chip memory refers to physically existing memory
on the micro controller itself. External code memory is the code memory that resides off chip.
This is often in the form of an external EPROM. External RAM is the Ram that resides off chip.
This often is in the form of standard static RAM or flash RAM.

4.4.1 Code memory


Code memory is the memory that holds the actual 8051 programs that is to be run. This
memory is limited to 64K. Code memory may be found on-chip or off-chip. It is possible to have
4K of code memory on-chip and 60K off chip memory simultaneously. If only off-chip memory
is available then there can be 64K of off chip ROM. This is controlled by pin provided as EA

4.4.2 Internal RAM


The 8051 have a bank of 128 bytes of internal RAM. The internal RAM is found on-chip.
So it is the fastest Ram available. And also it is most flexible in terms of reading and writing.
Internal Ram is volatile, so when 8051 is reset, this memory is cleared. 128 bytes of internal
memory are subdivided. The first 32 bytes are divided into 4 register banks. Each bank contains
8 registers. Internal RAM also contains 128 bits, which are addressed from 20h to 2Fh. These
bits are bit addressed i.e. each individual bit of a byte can be addressed by the user. They are
numbered 00h to 7Fh. The user may make use of these variables with commands such as SETB
and CLR.
4.5 Special Function registered memory:
Special function registers are the areas of memory that control specific functionality of
the 8051 micro controller.

4.5.1. Accumulator (0E0h)


As its name suggests, it is used to accumulate the results of large no of instructions. It can
hold 8 bit values.

4.5.2. B Register (0F0h)


The B register is very similar to accumulator. It may hold 8-bit value. The b register is
only used by MUL AB and DIV AB instructions. In MUL AB the higher byte of the product gets
stored in B register. In div AB the quotient gets stored in B with the remainder in A.
4.5.3. Stack pointer (81h)
The stack pointer holds 8-bit value. This is used to indicate where the next value to be
removed from the stack should be taken from. When a value is to be pushed onto the stack, the
8051 first store the value of SP and then store the value at the resulting memory location. When a
value is to be popped from the stack, the 8051 returns the value from the memory location
indicated by SP and then decrements the value of SP.

4.5.4.Data pointer
The SFRs DPL and DPH work together work together to represent a 16-bit value called
the data pointer. The data pointer is used in operations regarding external RAM and some
instructions code memory. It is a 16-bit SFR and also an addressable SFR.

4.5.5. Program counter


The program counter is a 16 bit register, which contains the 2 byte address, which tells the
8051 where the next instruction to execute to be found in memory. When the 8051 is initialized
PC starts at 0000h. And is incremented each time an instruction is executes. It is not addressable
SFR.
4.5.6. PCON (power control, 87h)
The power control SFR is used to control the 8051’s power control modes. Certain
operation modes of the 8051 allow the 8051 to go into a type of “sleep mode” which Sconsumes
much lee power.

Figure 4.3 SMOD Register


4.5.7. TCON (timer control, 88h)
The timer control SFR is used to configure and modify the way in which the 8051’s two
timers operate. This SFR controls whether each of the two timers is running or stopped and
contains a flag to indicate that each timer has overflowed. Additionally, some non-timer related
bits are located in TCON SFR. These bits are used to configure the way in which the external
interrupt flags are activated, which are set when an external interrupt occurs.

Figure 4.4 TCON Register

4.5.8. TMOD (Timer Mode, 89h)


The timer mode SFR is used to configure the mode of operation of each of the two timers.
Using this SFR your program may configure each timer to be a 16-bit timer, or 13 bit timer, 8-bit
auto reload timer, or two separate timers. Additionally you may configure the timers to only
count when an external pin is activated or to count “events” that are indicated on an external pin.
Figure 4.5 TMOD Register

4.5.9. TO (Timer 0 low/high, address 8A/8C h)


These two SFRs taken together represent timer 0. Their exact behavior depends on how
the timer is configured in the TMOD SFR; however, these timers always count up. What is
configurable is how and when they increment in value.

4.5.10. T1 (Timer 1 Low/High, address 8B/ 8D h)


These two SFRs, taken together, represent timer 1. Their exact behavior depends on how the
timer is configured in the TMOD SFR; however, these timers always count up..

4.5.11. P0 (Port 0, address 90h, bit addressable)


This is port 0 latch. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port
0 is pin P0.0, bit 7 is pin p0.7. Writing a value of 1 to a bit of this SFR will send a high level on
the corresponding I/O pin whereas a value of 0 will bring it to low level.

4.5.12. P1 (port 1, address 90h, bit addressable)


This is port latch1. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port
0 is pin P1.0, bit 7 is pin P1.7. Writing a value of 1 to a bit of this SFR will send a high level on
the corresponding I/O pin whereas a value of 0 will bring it to low level

4.5.13.P2 (port 2, address 0A0h, bit addressable)


This is a port latch2. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port
0 is pin P2.0, bit 7 is pin P2.7. Writing a value of 1 to a bit of this SFR will send a high level on
the corresponding I/O pin whereas a value of 0 will bring it to low level.
4.5.14.P3 (port 3, address B0h, bit addressable)
This is a port latch3. Each bit of this SFR corresponds to one of the pins on a micro
controller. Any data to be outputted to port 0 is first written on P0 register. For e.g., bit 0 of port
0 is pin P3.0, bit 7 is pin P3.7. Writing a value of 1 to a bit of this SFR will send a high level on
the corresponding I/O pin whereas a value of 0 will bring it to low level

4.5.14.IE (interrupt enable, 0A8h)


The Interrupt Enable SFR is used to enable and disable specific interrupts. The low 7 bits
of the SFR are used to enable/disable the specific interrupts, where the MSB bit is used to enable
or disable all the interrupts. Thus, if the high bit of IE is 0 all interrupts are disabled regardless of
whether an individual interrupt is enabled by setting a lower bit.

Figure 4.6 IE Register

4.5.14.IP (Interrupt Priority, 0B8h)


The interrupt priority SFR is used to specify the relative priority of each interrupt. On
8051, an interrupt may be either low or high priority. An interrupt may interrupt interrupts. For
e.g., if we configure all interrupts as low priority other than serial interrupt. The serial interrupt
always interrupts the system, even if another interrupt is currently executing. However, if a serial
interrupt is executing no other interrupt will be able to interrupt the serial interrupt routine since
the serial interrupt routine has the highest priority.

Figure 4.7 IP Register

4.5.15.PSW (Program Status Word, 0D0h)


The program Status Word is used to store a number of important bits that are set and
cleared by 8051 instructions. The PSW SFR contains the carry flag, the auxiliary carry flag, the
parity flag and the overflow flag. Additionally, it also contains the register bank select flags,
which are used to select, which of the “R” register banks currently in use.

Figure 4.8 PSW Register

4.5.16.SBUF (Serial Buffer, 99h)


SBUF is used to hold data in serial communication. It is physically two registers. One is
writing only and is used to hold data to be transmitted out of 8051 via TXD. The other is read
only and holds received data from external sources via RXD. Both mutually exclusive registers
use address 99h.

4.6. I/O ports:


One major feature of a microcontroller is the versatility built into the input/output (I/O)
circuits that connect the 8051 to the outside world. The main constraint that limits numerous
functions is the number of pins available in the 8051 circuit. The DIP had 40 pins and the
success of the design depends on the flexibility incorporated into use of these pins. For this
reason, 24 of the pins may each used for one of the two entirely different functions which
depend, first, on what is physically connected to it and, then, on what software programs are used
to “program” the pins.

4.6.1.PORT 0
Port 0 pins may serve as inputs, outputs, or, when used together, as a bi directional low-
order address and data bus for external memory. To configure a pin as input, 1 must be written
into the corresponding port 0 latch by the program. When used for interfacing with the external
memory, the lower byte of address is first sent via PORT0, latched using Address latch enable
(ALE) pulse and then the bus is turned around to become the data bus for external memory.

4.6.2.PORT 1
Port 1 is exclusively used for input/output operations. PORT 1 pins have no dual
function. When a pin is to be configured as input, 1 is to be written into the corresponding Port 1
latch.

4.6.3.PORT 2
Port 2 may be used as an input/output port. It may also be used to supply a high –order
address byte in conjunction with Port 0 low-order byte to address external memory. Port 2 pins
are momentarily changed by the address control signals when supplying the high byte a 16-bit
address. Port 2 latches remain stable when external memory is addressed, as they do not have to
be turned around (set to 1) for data input as in the case for Port 0.
4.6.4.PORT 3
Port 3 may be used to input /output port. The input and output functions can be
programmed under the control of the P3 latches or under the control of various special function
registers. Unlike Port 0 and Port 2, which can have external addressing functions and change all
eight-port b se, each pin of port 3 maybe individually programmed to be used as I/O or as one of
the alternate functions. The Port 3 alternate uses are:

Pin (SFR) Alternate Use


P3.0-RXD (SBUF) Serial data input
P3.1-TXD (SBUF) Serial data output
P3.2-INTO 0 (TCON.1) External interrupt 0
P3.3 - INTO 1 (TCON.3) External interrupt 1
P3.4 - T0 (TMOD) External Timer 0 input
P3.5 – T1 (TMOD) External timer 1 input

P3.6 - WR External memory write pulse

P3.7 - RD External memory read pulse

Figure 4.9 : Port 3 Alternate Uses


4.7 INTERRUPTS:
Interrupts are hardware signals that are used to determine conditions that exist in external
and internal circuits. Any interrupt can cause the 8051 to perform a hardware call to an interrupt
–handling subroutine that is located at a predetermined absolute address in the program memory.
Five interrupts are provided in the 8051. Three of these are generated automatically by the
internal operations: Timer flag 0, Timer Flag 1, and the serial port interrupt (RI or TI) Two
interrupts are triggered by external signals provided by the circuitry that is connected to the pins
INTO 0 and INTO1. The interrupts maybe enable or disabled, given priority or otherwise
controlled by altering the bits in the Interrupt Enabled (IE) register, Interrupt Priority (IP)
register, and the Timer Control (TCON) register. . These interrupts are mask able i.e. they can be
disabled. Reset is a non maskable interrupt which has the highest priority. It is generated when a
high is applied to the reset pin. Upon reset, the registers are loaded with the default values.
Each interrupt source causes the program to do store the address in PC onto the stack and
causes a hardware call to one of the dedicated addresses in the program memory. The appropriate
memory locations for each for each interrupt are as follows:

Interrupt Address
RESET 0000
IE0 (External interrupt 0003
0)
TF0 (Timer 0 interrupt) 000B
IE1 (External interrupt 0013
1)
TF1 (Timer 1 interrupt) 001B
SERIAL 0023

EA disable all interrupts. If EA=0, now interrupt is acknowledged. If EA=1, each interrupt
source is individually enabled or disabled by setting its enable a lap bit.
---- Not implemented, reserved for future use.
ET2 Enables or disables timer 2 overflow or capturer interrupt.
ES Enables or disables the serial port interrupt.
ET1 Enables or disables timer 1 overflow interrupt.
EX1 Enables or disables timer external interrupt 1.
ET0 Enables or disables timer 0 overflow interrupt.
EX0 Enables or disables timer external interrupt 0.

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

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


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


+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
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
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

4.12.LM35

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is
linearly proportional to the Celsius (Centigrade) temperature.
The LM35 thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the
user is not required to subtract a large constant voltage from its output to obtain convenient
Centigrade scaling. The LM35 does not require any external calibration or trimming to provide
typical accuracies of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to +150°C
temperature range.

Low cost is assured by trimming and calibration at the wafer level. The LM35’s low output
impedance,linear output, and precise inherent calibration make interfacing to readout or control
circuitry especially easy. It can be used with single power supplies, or with plus andminus
supplies. As it draws only 60 μA from its supply, it hasvery low self-heating, less than 0.1°C in
still air. The LM35 is rated to operate over a −55° to +150°C temperature range,while the
LM35C is rated for a −40° to +110°C range (−10°with improved accuracy).

The LM35 series is available packaged in hermetic TO-46 transistor packages, while the
LM35C, LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The
LM35D is also available in an 8-lead surface mount small outline package and a
plastic TO-220 package.

4.12.1.Features

Calibrated directly in ° Celsius (Centigrade)


Linear + 10.0 mV/°C scale factor
0.5°C accuracy guaranteeable (at +25°C)
Rated for full −55° to +150°C range
Suitable for remote applications
Low cost due to wafer-level trimming
Operates from 4 to 30 volts
Less than 60 μA current drain
Low self-heating, 0.08°C in still air
Nonlinearity only ±1⁄4°C typical
Low impedance output, 0.1 W for 1 mA load

Figure 4.16 LM35

4.13.GAS sensor

The sensor we are going to use is LPG gas sensor MQ-6. This is a simple-to-use liquefied petroleum
gas (LPG) sensor, suitable for sensing LPG (composed of mostly propane and butane) concentrations in
the air. The MQ-6 can detect gas concentrations anywhere from 200 to 10000ppm.

This sensor has a high sensitivity and fast response time. The sensor's output is an analog resistance. The
drive circuit is very simple; all you need to do is power the heater coil with 5V, add a load resistance, and
connect the output to an ADC.

4.13.1.Features

High sensitivity to LPG, iso-butane, propane


Small sensitivity to alcohol, smoke.
Fast response .
Stable and long life
Simple drive circuit

They are used in gas leakage detecting equipments in family and industry, are suitable for
detecting of LPG, iso-butane, propane, LNG, avoid the noise of alcohol and cooking fumes and
cigarette smoke. Sensor composed by micro AL2O3 ceramic tube, Tin Dioxide (SnO2) sensitive
layer, measuring electrode and heater are fixed into a crust made by plastic and stainless steel
net. The heater provides necessary work conditions for work of sensitive components. The
enveloped MQ-6 have 6 pin ,4 of them are used to fetch signals, and other 2 are used for
providing heating current.

Figure 4.17 Gas sensor

Figure 4.18 Gas sensor circuit


4.14 PIR Sensor
The PIR (Passive Infra-Red) Sensor is a pyroelectric device that detects motion by measuring
changes in the infrared levels emitted by surrounding objects. This motion can be detected by
checking for a high signal on a single I/O pin.
4.14.1. Features

Single bit output


Small size makes it easy to conceal
Compatible with all Parallax microcontrollers
3.3V & 5V operation with <100uA current draw

Pyroelectric devices, such as the PIR sensor, have elements made of a crystalline material that
generates an electric charge when exposed to infrared radiation. The changes in the amount of
infrared striking the element change the voltages generated, which are measured by an on-board
amplifier. The devicecontains a special filter called a Fresnel lens, which focuses the infrared
signals onto the element. As the ambient infrared signals change rapidly, the on-board amplifier
trips the output to indicate motion.
The PIR Sensor has a range of approximately 20 feet. This can vary with environmental
conditions. The sensor is designed to adjust to slowly changing conditions that would happen
normally as the day progresses and the environmental conditions change, but responds by
making its output high when sudden changes occur, such as when there is motion.

Figure 4.19 PIR sensor


4.15 ADC0808

The ADC0808, ADC0809 data acquisition component is a monolithic CMOS device with an 8-
bit analog-to-digital converter,8-channel multiplexer and microprocessor compatible control
logic. The 8-bit A/D converter uses successive approximation as the conversion technique. The
converter features a high impedance chopper stabilized comparator, a 256R voltage divider with
analog switch tree and a successive approximation register. The 8-channel multiplexer can
directly access any of 8-single-ended analog signals. The device eliminates the need for external
zero and full-scale adjustments. Easy interfacing to microprocessors is provided by the latched
and decoded multiplexer address inputs and latched TTL TRI-STATE outputs. The design of the
ADC0808, ADC0809 has been optimized by incorporating the most desirable aspects of several
A/Dconversion techniques. The ADC0808, ADC0809 offers highspeed, high accuracy, minimal
temperature dependence, excellentlong-term accuracy and repeatability, and consumes minimal
power. These features make this device ideally suitedto applications from process and machine
control to consumerand automotive applications. For 16-channel multiplexer with common
output .

Figure 4.20 ADC0808

4.16 LCD

• 8 data pins D7:D0


Bi-directional data/command pins.
Alphanumeric characters are sent in ASCII format.

• RS: Register Select


RS = 0 -> Command Register is selected
RS = 1 -> Data Register is selected

• R/W: Read or Write


0 -> Write, 1 -> Read

• E: Enable (Latch data)


Used to latch the data present on the data pins.
A high-to-low edge is needed to latch the data.

• VEE : contrast control

4.17 GSM AT Commands:

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

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.

CHAPTER 5

System Design

Designing of this system is possible when you select the specific controller to suite.For this we
selected 8051 controller.With the help of 8051 controller intelligent system can be developed by
connecting LM35,gas sensor and PIR sensor ant the same time GSM modem also.

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.

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.Gsm modem we can connect to the controller by using one UART of 8051.Now this
controller will monitor the status the three different sensors and sends message if there is any
problem.
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 GSM technology became very popular,here its very easy to use for
intelligent systems 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.

CHAPTER 9

Conclusion and Future Scope

The controller we used having the following featurtes like 8 bit 8051 architecture in a tiny 40 pin
DIP package,128B RAM and 4kB on-chip Flash Program Memory. For low end applications this
controller is very easy to use and at the same time GSM also widely accepted protocol for mobile
communication.

Future Scope
In future small scale intelligent systems based on 8051 controllers can be widely used along with
the help of GSM technology.

References
[1] 8051 Architecture and Programming by Mazidi

[2] 8051 Programming by Ayala

[3] GSM AT commands user manual

[4] MAX232 user guide by MAXIM semiconductors

[5] Wikipedia

[6]Sparkfun.com

[7]national.com
Source code:

void Delay(unsigned int);


void Delay_1ms();
void Delay_30ms();
void lcd_init(); //lcd initialisation
void lcd_clear(); //clear display
void lcd_cmd(unsigned char);
void lcd_pos(unsigned char); //set the lcd address
void lcd_char(unsigned char); //convert the integer void
lcd_print(unsigned char *); //write the string to LCD
sbit RS=P3^7; //REg sel
sbit RW =P3^6; //READ/WRITE
sbit EN =P3^5; //ENABLE
sfr LCD=0xA0;

sbit adc_a =P1^0;

sbit adc_b =P1.1;

sbit adc_c =P1^2;

sbit adc_start =P1^3;

sbit adc_ale=P1^4;

sbit adc_clk =P1^5;

sbit pir =P1^6;

//DATA0-DATA7 TO P2
unsigned char i;

void GSM_Init(void);
void Modem_send(unsigned char *);
void send_sms(unsigned char *,unsigned char *,unsigned char *,unsigned char *,unsigned char
*);

void uart_init(void);

main()
{
unsigned char j,key,pw[5];
lcd_init();

lcd_print("LCD is Ready");
Delay1(100);
uart_init();
lcd_clear();
lcd_print("uart is Ready");
Delay1(100);
GSM_Init();
Delay1(50);

lcd_clear();
Delay1(100);
cd_print("gsm is Ready");

while(1)

lcd_clear();
adc_ale=0;
adc_start=0
adc_a=0;

adc_b=0;

adc_c=0;

Delay1(10);
adc_ale=1;
Delay1(10);
adc_start=1;
Delay1(10);
adc_ale=0;
Delay1(10);
adc_start=0;
Delay1(10);
Value=P1;

If(value>200)
{
send_sms("AT+CMGS=\"","\"",”gas detected”);

adc_a=0;
adc_b=0;

adc_c=0;

Delay1(10);
adc_ale=1;
Delay1(10);
adc_start=1;
Delay1(10);
adc_ale=0;
Delay1(10);
adc_start=0;
Delay1(10);
Value=P1;
If(value>50)

send_sms("AT+CMGS=\"","\"",”Temp high”);

If(PIR==1)

send_sms("AT+CMGS=\"","\"",”object detected”);

void MSDelay(unsigned char itime)


{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1257;j++);
}

//===============================================
//Delays
void Delay_1ms()
{
unsigned int d;
for( d=0;d<335;d++);
}
void Delay_30ms()
{
unsigned char j;
for(i=0;i<15;i++)
for(j=0;j<95;j++);
}
void Delay(unsigned int v) //Here we are generating ms delay
{
unsigned int t;
for(t=0;t<v;t++)
Delay_1ms();
}
//===============================================
void lcd_init()
{
Delay(1); //only for avoiding warning
Delay_30ms();
lcd_cmd(0x38);
Delay_30ms();
lcd_cmd(0x01);
Delay_30ms();
lcd_cmd(0x0C);
Delay_30ms();
lcd_cmd(0x06);
Delay_30ms();
lcd_cmd(0x80);
Delay_30ms();

}
//===============================================
void lcd_clear(void)
{
lcd_cmd(0x01);
lcd_cmd(0x80);
}

//===============================================
//THIS IS THE FUNCTION FOR WRITE THE DATAS IN INSTRUCTION REG

void lcd_cmd(unsigned char cmd)


{
LCD =cmd;
RS =0;
RW =0;
EN =1;
for(i=0;i<50;i++);
EN =0;
for(i=0;i<50;i++);
}
//===============================================
//THIS IS THE FUNCTION FOR SETTING THE STARTING ADDRESS OF DATA
DISPLAY
void lcd_pos(unsigned char pos)
{
LCD =pos;
RS =0;
RW =0;
EN =1;
for(i=0;i<50;i++);
EN =0;
for(i=0;i<50;i++);
}
//===============================================
void lcd_char(unsigned char dat) //display_data
{
LCD =dat;
RS =1;
RW =0;
EN =1;
for(i=0;i<50;i++);
EN =0;
for(i=0;i<50;i++);

}
//===============================================
//DISPLAY STRING IN of data in LCD
void lcd_print(unsigned char *str)
{
while(*str!='\0')
{
LCD =*str;
RS =1;
RW =0;
EN =1;
Delay_30ms();
EN =0;
str++;
}
}
//===============================================//
// Delays //
//===============================================//
void Delay_1ms()
{
unsigned int d;
for( d=0;d<335;d++);
}
//===============================================
void Delay_30ms()
{
unsigned char j;
for(i=0;i<15;i++)
for(j=0;j<95;j++);
}
//===============================================
void Delay(unsigned int v) //Here we are generating ms
delay
{
unsigned int t;
for(t=0;t<v;t++)
Delay_1ms();
}
//===============================================
void MSDelay(unsigned char itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1257;j++);
}
//===============================================

void GSM_Init(void)
{
lcd_clear();
lcd_print("GSM Initializing");
Delay(200);
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");
lcd_print("GSM Initialized");
Delay(200);
}
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')
break;
SBUF = 'A';
while(TI == 0);
TI = 0;
SBUF = '/';
while(TI == 0);
TI = 0;
}
TI = 0;
RI = 0;
}
void send_sms(unsigned char *cmd1,unsigned char *cmd2,unsigned char *ch1)

{
unsigned char number[11]={"9885514414"};
unsigned char cha='X',P;
while(*cmd1)
{
RI=0;
TI=0;
SBUF=*cmd1;
while(TI==0);
TI=0;
RI=0;
cmd1++;
}

for(P=0;P<10;P++)
{
RI=0;
TI=0;
SBUF=number[P];
while(TI==0);
TI=0;
RI=0;
}

while(*cmd2)
{
RI=0;
TI=0;
SBUF=*cmd2;
while(TI==0);
TI=0;
RI=0;
cmd2++;
}

Enter();

while(cha!='>')
{
while(RI==0);
cha=SBUF;
RI=0;
}

for(P=0;P<10;P++)
{
RI=0;
TI=0;
SBUF=*ch1;
while(TI==0);
TI=0;
RI=0;
ch1++;
}
for(P=0;P<15;P++)
{
RI=0;
TI=0;
SBUF=*ch2;
while(TI==0);
TI=0;
RI=0;
ch2++;
}
for(P=0;P<15;P++)
{
RI=0;
TI=0;
SBUF=*ch3;
while(TI==0);
TI=0;
RI=0;
ch3++;
}
RI=0;
TI=0;
SBUF=0x1A;
while(TI==0);
TI=0;
RI=0;
}

void uart_init(void)
{
SCON = 0x50; //Mode 1..8 bit data,..1 stop bit,..1 start bit
TMOD = 0x20; //Timer 1....Mode 2...8 bit Auto Reload
TL1 = 0xFD;
TH1 = 0xFD; //Baud Rate 9600
TR1 = 1;
}

S-ar putea să vă placă și