Sie sind auf Seite 1von 88

Embedded Industrial Security System with

Auto-Dialer using 89C51 Microcontroller

1
Index
Technical Specifications --- 4

IEEE Reference Citation --- 6

Project Abstract --- 8

Project Block Diagram --- 11

Introduction --- 13

Explanation of each block --- 20

Regulated Power Supply --- 21

AT89C51 Microcontroller --- 28

Software Tools --- 70

Keil Compiler --- 71

Proload Flash --- 74

Source Code --- 75

Working Procedure --- 79

Advantages --- 82

Applications --- 84

Conclusion --- 86

Reference --- 88

2
Tables & Diagrams
Block Diagram --- 10

Block Diagram of 89C51 --- 22

Modes of flash programming --- 31

Flash programming --- 32

16X2 LCD Pin Diagram --- 37

LCD Pin Discretion --- 38

Block Diagram of Power Supply --- 43

3
Technical Specifications

Title of the project : Embedded Industrial Security System with


Auto-Dialer using 89C51 Microcontroller
Domain : Embedded Systems Design
Software : Embedded C, Keil, Proload

Microcontroller : AT89C51

Power Supply : +5V, 500mA Regulated Power Supply

Display : LED 5mm

Crystal : 11.0592MHz

Security Channels : 8

Access Sensor : Reed Switch / Magnetic sensors, IR Sensor

Vibration Sensor : Piezo Electric sensor

Panic Alert : Push-to-on switch

Light Detector : LDR

Auto Dialer : Redial on telephone key pad

Applications : Industries, Banks, Jeweler Shops, Home security

Developed By : M/S Wine Yard Technologies

3-6-148/1/A, Opp HDFC Bank,

Liberty Road, Himayathnagar, Hyd – 29

Phone : 040-65178887, www.wineyard.biz

4
IEEE Reference

5
IEEE Reference:

Embedded Industrial Security System with Auto-Dailer using


89C51 Microcontroller

Holler, G.   Fuchs, A.   Brasseur, G.  


Inst. of Electr. Meas. & Meas. Signal Process., Graz Univ. of Technol., Graz;

This paper appears in: Instrumentation and Measurement Technology


Conference Proceedings, 2008. IMTC 2008. IEEE
Publication Date: 12-15 May 2008
On page(s): 641-646
Location: Victoria, BC,
ISSN: 1091-5281
ISBN: 978-1-4244-1540-3
INSPEC Accession Number: 10059280
Digital Object Identifier: 10.1109/IMTC.2008.4547115
Current Version Published: 2008-06-20

6
Abstract

7
ABSTRACT

Security is primary concern for every one. This Project describes a design of
effective security alarm system that can monitor an industry with eight different sensors.
Unauthorized access, Fire accident, wall braking, IR detection, and fire 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 burglar alarm also has an input to 'arm' the alarm, a tamper input
and a couple of outputs to control a siren and Auto dialing system. The alarm is also
fitted with a so-called 'panic button'.

The burglar alarm is built around the AT89C51 micro controller from Atmel. This
micro controller provides all the functionality of the burglar 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 burglar 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.

Eight 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

8
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
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 out put of secondary of 230/12V step down transformer.

9
Block Diagram

10
Block Diagram

LED Array

SENSOR Driver
BOARD Circuit

ALARM

PANIC
SWITCH
ARM
89C51
SWITCH

Relay
Crystal Auto
Lift Auto
Relay Dialer
Dial

Reset
circuit

Step Bridge Filter


down Rectifier Circuit Regulator
T/F
DESCRIPTION
Power supply to all sections

11
Introduction

12
INTRODUCTION
Security is the condition of being protected against danger or loss. In the general sense,
security is a concept similar to safety. The nuance between the two is an added emphasis
on being protected from dangers that originate from outside. Individuals or actions that
encroach upon the condition of protection 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.
INTRODUCTION TO EMBEDDED SYSTEMS
An embedded system can be defined as a computing device that does a specific
focused job. Appliances such as the air-conditioner, VCD player, DVD player, printer,
fax machine, mobile phone etc. are examples of embedded systems. Each of these
appliances will have a processor and special hardware to meet the specific requirement of
the application along with the embedded software that is executed by the processor for
meeting that specific requirement. The embedded software is also called “firm ware”.
The desktop/laptop computer is a general purpose computer. You can use it for a variety
of applications such as playing games, word processing, accounting, software
development and so on. In contrast, the software in the embedded systems is always fixed
listed below:
· Embedded systems do a very specific task, they cannot be programmed to do different
things. . Embedded systems have very limited resources, particularly the memory.
Generally, they do not have secondary storage devices such as the CDROM or the floppy
disk. Embedded systems have to work against some deadlines. A specific job has to be
completed within a specific time. In some embedded systems, called real-time systems,
the deadlines are stringent. Missing a deadline may cause a catastrophe-loss of life or
damage to property. Embedded systems are constrained for power. As many embedded
systems operate through a battery, the power consumption has to be very low.
· Some embedded systems have to operate in extreme environmental conditions such as
very high temperatures and humidity.

13
Application Areas
Nearly 99 per cent of the processors manufactured end up in embedded systems. The
embedded system market is one of the highest growth areas as these systems are used in
very market segment- consumer electronics, office automation, industrial automation,
biomedical engineering, wireless communication,
data communication, telecommunications, transportation, military and so on.

Consumer appliances: At home we use a number of embedded systems which include


digital camera, digital diary, DVD player, electronic toys, microwave oven, remote
controls for TV and air-conditioner, VCO player, video game consoles, video recorders
etc. Today’s high-tech car has about 20 embedded systems for transmission control,
engine spark control, air-conditioning, navigation etc. Even wristwatches are now
becoming embedded systems. The palmtops are powerful embedded systems using which
we can carry out many general-purpose tasks such as playing games and word
processing.

Office automation: The office automation products using em embedded systems are
copying machine, fax machine, key telephone, modem, printer, scanner etc.

Industrial automation: Today a lot of industries use embedded systems for process
control. These include pharmaceutical, cement, sugar, oil exploration, nuclear energy,
electricity generation and transmission. The embedded systems for industrial use are
designed to carry out specific tasks such as monitoring the temperature, pressure,
humidity, voltage, current etc., and then take appropriate action based on the monitored
levels to control other devices or to send information to a centralized monitoring station.
In hazardous industrial environment, where human presence has to be avoided, robots are
used, which are programmed to do specific jobs. The robots are now becoming very
powerful and carry out many interesting and complicated tasks such as hardware
assembly.

14
Medical electronics: Almost every medical equipment in the hospital is an embedded
system. These equipments include diagnostic aids such as ECG, EEG, blood pressure
measuring devices, X-ray scanners; equipment used in blood analysis, radiation,
colonscopy, endoscopy etc. Developments in medical electronics have paved way for
more accurate diagnosis of diseases.

Computer networking: Computer networking products such as bridges, routers,


Integrated Services Digital Networks (ISDN), Asynchronous Transfer Mode (ATM),
X.25 and frame relay switches are embedded systems which implement the necessary
data communication protocols. For example, a router interconnects two networks. The
two networks may be running different protocol stacks. The router’s function is to obtain
the data packets from incoming pores, analyze the packets and send them towards the
destination after doing necessary protocol conversion. Most networking equipments,
other than the end systems (desktop computers) we use to access the networks, are
embedded systems
.
Telecommunications: In the field of telecommunications, the embedded systems can be
categorized as subscriber terminals and network equipment. The subscriber terminals
such as key telephones, ISDN phones, terminal adapters, web cameras are embedded
systems. The network equipment includes multiplexers, multiple access systems, Packet
Assemblers Dissemblers (PADs), sate11ite modems etc. IP phone, IP gateway, IP
gatekeeper etc. are the latest embedded systems that provide very low-cost voice
communication over the Internet.
Wireless technologies: Advances in mobile communications are paving way for many
interesting applications using embedded systems. The mobile phone is one of the marvels
of the last decade of the 20’h century. It is a very powerful embedded system that
provides voice communication while we are on the move. The Personal Digital Assistants
and the palmtops can now be used to access multimedia services over the Internet.
Mobile communication infrastructure such as base station controllers, mobile switching
centers are also powerful embedded systems.

