Академический Документы
Профессиональный Документы
Культура Документы
PROJECT REPORT
ON
BACHELOR OF TECHNOLOGY
IN
E.HEMALATHA
(13EK1A0404)
S.ALEKHYA
(13EK1A0418)
P.VINAY
(13EK1A0417)
K.SUSHMA
(14EK5A0406)
CERTIFICATE
This is to certify that this dissertation entitled PROJECT TITLE is a bonafide
work done by
NAME1
(HT NO1)
NAME2
(HT NO2)
NAME3
(HT NO3)
NAME4
(HT NO4)
In partial fulfillment of the requirements for the award of the Degree of Bachelor of
Technology in Electronics and Communication Engineering from Jawaharlal Nehru
Technological University Hyderabad, (JNTUH) during the Academic year 2009-2013.
Internal Guide
External examiner
DECLARATION
We hereby declare that the project report entitled PROJECT TITLESubmitted
to ABDUL KALAM
Place: KOTHAGUDEM
Date:
PROJECT ASSOCIATES
NAME1
(HT NO1)
NAME2
(HT NO2)
NAME3
(HT NO3)
NAME4
(HT NO4)
ii
ACKNOWLEDGEMENT
We would like to express my gratitude to all the people behind the screen who
helped me to transform an idea into a real application.
We would like to express my heart-felt gratitude to my parents without whom we
would not have been privileged to achieve and fulfill my dreams. We are grateful to our
principal, Dr. M.JANARDHAN who most ably run the institution and has had the major
hand in enabling me to do my project.
We profoundly thank Sri. G.RAJAIAH , Head of the Department of
Electronics and Communication Engineering who has been an excellent guide and also a
their constant guidance and encouragement crowns all the efforts with success. In this
context, I would like thank all the other staff members, both teaching and non-teaching,
which have extended their timely help and eased my task.
PROJECT ASSOCIATES
NAME1
(HT NO1)
NAME2
(HT NO2)
NAME3
(HT NO3)
NAME4
(HT NO4)
Submitted By:
Ritika Arora (0838131030)
Shubhashish Dixit (0838131031)
Humaira Anam (0838131409)
Rishabh Singh (0838131029)
Department of Electronics & Communication Engineering
A
PROJECT REPORT
ON
Pollution detection system with intelligent alerting system
submitted
In partial fulfillment
For the award of the degree of
Bachelor of Technology
In Department of Electronics & Communication Engineering
Submitted By:
Ritika Arora (0838131030)
Shubhashish Dixit (0838131031)
Humaira Anam (0838131409)
Rishabh Singh (0838131029)
Department of Electronics & Communication Engineering
Krishna Institute of Management & Technology Moradabad
Rampur Road, NH-24, Moradabad-244001(U.P)
PROJECT REPORT
ON
Pollution detection system with intelligent alerting system
By
Ritika Arora (0838131030)
Shubhashish Dixit (0838131031)
Humaira Anam (0838131409)
Mr. P.K.Raghav
PROJECT
INCHARGE
Project Incharge
Examiner
Project Guide
ACKNOWLEDGEMENT
We would like to place on record my deep sense of gratitude to Prof.
R.K.Yadav, HoD. of Electronics and Communication Engineering,
Krishna Institute of Management & Technology(KIMT), Moradabad,
India. Mr. Akhilesh Sharma, Associate Professor Department of
Electronics & Communication Engineering , KIMT, Moradabad for
their generous guidance, help and useful suggestions.
We express my sincere gratitude to Mr. Ajay Kumar, Senior
Lecturer; Department of Electronics & Communication Engineering,
KIMT, Moradabad Prof. Mr. P.K. Raghav, Senior Lecturer; Ms.
Sonali Gupta, Department of Electronics & Communication
Engineering, KIMT, Moradabad, India, for his stimulating guidance,
PAGE INDEX
S. No.
CONTENTS
Page no.
i
Certificate I
ii
Acknowledgement II
Iii List of Tables VIII
iv List of Figures IX
v
List of Symbols XI
vi Abstract XII
1
INTRODUCTION 1
1.1 General Introduction 1
1.2 Organization Of Project 3
1. 3 Project Statement 7
2
CIRCUIT STRUCTURE 9
2.1 GENERAL THEORY 9
2.2 PRIMARY COMPONENTS 9
115
LIST OF TABLES
Tables
Page No.
Table 2.1 Pin Description of IC 7805 18
Table 3.1 Pin Diagram of AT89C51
30
Table 3.2 Port 3 Functions 31
Table 3.3 Status of External Pins during Idle and Power-Down
Modes
34
Table 3.4 Flash Programming Mode Signature Codes 35
Table 3.5 Lock Bit Protection Modes 36
Table 3.6 Signature Bytes 38
Table 3.7 SFR Addresses 39
Table 3.8 Modes of Operation
40
Table 3.9 PSW Register Details 41
Table 3.10 PCON Register 42
LIST OF SYMBOLS
Symbols Meaning
LED Light Emitting Diode
IC Integrated Chip
GSMGlobal System Module
PC Personal Computer
DIP Dual In-line Package
RAM
Random Access Memory
ROM
Read Only Memory
I/O Input Output
VCC Level 1 Voltage
GNDGround
XTAL
Crystal
Ppm Parts per million
MCU
Micro Controller Unit
APR Auto Pre Recording
CMOS
UART
ABSTRACT
Security is primary concern for everyone. This Project describes a
design of effective security alarm system that can monitor an
industry with different sensors. Gas detection and fire detection can
be monitored by the status of each individual sensor and is indicated
with an LED, Buzzer Voice Recording & Playback Device and dial
up logic. These all shows whether the sensor has been activated and
whether the wiring to the sensor is in order. In this project we show
that how we use the telephone as a electronics eye. With the help of
any phone we can know the position of the house. In this logic we
attach some sensor with the telephone and if there is any
mishappening at home then telephone is automatic on and then
circuit press the redial button of the telephone and then telephone
dial the pre-dialed number and sense the voice message to the
received end.
The detection alarm is built around the AT89C51 microcontroller
from Atmel. This microcontroller provides all the functionality of the
detection alarm. It also takes care of filtering of the signals at the
inputs. A fire sensor can be connected to the gas sensor alarm. These
sensors need to have their contacts closed when in the inactive state
(i.e. normally closed). In addition, each sensor needs to have its
tamper connection wired as well. A power supply voltage of +5 VDC
CHAPTER - 1
INTRODUCTION
1.1 GENERAL INTRODUCTION
Engineering is not only a theoretical study but it is a implementation
of all we study for creating something new and making things more
easy and useful through practical study. It is an art which can be
gained with systematic study, observation and practice. In the college
curriculum we usually get the theoretical knowledge of industries,
and a little bit of implementation knowledge that how it is works?
But how can we prove our practical knowledge to increase the
productivity or efficiency of the industry????
Don't take the chance of becoming victim of carelessness, which is
often accompanied by serious accident. Protect our family and
valuables with this microcontroller based security system that will let
us rest our head knowing that there is anything like gas leakage or
fire existing into our home.
The motivation is to facilitate the users to know the state of their
homes having ubiquitous access. The system provides availability
due to development of a low cost system. This system is low cost but
very useful for users to know their home state wherever are located.
Home security has been a major issue where temperature starts
raising day by day and everybody wants to take proper measures to
prevent intrusion. There was need to prevent fires and gas leaks no
matter when they are in the house or outside. By using GSM
technology via Dial-Up logic we can help users to supervise their
home against intruders, gas leak and fire only at one product with a
low cost.
The security is what a person expects from a home, this project was
designed keeping this particular aspect in mind. The security system
is made fool proof to the maximum extent possible. In this project
we make use of a microcontroller as the main controller to control
the input and the output that reach the controller. There is a large
scope in the future enhancements that can be provided along with
this project like actuating a fire detection alarm or sensing a leakage
of gas etc.
Generally in any industry, there are several blocks and there is an
administrative block which controls all blocks. If any problem is
created in any one of the blocks, at first the persons in that particular
block has to inform to the administrative block and then the action
will be taken. So if we consider a fire accident in any one of the
blocks the person on that incident generally they makes a call to the
administrative block or security block as took over and they has to
call the ambulance, fire station etc. It will be a long time process, so
in the mean the damage may increase in gigantic extent. The most
basic fire protection methods include fire prevention, detection and
control. Buildings should be constructed using fire rated walls,
doors, ceilings and floors. The use of combustible materials in
interior furnishing should be kept to a minimum. There are several
types of detection devices. Automatic fire detection systems, when
combined with other elements of an emergency response and
evacuation plan, can significantly reduce property damage, personal
injuries, and loss of life from fire in the work place. Their main
function is to quickly identify a developing fire and alert building
occupants and emergency response personnel before extensive
damage transpire. Automatic fire detection systems do this by using
corresponding sensors. When the alarm has been activated, the LED
of the sensor that caused the alarm will light up, or flash in the event
of a cable failure.
When the alarm is armed, the LED 'alarm armed' will flash during
the exit-delay. After the exit-delay, the LED will light continuously.
The LED 'alarm triggered LED' flashes during the entry-delay and
will turn on continuously once an actual alarm has been generated.
'Alarm triggered LED' turns off only when the alarm is switched off
with key switch Sw1. When an alarm has taken place, it can be
determined afterwards which sensor (or tamper input) caused the
alarm to trigger. The LED 'tamper' lights up when the tamper input is
opened. This LED will also continue to be on until the alarm is
switched off.
The uniqueness of this project is not only alerting the neighbors by
siren, it also redials a mobile number which is already in dial list. A
mobile number or a land line number can be fixed for it. As this
system works on existing mobile, it can dial the number even the
subscriber is out of station. Another important feature that is
connected to circuit is Single-Chip Voice Recording & Playback
Device. An IC APR9600 is implemented for it. The APR9600 device
offers true single-chip voice recording, non-volatile storage, and
playback capability for 40 to 60 seconds. The device supports both
random and sequential access of multiple messages. Sample rates are
user-selectable, allowing designers to customize their design for
unique quality and storage time needs. Integrated output amplifier,
microphone amplifier, and AGC circuits greatly simplify system
design. The device is ideal for use in portable voice recorders, toys,
and many other consumer and industrial applications. APLUS
integrated achieves these high levels of storage capability by using
its proprietary analog/multilevel storage technology implemented in
an advanced Flash non-volatile memory process, where each
memory cell can store 256 voltage levels. This technology enables
the APR9600 device to reproduce voice signals in their natural form.
It eliminates the need for encoding and compression, which often
introduce distortion.
This project uses regulated 5V, 500mA power supply. 7805 three
terminal voltage regulator is used for voltage regulation. Bridge type
the corresponding n-channel transistors are off and the LED is off.
When both the inputs are High, both transistors are ON. Then the
output is LOW.
2.5 MQ-6 GAS SENSOR
Sensitive material of MQ-6 gas sensor is SnO2, which with lower
conductivity in clean air. When the target combustible gas exist, the
sensor's conductivity is higher along with the gas concentration
rising. Please use simple electro circuit, Convert change of
conductivity to correspond output signal of gas concentration. MQ-6
gas sensor has high sensitivity to Propane, Butane and LPG, also
response to Natural gas. The sensor could be used to detect different
combustible gas, especially Methane; it is with low cost and suitable
for different application.[7]
2.5.1 CHARACTERISTICS
"
Good sensitivity to Combustible gas in wide range
"
High sensitivity to Propane, Butane and LPG
"
Long life and low cost
"
Simple drive circuit
2.5.2 APPLICATIONS
"
Domestic gas leakage detector
"
Industrial Combustible gas detector
"
Portable gas detector
2.5.3 STRUCTURE AND CONFIGURATION
Structure and configuration of MQ-6 gas sensor is shown as Fig. 3,
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-4 has 6 pin, 4 of them are used to fetch signals, and
other 2 are used for providing heating current.
The sensors resistance produce reversible drift if it's stored for long
time without electrify, this drift is related with storage conditions.
Sensors should be stored in airproof without silicon jell bag with
clean air. For the sensors with long time storage but no electrify, they
need long aging time for stability before using.
"
Long time exposed to adverse environment
No matter the sensors electrified or not, if exposed to adverse
environment for long time, such as high humidity, high temperature,
or high pollution etc, it will affect the sensors performance badly.
"
Vibration
Continual vibration will result in sensors down-lead response then
rupture. In transportation or assembling line, pneumatic
screwdriver/ultrasonic welding machine can lead this vibration.
"
Concussion
If sensors meet strong concussion, it may lead its lead wire
disconnected.
"
Usage
For sensor, handmade welding is optimal way. If use wave crest
welding should meet the following conditions:
"
2.13 IC 7805
7805 is a voltage regulator integrated circuit. It is a member of 78xx
series of fixed linear voltage regulator ICs. The voltage source in a
circuit may have fluctuations and would not give the fixed voltage
output. The voltage regulator IC maintains the output voltage at a
constant value. The xx in 78xx indicates the fixed output voltage it is
designed to provide. 7805 provides +5V regulated power supply.
Capacitors of suitable values can be connected at input and output
pins depending upon the respective voltage levels.[8]
2.13.1 PIN DIAGRAM
resistor R12 connected across the OSCR (pin 7) of the chip and the
ground.[6][12]
2.14.1 MESSAGE MANAGEMENT
The APR9600 chip supports the following message modes. Random
access mode with 2, 4, 8 message within the total recording time.
Tape mode with two options: Auto rewind and Normal operation.
The modes are defined by pins 24, 25 and 9 cannot be mixed. An
important feature of the APR9600 chip is indication of changes in
the device status through beeps superimposed on the device output:
for example, the start of recording is indicated by a beep, so the
person can now start speaking into the microphone. This feature is
enabled by making pin 11 high.
2.15 IC 555 AS MONOSTABLE MULTIVIBRATOR
A monostable multivibrator (MMV) often called a one-shot
multivibrator, is a pulse generator circuit in which the duration of the
pulse is determined by the R-C network, connected externally to the
555 timer. In such a vibrator, one state of output is stable while the
other is quasi-stable (unstable). For auto-triggering of output from
quasi-stable state to stable state energy is stored by an externally
connected capacitor C to a reference level. The time taken in storage
determines the pulse width. The transition of output from stable state
to quasi-stable state is accomplished by external triggering. The
schematic of a 555 timer in monostable mode of operation is shown
in figure 2.6.[1][3]
Fig2.6 555-Timer-Monostable-Multivibrator
2.15.1 MONOSTABLE MULTIVIBRATOR CIRCUIT DETAILS
Pin 1 is grounded. Trigger input is applied to pin 2. In quiescent
condition of output this input is kept at + VCC. To obtain transition
of output from stable state to quasi-stable state, a negative-going
pulse of narrow width (a width smaller than expected pulse width of
output waveform) and amplitude of greater than + 2/3 VCC is
The capacitor C has to charge through resistance RA. The larger the
time constant RAC, the longer it takes for the capacitor voltage to
reach +2/3VCC.
In other words, the RC time constant controls the width of the output
pulse. The time during which the timer output remains high is given
as:
tp =1.0986RAC,
where RA is in ohms and C is in farads.
The pulse width of the circuit may range from micro-seconds to
many seconds. This circuit is widely used in industry for many
different timing applications.
2.16 GENERAL FUNCTIONAL DESCRIPTION
On power up, pin 23 is pulled low through resistor R7 to enable the
device for operation. Toggling this pin by switch S9 also resets
several message management features. Pin no 27 is pulled low to
enable recording and it is pulled high for playback. To start recording
playback switch the appropriate trigger pin as described in the
circuit. Glowing of the LED indicates that the device is busy and no
commands can be currently accepted. The LED is driven by PNP
transistor T1 which is connected to pin 10 of the chip. LED2
indicates recording in each individual memory segment. It is driven
by pin 22 through transistor.
2.17 FULL CIRCUIT STRUCTURE & EXPLANATION
Below the Fig 2.8 shows the final implemented electro circuit of Gas
& Heat Sensor along with auto dial up logic and voice recording and
playback device APR. The complete explained description of circuit
is as follows:
Firstly we ON the Power supply of 230V AC to provide to the
circuit. The AC is then step down by transformer to 12V, which is
then used for circuit. The 12V AC is rectified using bridge rectifier
to 9V DC supply. Now as per the requirement we certainly use 9V
and 5V DC supply. To remove out the ripples came during
rectification we applied filter circuit which block ripples to move in
forward direction. For 9V supply we use direct after filter circuit &
for the 5V we add the IC 7805 as voltage regulator. After IC 7805 we
again filter ripples present if any. Now the power circuitry is
completed.
Before starting from any one test we will reset the whole circuit last
configuration for better results. Let us take Gas Sensor firstly, if we
place sensor in the place of leakage the inner circuit of MQ-6 sensor
will short circuit by the concentration level above than 8 ppm, which
as the result give trigger input to IC 555. Trigger input is applied to
pin 2. In quiescent condition of output this input is kept at + VCC.
To obtain transition of output from stable state to quasi-stable state, a
negative-going pulse of narrow width (a width smaller than expected
pulse width of output waveform) and amplitude of greater than +
2/3 VCC is applied to pin 2. Output is taken from pin 3, which is
applied to Microcontroller 8951 IC. At the same time a exhaust fan is
given ON signal by IC 555 for Gas Sensor & fan starts exhausting
gas from ambient place. Microcontroller port 3.3 is for Gas Sensor
output. As 8951 is coded for it, it then sends signal to the relay
circuitry & APR for play recording message. Relay that already
connected to hands free will redial the last call or concerned
authorities of home, industry, hotel etc. APR will play pre recorded
message so the information is sent to owner & if within time limit
someone approaches there, chances of accident can be easily
eliminated. Along with dial up logic & message management, there's
implementation of Buzzer & LED in the circuit which will ON as
there is any type of detection so the person nearby can watch & hear
& safe lives by an unexpected mishaps.
Talking about Heat Sensor now, in case of short circuits at
homes, industries etc there arise high flames of fire and also there is
some places where excess of heat is too dangerous. Heat sensor
element senses it n give signal to triggered input IC 555. The IC 555
output is now connected to port 3.2 of IC 8951. The main difference
here is that the exhaust fan will not work during heat sensing case.
The rest working of Microcontroller will be the same. As
Microcontroller 8951 is coded for it, it then sends signal to the relay
circuitry & APR for play recording message. Relay that already
connected to hands free will redial the last call or concerned
authorities of home, industry, hotel etc. APR will play pre recorded
message so the information is sent to owner & if within time limit
someone approaches there, chances of accident can be easily
eliminated.
This is all about how stuff works. !!
CHAPTER - 3
MICROCONTROLLER AT89C51
"
3.1.2 DESCRIPTION
The AT89C51 is a low-power, high-performance CMOS 8-bit
microcomputer with 4K bytes of Flash Programmable and Erasable
Read Only Memory (PROM). The device is manufactured using
Atmel's high density nonvolatile memory technology and is
compatible with the industry standard MCS-51 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 Flash on a
3.2.5 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 it 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.
Pin No
Function Name
1
8 bit input/output port (P1) pins P1.0
2
P1.1
3
P1.2
4
P1.3
5
P1.4
6
P1.5
7
P1.6
8
P1.7
9
Reset pin; Active high Reset
10 Input (receiver) for serial communication Rx D 8 bit
input/output port (P3) pins P3.0
11 Output (transmitter) for serial communication
Tx D
P3.1
12 External interrupt 1 Int0
P3.2
13 External interrupt 2 Int1
P3.3
14 Timer1 external input T0
P3.4
15 Timer2 external input T1
P3.5
16 Write to external data memory. Write
P3.6
17 Read from external data memory.Read
P3.7
18 Quartz crystal oscillator (up to 24 MHz).
Crystal 2
19
Crystal 1
31
P2.0/ A8
P2.1/ A9
P2.2/ A10
P2.3/ A11
P2.4/ A12
P2.5/ A13
P2.6/ A14
P2.7/ A15
Alternate Functions
3.2.9 ALE/PROG
Address Latch Enable output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the
program pulse input (PROG) during Flash programming. In normal
operation ALE is emitted at a constant rate of 1/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.
3.2.10 PSEN
Program Store Enable is the read strobe to external program
memory.
This is an output pin. PSEN stands for "program store enable." In an
8031-based system in which an external ROM holds the program
code, this pin is connected to the OE pin of the ROM
When the AT89C51 is executing code from external program
memory, PSEN is activated twice each machine cycle, except that
two PSEN activations are skipped during each access to external
data memory.
3.2.11 EA/VPP
External Access Enable. EA must be strapped to GND in order to
enable the device to fetch code from external program memory
locations starting at 0000H up to FFFFH. Note, however, that if lock
bit 1 is programmed, EA will be internally latched on reset. EA
should be strapped to VCC for internal program executions. This pin
also receives the 12-volt programming enable voltage (VPP) during
Flash programming, for parts that require 12-volt VPP.
3.2.12 XTAL 1
Input to the inverting oscillator amplifier and input to the internal
clock operating circuit.
3.2.13 XTAL 2
Output from the inverting oscillator amplifier.
3.2.14 OSCILLATOR CHARACTERISTICS
XTAL 1 and XTAL 2 are the input and output, respectively, of an
inverting amplifier which can be configured for use as an on-chip
oscillator, as shown in Figure 1. Either a quartz crystal or ceramic
resonator may be used. To drive the device from an external clock
source, XTAL2 should be left unconnected while XTAL1 is driven
as shown in Figure 3.4.There are no requirements on the duty cycle
of the external clock signal, since the input to the internal clocking
circuitry is through a divide-by-two flip-flop, but minimum and
maximum voltage high and low time specifications must be
observed.
3.2.15 IDLE MODE
In idle mode, the CPU puts itself to sleep while all the on chip
peripherals remain active. The mode is invoked by software. The
content of the on-chip RAM and all the special functions registers
remain unchanged during this mode. The idle mode can be
terminated by any enabled Interrupt or by hardware reset. It should
be noted that when idle is terminated by a hard
Hardware reset, the device normally resumes program execution,
from where it left off, up to two machine cycles before the internal
reset algorithm takes control. On-chip hardware inhibits access to
internal RAM in this event, but access to the port pins is not
inhibited. To eliminate the possibility of an unexpected write to a
port pin when Idle is terminated by reset, the instruction following
the one that invokes Idle should not be one that writes to a port pin
or to external memory.
During the 2 modes, idle & power, the status of external pins
are described in table 3.3.
Mode
Program Memory
ALE
PORT1
PORT2
PORT3
PSEN
Idle Internal
Idle External
1
1
PORT0
Data
Power-down
Internal
Power-down
External
is a hardware reset. Reset redefines the SFRs but does not change the
on-chip RAM. The reset should not be activated before VCC is
restored to its normal operating level and must be held active long
enough to allow the oscillator to restart and stabilize.
3.2.18 PROGRAMMING THE FLASH
The AT89C51 is normally shipped with the on-chip Flash memory
array in the erased state (that is, contents = FFH) and ready to be
programmed. The programming interface accepts either a highvoltage (12-volt) or a low-voltage (VCC) program enable signal. The
low-voltage programming mode provides a convenient way to
program the AT89C51 inside the user's system, while the highvoltage programming mode is compatible with conventional thirdparty Flash or EPROM programmers.
The AT89C51 is shipped with either the high-voltage or low-voltage
programming mode enabled. The respective top-side marking and
device signature codes are listed in the following table 3.4.
The AT89C51 code memory array is programmed byte-by-byte in
either programming mode. To program any non-blank byte in the onchip Flash Memory, the entire memory must be erased using the
Chip Erase Mode.
VPP = 12V
VPP = 5V
Top-side Mark AT89C51 AT89C51
xxxx
xxxx-5
Yyww
yyww
Signature (030H)
= 1EH
(030)= 1EH
(031H)
= 51H
(031)= 51H
(032H)
=F FH
(032)= 05H
U
U
If lock bits LB1 and LB2 have not been programmed, the
programmed code data can be read back via the address and data
lines for verification. The lock bits cannot be verified directly.
Verification of the lock bits is achieved by observing that their
features are enabled.
3.3.4 CHIP ERASE
The entire Flash array is erased electrically by using the proper
combination of control signals and by holding ALE/PROG low for
10 ms. The code array is written with all "1"s. The chip erase
operation must be executed before the code memory can be reprogrammed.
3.3.5 READING THE SIGNATURE BYTES
The signature bytes are read by the same procedure as a normal
verification of locations 030H, 031H, and 032H, except that P3.6
and P3.7 must be pulled to a logic low. The values returned are as
following table 3.6.
(030H) = 1EH indicates manufactured by Atmel
(031H) = 51H indicates 89C51
(032H) = FFH indicates 12V programming
(032H) = 05H indicates 5V programming
Table 3.6 Signature Bytes
3.4 PROGRAMMING INTERFACE
Every code byte in the Flash array can be written and the entire array
can be erased by using the appropriate combination of control
signals. The write operation cycle is self timed and once initiated,
3.5.1.1 GATE
Gating control when set. Timer/counter is enabled only while the
INTX pin is high and the TRx control pin is set. When cleared, the
timer is enabled whenever the TRx control bit is set
3.5.1.2 C/T
Timer or counter selected cleared for timer operation (input from
internal system clock)
M1 Mode bit 1
M0 Mode bit 0
M1 M0 MODE
OPERATING MODE
0
0
0
13 BIT TIMER/MODE
0
1
1
16 BIT TIMER MODE
1
0
2
8 BIT AUTO RELOAD
1
1
3
SPLIT TIMER MODE
Table 3.8 Modes of Operation
3.5.2 PSW (PROGRAM STATUS WORD)
Below are the contents of PSW in figure 3.6 & details in table 3.9
F0
PSW.5
SMOD - Serial mode bit used to determine the baud rate with Timer
1.
Baud Rate
bit which is used for the serial communication is D7, the SMOD bit.
When the 8051 is powered up, D7 (SMOD BIT) OF PCON register
is zero. We can set it to high by software and thereby double the
baud rate. Table 3.11 shows the Baud Rate comparison for XTAL
TH1 (DECIMAL) HEX SMOD =0 SMOD =1
-3 FD 9600 19200
-6 FA 4800 9600
-12 F4 2400 4800
-24 E8 1200 2400
Table 3.11 Baud Rate Comparison for XTAL = 11.0592 MHZ
3.5.4 TCON - TIMER CONTROL REGISTER
Table 3.12 shows the TCON register.
D7 D6 D5 D4 D3 D2 D1 D0
TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0
Table 3.12 TCON Register
Address: 88H (bit addressable)
TF1 - Timer 1 overflow flag
TR1 - Timer 1 run control bit
TF0 - Timer 0 overflow flag
TR0 - Timer 0 run control bit
IE1 - External interrupt 1 edge flag. Set to 1 when edge detected.
IT1 - Edge control bit for external interrupt 1. 1 = edge, 0 = level
IE0 - External interrupt 0 edge flag. Set to 1 when edge detected
IT0 - Edge control bit for external interrupt 0. 1 = edge, 0 = level
3.5.5 SCON - SERIAL CONTROL REGISTER
Table 3.13 shows the SCON register.
D7 D6 D5 D4 D3 D2 D1
SM0 SM1 SM2 REN TB8 RB8 TI
D0
RI
0
0
1
1
SM0
SM1
Operation Baud rate
0
Shift register
Osc/12
1
8-bit UART
Set by timer
0
9-bit UART
Osc/12 or Osc/64
1
9-bit UART
Set by timer
1
1
TL0 is 8-bit counter controlled by Timer0 control bits.
TH0 is 8-bit counter controlled by Timer1 control bits. Timer 1 is
stopped
Table 3.16 Modes of TMOD
3.5.7 IE - INTERRUPT ENABLE REGISTER
Table 3.17 represents the IE register.
D7 D6 D5 D4 D3 D2 D1 D0
EA X
ET2 ES ET1 EX1 ET0 EX0
Table 3.17 IE Register
Address: 0A8H (bit addressable)
EA - Global interrupt enable
x - Not defined
ET2 - Timer 2 interrupt enable
ES - Serial port interrupt enable
ET1 - Timer 1 interrupt enable
EX1 - External interrupt 1 enable
ET0 - Timer 0 interrupt enable
EX0 - External interrupt 0 enable
3.5.8 IP - INTERRUPT PRIORITY REGISTER
Table 3.18 represents the IP register.
D7 D6 D5 D4 D3 D2 D1 D0
x
x
PT2 PS PT1 PX1 PT0 PX0
Table 3.18 IP Register
Address: 0B8H (bit addressable)
x - Not defined
PT2 - Priority for timer 2 interrupt
PS - Priority for serial port interrupt
PT1 - Priority for timer 1 interrupt
PX1 - Priority for external interrupt 1
PT0 - Priority for timer 0 interrupt
D6 D5 D4 D3 D2 D1 D0
RCLK
TCLK
EXEN2 TR2 C/T2 CP/
RL2
Table 3.19 T2CON Register
RCLK - Receive clock. When set causes the serial port to use timer 2
for reception.
TCLK - Transmit clock. When set causes the serial port to use timer
2 for transmission.
C/ T2 - Counter/Timer select.if 0 use internal timer if 1 use external
pin
CP/ RL2 - Capture/reload flag.
3.6 MCS-51 FAMILY INSTRUCTION SET
The instruction set is divided in to 5 categories. They are as follows:
1.
Arithmetic instructions
2.
Logic instructions.
3.
Data transfer instructions.
4.
Boolean variable manipulation instruction.
5.
Program and machine control instruction.
We have listed all the instructions of microcontroller with
description, Bytes, & Cycles, which is figured out and described by
next page.
((SP)) ?(PC15-8)
(PC10-0) ? page address
Bytes: 2
Cycles: 2
3.6.2 ADD A, SOURCEBYTE
Function: Add
Flags: OV, AC, CY
Description: ADD adds the byte variable indicated to the
accumulator, leaving the result in the accumulator. The carry and
auxiliary carry flags are set, respectively, if there is a carry out of bit
7 or bit 3, and cleared otherwise. When adding unsigned integers, the
carry flag indicates an overflow occurred. OV is set if there is a carry
out of bit 6 but not out of bit 7, or a carry out of bit 7 but not out of
bit 6; otherwise OV is cleared. When adding signed integers, OV
indicates a negative number produced as the sum of two positive
operands, or a positive sum from two negative operands. Four source
operand addressing modes are allowed: register, direct, register
indirect, or immediate.
Example:
MOV A,#45H ; A = 45H
ADD A,#4FH
Result: A = 94H, CY = 0.
The following addressing modes are supported for the ADD
instruction.
1. Immediate: ADD A, #data
Example: ADD A,#40H
2. Register: ADD A, Rn
Example: ADD A,R1
3. Direct: ADD A, direct
Example: ADD A, 20H ;Add data in RAM location 20H to A
4. Register-indirect: ADD A,@Ri
Example: ADD A,@R0 ;Add to A data pointed by R0
3.6.3 ADDC A,SOURCEBYTE
Function: Add with carry
Flags: OV, AC, CY
allowed for the source operand. A slash ("/") preceding the operand
in the assembly language indicates that the logical complement of
the addressed bit is used as the source value, but the source bit itself
is not affected.
3.6.7 CJNE DEST-BYTE, SRC-BYTE, TARGET
Function: Compare and jump if not equal
Flags: CY
Description: CJNE compares the magnitudes of the first two
operands, and branches if their values are not equal. The branch
destination is computed by adding the signed relative displacement
in the last instruction byte to the PC, after incrementing the PC to the
start of the next instruction. The carry flag is set if the unsigned
integer value of dest-byte is less than the unsigned integer value of
src-byte; otherwise, the carry is cleared. Neither operand is affected.
The first two operands allow four addressing mode combinations:
the accumulator may be compared with any directly addressed byte
or immediate data, and any indirect RAM location or working
register can be compared with an immediate constant.
Example:
1. Immediate: CJNE A, #data, target
Example: CJNE A, #40,GO ; JUMP if A is not 40
2. Direct: CJNE A, direct, target
Example: CJNE A, 20H,GO ; JUMP if A !=(20H)
3. Register: CJNE Rn,#data,target
Example: CJNE R5,#70,GO ; jump if R5 is not 70
In the fourth addressing mode, any RAM location can be destination.
The RAM location is held by register R0 or R1.
4. Register-indirect: CJNE @Ri,#data,target
Example: CJNE @R1,#40,GO ;Jump if RAM location whose
address is held by R1 is not equal to 40.
3.6.8 CLR A
Function: Clear accumulator
Flags: None are affected
Description: The accumulator is cleared (all bits set to zero).
Flags: CY
Description: DA A adjusts the eight-bit value in the accumulator
resulting from the earlier addition of two variables (each in packed
BCD format), producing two four-bit digits. Any ADD or ADDC
instruction may have been used to perform the addition. If
accumulator bits 3-0 are greater than nine (1010-1111), or if the AC
flag is one, six is added to the accumulator producing the proper
BCD digit in the low order nibble. This internal addition would set
the carry flag if a carry-out of the low order four-bit field propagated
through all high-order bits, but it would not clear the carry flag
otherwise. If the carry flag is now set, or if the four high-order bits
now exceed nine (1010-1111), these high-order bits are incremented
by six, producing the proper BCD digit in the high-order nibble.
Again, this would set the carry flag if there was a carryout of the
high-order bits, but wouldn't clear the carry. The carry flag thus
indicates if the sum of the original two BCD variables is greater than
100, allowing multiple precision decimal additions. OV is not
affected. All of this occurs during the one instruction cycle.
Essentially; this instruction performs the decimal conversion by
adding 00H, 06H, 60H, or 66H to the accumulator, depending on
initial accumulator and PSW conditions.
Note: DA A cannot simply convert a hexadecimal number in the
accumulator to BCD notation, nor does DA A apply to decimal
subtraction.
Example:
MOV A, #47H
ADD A, #38H
DA A
Result:
47H
+ 38H
---7FH
(invalid BCD)
06H
(after DA A)
---85H
(valid BCD)
----
In the above instruction, since the lower nibble was greater than 9,
DA added 6 to A. If the lower nibble is less than 9 but AC=1, it also
adds 6 to the lower nibble.
3.6.13 DEC BYTE
Function: Decrement
Flags: None
Description: The variable indicated is decremented by 1. An original
value of 00H will underflow to 0FFH. Four operand addressing
modes are allowed:
1. Accumulator: DEC A
2. Register: DEC Rn
3. Direct: DEC direct
4. Register-indirect: DEC @Ri
3.6.14 DIV AB
Function: Divide
Flags: CY and OV
Description: DIV AB divides the unsigned eight-bit integer in the
accumulator by the unsigned eight-bit integer in register B. The
accumulator receives the integer part of the quotient; register B
receives the integer remainder. The carry and OV flags will be
cleared.
Exception: If B had originally contained 00H, the values returned in
the accumulator and B register will be undefined and the overflow
flag will be set. The carry flag is cleared in any case.
Example:
MOV A,#35
MOV B,#10
DIV AB
Result: A=3 and B=5
3.6.15 DJNZ BYTE,TARGET
Function: Decrement and jump if not zero
Flags: None
Description: DJNZ decrements the location indicated by 1, and
branches to the address indicated by the second operand if the
3.6.18 JB BIT,TARGET
Function: Jump if bit is set
Flags: None
Description: If the indicated bit is a one, jump to the target address
indicated; otherwise proceed with the next instruction. The branch
destination is computed by adding the signed relative-displacement
in the third instruction byte to the PC, after incrementing the PC to
the first byte of the next instruction. The bit tested is not modified.
Example:
SETB P1.2; Make P1.2 an input port
HERE: JB P1.2,HERE ; stay here as long as P1.2=1
MOV P2,#20H ; Since P1.2=0 send 55H to P2
3.6.19 JBC BIT,TARGET
Function: Jump if bit is set and clear bit.
Flags: None
Description: If the indicated bit is one, branch to the target address
while at the same time clear the designated bit. The branch
destination is computed by adding the signed relative displacement
in the third instruction byte to the PC, after incrementing the PC to
the first byte of the next instruction.
Note: When this instruction is used to test an output pin, the value
used as the original data will be read from the output data latch, not
the input pin.
3.6.20 JC TARGET
Function: Jump if carry is set
Flags: None
Description: If the carry flag is set, branch to the target address
indicated; otherwise proceed with the next instruction.
3.6.21 JMP @A + DPTR
Function: Jump indirect
Flags: None
Description: The JMP instruction is an unconditional jump to a target
address. The target address provided by the total sum of register A
and the DPTR register.
branch destination is computed by adding the signed relativedisplacement in the second instruction byte to the PC, after
incrementing the PC twice. The accumulator is not modified. No
flags are affected.
3.6.26 LCALL 16-BIT ADDR
Function: Long call
Flags: None
Description: LCALL calls a subroutine located at the indicated
address. The instruction adds three to the program counter to
generate the address of the next instruction and then pushes the 16bit result onto the stack (low byte first), incrementing the stack
pointer by two. The high-order and low-order bytes of the PC are
then loaded, respectively, with the second and third bytes of the
LCALL instruction. Program execution continues with the
instruction at this address. The subroutine may therefore begin
anywhere in the full 64 Kbyte program memory address space.
Example: Initially the stack pointer equals 07H. The
label"SUBRTN" is assigned to program memory location 1234H.
After executing the instruction LCALL SUBRTN at location 0123H,
the stack pointer will contain 09H, internal RAM locations 08H and
09H will contain 26H and 01H, and the PC will contain 1234H.
3.6.27 LJMP 16-BIT ADDR
Function: Long jump
Flags: None
Description: LJMP causes an unconditional branch to the indicated
address, by loading the high order and low-order bytes of the PC
(respectively) with the second and third instruction bytes. The
destination may therefore be anywhere in the full 64K program
memory address space.
Example: The label"JMPADR" is assigned to the instruction at
program memory location 1234H. The instruction LJMP JMPADR at
location 0123H will load the program counter with 1234H.
3.6.28 MOV DEST-BYTE, SRC-BYTE
Function: Move byte variable
Flags: None
Description: The byte variable indicated by the second operand is
copied into the location specified by the first operand. The source
byte is not affected. No other register or flag is affected.
There are fifteen possible combinations for this instruction. They are
as follows:
Examples:
(a) Register A as the destination. This can have the following
formats.
1. MOV A, #data
Example: MOV A,#10H
2. MOV A, Rn
Example: MOV A,R5
3. MOV A, direct
Example: MOV A,50H
4. MOV A, @Ri
Example: MOV A,@R0
(b) Register A is the source. This can have the following formats.
1. MOV Rn, A
2. MOV direct, A
3. MOV @Ri, A
(c) Rn is the destination
1. MOV Rn, #immediate
2. MOV Rn, A
3. MOV Rn, direct
(d) The destination direct address
1. MOV direct, #data
2. MOV direct, @ri
3. MOV direct, A
4. MOV direct, Rn
(e) Destination is an indirect address held by R0 and R1.
1. MOV @Ri, #data
2. MOV @Ri, A
3. MOV @Ri, direct
3.6.29 MOV DEST-BIT, SRC-BIT
Function: Move bit data
Flags: None
Description: The Boolean variable indicated by the second operand
is copied into the location specified by the first operand. One of the
operands must be the carry flag; the other may be any directly
addressable bit. No other register or flag is affected.
Example: MOV P1.2,C ;copy carry bit to port bit P1.2
3.6.30 MOV DPTR, #DATA16
Function: Load data pointer with a 16-bit constant
Flags: None
Description: The data pointer is loaded with the 16-bit constant
indicated. The 16 bit constant is loaded into the second and third
bytes of the instruction. The second byte (DPH) is the high-order
byte, while the third byte (DPL) holds the low-order byte. This is the
only instruction which moves 16 bits of data at once.
Example: MOV DPTR, #434FH ;DPTR=434FH
3.6.31 MOVC A, @A + BASE-REG
Function: Move code byte
Flags: None
Description: The MOVC instructions load the accumulator with a
code byte, or constant from program memory. The address of the
byte fetched is the sum of the original unsigned eight-bit
accumulator contents and the contents of a sixteen-bit base register,
which may be either the data pointer or the PC. In the latter case, the
PC is incremented to the address of the following instruction before
being added to the accumulator; otherwise the base register is not
altered. Sixteen-bit addition is performed so a carry-out from the
low-order eight bits may propagate through higher-order bits.
Example:
MOVC A, @A + DPTR ; mov data at A+DPTR into A
MOVC A, @A + PC ; mov data at A+PC into A
3.6.32 MOVX DEST-BYTE, SRC-BYTE
Function: Move external
Flags: None
Flags: None
Description: This performs no operation and execution continues
with the next instruction. It is sometimes used for timing delays to
waste clock cycles. This instruction only updates the PC to point to
the next instruction following NOP.
3.6.35 ORL DEST-BYTE, SRC-BYTE
Function: Logical OR for byte variables
Flags: None
Description: ORL performs the bitwise logical OR operation
between the indicated variables, storing the results in the destination
byte.
The two operands allow six addressing mode combinations. When
the destination is the accumulator, the source can use register, direct,
register-indirect, or immediate addressing; when the destination is a
direct address, the source can be the accumulator or immediate data.
Note: When this instruction is used to modify an output port, the
value used as the original port data will be read from the output data
latch, not the input pins.
Example: If the accumulator holds 0C3H (11000011B) and R0 holds
55H (01010101B) then the instruction ORL A,R0 will leave the
accumulator holding the value 0D7H (11010111B).
Different types of addressing modes are as follows.
1. Immediate: ORL A, #data
Example: ORL A,#30h
2. Register: ORL A, Rn
Example: ORL A, R5
3. Direct: ORL A,direct
Example: ORL A,20H; OR A with data in RAM location 20H
4. Register-indirect: ORL A, @Ri
Example: ORL A,@R1; OR A with data pointed by R0.
3.6.36 ORL C, SRC-BIT
Function: Logical OR for bit variables
Flags: CY
Description: In this instruction the carry flag bit is ANDed with a
source bit and the result is placed in carry. If the Boolean value of
the source bit is logic 0 then clear the carry flag; otherwise leave the
carry flag in its current state. Only direct bit addressing is allowed
for the source operand. A slash ("/") preceding the operand in the
assembly language indicates that the logical complement of the
addressed bit is used as the source value, but the source bit itself is
not affected. No other flags are affected.
3.6.37 POP DIRECT
Function: Pop from stack
Flags: None
Description: This copies the byte pointed by SP to the location
whose direct address indicated, and decrements SP by 1. Notice that
this instruction supports only direct addressing mode. Therefore,
instruction such as POP A, POP R3 is illegal.
Example:
POP 0E0H; Where E0H is the RAM address belonging to Register
A.
Operation:
(direct) ? ((SP))
(SP) ? (SP) - 1
3.6.38 PUSH DIRECT
Function: Push onto stack
Flags: None
Description: This copies the indicated byte onto the stack increments
SP by 1. Notice that this instruction supports only direct addressing
mode. Therefore, instruction such as PUSH A, PUSH R3 is illegal.
Example:
PUSH 0E0H; Where E0H is the RAM address belonging to Register
A.
Operation:
(SP) ? (SP) + 1
((SP)) ? (direct)
3.6.39 RET
Function: Return from subroutine
Flags: None
3.6.48 SWAP A
Function: Swap nibbles within the accumulator
Flags: None
Description: SWAP A interchanges the low and high-order nibbles
(four-bit fields) of the accumulator (bits 3-0 and bits 7-4). The
operation can also be thought of as a four bit rotate instruction.
Example:
MOV A, #25H
SWAP A
Result: A = 52H
3.6.49 XCH A, BYTE
Function: Exchange accumulator with byte variable
Flags: None
Description: This instruction swaps the content of register A and the
source byte. The source byte can be any register or RAM location.
Example:
MOV A, #49H; A = 49H
MOV R2, #30H; R2 = 30H
XCH A,R2
Result: A=30H, R2=49H
Different types of addressing modes are as follows.
1. Register: XCH A, Rn
Example: XCH A, R5
2. Direct: XCH A, direct
Example: XCH A, 20H
3. Register-indirect: XCH A, @Ri
Example: XCH A,@R1
3.6.50 XCHD A,@Ri
Function: Exchange digit
Flags: None
Description: XCHD exchanges the low-order nibble of the
accumulator (bits 30), with that of the internal RAM location
indirectly addressed by the specified register. The high-order nibbles
(bits 7-4) of each register are not affected.
CHAPTER - 4
COMPUTER AIDED INSTRUCTION
4.1 INTRODUCTION
In MPS we you will be developing code for the C8051F120 EVB
(evaluation board). This board is from Silicon Laboratories (SiLabs).
For that purpose, you will be using a x86 based PC (your laptop, a
desktop, or co processor card in a Sun Ultra 10 workstation) to write
and compile the controller programs. This type of development is
called Cross Platform Development. After generating the machine
code for the target environment and before you can run it you must
download it to the C8051F120.
When doing cross platform development, extra knowledge of the
target environment is needed. It is important to be able to answer the
following questions:
o What memory resources does the execution environment have?
128 Kbytes of FLASH ROM that extends from 00000 to 1FFFFH
and 8 Kbytes of RAM. The compiler - and more specifically the
linker - has been configured to make use of this memory address
space.
o Are we dealing with only hardware or is there an interface program
we have to go through?
All communication to the C8051F120 evaluation board is currently
through the IDE (integrated development environment) from Silicon
Laboratories running on the PC.
The SiLabs IDE is a convenient way to edit, compile, and download
source code written for the microcontroller. While SiLabs provides a
nice interface for making source code changes and easily
downloading them to the development boards, it lacks the actual
compiler portion which converts C code to hex files, the common
format used by the 8051. To do this, a free and widely used open
source tool called Small Device C Compiler (SDCC) is used. SDCC
compiles the C code written, and automatically optimizes and
converts it to hex. Due to its popularity, support for SDCC in the
SiLabs IDE comes standard, making it easy and convenient to use.
Once again, click Browse and select the path to where SDCC is
installed. If you kept all the paths to the default, the full path should
be: C:\Program Files\SDCC\bin\sdcc.exe
6.
Finally, to configure the linker, select the Linker tab. Click
Browse and select the path where SDCC is installed. The full path
for a default installation should be: C:\Program
Files\SDCC\bin\sdcc.exe
7.
Once you have made these changes, click OK. It is very
important that you not change anything outside of what has been
mentioned above, especially the command line flags passed to
SDCC.
8.
You have successfully set up SiLabs IDE to use SDCC!
4.6 CREATING A PROJECT
1.
To create a new project, click on: Project?New. This will create
an empty project.
2.
Add a new C file to the project by clicking on: Project?Add
Files to Project. Give your new file a name, such as myprog.c.
3.
The file will now be part of the project, and can be compiled.
Save the project by clicking on: Project?Save Project.
4.6.1 COMPILING A PROJECT
You will be using the SDCC 2.7 cross compiler. The compiler
generates executable files with the extension .exe from the C source
files.
To create an executable program that runs on the C8051F120
processor from C code, there are three steps that must be taken. First
the compiler takes the C source file (.c) and creates an object file
(.hex). A linker takes the object file from the compiler and adds in
the language library routines to create a link file. Finally a hex
converter (or loader) takes the link file and generates a downloadable
executable file that can be passed to the C8051F120 by the IDE. The
IDE program downloads the .out file into the C8051F120 for
execution.
Fortunately there are menu items that will perform all these
operations. For a C source file in an opened IDE Project, the menu
commands to generate the .exe download file are:
1.
To compile your project, first verify that all of your code is
correct. If it's not, don't worry, the compiler will catch your mistakes.
2.
Click on: Project?Assemble/Compile File (<Ctrl><F7> or
icon) this will compile your project source code. The window at the
bottom of the IDE will alert you of any errors or warnings it finds in
your code. If there are errors, correct them first before moving on to
the next step. If there are warnings, you may or may not want to
correct them, depending on the nature of the warning.
3.
Next click on: Project?Build/Make Project(<F7> or icon) This
will link your compiled file. Any errors detected by the linker will be
displayed.
Transferring the Executable Machine Code to the C8051F120
4.
After successfully building your project, you will want to
download it to the development board. Before doing this, you will
need to configure the adapter used to download the source code and
establish the connection. To do this, click on: Options?Connection
Options Once the window opens, select the USB Debug Adapter and
click OK.
5.
To establish the connection to the 8051 you must click on:
Debug?Connect This will connect the IDE to the development board
through the USB Debug Adapter.
6.
Click on: Debug?Download Object File (<Alt><D> or icon)
Select the file you just compiled, and click Download. This will
download the code to the development board.
4.6.2 EXECUTING THE PROGRAM ON THE C8051F120
Finally, to execute your code on the C8051F120, click on: Debug?
Go
4.6.3 ASCII TERMINAL PROGRAMS
KEYCHECK:
JNB P3.0,OK
JNB P3.4,WRONG
JNB P3.5,WRONG
JNB P3.7,WRONG
JNB P3.1,WRONG
JNB P3.2,WRONG
JNB P3.3,WRONG
SJMP KEYCHECK
OK:
ACALL DELAY1
;
JNB
P3.0,WRONG
JNB P3.1,OK1 ;
JNB
P3.2,WRONG ;
JNB P3.3,WRONG
JNB
P3.4,WRONG
JNB P3.5,WRONG
JNB
P3.7,WRONG
SJMP OK
OK1:
JNB
P3.0,WRONG
JNB P3.1,WRONG
JNB P3.2,OK2
JNB P3.3,WRONG
JNB P3.4,WRONG
JNB
P3.5,WRONG
JNB P3.7,WRONG
SJMP OK1
OK2:
JNB P3.2,$
ACALL DELAY
;
JNB
P3.0,WRONG ;
JNB P3.1,WRONG ;
JNB P3.2,WRONG
JNB P3.3,OK3
JNB P3.4,WRONG
JNB P3.5,WRONG
JNB P3.7,WRONG OK3:
CLR P1.3
; BUZZER
CLR P1.0
SETB P1.1
ACALL
DELAY1
SETB P1.3
; BUZZER OFF
SETB
P1.0
SETB P1.1
ACALL DELAY1
SETB P1.0
CLR P1.1
ACALL DELAY1
SETB P1.0
SETB
P1.1
LJMP MAIN DELAY1:
MOV R3,#00
MOV R2,#00
MOV R1,#12 DELAY:
DJNZ
R3,DELAY
DJNZ R2,DELAY
DJNZ R1,DELAY RET
WRONG:
ACALL DELAY
CLR BUZ
CLR
RELAY
ACALL DELAY
SETB RELAY
ACALL DELAY
CLR RELAY
ACALL
DELAY
SETB RELAY
In the Gas sensor, we use IC 555 along with sensor as a main
component. Pin no 4 and pin no 8 is connected to the positive supply.
Pin no 1 is connected to the negative voltage. One capacitor is
grounded from the pin no 5 for noise cancellation. Output is
available on the pin no 3. Sensor is connected to the pin no 2. In the
case of Gas sensor, Pin no 2 is negative bias through the 33k ohm
resistor and pin no 3 is positively biased. Infrared LED is directly
connected to the positive and negative supply through the 470 ohm
resistor.
which provides info to the concerned people. Note that exhaust fan
will remain in its idle state of OFF in case of heat/fire detection &
prevention.
Note that microcontroller sense only negative input to the
microcontroller.
CHAPTER - 5
APR9600 RE-RECORDING VOICE IC
5.4
MESSAGE MANAGEMENT
low for least 400 cycles of the sampling clock. After the device is
incremented to the desired message the user can initiate playback of
the message with the playback sequence described above. A special
case exists when the /M2_NEXT pin goes low during playback.
Playback of the current message will stop, the device will beep,
advance to the next message and initiate playback of the next
message. (Note that if /M2 Next goes low when not in playback
mode, the device will prepare to play the next message, but will not
actually initiate playback).
If the /CE pin goes high during playback, playback of the current
message will stop, the device will beep, reset to the beginning of the
first message, and wait for a subsequent playback command. When
you reach the end of the memory array, any subsequent pulsing
of /M1_MESSAGE or /M2_NEXT will only result in a double beep.
To precede from this state the user must rewind the device to the
beginning of the m memory array. This can be accomplished by
toggling the /CE pin low or cycling power.
5.4.3.3 FUNCTIONAL DESCRIPTION OF RECORDING IN TAPE
MODE USING THE NORMAL OPTION
On power-up, the device is ready to record or playback, starting at
the first address in the memory array. Before you can begin
recording, the /CE input must be set to low to enable the device
and /RE must be set to low to enable recording. On a falling edge of
the /M1_MESSAGE pin the device will beep once and initiate
recording. A subsequent rising edge on the /M1 Message pin will
stop recording and insert a single beep. If the /M1_ MESSAGE pin
is held low beyond the end of the available memory, recording Stops
automatically, and two beeps are inserted; regardless of the state of
the /M1_MESSAGE pin. The device returns to the standby mode
when the /M1_MESSAGE pin is returned high. A subsequent falling
edge on the /M1_MESSAGE pin starts a new record operation in the
memory array immediately following the last recorded message, thus
preserving the last recorded message. To record over all previous
messages you must pulse the /CE pin low once to reset the device to
the beginning of the first message. You can then initiate a record
sequence, as described above, to record a new message. The most
Each memory cell can support voltage ranges from 0 to 256 levels.
These 256 discrete voltage levels are the equivalent of 8-bit
(28=256) binary encoded values. During playback the stored signals
are retrieved from memory, smoothed to form a continuous signal,
and then amplified before being fed to an external speaker.
5.7 SAMPLING RATE & VOICE QUALITY
According to Shannon's sampling theorem, the highest possible
frequency component introduced to the input of a sampling system
must be equal to or less than half the sampling frequency if aliasing
errors are to be eliminated. The APR9600 automatically filters its
input, based on the selected sampling frequency, to meet this
requirement. Higher sampling rates increase the bandwidth and
hence the voice quality, but they also use more memory cells for the
same length of recording time. Lower sampling rates use fewer
memory cells and effectively increase the duration capabilities of the
device, but they also reduce incoming signal bandwidth. The
APR9600 accommodates sampling rates as high as 8 kHz and as low
as 4 kHz. You can control the quality/duration trade off by
controlling the sampling frequency. An internal oscillator provides
the APR9600 sampling clock. Oscillator frequency can be changed
by changing the resistance from the OscR pin to GND. Table 5.2
summarizes resistance values and the corresponding sampling
frequencies, as well as the resulting input bandwidth and duration.
Resistance
(k ohm) Sampling
Frequency(kHz)
Input
Bandwidth (kHz)
Duration(sec)
84 4.2 2.1 60
38 6.4 3.2 40
34 8
4
32
Table 5.2 Input Bandwidth & Duration
"
PROJECT REPORT
ON
By
Ritika Arora (0838131030)
Shubhashish Dixit (0838131031)
Humaira Anam (0838131409)
Rishabh Singh (0838131029)
Prof. R.K.Yadav
Mr. Akhilesh Sharma
Mr. Ajay Kumar
Mr. P.K.Raghav
PROJECT INCHARGE
CERTIFICATE
Project Incharge
Examiner
Project Guide
ACKNOWLEDGEMENT
We would like to place on record my deep sense of gratitude to Prof.
R.K.Yadav, HoD. of Electronics and Communication Engineering, Krishna
Institute of Management & Technology(KIMT), Moradabad, India.
Mr.
PAGE INDEX
S. No.
CONTENTS
Page no.
i
ii
Iii
iv
v
vi
Certificate
Acknowledgement
List of Tables
List of Figures
List of Symbols
Abstract
I
II
VIII
IX
XI
XII
INTRODUCTION
1.1 General Introduction
1.2 Organization Of Project
1. 3 Project Statement
CIRCUIT STRUCTURE
9
9
10
10
12
12
12
12
12
13
13
13
15
15
15
16
16
16
1
3
7
17
17
17
18
18
MICROCONTROLLER AT89C51
25
25
25
25
26
26
27
28
28
28
28
30
30
31
31
32
32
32
32
19
19
20
20
21
21
22
32
33
34
72
4.1 INTRODUCTION
4.2 CONCEPT OF COMPILER
4.3 CONCEPT OF CROSS COMPILER
4.3.1 WHY DO WE NEED CROSS COMPILER?
4.4 INSTALLING SDCC
4.5 INSTALLING SiLABS IDE
4.5.1 CONFIGURING SiLABS IDE WITH SDCC
4.6 CREATING A PROJECT
4.6.1 COMPILING A PROJECT
4.6.2 EXECUTING THE PROGRAM ON THE
C8051F120
4.6.3 ASCII TERMINAL PROGRAMS
4.6.4 IDE FILE LOCATION REQUIREMENT
4.7 PROGRAMMING HINT
73
74
74
75
75
76
76
76
77
77
34
35
36
36
37
37
37
37
38
38
38
39
46
78
78
78
78
79
86
91
91
91
92
92
93
93
103
106
108
110
95
95
96
96
96
97
98
99
100
101
101
102
102
CONCLUSION
ENHANCEMENT
AND
FUTURE 111
6.1 CONCLUSION
6.2 RESULT
6.3 LIMITATIONS
6.4 FUTURE SCOPE
111
112
112
113
BIBLIOGRAPHY
115
LIST OF TABLES
Tables
Table 2.1 Pin Description of IC 7805
Table 3.1 Pin Diagram of AT89C51
Table 3.2 Port 3 Functions
Table 3.3 Status of External Pins during Idle and Power-Down
Modes
Table 3.4 Flash Programming Mode Signature Codes
Table 3.5 Lock Bit Protection Modes
Table 3.6 Signature Bytes
Table 3.7 SFR Addresses
Table 3.8 Modes of Operation
Table 3.9 PSW Register Details
Table 3.10 PCON Register
Table 3.11 Baud Rate Comparison for XTAL = 11.0592 MHZ
Table 3.12 TCON Register
Table 3.13 SCON Register
Table 3.14 Modes of SCON Register
Table 3.15 TMOD Register
Table 3.16 Modes of TMOD
Table 3.17 IE Register
Table 3.18 IP Register
Table 3.19 T2CON Register
Table 5.1 Mode selection
Table 5.2 Input Bandwidth & Duration
Table 5.3 Pin Description of APR 9600
Table 5.4 Absolute Maximum Ratings
Table 5.5 DC Characteristics
Table 5.6 Analog Characteristics
Page No.
18
30
31
34
35
36
38
39
40
41
42
42
43
43
44
44
44
45
45
46
95
101
108
109
109
109
LIST OF FIGURES
Figures
Fig 2.1 Gas & Fire Sensor using 555 IC
Fig 2.2 Structure & Configuration of Gas Sensor MQ-6
Fig 2.3 Basic Test Loop
Fig 2.4 Basic Relay Block with Handsfree
Fig 2.5 Pin Diagram of IC 7805
Fig 2.6 555-Timer-Monostable-Multivibrator
Fig 2.7 555 Monostable-Multivibrator-Operation
Fig 2.8 Complete Circuit structure of Gas & Heat Sensor with
auto dial up logic
Fig 3.1 Basic Architecture of AT89C51 Microcontroller
Fig 3.2 Pin Diagram of Micro controller 8951
Fig 3.3 Oscillator connection
Figure 3.4 External Clock Drive Configuration
Fig 3.5 TMOD Register
Fig 3.6 PSW Register
Fig 3.8 Arithmetic Operation
Fig 3.9 Logic Operation
3.10 Data Transfer Operation
Fig 3.11 Boolean Manipulation & Program & Machine Control
Operation
Fig 4.1 Load New File in 8051 IDE
Fig 4.2 Auto Dial Up Coding
Fig 4.3 8951 Selection
Fig 4.4 Loading Flash Buffer
Fig 4.5 Gas Sensor with MCU
Fig 4.6 Gas Sensor with MCU
Fig 5.1 Pin Diagram of APR 9600 IC
Figure 5.2 APR9600 Block Diagram
Fig 5.3 APR9600 Experimental board
Figure 5.4 Tape Mode, Normal Option
Figure 5.5 Tape Mode, Auto Rewind Option
Page No.
11
13
14
16
17
20
20
24
26
27
33
34
39
41
47
49
49
50
82
83
84
85
88
89
93
94
100
103
104
105
LIST OF SYMBOLS
Symbols
Meaning
LED
IC
GSM
PC
DIP
RAM
ROM
I/O
VCC
GND
XTAL
Ppm
MCU
APR
AGC
CMOS
MHz
AC
DC
UART
CPU
BIT
CLK
ANA
ABSTRACT
Security is primary concern for everyone. This Project describes a
design of effective security alarm system that can monitor an industry with
different sensors. Gas detection and fire detection can be monitored by the
status of each individual sensor and is indicated with an LED, Buzzer Voice
Recording & Playback Device and dial up logic. These all shows whether the
sensor has been activated and whether the wiring to the sensor is in order. In
this project we show that how we use the telephone as a electronics eye. With
the help of any phone we can know the position of the house. In this logic we
attach some sensor with the telephone and if there is any mishappening at
home then telephone is automatic on and then circuit press the redial button of
the telephone and then telephone dial the pre-dialed number and sense the
voice message to the received end.
The detection alarm is built around the AT89C51 microcontroller from
Atmel. This microcontroller provides all the functionality of the detection
alarm. It also takes care of filtering of the signals at the inputs. A fire sensor
can be connected to the gas sensor alarm. These sensors need to have their
contacts closed when in the inactive state (i.e. normally closed). In addition,
each sensor needs to have its tamper connection wired as well. A power
supply voltage of +5 VDC is available for each sensor at the corresponding
wiring terminals. LEDs indicate the status of the corresponding sensors.
When the alarm has been activated, the LED of the sensor that caused the
alarm will light up and pre recorded message starts to play.
The uniqueness of this project is not only alerting the neighbors by
siren, it also dials a mobile number which is already programmed into the
system. A mobile number or a land line number can be programmed into
the system. As this system works on existing telephone line, it can dial the
number even the subscriber is out of station.
This project uses regulated 5V, 500mA power supply. 7805 three
terminal voltage regulator is used for voltage regulation. Bridge type full wave
rectifier is used to rectify the ac output of secondary of 230/12V step down
transformer.
CHAPTER - 1
INTRODUCTION
1.1 GENERAL INTRODUCTION
Engineering is not only a theoretical study but it is a implementation of
all we study for creating something new and making things more easy and
useful through practical study. It is an art which can be gained with systematic
study, observation and practice. In the college curriculum we usually get the
theoretical knowledge of industries, and a little bit of implementation
knowledge that how it is works? But how can we prove our practical
knowledge to increase the productivity or efficiency of the industry????
Dont take the chance of becoming victim of carelessness, which is
often accompanied by serious accident. Protect our family and valuables with
this microcontroller based security system that will let us rest our head
knowing that there is anything like gas leakage or fire existing into our home.
The motivation is to facilitate the users to know the state of their homes having
ubiquitous access. The system provides availability due to development of a
low cost system. This system is low cost but very useful for users to know
their home state wherever are located. Home security has been a major issue
where temperature starts raising day by day and everybody wants to take
proper measures to prevent intrusion. There was need to prevent fires and gas
leaks no matter when they are in the house or outside. By using GSM
technology via Dial-Up logic we can help users to supervise their home against
intruders, gas leak and fire only at one product with a low cost.
The security is what a person expects from a home, this project was
designed keeping this particular aspect in mind. The security system is made
fool proof to the maximum extent possible. In this project we make use of a
microcontroller as the main controller to control the input and the output that
reach the controller. There is a large scope in the future enhancements that can
be provided along with this project like actuating a fire detection alarm or
sensing a leakage of gas etc.
Generally in any industry, there are several blocks and there is an
administrative block which controls all blocks. If any problem is created in any
one of the blocks, at first the persons in that particular block has to inform to
the administrative block and then the action will be taken. So if we consider a
fire accident in any one of the blocks the person on that incident generally they
makes a call to the administrative block or security block as took over and they
has to call the ambulance, fire station etc. It will be a long time process, so in
the mean the damage may increase in gigantic extent. The most basic fire
protection methods include fire prevention, detection and control. Buildings
should be constructed using fire rated walls, doors, ceilings and floors. The use
of combustible materials in interior furnishing should be kept to a minimum.
There are several types of detection devices. Automatic fire detection systems,
when combined with other elements of an emergency response and evacuation
plan, can significantly reduce property damage, personal injuries, and loss of
life from fire in the work place. Their main function is to quickly identify a
developing fire and alert building occupants and emergency response
personnel before extensive damage transpire. Automatic fire detection systems
do this by using electronic sensors to detect the smoke, heat or flames and
providing an early warning. Heat detectors which respond to heat generated in
the flame stage of a fire and smoke detectors which respond to the particles of
cumbers ion produced in a fire.
A fire alarm control panel, normally referred to as a panel within the
active fire protection industry is central control device for detecting, reporting
and acting on occurrences of fire with in a building. There are two types of
panel's fallen conventional panels and analogue addressable panels. In a
conventional panel, fire detection devices including, but not limited to smoke
detectors, heat detectors and manual call points are joined up with a number
connected to the circuit. When a device on the circuit is activated the panel
recognizes an alarm on that circuit and could be setup to take a number of
actions including directly calling the fire department via an alarm
transportation system. An addressable panel is a more modern type of panel
and has a greater flexibility than a conventional panel. An addressable panel
has a number of loops where a number of devices are to be connected, each
with its own address. Bad experiences with early systems have left the police
reluctant to allow domestic security system to call for assistance directly,
except on high risk situations. Security systems can now be configured to call
telephones in the event of an alarm so that the occupants are nominated care
takers can be alerted before calling the police.
Business and industry today requires security systems that are the fact of
life. Your company simply must have them to protect your employees, your
equipment and sky scrapers themselves. There is only one thing more
important than the selection of the security systems to protect your facilities.
That is why you should consider reliable fire equipment for your security
system requirements. Security and fire protection are closely related to energy
management in so far as they present tractable goals for automated systems. It
has been considered relatively easy for machine based systems to recognize
anomalous activity around the home which could be interpreted as possible
security breaches, accidents or fires. Fire damage, however can be permanent
and involves the entire life of human. Much can be done to minimize the
chance of a fire stating or spreading. Progress in fire technologies has been
substantial over last decade due to advances in sensor, microelectronics and
are responsible for the breach of security. The word "security" in general usage
is synonymous with "safety," but as a technical term "security" means that
something not only is secure but that it has been secured. One of the best
options for providing good security is by using a technology named
EMBEDDED SYSTEMS. When people become more and more attach
importance to the quality of life, the security and service is important. Security
has arguably become the prime mover of global politics today. It is the basic
common denominator for any successful society all over the world. Now days
the security system can identify potential hazards to protect human. A typical
intelligent security system consists of intruders, fire, gas, environment sensors
and more variety sensors to be installed.
Monitoring of the security system ensures an effective response to an
electronic activation or in times of personal duress. The response opinions are
customized to suit the individual risk security requirements in cost effective
manner. Monitoring is done through a telephone line and depending on the
security task it will involve a basic digital dialer or a security interface. The
most common method of monitoring is achieved via the basic dialer. This is
for low to medium security risk and is connected to the existing telephone line
through a special socket. The system will communicate when an alarm
condition needs to be reported or when a call is made to test the system. This
test is made as often as required to ensure more or less security. The security
interface provides the same service but it involves a scanning of the existing
telephone line by the telephone company to ensure greater security. Should the
telephone line be damaged accidentally or on purpose the monitoring station
will detect the alarm condition within seconds????
Nowadays trend in network communication leads to replacing the
cables, providing mobility and freedom of movement for the users. The
utilization of wireless techniques has spread its scope on to different
application fields. One of such spheres is industry with the addition of wireless
connectivity to most embedded designs; zones of security will be needed
around each critical system MCU, in addition to the one traditionally
surrounding the gateway to the broader network.
(Source: Atmel)."Beyond the huge cost savings incurred by eliminating
wires, are the continuing costs in maintenance that will be eliminated, as well
as the flexibility that gives the manufacturer who wants to recognize the
factory floor, add new systems and eliminate others. No wires to connect and
disconnect eliminates a lot of costs and will make the factory floor a much
more dynamic environment".
This Project describes a design of effective security alarm system that
can monitor an industry with two different sensors. Fire accident and gas
detection can be monitored by the status of each individual sensor and is
indicated with an LED. This LED shows whether the sensor has been activated
and whether the wiring to the sensor is in order. Obviously, this alarm also has
an input to 'arm' the alarm to control a siren and Auto dialing system.
The gas sensor and fire sensor alarm is built around the AT89C51 micro
controller from Atmel. This micro controller provides all the functionality of
the detection alarm. It also takes care of filtering of the signals at the inputs.
Only after an input has remained unchanged for 30 milliseconds, is this new
signal level passed on for processing by the micro controller program. This
time can be varied by adopting small changes in the source code.
A maximum of 8 sensors can be connected to the 8951but here we only
connected 2 sensors. These sensors need to have their contacts closed when in
the inactive state (i.e. Normally Closed). In addition, each sensor needs to have
its tamper connection wired as well. A power supply voltage of +5 VDC is
available for each sensor at the corresponding wiring terminals. LEDs indicate
the status of the corresponding sensors. When the alarm has been activated, the
LED of the sensor that caused the alarm will light up, or flash in the event of a
cable failure.
When the alarm is armed, the LED 'alarm armed' will flash during the
exit-delay. After the exit-delay, the LED will light continuously. The LED
'alarm triggered LED' flashes during the entry-delay and will turn on
continuously once an actual alarm has been generated. 'Alarm triggered LED
turns off only when the alarm is switched off with key switch Sw1. When an
alarm has taken place, it can be determined afterwards which sensor (or tamper
input) caused the alarm to trigger. The LED 'tamper' lights up when the tamper
input is opened. This LED will also continue to be on until the alarm is
switched off.
The uniqueness of this project is not only alerting the neighbors by
siren, it also redials a mobile number which is already in dial list. A mobile
number or a land line number can be fixed for it. As this system works on
existing mobile, it can dial the number even the subscriber is out of station.
Another important feature that is connected to circuit is Single-Chip Voice
Recording & Playback Device. An IC APR9600 is implemented for it. The
APR9600 device offers true single-chip voice recording, non-volatile storage,
and playback capability for 40 to 60 seconds. The device supports both
random and sequential access of multiple messages. Sample rates are userselectable, allowing designers to customize their design for unique quality and
storage time needs. Integrated output amplifier, microphone amplifier, and
AGC circuits greatly simplify system design. The device is ideal for use in
portable voice recorders, toys, and many other consumer and industrial
applications. APLUS integrated achieves these high levels of storage capability
by using its proprietary analog/multilevel storage technology implemented in
an advanced Flash non-volatile memory process, where each memory cell can
store 256 voltage levels. This technology enables the APR9600 device to
reproduce voice signals in their natural form. It eliminates the need for
encoding and compression, which often introduce distortion.
This project uses regulated 5V, 500mA power supply. 7805 three
terminal voltage regulator is used for voltage regulation. Bridge type full wave
rectifier is used to rectify the ac output of secondary of 230/12V step down
transformer.
As the operation of microcontroller-based system is inherently based on
the stored program control concept, the software plays a very crucial role. The
relationship between the hardware and software is similar to the relation
between body and soul. One has not a meaningful existence without the other.
The hardware is the body, which is used as the medium of software. In order to
develop the software for microcontroller based system, one must acquire
knowledge about the set of instructions which are used as a building blocks in
writing a program and learn the art of program that is the tools and techniques
of putting instructions together in a logic manner to form a program
implementing the desired operations. The 8051 IDE Assembler + Compiler
development tools are designed to solve the complex problems facing
embedded software developed.
1. 3 PROJECT STATEMENT
Nowadays, most couples leave for work early in the morning and get
back only in the evening. Most people also have to travel to other cities for
their work. When they are away, their house is empty. Therefore case like
leakage of LPG and short circuitry fire or else is easy to occur because the
home owners are not in the house. Our Country India has many such cases and
still going ascending day by day. The based solution is to develop home
security system using a wireless to keeps your house safe from such accidents
and enables you to work in peace.
Based on the events above, the project can be developing to make our
home secure and safe. We never anxious and worried anymore even we leave
the house. So this project is to design and develop a home security system that
can provide security against gas leak, fire and other emergency situation by
alarm via calling to the home owner as there is something suspicious at home.
Today there are a many wireless home security alarm system available in the
market. Some are designed for very high security level protection and some
are basic type. Most of the alarm systems are very expensive and therefore not
affordable by poor or middle class families. Some systems which cheaper in
cost do not provide reliable features like status checking. To provide the public
with a cost effective wireless security system, it is important to design a low
cost system with advanced features which ease the residents' life and benefits
the public and also will decrease the accident rate of India. Besides that, to
develop the system that can monitor gas leakage and fire detector including
control appliances in our home is a good matter. It is important because the
system can be help people through the realization of fully automated home
protections. So this project wills develops and design the home security system
that can control the lamp in the house.
CHAPTER 2
CIRCUIT STRUCTURE
This chapter deals with the general introduction of all the components
used in this project. So we can have a general idea about all the components.
We also have some computer aided instructions and their operation which
will discussed in next chapter.
Reset circuit
ALARM
Relays
Crystal oscillator
Auto dialer
Power supply
mono stable timer and output signal is available on the pin 3 this signal is
connected to the microcontroller .When fire is on then sensor detect the logic
and immediate provide a signal to the controller.
Gas sensor is a special sensor when gas sensor sense the gas then gas
sensor again provides a small signal to the microcontroller via IC 555.
In the gas sensor interface we use gas sensor as a input logic. We attach one IC
555 as with this sensor. Here IC 555 works as a monostable multivibrator
timer. Sensor output is connected to the IC 555 pin no 2 via NPN transistor.
Pin no 2 is a negative triggered IC. When sensor activate then positive output
is available and this positive output is converted into negative with the help of
the NPN transistor. Output of the NPN transistor is now connected to the pin
no 2 of the IC 555. Pin no 4 and 8 of the IC 555 is connected to the positive
supply. Pin no 1 is connected to the ground pin. Pin no 7 is the output pin. Pin
no 6 and 7 is the time constant pin. Pin no 6 and 7 provide a time constant
option. When IC 555 works then output is available on the pin no 3. Now this
output is switching by the further NPN transistor. One LED is also connected
to the transistor circuit. Output of the NPN transistor is available on the
collector point. This output from the collector of NPN is now connected to the
microcontroller pin no 1 which is port p1.0. Pin no 40 of the controller is
connected to the positive supply. We supply a 5 volt for supply.
These sensors firstly connected with the monostable circuit and then
connected to the microcontroller interface. In the monostable circuit we use IC
555 as a monostable circuit.
station. Once the call is activate then sound is transfer from the voice processor
to the mobile phone. Here we use IC APR 9600. With the help of this IC we
produce up to 6 sounds and it is possible to send a different sound on different
application with the help of the mobile phone. When the relay is on and activates
the last number redial the after few second voice processor pin is on and play a
voice message this message is transfer to the phone automatically.
even if the alarm is not heard by anyone present in the vicinity of the system,
the message can be intimated to the required destination by the number which
is already stored in it. This helps to improve out security level by use of electro
circuit.
2.12 POWER SUPPLY
The input to the circuit is applied from the regulated power supply. The
AC input i.e., 230V from the mains supply is step down by the transformer
to 12V and is fed to a rectifier. The output obtained from the rectifier is a
pulsating DC voltage. So in order to get a pure DC voltage, the output voltage
from the rectifier is fed to a filter to remove any AC components present
even after rectification. Now, this voltage is given to a voltage regulator 7805
to obtain a pure constant dc voltage.
2.13 IC 7805
7805 is a voltage regulator integrated circuit. It is a member of 78xx
series of fixed linear voltage regulator ICs. The voltage source in a circuit may
have fluctuations and would not give the fixed voltage output. The voltage
regulator IC maintains the output voltage at a constant value. The xx in 78xx
indicates the fixed output voltage it is designed to provide. 7805 provides +5V
regulated power supply. Capacitors of suitable values can be connected at
input and output pins depending upon the respective voltage levels.[8]
2.13.1 PIN DIAGRAM
7805
Function
Name
Input
Ground
Output
directly into the chip using Ana-In (pin 20), but the connection between Ana-in
( pin 20) and Ana-out (pin 21) is still required for playback. An internal antialiasing filter automatically adjusts its response according to the sampling
frequency selected. Then the signal is processed into the memory array
through a combination of the sample and hold circuits and analogue read/write
circuit. The incoming voice signals are sampled and the instantaneous voltage
samples are stored in the non-volatile flash memory cells in the 8 bit binary
encoded format. During playback, the stored signals are retrieved from the
memory, smoothed to form a continuous signal level at the speaker terminals
SP+ and SP- ( pins 14 and 15 respectively) is at about 12mw power into 16
ohm impedance. The output from pin 14 (SP+) is further amplified by the low
power amplifier using LM386 (IC2) as shown in the figure. The recorded
message is reproduced into speaker LS1. An internal oscillator provides
sampling clock to the APR 9600. The frequency of the oscillator and sampling
rate depend on the value of resistor R12 connected across the OSCR (pin 7) of
the chip and the ground.[6][12]
2.14.1 MESSAGE MANAGEMENT
The APR9600 chip supports the following message modes. Random
access mode with 2, 4, 8 message within the total recording time. Tape mode
with two options: Auto rewind and Normal operation. The modes are defined
by pins 24, 25 and 9 cannot be mixed. An important feature of the APR9600
chip is indication of changes in the device status through beeps superimposed
on the device output: for example, the start of recording is indicated by a beep,
so the person can now start speaking into the microphone. This feature is
enabled by making pin 11 high.
2.15 IC 555 AS MONOSTABLE MULTIVIBRATOR
A monostable multivibrator (MMV) often called a one-shot
multivibrator, is a pulse generator circuit in which the duration of the pulse is
determined by the R-C network, connected externally to the 555 timer. In such
a vibrator, one state of output is stable while the other is quasi-stable
(unstable). For auto-triggering of output from quasi-stable state to stable state
energy is stored by an externally connected capacitor C to a reference level.
The time taken in storage determines the pulse width. The transition of output
from stable state to quasi-stable state is accomplished by external triggering.
The schematic of a 555 timer in monostable mode of operation is shown in
figure 2.6.[1][3]
Fig2.6 555-Timer-MonostableMultivibrator
2.15.1 MONOSTABLE MULTIVIBRATOR CIRCUIT DETAILS
Pin 1 is grounded. Trigger input is applied to pin 2. In quiescent
condition of output this input is kept at + VCC. To obtain transition of output
from stable state to quasi-stable state, a negative-going pulse of narrow width
(a width smaller than expected pulse width of output waveform) and
amplitude of greater than + 2/3 VCC is applied to pin 2. Output is taken from
pin 3. Pin 4 is usually connected to + VCC to avoid accidental reset. Pin 5 is
grounded through a 0.01 u F capacitor to avoid noise problem. Pin 6
(threshold) is shorted to pin 7. A resistor RA is connected between pins 6 and 8.
At pins 7 a discharge capacitor is connected while pin 8 is connected to supply
VCC.
2.15.2 555 IC MONOSTABLE MULTIVIBRATOR OPERATIONS
Operation
The capacitor C has to charge through resistance RA. The larger the time
constant RAC, the longer it takes for the capacitor voltage to reach +2/3VCC.
In other words, the RC time constant controls the width of the output pulse.
The time during which the timer output remains high is given as:
tp =1.0986RAC,
where RA is in ohms and C is in farads.
The pulse width of the circuit may range from micro-seconds to many
seconds. This circuit is widely used in industry for many different timing
applications.
CHAPTER 3
MICROCONTROLLER AT89C51
3.1 AT89C51 MICROCONTROLLER
3.1.1 FEATURES
3.1.2 DESCRIPTION
The AT89C51 is a low-power, high-performance CMOS 8-bit
microcomputer with 4K bytes of Flash Programmable and Erasable Read Only
Memory (PROM). The device is manufactured using Atmels high density
nonvolatile memory technology and is compatible with the industry standard
MCS-51 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 Flash on a
monolithic chip, the ATMEL AT89C51 is a powerful microcomputer which
provides a highly flexible and cost effective solution to many embedded
control applications. The AT89C51 provides the following standard features:
4K bytes of Flash, 128 bytes of RAM, 32 I/O lines, two 16-bit timer/counters,
five vector two-level interrupt architecture, a full duplex serial port, and onchip oscillator and clock circuitry.
In addition, the AT89C51 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 functions until the next hardware reset.
3.2.1 VCC
Pin 40 provides supply voltage to the chip. The voltage source is +5V.
3.2.2 GND
Pin 20 of 8951 is connected to ground.
3.2.3 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 may also be configured to be the
multiplexed low order address/data bus during accesses to external program
and data memory. In this mode P0 has internal pull-ups. Port 0 also receives
the code bytes during Flash programming, and outputs the code bytes during
program verification.
External pull-ups are required during program verification.
3.2.4 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. Port 1 also receives the low-order address
bytes during flash programming and verification.
3.2.5 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
it 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.
Pin
No
1
2
3
4
5
6
7
8
9
10
Input
Function
Name
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
Reset
bitP3.0
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
communication
Output (transmitter) for serial
Tx D
communication
External interrupt 1
Int0
External interrupt 2
Int1
Timer1 external input
T0
Timer2 external input
T1
Write to external data memory. Write
Read from external data
Read
memory.
P3.1
P3.2
input/output P3.3
port (P3) pins P3.4
P3.5
P3.6
P3.7
Crystal 2
Crystal 1
Ground (0V).
Ground
P2.0/ A8
P2.1/ A9
8 bit input/output port (P2) pins
High-order address bits when interfacing with external P2.2/ A10
memory.
P2.3/ A11
P2.4/ A12
P2.5/ A13
P2.6/ A14
Quartz crystal oscillator (up to 24 MHz).
P2.7/ A15
Program store enable; Read from external program
PSEN
memory.
Address Latch Enable
ALE
Program pulse input during Flash programming
Prog
External Access Enable; VCC for internal program
EA
executions
Programming enable voltage; 12V (during Flash
VPP
programming)
8 bit input/output port (P0) pins.
P0.7/ AD7
P0.6/ AD6
Low-order address bits when interfacing with external P0.5/ AD5
memory.
P0.4/ AD4
36
37
38
39
40
P0.3/ AD3
P0.2/ AD2
P0.1/ AD1
P0.0/ AD0
Vcc
3.2.6 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 (I IL)
because of the pull-ups. Port 3 also serves the functions of various special
features of the AT89C51 as listed below:
Port 3 also receives some control signals for Flash programming and
verification.
3.2.7 RST
Reset input. A high on this pin for two machine cycles while the
oscillator is running resets the device.
Alternate Functions
P3.0
P3.1
P3.2
P3.3
P3.4
P3.5
P3.6
P3.7
3.2.9 ALE/PROG
Address Latch Enable output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the program pulse
input (PROG) during Flash programming. In normal operation ALE is emitted
at a constant rate of 1/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.
3.2.10 PSEN
Mode
Program
Memory
ALE
Idle
Internal
Data
Data
Data
Idle
External
Float
Data
Address Data
PSEN PORT0
Power-down Internal
Data
Data
Data
Data
Power-down External
Float
Data
Data
Data
Table 3.3 Status of External Pins during Idle and PowerDown Modes
MODE LB1
LB2
LB3
Protection Type
Same as mode 3,
execution is disabled
also
external
The above figure 3.5 signifies the lock bit protection modes
of 8951.
3.3.2 READY/BUSY
The progress of byte programming can also be monitored by the
RDY/BSY output signal. P3.4 is pulled low after ALE goes high during
programming to indicate BUSY. P3.4 is pulled high again when programming
is done to indicate READY.
ACCUMULATOR
B REGISTER
0E0H
0F0H
PSW
SP
DPTR
DPL
DPH
P0
P1
P2
P3
TMOD
TCON
TH0
TLO
TH1
TL1
SCON
SBUF
PCON
0D0H
81H
82H
83H
80H
90H
0A0H
0B0H
89H
88H
8CH
8AH
8DH
8BH
98H
99H
Both timers are the 89c51 share the one register TMOD. 4 LSB bit for
the timer 0 and 4 MSB for the timer 1. In each case lower 2 bits set the mode
of the timer, Upper two bits set the operations.
3.5.1.1 GATE
Gating control when set. Timer/counter is enabled only while the INTX
pin is high and the TRx control pin is set. When cleared, the timer is enabled
whenever the TRx control bit is set
3.5.1.2 C/T
Timer or counter selected cleared for timer operation (input from
internal system clock)
M1
M0
Mode bit 1
Mode bit 0
M1
M0
MODE
OPERATING
MODE
13
BIT
TIMER/MODE
16 BIT TIMER
MODE
8 BIT AUTO
RELOAD
SPLIT TIMER
MODE
CY
AC
PSW.7
PSW.6
F0
PSW.5
RS1
PSW.4
RS0
PSW.3
0V
PSW.2
--
PSW.1
PSW.0
CARRY FLAG
AUXILIARY
CARRY
AVAILABLE
FOR THE USER
FRO GENERAL
PURPOSE
REGISTER
BANK
SELECTOR BIT
1
REGISTER
BANK
SELECTOR BIT
0
OVERFLOW
FLAG
USER
DEFINABLE
BIT
PARITY FLAG
SET/CLEARED
BY HARDWARE
D6
X
D5
x
D4
x
D3
GF1
D2
GF0
D1
PD
D0
IDL
There are two ways to increase the baud rate of data transfer in the 8051
To use a higher frequency crystal
To change a bit in the PCON register
PCON register is an 8 bit register. Of the 8 bits, some are unused, and some
are used for the power control capability of the 8051. The bit which is used
for the serial communication is D7, the SMOD bit. When the 8051 is powered
up, D7 (SMOD BIT) OF PCON register is zero. We can set it to high by
software and thereby double the baud rate. Table 3.11 shows the Baud Rate
comparison for XTAL
TH1
(DECIMAL)
-3
-6
-12
-24
MHZ
HEX
FD
FA
F4
E8
SMOD
=0
9600
4800
2400
1200
SMOD
=1
19200
9600
4800
2400
D7
TF1
D6
TR1
D5
TF0
D4
TR0
D3
IE1
D2
IT1
D1
IE0
D0
IT0
D6
SM1
D5
SM2
D4
REN
D3
TB8
D2
RB8
D1
TI
D0
RI
SM0
SM1
Operati
on
Baud
rate
Shift
register
Osc/12
8-bit
UART
9-bit
UART
Set by
timer
Osc/12
or
Osc/64
Set by
timer
9-bit
UART
D6
C/T
D5
M1
Timer 1
D4
M0
D3
Gate
D2
C/T
D1
M1
Timer 0
D0
M0
M1
0
M0
0
Mode
13-bit
mode
for
compatibility to 8048
family
16- bit Timer/Counter.
User must reload in
software
8-bit autoreload. TLx is
automatically reloaded
from THx
TL0 is 8-bit counter
controlled by Timer0
control bits. TH0 is 8bit counter controlled
by Timer1 control bits.
Timer 1 is stopped
D6
X
D5
ET2
D4
ES
D3
ET1
D2
EX1
D1
ET0
D0
EX0
D6
x
D5
PT2
D4
PS
D3
PT1
D2
PX1
D1
PT0
D0
PX0
D1
C/T2
D0
CP/ RL2
D3
D2
EXEN2 TR2
RCLK Receive clock. When set causes the serial port to use timer 2 for
reception.
TCLK Transmit clock. When set causes the serial port to use timer 2 for
transmission.
C/ T2 - Counter/Timer select.if 0 use internal timer if 1 use external pin
CP/ RL2 - Capture/reload flag.
Description: In this instruction the carry flag bit is ANDed with a source bit
and the result is placed in carry. If the Boolean value of the source bit is a logic
0 then clear the carry flag; otherwise leave the carry flag in its current state.
Only direct bit addressing is allowed for the source operand. A slash (/)
preceding the operand in the assembly language indicates that the logical
complement of the addressed bit is used as the source value, but the source bit
itself is not affected.
3.6.8 CLR A
Function: Clear accumulator
Flags: None are affected
Description: The accumulator is cleared (all bits set to zero).
Example: The accumulator contains 5CH. The instruction CLR A will leave
the accumulator set to 00H.
3.6.10 CPL A
Function: Complement accumulator
Flags: None are affected
Description: Each bit of the accumulator is logically complemented (ones
complement). Bits which previously contained a one are changed to zero and
vice versa.
Example: The accumulator contains 5CH (01011100B). The instruction CPL
A will leave the accumulator set to 0A3H (10100011 B).
3.6.12 DA A
Function: Decimal adjust accumulator after addition
Flags: CY
Description: DA A adjusts the eight-bit value in the accumulator resulting
from the earlier addition of two variables (each in packed BCD format),
producing two four-bit digits. Any ADD or ADDC instruction may have been
used to perform the addition. If accumulator bits 3-0 are greater than nine
(1010-1111), or if the AC flag is one, six is added to the accumulator
producing the proper BCD digit in the low order nibble. This internal addition
would set the carry flag if a carry-out of the low order four-bit field propagated
through all high-order bits, but it would not clear the carry flag otherwise. If
the carry flag is now set, or if the four high-order bits now exceed nine (10101111), these high-order bits are incremented by six, producing the proper BCD
digit in the high-order nibble. Again, this would set the carry flag if there was a
carryout of the high-order bits, but wouldnt clear the carry. The carry flag thus
indicates if the sum of the original two BCD variables is greater than 100,
allowing multiple precision decimal additions. OV is not affected. All of this
occurs during the one instruction cycle. Essentially; this instruction performs
the decimal conversion by adding 00H, 06H, 60H, or 66H to the accumulator,
depending on initial accumulator and PSW conditions.
Note: DA A cannot simply convert a hexadecimal number in the accumulator
to BCD notation, nor does DA A apply to decimal subtraction.
Example:
MOV A, #47H
ADD A, #38H
DA A
Result:
47H
+ 38H
7FH
(invalid BCD)
06H
(after DA A)
85H
(valid BCD)
In the above instruction, since the lower nibble was greater than 9, DA added 6
to A. If the lower nibble is less than 9 but AC=1, it also adds 6 to the lower
nibble.
3.6.14 DIV AB
Function: Divide
Flags: CY and OV
Description: DIV AB divides the unsigned eight-bit integer in the accumulator
by the unsigned eight-bit integer in register B. The accumulator receives the
integer part of the quotient; register B receives the integer remainder. The
carry and OV flags will be cleared.
Exception: If B had originally contained 00H, the values returned in the
accumulator and B register will be undefined and the overflow flag will be set.
The carry flag is cleared in any case.
Example:
MOV A,#35
MOV B,#10
DIV AB
Result: A=3 and B=5
Note: When this instruction is used to modify an output port, the value used as
the original port data will be read from the output data latch, not the input pins.
3.6.18 JB BIT,TARGET
Function: Jump if bit is set
Flags: None
Description: If the indicated bit is a one, jump to the target address indicated;
otherwise proceed with the next instruction. The branch destination is
computed by adding the signed relative-displacement in the third instruction
byte to the PC, after incrementing the PC to the first byte of the next
instruction. The bit tested is not modified.
Example:
SETB P1.2; Make P1.2 an input port
HERE: JB P1.2,HERE ; stay here as long as P1.2=1
MOV P2,#20H ; Since P1.2=0 send 55H to P2
3.6.20 JC TARGET
Function: Jump if carry is set
Flags: None
Description: If the carry flag is set, branch to the target address indicated;
otherwise proceed with the next instruction.
byte to the PC, after incrementing the PC twice. The accumulator is not
modified.
3.6.25 JZ TARGET
Function: Jump if accumulator is zero
Flags: None
Description: If all bits of the accumulator are zero, branch to the address
indicated; otherwise proceed with the next instruction. The branch destination
is computed by adding the signed relative-displacement in the second
instruction byte to the PC, after incrementing the PC twice. The accumulator is
not modified. No flags are affected.
MOVX A,@DPTR
This moves into the accumulator a byte from external memory whose address
is pointed by DPTR.
MOVX @DPTR, A
This moves the content of accumulator to the external memory location whose
address is held by DPTR.
(b) The 8-bit address of external memory is held by R0 or R1
MOVX A,@Ri
This moves to the accumulator a byte from external memory whose 8-bit
address is pointed by R0 or R1.
MOVX @Ri,A
This moves a byte from register A to an external memory whose 8-bit address
is held by R0 or R1.
3.6.33 MUL AB
Function: Multiply
Flags: OV, CY
Description: MUL AB multiplies the unsigned eight-bit integers in the
accumulator and register B. The low-order byte of the sixteen-bit product is
left in the accumulator, and the high-order byte in B. If the product is greater
than 255 (0FFH) the overflow flag is set; otherwise it is cleared. The carry flag
is always cleared.
Example:
MOV A,#5
MOV B,#7
MUL AB
Result: A=35=23H, B=0
3.6.34 NOP
Function: No operation
Flags: None
Description: This performs no operation and execution continues with the
next instruction. It is sometimes used for timing delays to waste clock cycles.
This instruction only updates the PC to point to the next instruction following
NOP.
3.6.39 RET
Function: Return from subroutine
Flags: None
Description: This instruction is used to return from a subroutine. RET pops
the high and low-order bytes of the PC successively from the stack,
decrementing the stack pointer by two. Program execution continues at the
resulting address, generally the instruction immediately following an ACALL
or LCALL.
3.6.40 RETI
Function: Return from interrupt
Flags: None
Description: This instruction is used to return from an interrupt service
routine. RETI pops the high and low-order bytes of the PC successively from
the stack, and restores the interrupt logic to accept additional interrupts at the
same priority level as the one just processed. The stack pointer is left
decremented by two. The PSW is not automatically restored to its pre-interrupt
status. Program execution continues at the resulting address, which is generally
the instruction immediately after the point at which the interrupt request was
detected. If a lower or same-level interrupt is pending when the RETI
instruction is executed, that one instruction will be executed before the
pending interrupt is processed.
3.6.41 RL A
Function: Rotate accumulator left
Flags: None
Description: The eight bits in the accumulator are rotated one bit to the left.
Bit 7 is rotated into the bit 0 position.
Example: The accumulator holds the value 0C5H (11000101B). The
instruction RL A leaves the accumulator holding the value 8BH (10001011B)
with the carry unaffected.
3.6.42 RLC A
Function: Rotate accumulator left through carry flag
Flags: CY
Description: The eight bits in the accumulator and the carry flag are together
rotated one bit to the left. Bit 7 moves into the carry flag; the original state of
the carry flag moves into the bit 0 position.
Example: The accumulator holds the value 0C5H (11000101B), and the carry
is zero. The instruction
RLC A leaves the accumulator holding the value 8AH (10001010B) with the
carry set.
3.6.43 RR A
Function: Rotate accumulator right
Flags: None
Description: The eight bits in the accumulator are rotated one bit to the right.
Bit 0 is rotated into the bit 7 position.
Example: The accumulator holds the value 0C5H (11000101B). The
instruction RR A leaves the accumulator holding the value 0E2H (11100010B)
with the carry unaffected.
3.6.44 RRC A
Function: Rotate accumulator right through carry flag
Flags: CY
Description: The eight bits in the accumulator and the carry flag are together
rotated one bit to the right. Bit 0 moves into the carry flag; the original value
of the carry flag moves into the bit 7 position.
Example: The accumulator holds the value 0C5H (11000101B), the carry is
zero. The instruction
RRC A leaves the accumulator holding the value 62H (01100010B) with the
carry set.
3.6.48 SWAP A
Function: Swap nibbles within the accumulator
Flags: None
Description: SWAP A interchanges the low and high-order nibbles (four-bit
fields) of the accumulator (bits 3-0 and bits 7-4). The operation can also be
thought of as a four bit rotate instruction.
Example:
MOV A, #25H
SWAP A
Result: A = 52H
Flags: None
Description: XCHD exchanges the low-order nibble of the accumulator (bits
30), with that of the internal RAM location indirectly addressed by the
specified register. The high-order nibbles (bits 7-4) of each register are not
affected.
Example: R0 contains the address 20H. The accumulator holds the value
36H. Internal RAM location 20H holds the value 75H. The instruction XCHD
A, @ R0 will leave RAM location 20H holding the value 76H and 35H in the
accumulator.
CHAPTER - 4
4.1 INTRODUCTION
In MPS we you will be developing code for the C8051F120 EVB
(evaluation board). This board is from Silicon Laboratories (SiLabs). For that
purpose, you will be using a x86 based PC (your laptop, a desktop, or co
processor card in a Sun Ultra 10 workstation) to write and compile the
controller programs. This type of development is called Cross Platform
Development. After generating the machine code for the target environment
and before you can run it you must download it to the C8051F120.
When doing cross platform development, extra knowledge of the target
environment is needed. It is important to be able to answer the following
questions:
What memory resources does the execution environment have?
128 Kbytes of FLASH ROM that extends from 00000 to 1FFFFH and 8
Kbytes of RAM. The compiler - and more specifically the linker - has been
configured to make use of this memory address space.
Are we dealing with only hardware or is there an interface program we
have to go through?
All communication to the C8051F120 evaluation board is currently
through the IDE (integrated development environment) from Silicon
Laboratories running on the PC.
The SiLabs IDE is a convenient way to edit, compile, and download
source code written for the microcontroller. While SiLabs provides a nice
interface for making source code changes and easily downloading them to the
development boards, it lacks the actual compiler portion which converts C
code to hex files, the common format used by the 8051. To do this, a free and
widely used open source tool called Small Device C Compiler (SDCC) is used.
SDCC compiles the C code written, and automatically optimizes and converts
it to hex. Due to its popularity, support for SDCC in the SiLabs IDE comes
standard, making it easy and convenient to use.
You will be using the SDCC 2.7 cross compiler. The compiler
generates executable files with the extension .exe from the C source files.
CLR A
Function: clear accumulator
Description: The accumulator is cleared (all bits reset to zero). No flags are
affected.
CPL A
Function: Complement accumulator.
Description: Each bit of the accumulator is logically complemented (ones
complemented). Bits which previously contained a one are changed to a zero
and vice-versa. No flags are affected.
JB bit,rel
Function: jump if bit set
JNB bit,rel
Function: jump if bit not set
Description: If the carry bit is zero, branch to the indicated address; otherwise
proceed with the next instruction. The branch destination is computed by
adding the signed relative-displacement in the third instruction byte to the PC,
after incrementing the PC to the first byte of the next instruction. The bit tested
is modified. No flags are affected.
LJMP addr16
Function: Long jump
Description: LJMP causes an unconditional branch to the indicated address, by
loading the high order and low-order bytes of the PC (respectively) with the
second and third instruction bytes. The destination may therefore be anywhere
in the full 64K program memory address space. No flags are affected.
RET
Function: Return from subroutine
Description: RET pops the high and low-order bytes of the PC successively
from the stack, decrementing the stack pointer by two. Program execution
continues at the resulting address, generally the instruction immediately
following an ACALL or LCALL. No flags are affected.
SETB <bit>
Function: set bit
Description: SETB sets the indicated bit to one. SETB can operate on the
carry flag or any directly addressable bit. No other flags are affected.
SJMP rel
Function: short jump
Description: program control branches unconditionally to the address
indicated. The branch destination is computed by adding the signed
displacement in the second instruction byte to the PC, after incrementing the
PC twice. Therefore, the range of destinations allowed is from 128 bytes
preceding this instruction to 127 bytes following it.
;
;
;
OK1:
JNB P3.0,WRONG
JNB P3.1,WRONG
JNB P3.2,OK2
JNB P3.3,WRONG
JNB P3.4,WRONG
JNB P3.5,WRONG
JNB P3.7,WRONG
SJMP OK1
OK2:
JNB P3.2,$
ACALL DELAY
;
;
;
JNB P3.0,WRONG
JNB P3.1,WRONG
JNB P3.2,WRONG
JNB P3.3,OK3
JNB P3.4,WRONG
JNB P3.5,WRONG
JNB P3.7,WRONG
OK3:
CLR P1.3
; BUZZER
CLR P1.0
SETB P1.1
ACALL DELAY1
SETB P1.3
; BUZZER OFF
SETB P1.0
SETB P1.1
ACALL DELAY1
SETB P1.0
CLR P1.1
ACALL DELAY1
SETB P1.0
SETB P1.1
LJMP MAIN
DELAY1:
MOV R3,#00
MOV R2,#00
MOV R1,#12
DELAY:
DJNZ R3,DELAY
DJNZ R2,DELAY
DJNZ R1,DELAY
RET
WRONG:
ACALL DELAY
CLR BUZ
CLR RELAY
ACALL DELAY
SETB RELAY
ACALL DELAY
CLR RELAY
ACALL DELAY
SETB RELAY
which will start to play recording message in few seconds for Gas. In that mid
time hands free dials last redialed number of the mobile phone which provides
info to the concerned people.
In the case of Fire sensor, we use IC 555 along with Heat sensor as a
main component. Pin no 4 and pin no 8 is connected to the positive supply. Pin
no 1 is connected to the negative voltage. One capacitor is grounded from the
pin no 5 for noise cancellation. Output is available on the pin no 3. Sensor is
connected to the pin no 2. In the heat sensor, Pin no 2 is negative bias through
the 33k ohm resistor and pin no 3 is positively biased. Infrared LED is directly
connected to the positive and negative supply through the 470 ohm resistor.
CHAPTER - 5
5.1.2 FEATURES
signal can be heard by connecting a speaker to the SP+ and SP- pins. Chipwide management is accomplished through the device control block shown in
the upper right hand corner. Message management is provided through the
message control block represented in the lower center of the block diagram.
More detail on actual device application can be found in the Sample
Application section. More detail on sampling control can be found in the
Sample Rate and Voice Quality section. More detail on Message management
and device control can be found in the Message Management section.
hold the /M1_MESSAGE pin low continuously the same message will play
continuously in a looping fashion. A 1,540ms period of silence is inserted
during looping as an indicator to the user of the transition between the
beginning and end of the message. Note that in auto rewind mode the device
always rewinds to the beginning of the current message. To listen to a
subsequent message the device must be fast forwarded past the current
message to the next message. This function is accomplished by toggling
the /M2_NEXT pin from high to low. The pulse must be low for least 400
cycles of the sampling clock. After the device is incremented to the desired
message the user can initiate playback of the message with the playback
sequence described above. A special case exists when the /M2_NEXT pin goes
low during playback. Playback of the current message will stop, the device
will beep, advance to the next message and initiate playback of the next
message. (Note that if /M2 Next goes low when not in playback mode, the
device will prepare to play the next message, but will not actually initiate
playback).
If the /CE pin goes high during playback, playback of the current
message will stop, the device will beep, reset to the beginning of the first
message, and wait for a subsequent playback command. When you reach the
end of the memory array, any subsequent pulsing of /M1_MESSAGE or
/M2_NEXT will only result in a double beep. To precede from this state the
user must rewind the device to the beginning of the m memory array. This can
be accomplished by toggling the /CE pin low or cycling power.
5.4.3.3 FUNCTIONAL DESCRIPTION OF RECORDING IN TAPE
MODE USING THE NORMAL OPTION
On power-up, the device is ready to record or playback, starting at the
first address in the memory array. Before you can begin recording, the /CE
input must be set to low to enable the device and /RE must be set to low to
enable recording. On a falling edge of the /M1_MESSAGE pin the device will
beep once and initiate recording. A subsequent rising edge on the /M1 Message
pin will stop recording and insert a single beep. If the /M1_ MESSAGE pin is
held low beyond the end of the available memory, recording Stops
automatically, and two beeps are inserted; regardless of the state of the
/M1_MESSAGE pin. The device returns to the standby mode when the
/M1_MESSAGE pin is returned high. A subsequent falling edge on the
/M1_MESSAGE pin starts a new record operation in the memory array
immediately following the last recorded message, thus preserving the last
recorded message. To record over all previous messages you must pulse the
/CE pin low once to reset the device to the beginning of the first message. You
can then initiate a record sequence, as described above, to record a new
message. The most recently recorded message will become the last recorded
message and all previously recorded messages following this message will
become inaccessible. If you wish to preserve any current messages it is
recommend that the Auto Rewind option be used instead of the Normal option.
If the Normal option is necessary the following sequence can be used. To
preserve current messages you must fast forward past the messages you want
to keep before you can record a new message. To fast forward when using the
Normal option you must switch to play mode and listen to messages
sequentially until you arrive at the beginning of the message you wish to
overwrite. At this stage you should switch back to record mode and overwrite
the desired message. The most recently recorded message will become the last
recorded message and all previously recorded messages following this
message will become inaccessible. All inputs, except /CE, are ignored during
recording.
5.4.3.4 FUNCTIONAL DESCRIPTION OF PLAYBACK IN TAPE
MODE USING THE NORMAL OPTION
On power-up or after a low to high transition on /RE the device is ready
to record or playback starting at the first address in the memory array. Before
you can begin playback of messages, the /CE input must be set to low to
enable the device and /RE must be set to high to enable playback. The first
high to low going pulse of the /M1_MESSAGE pin initiates playback from the
beginning of the current message. When the /M1_MESSAGE pin pulses from
high to low a second time, playback of the current message stops immediately.
When the /M1_MESSAGE pin pulses from high to low a third time, playback
of the next message starts again from the beginning. If you hold the
/M1_MESSAGE pin low continuously, the current message and subsequent
messages play until the one of the following conditions is met: the end of the
memory array is reached, the last message is reached, the /M1_message pin is
released. If the last recorded message has already played, any further
transitions on the /M1_MESSAGE pin will initiate a double beep for warning
and the /M7_END pin will go low. To exit this state you must pulse the /CE
pin high and then low once during standby to reset the pointer to the beginning
of the first message.
5.5
MICROPROCESSOR
MANAGEMENT
CONTROLLED
MESSAGE
Resistance
(k ohm)
Sampling
Frequency(kHz)
Input
Bandwidth (kHz)
Duration(sec)
84
4.2
2.1
60
38
6.4
3.2
40
34
32
Table 5.3 shows the Pin Description & Functionality of APR 9600 in different
modes.
CHAPTER - 6
So, our project will help a lot everywhere because of its security and
alertness. We will still develop and extend our project to maximum level to
safeguard the places and extend the service with good response.
6.2 RESULT
This project is microcontroller based project. A Gas sensor is used to
detect dangerous gas leaks in the home kitchen, large scale industries,
manufacturing plants, skyscrapers, lodge, hotels etc. Mainly since its a small
unit we can ideally implement to detect dangerous gas leaks in the kitchen. For
large scale, we have to implement complex circuitry with same logic. The
sensor can also sense LPG leak in your car or in a service station, storage tank
environment. This unit can be easily incorporated into an alarm unit, to sound
an alarm. The sensor has excellent sensitivity combined with a quick response
time. When GAS leakage is detected above 8 ppm, the sensor sends electrical
signal to microcontroller which in turn sends ON signal exhaust fan, alarm,
auto dial up and APR. So the four systems start working simultaneously to
enhance security & preserve accidents. First the exhaust fan will start that will
try to reduce the concentration of the gas so that any incident can be avoided;
secondly the alarm will start and will warn the people of surrounding areas.
Lastly, the auto dial up will start working and will call to the to the authorized
person using cellular network called GSM specifically to the last called
number or stored number of the mobile telephony, and lastly the APR with the
help of speaker will give the message of gas leakage to the called person.
Another feature that we added to our project is a fire sensor. A fire
sensor will start working in case if there occurred fire due to some sparking or
blazes elements present there, then fire sensor will do the same work as done
by gas sensor. It will send signals to the microcontroller which in turn will give
signal to alarm and the alarm will start. Also it will give signal to the APR and
auto dial up system. The auto dial up system as said above will call the last
caller and the speaker connected to APR will give the message about the fire.
6.3 LIMITATION
Only Detection, not Blockage
The major limitation of the project is that it can only detect the gas leakage
and can alert about it but it cant stop the leakage.
High Sensitivity of Heat Sensor
The fire sensor that we used is highly sensitive, in case of normal heat in
the kitchen or industry it will start working and alarm will be on.
Beside these limitations there are some limitations of gas sensor used.
There are some conditions that must be prohibited while using gas sensor.
They are as follows:
Exposure to Organic Silicon Steam
Organic silicon steam cause sensors invalid, sensors must be avoid
exposing to silicon bond, fixture, silicon latex, putty or plastic contain silicon
environment.
High Corrosive Gas
If the sensors exposed to high concentration corrosive gas (such as H2Sz,
SOXCl2, HCl etc), it will not only result in corrosion of sensors structure, also it
cause sincere sensitivity attenuation.
Alkali, Corrosive Alkali Metals Salt, Halogen Pollution
The sensors performance will be changed badly if sensors be sprayed
polluted by alkali metals salt especially brine, or be exposed to halogen such
as florin.
Touch Water
Sensitivity of the sensors will be reduced when spattered or dipped in
water.
Freezing
Do avoid icing on sensors surface, otherwise sensor would lose sensitivity.
Applied Voltage Higher
Applied voltage on sensor should not be higher than stipulated value,
otherwise it cause down-line or heater damaged, and bring on sensors
sensitivity characteristic changed badly.
More dial up option up to 25 last redial list are available which can
be implemented for better security results.
BIBLIOGRAPHY