15
Insemination: Testing and measurement are the fundamental requirements in all
scientific and engineering activities. The measuring equipment we use in laboratories to
measure parameters such as weight, temperature, pressure, humidity, voltage, current etc.
are all embedded systems. Test equipment such as oscilloscope, spectrum analyzer, logic
analyzer, protocol analyzer, radio communication test set etc. are embedded systems built
around powerful processors. Thank to miniaturization, the test and measuring equipment
are now becoming portable facilitating easy testing and measurement in the field by
field-personnel.

Security: Security of persons and information has always been a major issue. We need to
protect our homes and offices; and also the information we transmit and store.
Developing embedded systems for security applications is one of the most lucrative
businesses nowadays. Security devices at homes, offices, airports etc. for authentication
and verification are embedded systems. Encryption devices are nearly 99 per cent of
the processors that are manufactured end up in~ embedded systems. Embedded systems
find applications in . every industrial segment- consumer electronics, transportation,
avionics, biomedical engineering, manufacturing, process control and industrial
automation, data communication, telecommunication, defense, security etc. Used to
encrypt the data/voice being transmitted on communication links such as telephone lines.
Biometric systems using fingerprint and face recognition are now being extensively used
for user authentication in banking applications as well as for access control in high
security buildings.
Finance: Financial dealing through cash and cheques are now slowly paving way for
transactions using smart cards and ATM (Automatic Teller Machine, also expanded as
Any Time Money) machines. Smart card, of the size of a credit card, has a small micro-
controller and memory; and it interacts with the smart card reader! ATM machine and
acts as an electronic wallet. Smart card technology has the capability of ushering in a
cashless society. Well, the list goes on. It is no exaggeration to say that eyes wherever
you go, you can see, or at least feel, the work of an embedded system!

16
Overview of Embedded System Architecture
Every embedded system consists of custom-built hardware built around a Central
Processing Unit (CPU). This hardware also contains memory chips onto which the
software is loaded. The software residing on the memory chip is also called the
‘firmware’. The embedded system architecture can be represented as a layered
architecture as shown in Fig.
The operating system runs above the hardware, and the application software runs above

the operating system. The same architecture is applicable to any computer including a
desktop computer. However, there are significant differences. It is not compulsory to
have an operating system in every embedded system. For small appliances such as remote
control units, air conditioners, toys etc., there is no need for an operating system and you
can write only the software specific to that application. For applications involving
complex processing, it is advisable to have an operating system. In such a case, you need
to integrate the application software with the operating system and then transfer the entire
software on to the memory chip. Once the software is transferred to the memory chip, the
software will continue to run for a long time you don’t need to reload new software.
Now, let us see the details of the various building blocks of the hardware of an embedded
system. As shown in Fig. the building blocks are;
· Central Processing Unit (CPU)
· Memory (Read-only Memory and Random Access Memory)
· Input Devices
· Output devices

17
· Communication interfaces
· Application-specific circuitry

Central Processing Unit (CPU):


The Central Processing Unit (processor, in short) can be any of the following:
microcontroller, microprocessor or Digital Signal Processor (DSP). A micro-controller is
a low-cost processor. Its main attraction is that on the chip itself, there will be many other
components such as memory, serial communication interface, analog-to digital converter
etc. So, for small applications, a micro-controller is the best choice as the number of
external components required will be very less. On the other hand, microprocessors are
more powerful, but you need to use many external components with them. D5P is used
mainly for applications in which signal processing is involved such as audio and video
processing.
Memory:
The memory is categorized as Random Access 11emory (RAM) and Read Only Memory
(ROM). The contents of the RAM will be erased if power is switched off to the chip,
whereas ROM retains the contents even if the power is switched off. So, the firmware is
stored in the ROM. When power is switched on, the processor reads the ROM; the
program is program is executed.

Input devices:

18
Unlike the desktops, the input devices to an embedded system have very limited
capability. There will be no keyboard or a mouse, and hence interacting with the
embedded system is no easy task. Many embedded systems will have a small keypad-you
press one key to give a specific command. A keypad may be used to input only the digits.
Many embedded systems used in process control do not have any input device for user
interaction; they take inputs from sensors or transducers 1’fnd produce electrical signals
that are in turn fed to other systems.

Output devices:
The output devices of the embedded systems also have very limited capability. Some
embedded systems will have a few Light Emitting Diodes (LEDs) to indicate the health
status of the system modules, or for visual indication of alarms. A small Liquid Crystal
Display (LCD) may also be used to display some important parameters.

Communication interfaces:
The embedded systems may need to, interact with other embedded systems at they may
have to transmit data to a desktop. To facilitate this, the embedded systems are provided
with one or a few communication interfaces such as RS232, RS422, RS485, Universal
Serial Bus (USB), IEEE 1394, Ethernet etc.

Application-specific circuitry:
Sensors, transducers, special processing and control circuitry may be required fat an
embedded system, depending on its application. This circuitry interacts with the
processor to carry out the necessary work. The entire hardware has to be given power
supply either through the 230 volts main supply or through a battery. The hardware has to
designed in such a way that the power consumption is minimized.

19
Explanation of Each Block

20
Power Supply Design

21
POWER SUPPLY:

The input to the circuit is applied from the regulated power supply. The a.c. 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 d.c voltage. So in order to

get a pure d.c voltage, the output voltage from the rectifier is fed to a filter to remove any

a.c components present even after rectification. Now, this voltage is given to a voltage

regulator to obtain a pure constant dc voltage.

230V AC
50Hz D.C
Output

Step down Bridge


Filter Regulator
transform Rectifie

Fig: Power supply

22
Transformer:

Usually, DC voltages are required to operate various electronic equipment and these

voltages are 5V, 9V or 12V. But these voltages cannot be obtained directly. Thus the a.c

input available at the mains supply i.e., 230V is to be brought down to the required

voltage level. This is done by a transformer. Thus, a step down transformer is employed

to decrease the voltage to a required level.

Rectifier:

The output from the transformer is fed to the rectifier. It converts A.C. into pulsating

D.C. The rectifier may be a half wave or a full wave rectifier. In this project, a bridge

rectifier is used because of its merits like good stability and full wave rectification.

23
The Bridge rectifier is a circuit, which converts an ac voltage to dc voltage using both
half cycles of the input ac voltage. The Bridge rectifier circuit is shown in the figure. The
circuit has four diodes connected to form a bridge. The ac input voltage is applied to the
diagonally opposite ends of the bridge. The load resistance is connected between the
other two ends of the bridge.

For the positive half cycle of the input ac voltage, diodes D1 and D3 conduct, whereas
diodes D2 and D4 remain in the OFF state. The conducting diodes will be in series with
the load resistance RL and hence the load current flows through RL.

For the negative half cycle of the input ac voltage, diodes D2 and D4 conduct whereas,
D1 and D3 remain OFF. The conducting diodes D2 and D4 will be in series

with the load resistance RL and hence the current flows through RL in the same direction
as in the previous half cycle. Thus a bi-directional wave is converted into a unidirectional
wave.

24
25
Filter:

Capacitive filter is used in this project. It removes the ripples from the output of rectifier
and smoothens the D.C. Output received from this filter is constant until the mains
voltage and load is maintained constant. However, if either of the two is varied, D.C.
voltage received at this point changes. Therefore a regulator is applied at the output stage.

Voltage regulator:

As the name itself implies, it regulates the input applied to it. A voltage

regulator is an electrical regulator

designed to automatically maintain a

constant voltage level. In this

project, power supply of 5V and 12V

are required. In order to obtain these

voltage levels, 7805 and 7812 voltage regulators are to be used. The first number 78

represents positive supply and the numbers 05, 12 represent the required output voltage

levels. The L78xx series of three-terminal positive regulators is available in TO-

220, TO-220FP, TO-3, D2PAK and DPAK packages and several

fixed output voltages, making it useful in a wide range of

applications. These regulators can provide local on-card

regulation, eliminating the distribution problems associated

with single point regulation. Each type employs internal current

limiting, thermal shut-down and safe area protection, making it

26
essentially indestructible. If adequate heat sinking is provided, they can deliver

over 1 A output current. Although designed primarily as fixed voltage

regulators, these devices can be used with external components to obtain

adjustable voltage and currents.

27
AT89C51 Microcontroller

28
MICROCONTROLLERS

Microcontrollers’ producers have been struggling for a long time for attracting more and
more choosy customers. Every couple of days a new chip with a higher operating
frequency, more memory and more high-quality A/D converters comes on the market.

Nevertheless, by analyzing their structure it is concluded that most of them have the same
(or at least very similar) architecture known in the product catalogs as “8051
compatible”. What is all this about?

The whole story began in the far 80s when Intel launched its series of the
microcontrollers labelled with MCS 051. Although, several circuits belonging to this
series had quite modest features in comparison to the new ones, they took over the world
very fast and became a standard for what nowadays is ment by a word microcontroller.

The reason for success and such a big popularity is a skillfully chosen configuration
which satisfies needs of a great number of the users allowing at the same time stable
expanding ( refers to the new types of the microcontrollers ). Besides, since a great deal
of software has been developed in the meantime, it simply was not profitable to change
anything in the microcontroller’s basic core. That is the reason for having a great number

29
of various microcontrollers which actually are solely upgraded versions of the 8051
family. What is it what makes this microcontroller so special and universal so that almost
all the world producers manufacture it today under different name?

FEATURES OF AT89C51:

 4K Bytes of Re-programmable Flash Memory.


 RAM is 128 bytes.

 2.7V to 6V Operating Range.

 Fully Static Operation: 0 Hz to 24 MHz.

 Two-level Program Memory Lock.

 128 x 8-bit Internal RAM.

 32 Programmable I/O Lines.

 Two 16-bit Timer/Counters.

 Six Interrupt Sources.

 Programmable Serial UART Channel.

 Low-power Idle and Power-down Modes

 4 Kb program memory is not much at all.


 128Kb RAM (including SFRs as well) satisfies basic needs, but it is not imposing
amount.
 4 ports having in total of 32 input/output lines are mostly enough to make
connection to peripheral environment and are not luxury at all.

As it is shown on the previous picture, the 8051 microcontroller have nothing impressive
at first sight:

30
The whole configuration is obviously envisaged as such to satisfy the needs of most
programmers who work on development of automation devices. One of advantages of
this microcontroller is that nothing is missing and nothing is too much. In other words, it
is created exactly in accordance to the average user‘s taste and needs. The other
advantage is the way RAM is organized, the way Central Processor Unit (CPU) operates
and ports which maximally use all recourses and enable further upgrading.

8051 Microcontroller's pins

Pins 1-8: Port 1 Each of these pins can be configured as input or output.

Pin 9 : RS Logical one on this pin stops microcontroller’s operating and erases the
contents of most registers. By applying logical zero to this pin, the program starts
execution from the beginning. In other words, a positive voltage pulse on this pin resets
the microcontroller.

Pins10-17: Port 3 Similar to port 1, each of these pins can serve as universal input or
output . Besides, all of them have alternative functions:

Pin 10: RXD Serial asynchronous communication input or Serial synchronous


communication output.

Pin 11: TXD Serial asynchronous communication output or Serial synchronous


communication clock output.

Pin 12: INT0 Interrupt 0 input

Pin 13: INT1 Interrupt 1 input

Pin 14: T0 Counter 0 clock input

Pin 15: T1 Counter 1 clock input

31
Pin 16: WR Signal for writing to external (additional) RAM

Pin 17: RD Signal for reading from external RAM

Pin 18, 19: X2, X1 Internal oscillator input and output. A quartz crystal which
determines operating frequency is usually connected to these pins. Instead of quartz
crystal, the miniature ceramics resonators can be also used for frequency stabilization.
Later versions of the microcontrollers operate at a frequency of 0 Hz up to over 50 Hz.

Pin 20: GND Ground

Pin 21-28: Port 2 If there is no intention to use external memory then these port pins are
configured as universal inputs/outputs. In case external memory is used then the higher
address byte, i.e. addresses A8-A15 will appear on this port. It is important to know that
even memory with capacity of 64Kb is not used ( i.e. note all bits on port are used for
memory addressing) the rest of bits are not available as inputs or outputs.

Pin 29: PSEN If external ROM is used for storing program then it has a logic-0 value
every time the microcontroller reads a byte from memory.

Pin 30: ALE Prior to each reading from external memory, the microcontroller will set
the lower address byte (A0-A7) on P0 and immediately after that activates the output
ALE. Upon receiving signal from the ALE pin, the external register (74HCT373 or
74HCT375 circuit is usually embedded ) memorizes the state of P0 and uses it as an
address for memory chip. In the second part of the microcontroller’s machine cycle, a
signal on this pin stops being emitted and P0 is used now for data transmission (Data
Bus). In this way, by means of only one additional (and cheap) integrated circuit, data
multiplexing from the port is performed. This port at the same time used for data and
address transmission.

Pin 31: EA By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. That means that
even there is a program written to the microcontroller, it will not be executed, the

32
program written to external ROM will be used instead. Otherwise, by applying logic one
to the EA pin, the microcontroller will use both memories, first internal and afterwards
external (if it exists), up to end of address space.

Pin 32-39: Port 0 Similar to port 2, if external memory is not used, these pins can be
used as universal inputs or outputs. Otherwise, P0 is configured as address output (A0-
A7) when the ALE pin is at high level (1) and as data output (Data Bus), when logic zero
(0) is applied to the ALE pin.

Pin 40: VCC Power supply +5V

Input/Output Ports (I/O Ports)

All 8051 microcontrollers have 4 I/O ports, each consisting of 8 bits which can be
configured as inputs or outputs. This means that the user has on disposal in total of 32
input/output lines connecting the microcontroller to peripheral devices.

A logic state on a pin determines whether it is configured as input or output: 0=output,


1=input. If a pin on the microcontroller needs to be configured as output, then a logic
zero (0) should be applied to the appropriate bit on I/O port. In this way, a voltage level
on the appropriate pin will be 0.

Similar to that, if a pin needs to be configured as input, then a logic one (1) should be
applied to the appropriate port. In this way, as a side effect a voltage level on the
appropriate pin will be 5V (as it is case with any TTL input). This may sound a bit
confusing but everything becomes clear after studying a simplified electronic circuit
connected to one I/O pin.

33
34
Input/Output (I/O) pin
This is a simplified overview of what is
connected to a pin inside the
microcontroller. It concerns all pins except
those included in P0 which do not have
embedded pullup resistor.

Output pin

A logic zero (0) is applied to a bit in the P register. By turning output FE transistor on,
the appropriate pin is directly connected to ground.

Input pin
A logic one (1) is applied to a bit in the P
register. Output FE transistor is turned off.
The appropriate pin remains connected to
voltage power supply through a pull-up
resistor of high resistance.A logic state
(voltage) on any pin can be changed or read
at any moment. A logic zero (0) and logic
one (1) are not equal. A logic one (0)
represents almost short circuit to ground. Such a pin is configured as output.

35
A logic one (1) is “loosely” connected to voltage power supply through resistors of high
resistance. Since this voltage can be easily “pulled down” by an external signal, such a
pin is configured as input.

Port 0

It is specific to this port to have a double purpose. If external memory is used then the
lower address byte (addresses A0-A7) is applied on it. Otherwise, all bits on this port are
configured as inputs or outputs.

Another characteristic is expressed when it is configured as output. Namely, unlike other


ports consisting of pins with embedded pull-up resistor ( connected by its end to 5 V
power supply ), this resistor is left out here. This, apparently little change has its
consequences:

If any pin on this port is configured as input then it performs as if it “floats”. Such input
has unlimited input resistance and has no voltage coming from “inside”.

36
When the pin is configured as output, it performs as “open drain”, meaning that by
writing 0 to some port’s bit, the appropriate pin will be connected to ground (0V). By
writing 1, the external output will keep on “floating”. In order to apply 1 (5V) on this
output, an external pull-up resistor must be embedded.

Only in case P0 is used for addressing external memory ( only in that case), the
microcontroller will provide internal power supply source in order to establish logical
ones on pins. There is no need to add external pullup resistors.

Port 1

This is a true I/O port, because there are no role assigning as it is the case with P0. Since
it has embedded pull-up resistors it is completely compatible with TTL circuits.

Port 2

Similar to P0, when using external memory, lines on this port occupy addresses intended
for external memory chip. This time it is the higher address byte with addresses A8-A15.
When there is no additional memory, this port can be used as universal input-output port
similar by its features to the port 1.

Port 3

Even though all pins on this port can be used as universal I/O port, they also have an
alternative function. Since each of these functions use inputs, then the appropriate pins
have to be configured like that. In other words, prior to using some of reserve port
functions, a logical one (1) must be written to the appropriate bit in the P3 register. From
hardware’s perspective , this port is also similar to P0, with the difference that its outputs
have a pull-up resistor embedded.

37
Current limitations on pins

When configured as outputs ( logic zero (0) ), single port pins can "receive" current of
10mA. If all 8 bits on a port are active, total current must be limited to 15mA (port P0:
26mA). If all ports (32 bits) are active, total maximal current must be limited to 71mA.
When configured as inputs (logic 1), embedded pull-up resistor provides very weak
current, but strong enough to activate up to 4 TTL inputs from LS series.

It may be seen from description of some ports, that even though all pins have more or less
similar internal structure, it is necessary to pay attention to which of them will be used for
what and how.

For example: If they are used as outputs with high voltage level (5V), then port 0 should
be avoided because its pins do not have added resistor for connection to +5V. Only low
logic level can be obtained therefore, if another port is used for the same purpose, one
should have in mind that pull-up resistors have a relatively high resistance.
Consequentaly it can be counted on only several hundreds microamperes of current
coming out of a pin.

8051 Microcontroller Memory Organisation

The microcontroller memory is divided into Program Memory and Data Memory.
Program Memory (ROM) is used for permanent saving program being executed, while
Data Memory (RAM) is used for temporarily storing and keeping intermediate results
and variables. Depending on the model in use ( still referring to the whole 8051
microcontroller family) at most a few Kb of ROM and 128 or 256 bytes of RAM can be
used. However…

All 8051 microcontrollers have 16-bit addressing bus and can address 64 kb memory. It
is neither a mistake nor a big ambition of engineers who were working on basic core

38
development. It is a matter of very clever memory organization which makes these
controllers a real “ programmers’ tidbit“ .

Program Memory

The oldest models of the 8051 microcontroller family did not have internal program
memory . It was added from outside as a separate chip. These models are recognizable by
their label beginning with 803 ( for ex. 8031 or 8032). All later models have a few
Kbytes ROM embedded, Even though it is enough for writing most of the programs,
there are situations when additional memory is necessary. A typical example of it is the
use of so called lookup tables. They are used in cases when something is too complicated
or when there is no time for solving equations describing some process. The example of it
can be totally exotic (an estimate of self-guided rockets’ meeting point) or totally
common( measuring of temperature using non-linear thermo element or asynchronous
motor speed control). In those cases all needed estimates and approximates are executed
in advance and the final results are put in the tables ( similar to logarithmic tables ).

How does the microcontroller handle external memory depends on the pin EA logic state:

39
EA=0 In this case, internal program memory is completely ignored, only a program
stored in external memory is to be executed.

EA=1 In this case, a program from built in ROM is to be executed first ( to the last
location). Afterwards, the execution is continued by reading additional memory.

in both cases, P0 and P2 are not available to the user because they are used for data nd
address transmission. Besides, the pins ALE and PSEN are used too.

40
Data Memory
As already mentioned, Data Memory is used for temporarily storing and keeping data and
intermediate results created and used during microcontroller’s operating. Besides, this
microcontroller family includes many other registers such as: hardware counters and
timers, input/output ports, serial data buffers etc. The previous versions have the total
memory size of 256 locations, while for later models this number is incremented by
additional 128 available registers. In both cases, these first 256 memory locations
(addresses 0-FFh) are the base of the memory. Common to all types of the 8051
microcontrollers. Locations available to the user occupy memory space with addresses
from 0 to 7Fh. First 128 registers and this part of RAM is divided in several blocks.

The first block consists of 4 banks each including 8 registers designated as R0 to R7.
Prior to access them, a bank containing that register must be selected. Next memory
block ( in the range of 20h to 2Fh) is bit- addressable, which means that each bit being
there has its own address from 0 to 7Fh. Since there are 16 such registers, this block
contains in total of 128 bits with separate addresses (The 0th bit of the 20h byte has the
bit address 0 and the 7th bit of th 2Fh byte has the bit address 7Fh). The third group of
registers occupy addresses 2Fh-7Fh ( in total of 80 locations) and does not have any
special purpose or feature.

Additional Memory Block of Data Memory


In order to satisfy the programmers’ permanent hunger for Data Memory, producers have
embedded an additional memory block of 128 locations into the latest versions of the
8051 microcontrollers. Naturally, it’s not so simple…The problem is that electronics
performing addressing has 1 byte (8 bits) on disposal and due to that it can reach only the
first 256 locations. In order to keep already existing 8-bit architecture and compatibility
with other existing models a little trick has been used.

Using trick in this case means that additional memory block shares the same addresses
with existing locations intended for the SFRs (80h- FFh). In order to differentiate
between these two physically separated memory spaces, different ways of addressing are

41
used. A direct addressing is used for all locations in the SFRs, while the locations from
additional RAM are accessible using indirect addressing.

How to extend memory?

In case on-chip memory is not enough, it is possible to add two external memory chips
with capacity of 64Kb each. I/O ports P2 and P3 are used for their addressing and data
transmission.

42
From the users’ perspective, everything functions quite simple if properly connected
because the most operations are performed by the microcontroller itself. The 8051
microcontroller has two separate reading signals RD#(P3.7) and PSEN#. The first one is
activated byte from external data memory (RAM) should be read, while another one is
activated to read byte from external program memory (ROM). These both signals are
active at logical zero (0) level. A typical example of such memory extension using
special chips for RAM and ROM is shown on the previous picture. It is called Hardward
architecture.

Even though the additional memory is rarely used with the latest versions of the
microcontrollers, it will be described here in short what happens when memory chips are
connected according to the previous scheme. It is important to know that the whole
process is performed automatically, i.e. with no intervention in the program.

 When the program during execution encounters the instruction which resides in
external memory (ROM), the microcontroller will activate its control output ALE
and set the first 8 bits of address (A0-A7) on P0. In this way, IC circuit
74HCT573 which "lets in" the first 8 bits to memory address pins is activated.
 A signal on the pin ALE closes the IC circuit 74HCT573 and immediately
afterwards 8 higher bits of address (A8-A15) appear on the port. In this way, a
desired location in additional program memory is completely addressed. The only
thing left over is to read its content.
 Pins on P0 are configured as inputs, the pin PSEN is activated and the microcon
troller reads content from memory chip. The same connections are used both for
data and lower address byte.

Similar occurs when it is a needed to read some location from external Data Memory.
Now, addressing is performed in the same way, while reading or writing is performed via
signals which appear on the control outputs RD or WR .

43
Addressing

While operating, processor processes data according to the program instructions. Each
instruction consists of two parts. One part describes what should be done and another part
indicates what to use to do it. This later part can be data (binary number) or address
where the data is stored. All 8051 microcontrollers use two ways of addressing depending
on which part of memory should be accessed:

Direct Addressing

On direct addressing, a value is obtained from a memory location while the address of
that location is specified in instruction. Only after that, the instruction can process data
(how depends on the type of instruction: addition, subtraction, copy…). Obviously, a
number being changed during operating a variable can reside at that specified address.
For example:

Since the address is only one byte in size ( the greatest number is 255), this is how only
the first 255 locations in RAM can be accessed in this case the first half of the basic
RAM is intended to be used freely, while another half is reserved for the SFRs.

Indirect Addressing

On indirect addressing, a register which contains address of another register is specified


in the instruction. A value used in operating process resides in that another register. For
example:

Only RAM locations available for use are accessed by indirect addressing (never in the
SFRs). For all latest versions of the microcontrollers with additional memory block
( those 128 locations in Data Memory), this is the only way of accessing them. Simply,
when during operating, the instruction including “@” sign is encountered and if the
specified address is higher than 128 ( 7F hex.), the processor knows that indirect
addressing is used and jumps over memory space reserved for the SFRs.

44
On indirect addressing, the registers R0, R1 or Stack Pointer are used for specifying 8-bit
addresses. Since only 8 bits are available, it is possible to access only registers of internal
RAM in this way (128 locations in former or 256 locations in latest versions of the
microcontrollers). If memory extension in form of additional memory chip is used then
the 16-bit DPTR Register (consisting of the registers DPTRL and DPTRH) is used for
specifying addresses. In this way it is possible to access any location in the range of 64K.

SFRs (Special Function Registers)

SFRs are a kind of control table used for running and monitoring microcontroller’s
operating. Each of these registers, even each bit they include, has its name, address in the
scope of RAM and clearly defined purpose ( for example: timer control, interrupt, serial
connection etc.). Even though there are 128 free memory locations intended for their
storage, the basic core, shared by all types of 8051 controllers, has only 21 such registers.
Rest of locations are intensionally left free in order to enable the producers to further
improved models keeping at the same time compatibility with the previous versions. It
also enables the use of programs written a long time ago for the microcontrollers which
are out of production now.

45
A Register (Accumulator)

This is a general-purpose register which serves for storing intermediate results during
operating. A number (an operand) should be added to the accumulator prior to execute an
instruction upon it. Once an arithmetical operation is preformed by the ALU, the result is
placed into the accumulator. If a data should be transferred from one register to another,
it must go through accumulator. For such universal purpose, this is the most commonly
used register that none microcontroller can be imagined without (more than a half 8051
microcontroller's instructions used use the accumulator in some way).

46
B Register

B register is used during multiply and divide operations which can be performed only
upon numbers stored in the A and B registers. All other instructions in the program can
use this register as a spare accumulator (A).

During programming, each of registers is called by name so that their exact address is not
so important for the user. During compiling into machine code (series of hexadecimal
numbers recognized as instructions by the microcontroller), PC will automatically,
instead of registers’ name, write necessary addresses into the microcontroller.

R Registers (R0-R7)

47
This is a common name for the total 8 general purpose registers (R0, R1, R2 ...R7). Even
they are not true SFRs, they deserve to be discussed here because of their purpose. The
bank is active when the R registers it includes are in use. Similar to the accumulator, they
are used for temporary storing variables and intermediate results. Which of the banks will
be active depends on two bits included in the PSW Register. These registers are stored in
four banks in the scope of RAM.

Light-emitting diode (LED)

Light-emitting diodes are elements for light signalization in electronics. They are
manufactured in different shapes, colors and sizes. For their low price, low consumption
and simple use, they have almost completely pushed aside other light sources- bulbs at
first place. They perform similar to common diodes with the difference that they emit
light when current flows through them.

It is important to know that each diode will be immediately destroyed unless its current is
limited. This means that a conductor
must be connected in parallel to a
diode. In order to correctly determine
value of this conductor, it is necessary
to know diode’s voltage drop in
forward direction, which depends on
what material a diode is made of and

48
what colour it is. Values typical for the most frequently used diodes are shown in table
below: As seen, there are three main types of LEDs. Standard ones get ful brightness at
current of 20mA. Low Current diodes get ful brightness at ten times lower current while
Super Bright diodes produce more intensive light than Standard ones.

Since the 8051 microcontrollers can provide only low input current and since their pins
are configured as outputs when voltage level on them is equal to 0, direct connectining to
LEDs is carried out as it is shown on figure (Low current LED, cathode is connected to
output pin).

Switches and Pushbuttons

There is nothing simpler than this! This is the simplest way of controlling appearance of
some voltage on microcontroller’s input pin. There is also no need for additional
explanation of how these components operate.

Nevertheless, it is not so simple in practice... This is about something commonly


unnoticeable when using these components in everyday life. It is about contact bounce- a
common problem with m e c h a n i c a l switches. If contact switching does not happen
so quickly, several consecutive bounces can be noticed prior to maintain stable state. The
reasons for this are: vibrations, slight rough spots and dirt. Anyway, whole this process
does not last long (a few micro- or miliseconds), but long enough to be registered by the
microcontroller. Concerning pulse counter, error occurs in almost 100% of cases!

49
The simplest solution is to connect simple RC circuit which will “suppress” each quick
voltage change. Since the bouncing time is not defined, the values of elements are not
strictly determined. In the most cases, the values shown on figure are sufficient.

If complete safety is needed, radical measures should be taken! The circuit, shown on the
figure (RS flip-flop), changes logic state on its output with the first pulse triggered by
contact bounce. Even though this is more expensive solution (SPDT switch), the problem
is definitely resolved! Besides, since the condensator is not used, very short pulses can be
also registered in this way. In addition to these hardware solutions, a simple software
solution is commonly applied too: when a program tests the state of some input pin and
finds changes, the check should be done one more time after certain time delay. If the
change is confirmed it means that switch (or pushbutton) has changed its position. The
advantages of such solution are obvious: it is free of charge, effects of disturbances are
eliminated too and it can be adjusted to the worst-quality contacts.

50
AUTO DIALER:

The very simplest working telephone would look like this inside:

As you can see, it only contains three parts and they are all simple:
 A switch to connect and disconnect the phone from the network - This
switch is generally called the hook switch. It connects when you lift the
handset.
 A speaker - This is generally a little 50-cent, 8-ohm speaker of some sort.
 A microphone - In the past, telephone microphones have been as simple
as carbon granules compressed between two thin metal plates. Sound
waves from your voice compress and decompress the granules, changing
the resistance of the granules and modulating the current flowing through
the microphone.
Most people find that annoying, so any "real" phone contains a device called a duplex
coil or something functionally equivalent to block the sound of your own voice from
reaching your ear. A modern telephone also includes a bell so it can ring and a touch-
tone keypad and frequency generator. A "real" phone looks like this:

51
A "real" telephone

Still, it's pretty simple. In a modern phone there is an electronic microphone, amplifier
and circuit to replace the carbon granules and loading coil. The mechanical bell is often
replaced by a speaker and a circuit to generate a pleasant ringing tone.
Here in our project we will be replacing the HOOK SWITCH with a RELAY so that the
switching can be controlled with the microcontroller itself. That is nothing but we are
connecting to the telephone line when ever we want by just activating that relay.

Redial:

The telephone stores in memory the last number you called. The number will remain
in the Redial memory until you dial another number.

To dial the same number again

1. Lift the handset or press your telephone's Hands free button.

2. Listen for the dial tone, and press Redial.

This is done manually but as we want all this to be done automatically we will be
replacing the redial button with another RELAY. Here we are using two relays for
controlling the ON and OFF of the phone and for redialing. So now every thing is
automatic as the relays are being controlled by the microcontroller itself.

52
RELAYS:

A relay is an electrically controllable switch widely used in industrial controls,


automobiles and appliances.

The relay allows the isolation of two separate sections of a system with two different
voltage sources i.e., a small amount of voltage/current on one side can handle a large
amount of voltage/current on the other side but there is no chance that these two voltages
mix up.

Inductor

Fig: Circuit symbol of a relay

Operation:

When current flows through the coil, a magnetic field is created around the coil
i.e., the coil is energized. This causes the armature to be attracted to the coil. The
armature’s contact acts like a switch and closes or opens the circuit. When the coil is not
energized, a spring pulls the armature to its normal state of open or closed. There are all
types of relays for all kinds of applications.

53
Fig: Relay Operation and use of protection diodes

Transistors and ICs must be protected from the brief high voltage 'spike' produced
when the relay coil is switched off. The above diagram shows how a signal diode (eg
1N4148) is connected across the relay coil to provide this protection. The diode is
connected 'backwards' so that it will normally not conduct. Conduction occurs only when
the relay coil is switched off, at this moment the current tries to flow continuously
through the coil and it is safely diverted through the diode. Without the diode no current
could flow and the coil would produce a damaging high voltage 'spike' in its attempt to
keep the current flowing.

In choosing a relay, the following characteristics need to be considered:

1. The contacts can be normally open (NO) or normally closed (NC). In the NC type, the
contacts are closed when the coil is not energized. In the NO type, the contacts are closed
when the coil is energized.

54
2. There can be one or more contacts. i.e., different types like SPST (single pole single
throw), SPDT (single pole double throw) and DPDT (double pole double throw) relays.

3. The voltage and current required to energize the coil. The voltage can vary from a few
volts to 50 volts, while the current can be from a few milliamps to 20milliamps. The relay
has a minimum voltage, below which the coil will not be energized. This minimum
voltage is called the “pull-in” voltage.

4. The minimum DC/AC voltage and current that can be handled by the contacts. This is
in the range of a few volts to hundreds of volts, while the current can be from a few amps
to 40A or more, depending on the relay.

SENSOR BOARD:

The different sensors used in this project are as follows:

1. REED SWITCHES or MAGNETIC SENSORS


2. LED & LDR section

3. VIBRATION DETECTOR

4. TEMPERATURE SENSOR

5. PANIC SWITCH

6. IR tx AND IR rx.

7. SMOKE DETECTOR

Let us see the description of each sensor.

55
REED SWITCHES OR MAGNETIC SENSORS:

The reed switch is an electrical switch operated by an applied magnetic field. The basic

reed switch consists of two identical flattened ferromagnetic reeds, sealed in a dry inert-

gas atmosphere within a glass capsule, thereby protecting the contact from

contamination. The reeds are sealed in the capsule in such a way that their free ends

overlap and are separated by a small air gap.

Fig: Reed Switch

The contacts may be normally open, closing when a magnetic field is present, or

normally closed and opening when a magnetic field is applied.

A magnetic field from an electromagnet or a permanent magnet will cause the contacts to

pull together, thus completing an electrical circuit. The stiffness of the reeds causes them

to separate, and open the circuit, when the magnetic field ceases. Good electrical contact

56
is assured by plating a thin layer of precious metal over the flat contact portions of the

reeds.

Since the contacts of the reed switch are sealed away from the atmosphere, they are

protected against atmospheric corrosion. The hermetic sealing of a reed switch makes

them suitable for use in explosive atmospheres where tiny sparks from conventional

switches would constitute a hazard.

REED SENSOR:

A reed sensor is a device built using a reed switch with additional functionality like

ability to withstand higher shock, easier mounting, additional intelligent circuitry, etc.

In production, a metal reed is inserted in each end of a glass tube and the end of the tube

heated so that it seals around a shank portion on the reed. Infrared-absorbing glass is

used, so an infrared heat source can concentrate the heat in the small sealing zone of the

glass tube. The thermal coefficient of expansion of the glass material and metal parts

must be similar to prevent breaking the glass-to-metal seal. The glass used must have a

high electrical resistance and must not contain volatile components such as lead oxide

and fluorides. The leads of the switch must be handled carefully to prevent breaking the

glass envelope.

How does a reed switch work?

When a magnetic force is generated parallel to the reed switch, the reeds become flux

carriers in the magnetic circuit. The overlapping ends of the reeds become opposite

57
magnetic poles, which attract each other. If the magnetic force between the poles is

strong enough to overcome the restoring force of the reeds, the reeds will be drawn

together.

One important quality of the switch is its sensitivity, the amount of magnetic energy

necessary to actuate it. Sensitivity is measured in units of Ampere-turns, corresponding to

the current in a coil multiplied by the number of turns. Typical pull-in sensitivities for

commercial devices are in the 10 to 60 AT range.

Uses:

Reed switches are widely used for electrical circuit control, particularly in the

communications field. Reed switches are commonly used in mechanical systems as

proximity switches as well as in door and window sensors in burglar alarm systems and

tamper proofing methods. These were formerly used in the keyboards for computer

terminals, where each key had a magnet and a reed switch actuated by depressing the

key. Speed sensors on bicycles use a reed switch to detect when the magnet on the wheel

passes the sensor.

Advantages:

1. They are hermetically sealed in glass environment.

2. Free from contamination, and are safe to use in harsh industrial and explosive

environments.

58
3. Reed switches are immune to electrostatic discharge (ESD) and do not require

any external ESD protection circuits. The isolation resistance between the

contacts is as high as 1015 ohms, and contact resistance is as low as 50 milliohms.

4. They can directly switch loads as low as a few microwatts without the help of

external amplification circuits, to as high as 120W.

5. When the reed switches are combined with magnets and coils, they can be used

to form many different types of relays.

Six reed switches are used in our project to indicate different levels of the petrochemical

liquid in the process container. When the floating magnet comes in contact with any of

the reed switches, magnetic field will be generated and the reeds are drawn together and

thus the reed switch is triggered and this change is applied to the microcontroller for

further processing.

The arrangement of the reed switch in our project is as shown in the figure above. We

will be using two reed switches, one at the door and other at the window.

59
LED AND LDR SECTION:

LDR:

LDRs or Light Dependent Resistors are very useful especially in light/dark sensor
circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000 000
ohms, but when they are illuminated with light resistance drops dramatically.

When the light level is low the resistance of the LDR is high. This prevents current from
flowing to the base of the transistors. Consequently the LED does not light.

However, when light shines onto the LDR its resistance falls and current flows into the
base of the first transistor and then the second transistor. The LED lights.

60
Here in our project to avoid the light from led to fall on to LDR we place a box in which
we will keep our jewelry. If any one removes the box the light from led falls directly on
to the LDR and then the transistor will be on which is monitored by the microcontroller.
The

Vibration Detector:

Here we use a ceramic piezoelectric buzzer plate for vibration detection.


Piezoceramic buzzers generate sound through the bending vibrations of a thin metal plate
adhered to a piezoceramic disc.

These buzzers feature low power consumption, a safe, spark-free and non-contact
structure, and a small size and light weight for an easy mounting to printed circuit boards.
As a result, an increasing number of piezoceramic buzzers are now used to generate an
artificial voice in combination with voice synthesizing ICs. To produce high-quality
piezoceramic buzzers, FDK has capitalized on many years of piezoceramics production
and outstanding ceramic processing technologies and thin film forming techniques. By
adding a sophisticated audio know-how to this manufacturing expertise, FDK offers a
large array of electronic tone generating products, such as piezoceramic diaphragms,
sounders and buzzers, to meet loud sound outputs, wide frequency ranges, and many
other requirements.

61
We will be placing it at the door so that a small vibration at the door also can be detected.

The arrangement of this sensor in our project is as shown in the figure above which is
sensed by the microcontroller. After sensing the signal the corresponding action is done
by the microcontroller which is preprogrammed.

Temperature Sensor:

A sensor can be defined as a device which can convert one form of energy into electrical
energy. Here we are using a sensor to sense the temperature around us. For this purpose
we will be taking help of LM 35 which is a temperature sensor.

LM35:

The LM35 series are precision integrated-circuit temperature sensors, whose output
voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus
has an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not
required to subtract a large constant voltage from its output to obtain convenient
Centigrade scaling. The LM35 does not require any external calibration or trimming to
provide typical accuracies of ±1⁄4°C at room temperature and ±3⁄4°C over a full −55 to
+150°C temperature range. Low cost is assured by trimming and calibration at the wafer
level. The LM35’s low output impedance, linear output, and precise inherent calibration
make interfacing to readout or control circuitry especially easy. It can be used with single
power supplies, or with plus and minus supplies. As it draws only 60 μA from its supply,
it has very low self-heating, less than 0.1°C in still air. The LM35 is rated to operate over
a −55° to +150°C temperature range.

Features
 Calibrated directly in ° Celsius (Centigrade)

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

Typical Applications

The arrangement of this sensor in our board is as shown in the figure below.

63
In this we directly connect the output of the sensor to the base of the transistor as of
LM35 for every 1˚C rise of temperature the output will increase for 10mV. Now if the
temperature reaches 70˚C the output voltage will be 0.7V which is enough for the
transistor junction to be biased. Hence the transistor gets on and the output is sensed by
the microcontroller.

Panic Switch:

This is nothing but a simple switch which is connected in the sensor board.the
arrangement of this is as shown in the figure below.

64
The response of this switch is monitored by the microcontroller and the corresponding
action takes place.

IR Section:

IR Tx.:

TSAL6200 is a high efficiency infrared emitting diode in GaAlAs on GaAs technology,


molded in clear, bluegrey tinted plastic packages. In comparison with the standard GaAs
on GaAs technology these emitters achieve more than 100 % radiant power improvement
at a similar wavelength. The forward voltages at low current and at high pulse current
roughly correspond to the low values of the standard technology. Therefore these emitters
are ideally suitable as high performance replacements of standard emitters.

Features
• Extra high radiant power and radiant intensity
• High reliability
• Low forward voltage
• Suitable for high pulse current operation
• Standard T-1¾ (∅ 5 mm) package
• Angle of half intensity ϕ = ± 17°
• Peak wavelength λp = 940 nm
• Good spectral matching to Si photodetectors
.

IR Rx:

Description
The TSOP17.. – series are miniaturized receivers for infrared remote control systems.
PIN diode and preamplifier are assembled on lead frame, the epoxy package is designed
as IR filter.
The demodulated output signal can directly be decoded by a microprocessor. TSOP17XX
is the
standard IR remote control receiver series, supporting all major transmission codes.

Features
 Photo detector and preamplifier in one package
 Internal filter for PCM frequency

65
 Improved shielding against electrical field disturbance
 TTL and CMOS compatibility
 Output active low
 Low power consumption
 High immunity against ambient light
 Continuous data transmission possible (up to 2400 bps)
 Suitable burst length .10 cycles/burst.

Block Diagram

Application Circuit

The circuit of the TSOP17.. is designed in that way that unexpected output pulses due to
noise or disturbance signals are avoided. A bandpassfilter, an integrator stage and an
automatic gain control are used to suppress such disturbances. The distinguishing mark
between data signal and

66
disturbance signal are carrier frequency, burst length and duty cycle. The data signal
should fullfill the following condition:
 Carrier frequency should be close to center frequency of the band pass (e.g.
38kHz).
 Burst length should be 10 cycles/burst or longer.
 After each burst which is between 10 cycles and 70 cycles a gap time of at least
14 cycles is necessary.
 For each burst which is longer than 1.8ms a corresponding gap time is necessary
at some time in the data stream. This gap time should have at least same length as
the burst.
 Up to 1400 short bursts per second can be received continuously.
When a disturbance signal is applied to the TSOP17.. it can still receive the data signal.
However the sensitivity is reduced to that level that no unexpected pulses will occur.

The arrangement of this sensors is as shown below.

Smoke Detector:

67
DESCRIPTION

The H21A1, H21A2 and H21A3 consist of a gallium arsenide infrared emitting diode
coupled with a silicon phototransistor in a plastic housing. The packaging system is
designed to optimize the mechanical
resolution, coupling efficiency, ambient light rejection, cost and reliability. The gap in the
housing provides a means of interrupting the signal with an opaque material, switching
the output from an “ON” to an “OFF” state.

FEATURES
• Opaque housing
• Low cost
• .035” apertures
• High IC(ON)
1. Derate power dissipation linearly 1.33 mW/°C above 25°C.
2. RMA flux is recommended.
3. Methanol or isopropyl alcohols are recommended as cleaning
agents.
3. Soldering iron tip 1/16” (1.6mm) minimum from housing.

This sensor is used to detect any fire accidents. When ever a fire accident occurs some
smoke is generated. This sensor detest that smoke and gives the response to the
microcontroller. The arrangement of this sensor in our sensor board is as shown below.

68
Software Tools

69
KEIL SOFTWARE:

Keil compiler is a software used where the machine language code is


written and compiled. After compilation, the machine source code is converted
into hex code which is to be dumped into the microcontroller for further
processing. Keil compiler also supports C language code.

STEPS TO WRITE AN ASSEMBLY LANGUAGE PROGRAM IN KEIL AND HOW TO COMPILE


IT:

1. Install the Keil Software in the PC in any of the drives.


2. After installation, an icon will be created with the name “Keil uVision3”.
Just drag this icon onto the desktop so that it becomes easy whenever
you try to write programs in keil.
3. Double click on this icon to start the keil compiler.
4. A page opens with different options in it showing the project workspace at
the leftmost corner side, output window in the bottom and an ash coloured
space for the program to be written.
5. Now to start using the keil, click on the option “project”.
6. A small window opens showing the options like new project, import
project, open project etc. Click on “New project”.
7. A small window with the title bar “Create new project” opens. The window
asks the user to give the project name with which it should be created and
the destination location. The project can be created in any of the drives
available. You can create a new folder and then a new file or can create
directly a new file.
8. After the file is saved in the given destination location, a window opens
where a list of vendors will be displayed and you have to select the device
for the target you have created.
9. The most widely used vendor is Atmel. So click on Atmel and now the
family of microcontrollers manufactured by Atmel opens. You can select
any one of the microcontrollers according to the requirement.

70
10. When you click on any one of the microcontrollers, the features of that
particular microcontroller will be displayed on the right side of the page.
The most appropriate microcontroller with which most of the projects can
be implemented is the AT89C51. Click on this microcontroller and have a
look at its features. Now click on “OK” to select this microcontroller.
11. A small window opens asking whether to copy the startup code into the file
you have created just now. Just click on “No” to proceed further.
12. Now you can see the TARGET and SOURCE GROUP created in the
project workspace.
13. Now click on “File” and in that “New”. A new page opens and you can start
writing program in it.
14. After the program is completed, save it with any name but with the .asm
extension. Save the program in the file you have created earlier.
15. You can notice that after you save the program, the predefined keywords
will be highlighted in bold letters.
16. Now add this file to the target by giving a right click on the source group. A
list of options open and in that select “Add files to the source group”.
Check for this file where you have saved and add it.
17. Right click on the target and select the first option “Options for target”. A
window opens with different options like device, target, output etc. First
click on “target”.
18. Since the set frequency of the microcontroller is 11.0592 MHz to interface
with the PC, just enter this frequency value in the Xtal (MHz) text area and
put a tick on the Use on-chip ROM. This is because the program what we
write here in the keil will later be dumped into the microcontroller and will
be stored in the inbuilt ROM in the microcontroller.
19. Now click the option “Output” and give any name to the hex file to be
created in the “Name of executable” text area and put a tick to the “Create
HEX file” option present in the same window. The hex file can be created

71
in any of the drives. You can change the folder by clicking on “Select
folder for Objects”.
20. Now to check whether the program you have written is errorless or not,
click on the icon exactly below the “Open file” icon which is nothing but
Build Target icon. You can even use the shortcut key F7 to compile the
program written.
21. To check for the output, there are several windows like serial window,
memory window, project window etc. Depending on the program you have
written, select the appropriate window to see the output by entering into
debug mode.
22. The icon with the letter “d” indicates the debug mode.
23. Click on this icon and now click on the option “View” and select the
appropriate window to check for the output.
24. After this is done, click the icon “debug” again to come out of the debug
mode.
25. The hex file created as shown earlier will be dumped into the
microcontroller with the help of another software called Proload.

72
PROLOAD:

Proload is a software which accepts only hex files. Once the machine
code is converted into hex code, that hex code has to be dumped into the
microcontroller placed in the programmer kit and this is done by the Proload.
Programmer kit contains a microcontroller on it other than the one which is to be
programmed. This microcontroller has a program in it written in such a way that it
accepts the hex file from the keil compiler and dumps this hex file into the
microcontroller which is to be programmed. As this programmer kit requires
power supply to be operated, this power supply is given from the power supply
circuit designed above. It should be noted that this programmer kit contains a
power supply section in the board itself but in order to switch on that power
supply, a source is required. Thus this is accomplished from the power supply
board with an output of 12volts or from an adapter connected to 230 V AC.

1. Install the Proload Software in the PC.


2. Now connect the Programmer kit to the PC (CPU) through serial cable.

3. Power up the programmer kit from the ac supply through adapter.

4. Now place the microcontroller in the GIF socket provided in the


programmer kit.

5. Click on the Proload icon in the PC. A window appears providing the
information like Hardware model, com port, device type, Flash size etc.
Click on browse option to select the hex file to be dumped into the
microcontroller and then click on “Auto program” to program the
microcontroller with that particular hex file.

6. The status of the microcontroller can be seen in the small status window in
the bottom of the page.

73
7. After this process is completed, remove the microcontroller from the
programmer kit and place it in your system board. Now the system board
behaves according to the program written in the microcontroller.

Source Code

74
CODING

;
*********************************************************************
****
;********************** 8-ZONE SECURITY SYSTEM
**********************
;********************** WK-204 **********************
;
*********************************************************************
****

; SECURITY SYSTEM
; p1 to sensors (normally closed)
; p2 LED
; p3.6 for entry delay LED
; p3.7 for exit delay
; p3.4 for buzzer
; p0.0 for MAIN DOOR LED(NORMALLY OPEN)
; p2.6 for phone hook up RELAY
; p2.7 for redial RELAY

ORG 00H
MOV P1,#3CH
SETB P3.5 ;KEY

BEGIN : MOV P0,#0FFH


SETB P3.7 ;EXIT DELAY LED OFF
SETB P3.6 ;ENTRY DELAY LED OFF
CLR P3.4 ;BUZZER OFF
CLR P2.6 ;PHONE HOOK UP OFF
CLR P2.7 ;REDIAL OFF

STAY : JB P3.5,STAY ;KEY


; MOV P0,#0FFH
; SETB P3.7 ;EXIT DELAY LED OFF

75
; SETB P3.6 ;ENTRY DELAY LED OFF
; CLR P3.4 ;BUZZER OFF
; CLR P2.6 ;PHONE HOOK UP OFF
; CLR P2.7 ;REDIAL OFF

; TEST FOR SENSOR OPEN

SENSOR1: JB P1.0,EXIT
JB P1.1,LED1
JNB P1.2,LED2
JNB P1.3,LED3
JNB P1.4,LED4
JNB P1.5,LED5
JB P1.6,LED6
JB P1.7,LED7
SJMP SENSOR1

EXIT : MOV R4,#50


BLINK1: CPL P3.7 ;EXIT DELAY LED
BLINKING
CLR P0.0
ACALL DELAY
ACALL DELAY
DJNZ R4,BLINK1
CLR P3.7 ;EXIT DELAY LED
ON
; MOV P0,#0FEH
SETB P0.0
SENSOR2:JB P1.0,ENTRY
JB P1.1,LED1
JNB P1.2,LED2
JNB P1.3,LED3
JNB P1.4,LED4
JNB P1.5,LED5
JB P1.6,LED6
JB P1.7,LED7
SJMP SENSOR2

LED1: CLR P0.1


ACALL SIREN
LED2: CLR P0.2
ACALL SIREN
LED3: CLR P0.3
ACALL SIREN

76
LED4: CLR P0.4
ACALL SIREN
LED5: CLR P0.5
ACALL SIREN
LED6: CLR P0.6
ACALL SIREN
LED7: CLR P0.7
ACALL SIREN

ENTRY : MOV R5,#50


BLINK2: CPL P3.6
CLR P0.0
ACALL DELAY
ACALL DELAY
DJNZ R5,BLINK2
CLR P3.6 ;ENTRY DELAY LED ON
SETB P0.0
JB P3.5,REPEATE
SIREN : SETB P3.4 ;BUZZER ON
SETB P2.6 ;PHONE HOOK ON
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
SETB P2.7 ;REDIAL ON
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
ACALL DELAY
CLR P2.7 ;REDIAL OFF
KEY : JNB P3.5,KEY
; MOV P1,#0FFH
; SETB P3.0 ;ENTRY DELAY LED OFF
; SETB P3.1 ;EXIT DELAY LED OFF
; SETB P3.2 ;BUZZER OFF
; SETB P3.4 ;PHONE HOOK OFF
REPEATE:LJMP BEGIN

DELAY : MOV R2, #255

77
HERE2 : MOV R3, #255
HERE : DJNZ R3,HERE
DJNZ R2,HERE2
RET

END

WORKING PROCEDURE

78
WORKING PROCEDURE:

This is a stand alone project to provide security to industries using an advanced


technology called embedded systems. In this we are providing security by taking 8
different sensors. They are namely..
1. Reed sensor
2. LED & LDR
3. Vibration Detector
4. Temperature Sensor
5. Panic Switch
6. IR Tx & IR Rx.
7. Smoke Detector

The working of all these sensors will start only when the arm key which is connected
to the main board is made on.

Here we will be using Reed switches at two different places viz. At doors and at
windows. When using at doors we have two conditions to be checked, they are,
whether the person is leaving outside or coming inside. We call these two conditions
as EXIT DELAY and ENTRY DELAY.

Exit Delay:

This case arises when the microcontroller detects that the door is opened for the
first time. In this case the controller will wait for some time giving the user to close
the door or to off the key. If the user closes the door within the given delay the
controller will not ring the buzzer or the alarm and will wait again for another sensor
to be activated. If the user can’t close the door in the given time the controller will
enter into the next case which is called as the entry delay.

Entry Delay:
The controller will enter into this case if the door is opened for the second time or if
the door is not closed in the exit delay. In this case the only option available with the
user is to off the arm key. The controller will wait for some time giving the user to

79
make the arm key off. If the arm key is not made off within the given time the
controller will ring a buzzer continuously and go for auto-dialer by making the relays
on and off for the corresponding action.

Another reed sensor is placed at the window. If the window is opened then the
buzzer is activated and then the auto-dialer action is performed.

After this comes the LED & LDR section. In this we will be placing all important
things in a box and place that box on the LDR such that it objects the light falling
from the LED. If any one removes the box the light falls on the ldr and then the
microcontroller detects it and the buzzer will be activated and then the auto-dialer.

After this comes the Vibration detector. This can be placed to the doors because it
can detect the vibrations. If any one intruder wants to break the door and bangs on the
door this sensor gets activated and then the alarm followed by auto-dialer.

The next sensor is Temperature sensor. This sensor gets activated only when the
temperature in the room exceeds 70 degrees. This is because of the hardware
connections we have made. When this sensor is activated the buzzer followed by
auto-dialer is also activated.

The next one is the panic switch. This can be activated by pressing this switch
which will lead to the activation of buzzer and auto-dialer.

Next comes the IR section. This contains a IR Tx. and IR Rx. This is arranged in
such a manner that the IR signal falls continuously on the IR Rx. When ever an
obstacle is passed through this pair this sensor gets activated. When this sensor is
activated the alarm is on and auto-dialer is activated.

The final sensor is the Smoke detector. Internally this has a pair of IR Tx. and Rx.
This sensor is activated when there is a fire accident which results in smoke. This
smoke is detected by this sensor and then the buzzer is activated followed by auto-
dialer.

80
ADVANTAGES

81
Advantages:

Highly sensitive

Fit and Forget system

Night – Day mode sensing

Low cost and reliable circuit

Complete elimination of manpower

82
APPLICATIONS

83
APPLICATIONS:

1. Infrared remote control units with high power requirements.

2. Free air transmission systems.

3. Infrared source for optical counters and card readers.

4. IR source for smoke detectors.

84
CONCLUSION

85
CONCLUSION

Hence by this project we can design an effective security alarm system that can
monitor an industry with eight different sensors. 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.

86
REFERENCE

87
REFERENCE

1. WWW. howstuffworks.com

2. EMBEDDED SYSTEM BY RAJ KAMAL

3. 8051 MICROCONTROLLER AND EMBEDDED SYSTEMS BY MAZZIDI

4. Magazines

5. Electronics for you

6. Electrikindia

7. WWW.google.com

8. WWW.Electronic projects.com

88

Das könnte Ihnen auch gefallen