Upload
bhanuprakash-k
View
58
Download
2
Embed Size (px)
Citation preview
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
CHAPTER 1
INTRODUCTION
I. INTRODUCTION
Dept. of ECE, B.Tech, SITAMS Page 1
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
The application of micro controller based devices are continuing to rise with its
greater processing speed and flexible control; and the electrical appliances are getting
more miniaturized, less costly and low power consuming. Microcontrollers reduce the
number of chips and the amount of wiring and circuit board space. Thus, this
programmable device (micro controller) provides a unique tool to interface the 'Nature
and Device', to add a Hi-Tech dimension in the fashion of our everyday life.
This phenomenal aspect of opportunity led our to a vision of interfacing the
Light (nature) and the LED (device). To interface the light, an LDR is used which has a
negative coefficient of resistance and this property is utilized for the intelligent control
of an LED, correspond to a time varying light intensity.
Microcontroller based system makes an LED lamp programmable and
intelligent. More on the accuracy and lower power consumption makes the
microcontroller based LED system more efficient, regarding operation control and
energy management. This project work implements this vision of designing and
controlling an LED's ON/OFF state and its illumination pattern according to the change
in light intensity; using microcontroller 8052. The turning ON operation state, of LED
is annotated with a Buzzer by alarming sound. Moreover, an LCD is interfaced to
display the information related to light intensity.
Dept. of ECE, B.Tech, SITAMS Page 2
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
CHAPTER 2
INTRODUCTION TO EMBEDDED SYSTEMS
Dept. of ECE, B.Tech, SITAMS Page 3
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
2.1 BASICS OF 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. It is used for a
variety of applications such as playing games, word processing, accounting, software
development and so on.
Fig 2.1: Representation of embedded systems
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.
Dept. of ECE, B.Tech, SITAMS Page 4
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
2.2 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, a number of embedded systems are used 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, wrist watches are becoming
embedded systems. The palmtops are powerful embedded systems using which one can
carry out many general-purpose tasks such as playing games and word processing.
Office automation:
The office automation products using 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 becoming very powerful and
carry out many interesting and complicated tasks such as hardware assembly.
Dept. of ECE, B.Tech, SITAMS Page 5
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
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, colonoscopy,
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), satellite 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’th 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
Dept. of ECE, B.Tech, SITAMS Page 6
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
communication infrastructure such as base station controllers, mobile switching centers
are also powerful embedded systems.
Insemination:
Testing and measurement are the fundamental requirements in all scientific and
engineering activities. The measuring equipment used 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. Due 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. Homes and
offices should be protected; along with the information transmitted and stored.
Developing embedded systems for security applications is one of the most lucrative
business now a days. 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. It is 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 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
Dept. of ECE, B.Tech, SITAMS Page 7
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
acts as an electronic wallet. Smart card technology has the capability of ushering in a
cashless society. It is no exaggeration to say that wherever we go, we can see the work
of an embedded system.
2.3 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 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
Fig 2.2: Layered architecture of an embedded system
system and only, the software is written to that application.
For applications involving complex processing, it is advisable to have an operating
system. In such a case, integration of the application software with the operating system
is done and then transfer of the entire software on to the memory chip is performed.
Dept. of ECE, B.Tech, SITAMS Page 8
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Once the software is transferred to the memory chip, the software will continue to run
for a long time, reloading of new software is not required.
The various building blocks of the hardware of an embedded system are given as
follows.
· Central Processing Unit (CPU)
· Memory (Read-only Memory and Random Access Memory)
· Input Devices
· Output devices
· Communication interfaces
· Application-specific circuitry
Central Processing Unit (CPU):
The Central Processing Unit (processor) 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 many external components are used with them.
DSP 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 Memory (RAM) and Read Only
Memory ( ROM).
Dept. of ECE, B.Tech, SITAMS Page 9
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 2.3: Central Processing Unit
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 firm ware
is stored in the ROM. When power is switched on, the processor reads the ROM; the
program is program is executed.
Input devices:
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 and 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
Dept. of ECE, B.Tech, SITAMS Page 10
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
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), and IEEE 1394, Ethernet etc.
Application-specific circuitry:
Sensors, transducers, special processing and control circuitry may require 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 design in such a way that the power consumption is minimized.
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 to obtain a pure constant DC voltage.
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 AC 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.
Dept. of ECE, B.Tech, SITAMS Page 11
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 2.4: Power Supply
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.
Filter:
Capacitive filter is used in this project. It removes the ripples from the output of
rectifier and smoothens the DC 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 changes at this point. Therefore a regulator is applied at the
output stage.
Voltage regulator:
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.
Dept. of ECE, B.Tech, SITAMS Page 12
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
CHAPTER 3
MICRO CONTROLLER 8052
Dept. of ECE, B.Tech, SITAMS Page 13
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
3.1 FEATURES OF MICROCONTROLLERS:
Microprocessors and microcontrollers are widely used in embedded systems
products. Microcontroller is a programmable device. A microcontroller has a CPU in
addition to a fixed amount of RAM, ROM, I/O ports and a timer embedded all on a
single chip. The fixed amount of on-chip ROM, RAM and number of I/O ports in
microcontrollers makes them ideal for many applications in which cost and space are
critical.
The Intel 8052 is Harvard architecture, single chip microcontroller (µC) which was
developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s
and early 1990s, but today it has largely been superseded by a vast range of enhanced
devices with 8052-compatible processor cores that are manufactured by more than 20
independent manufacturers including Atmel, Infineon Technologies and Maxim
Integrated Products.
Fig 3.1: AT89S52 Microcontroller
8052 is an 8-bit processor, meaning that the CPU can work on only 8 bits of
data at a time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed
by the CPU. 8052 is available in different memory types such as UV-EPROM, Flash
and NV-RAM. The present project is implemented on Keil uVision. In order to
program the device, preload tool has been used to burn the program onto the
microcontroller. The features, pin description of the microcontroller and the software
tools used are given in the following sections.
Dept. of ECE, B.Tech, SITAMS Page 14
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
FEATURES
The features of 8052 micro controller are given as follows.
• Compatible with MCS-51® Products
• 8K Bytes of In-System Programmable (ISP) Flash Memory
– Endurance: 1000 Write/Erase Cycles
• 4.0V to 5.5V Operating Range
• Fully Static Operation: 0 Hz to 33 MHz
• Three-level Program Memory Lock
• 256 x 8-bit Internal RAM
• 32 Programmable I/O Lines
• Three 16-bit Timer/Counters
• Eight Interrupt Sources
• Full Duplex UART Serial Channel
• Low-power Idle and Power-down Modes
• Interrupt Recovery from Power-down Mode
• Watchdog Timer
• Dual Data Pointer
• Power-off Flag
3.2 DESCRIPTION OF FEATURES:
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with
8K bytes of in-system programmable Flash memory. The device is manufactured using
Atmel’s high-density nonvolatile memory technology and is compatible with the
industry- standard 80C51 instruction set and pin out. The on-chip Flash allows the
program memory to be reprogrammed in system or by a conventional nonvolatile
Dept. of ECE, B.Tech, SITAMS Page 15
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
memory programmer. By combining a versatile 8-bit CPU with in-system
programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful
microcontroller which provides a highly-flexible and cost-effective solution to many
embedded control applications.
The AT89S52 provides the standard features such as 8K bytes of Flash, 256 bytes
of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a
six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator,
and clock circuitry. In addition, the AT89S52 is designed with static logic for operation
down to zero frequency and supports two software selectable power saving modes.
The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port,
and interrupt system to continue functioning. The Power-down mode saves the RAM
contents but freezes the oscillator, disabling all other chip functions until the next
interrupt or hardware reset.
Dept. of ECE, B.Tech, SITAMS Page 16
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
CHAPTER 4
PIN CONFIGURATION OF 8052
Dept. of ECE, B.Tech, SITAMS Page 17
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
4.1 Pin Configuration:
Fig 4.1: Pin configuration of 8052
The 40 pin configuration corresponding to the micro controller 8052 is given above.
Dept. of ECE, B.Tech, SITAMS Page 18
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
4.2 Block Diagram of 8052:
Fig 4.2: Block diagram of 8052
4.3 PIN DESCRIPTION
VCC: Supply voltage.
GND: Ground.
Port 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin
can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as
high impedance inputs. Port 0 can also be configured to be the multiplexed low order
address/data bus during accesses to external program and data memory. In this mode,
P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming
Dept. of ECE, B.Tech, SITAMS Page 19
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
and outputs the code bytes during program verification. External pull-ups are required
during program verification.
Port 1
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output
buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins
that are externally being pulled low will source current (IIL) because of the internal
pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external
count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively,
as shown in the following table. Port 1 also receives the low-order address bytes during
Flash programming and verification.
Table 4.1: Functionality of port 1 pins
Port 2
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output
buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins
that are externally being pulled low will source current (IIL) because of the internal
pull-ups.
Port 2 emits the high-order address byte during fetches from external program
memory and during accesses to external data memory that uses 16-bit addresses
(MOVX @ DPTR). In this application, Port 2 uses strong internal pull-ups when
Dept. of ECE, B.Tech, SITAMS Page 20
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
emitting 1s. During accesses to external data memory that uses 8-bit addresses (MOVX
@ RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also
receives the high-order address bits and some control signals during Flash
programming and verification.
Port 3
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output
buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are
pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins
that are externally being pulled low with source current because of the pull-ups. Port 3
also serves the functions of various special features of the AT89S52, as shown in the
following table. Port 3 also receives some control signals for Flash programming and
verification.
Table 4.2: Functionality of port 3 pins
RST:
It indicates reset input. A high on this pin for two machine cycles while the
oscillator is running resets the device. This pin drives High for 96 oscillator periods
after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be
used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out
feature is enabled.
ALE/PROG:
Dept. of ECE, B.Tech, SITAMS Page 21
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Address Latch Enable (ALE) is an output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the program pulse input
(PROG) during Flash programming. In normal operation, ALE is emitted at a constant
rate of 1/6 the oscillator frequency and may be used for external timing or clocking
purposes. However, one ALE pulse is skipped during each access to external data
memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location
8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction.
Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if
the microcontroller is in external execution mode.
PSEN:
Program Store Enable (PSEN) is the read strobe to external program memory.
When the AT89S52 is executing code from external program memory, PSEN is
activated twice each machine cycle, except that two PSEN activations are skipped
during each access to external data memory.
EA/VPP:
It is 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. However, if bit 1 is programmed, EA will be internally latched on reset.
EA should be strapped to VCC for internal program executions. This pin also
receives the 12-volt programming enable voltage (VPP) during Flash programming.
XTAL1
It is input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2
It is output from the inverting oscillator amplifier.XTAL1 and XTAL2 are the
input and output, respectively, of an inverting amplifier that can be configured for use
as an on-chip oscillator, as shown in Figure.
Dept. of ECE, B.Tech, SITAMS Page 22
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 4.3: Oscillator Connections
C1, C2 = 30 pF ± 10 pF for Crystals
= 40 pF ± 10 pF for Ceramic Resonators
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
Fig 4.4: External Clock Drive Configuration
XTAL1 is driven, as shown in the figure above.
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.
Dept. of ECE, B.Tech, SITAMS Page 23
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
CHAPTER 5
MICRO CONTROLLER MEMORY ORGANIZATION
Dept. of ECE, B.Tech, SITAMS Page 24
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
5.1 8052 MICROCONTROLLER MEMORY ORGANIZATION
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, at most a few Kb of
ROM and 128 or 256 bytes of RAM can be used. However, all 8052 microcontrollers
have 16-bit addressing bus and can address 64 kb memory
Program Memory
The oldest models of the 8052 microcontroller family did not have any 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).
Fig 5.1: Memory interfacing of micro controller
Dept. of ECE, B.Tech, SITAMS Page 25
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
The microcontroller can handle external memory depending on the pin EA logic
state as follows.
Fig 5.2: Additional memory interfacing
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 and
address transmission. Besides, the pins ALE and PSEN are used too.
Data Memory
Dept. of ECE, B.Tech, SITAMS Page 26
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
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. It is common to all types of the 8052
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 the 2Fh byte has the bit address 7Fh). The third
groups 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
As need for Data Memory has gradually increased, producers have embedded
an additional memory block of 128 locations into the latest versions of the 8052
microcontrollers. 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,
additional memory block shares the same addresses with existing locations intended for
the SFRs (80h- FFh).
Dept. of ECE, B.Tech, SITAMS Page 27
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 5.3: Microcontroller internal structure
In order to differentiate between these two physically separated memory spaces,
different ways of addressing are used. A direct addressing is used for all locations in
the SFRs, while the locations from additional RAM are accessible using indirect
addressing.
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.
Dept. of ECE, B.Tech, SITAMS Page 28
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 5.4: Register banks of 8052
Fig 5.5: Memory Organization in microcontroller
The 8052 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 Harvard architecture.
The changes that occur when additional memory is used is given as follows.
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.
Dept. of ECE, B.Tech, SITAMS Page 29
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
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
microcontroller reads content from memory chip. The same connections are used
both for data and lower address byte.
Similar occurs when it is a need 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.
5.2 Addressing modes of micro controller
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 8052 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
Dept. of ECE, B.Tech, SITAMS Page 30
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
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.
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.
5.3 SFRs (Special Function Registers):
SFRs are a kind of control table used for running and monitoring
microcontroller’s operation. 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 8052
controllers, has only 21 such registers. Rest of locations is intentionally 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.
Dept. of ECE, B.Tech, SITAMS Page 31
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 5.6: Special function registers
A Register (Accumulator)
Fig 5.7: 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 performed 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.
B Register
Dept. of ECE, B.Tech, SITAMS Page 32
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 5.8: Base 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):
This is a common name for the total 8 general purpose registers (R0, R1,
R2 ...R7). The bank is active when the R registers it includes are in use. They are
represented as follows.
Fig 5.9: General purpose registers
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.
Description:
Dept. of ECE, B.Tech, SITAMS Page 33
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
The AT89S52 is a low-voltage, high-performance CMOS 8-bit microcontroller
with 4K bytes of Flash programmable memory. The device is manufactured using
Atmel’s high-density nonvolatile memory technology and is compatible with the
industry-standard MCS-51 instruction set. By combining a versatile 8-bit CPU with
Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer, which
provides a highly flexible and cost-effective solution to many embedded control
applications.
In addition, the AT89S52 is designed with static logic for operation down to
zero frequency and supports two software selectable power saving modes. The Idle
Mode stops the CPU while allowing the RAM, timer/counters, serial port and interrupt
system to continue functioning. The power-down mode saves the RAM contents but
freezes the oscillator disabling all other chip functions until the next hardware reset.
5.4 Machine cycle for the 8052
The CPU takes a certain number of clock cycles to execute an instruction. In the
8052 family, these clock cycles are referred to as machine cycles. The length of the
machine cycle depends on the frequency of the crystal oscillator. The crystal oscillator,
along with on-chip circuitry, provides the clock source for the 8052 CPU.
The frequency can vary from 4 MHz to 30 MHz, depending upon the chip
rating and manufacturer. But the exact frequency of 11.0592 MHz crystal oscillator is
used to make the 8052 based system compatible with the serial port of the IBM PC.
Dept. of ECE, B.Tech, SITAMS Page 34
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
CHAPTER 6
INTERFACING OF COMPONENTS
Dept. of ECE, B.Tech, SITAMS Page 35
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
6.1 BLOCK DIAGRAM :
The block diagram corresponding to the project is given as follows.
Dept. of ECE, B.Tech, SITAMS Page 36
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 6.1: Block diagram
Power supply:
The power supply blocks are given as follows:
Dept. of ECE, B.Tech, SITAMS Page 37
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 6.2: Power supply blocks
6.2 Interfacing components
6.2.1 LIQUID CRYSTAL DISPLAY:
LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing
LEDs (seven segment LEDs or other multi segment LEDs) because of the following
reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters and graphics. This is in contrast to
LEDs, which are limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of
the task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU
to keep displaying the data.
4. Ease of programming for characters and graphics.
These components are “specialized” for being used with the microcontrollers,
which means that they cannot be activated by standard IC circuits. They are used for
writing different messages.
Interfacing LCD to project:
Fig 6.3: Liquid Crystal Display
Pins Functionality
There are pins along one side of the small printed board used for connection to
the microcontroller. There are total of 14 pins marked with numbers.
Dept. of ECE, B.Tech, SITAMS Page 38
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Function Pin Number Name Logic
State Description
Ground 1 Vss - 0V
Power supply 2 Vdd - +5V
Contrast 3 Vee - 0 – Vdd
Control of operating
4 RS 01
D0 – D7 are interpreted as commands
D0 – D7 are interpreted as data
5 R/W 01
Write data (from controller to LCD)
Read data (from LCD to controller)
6` E
01From 1 to 0
Access to LCD disabledNormal operating
Data/commands are transferred to LCD
Data / commands
7 D0 0/1 Bit 0 LSB
8 D1 0/1 Bit 1
9 D2 0/1 Bit 2
10 D3 0/1 Bit 3
11 D4 0/1 Bit 4
12 D5 0/1 Bit 5
13 D6 0/1 Bit 6
14 D7 0/1 Bit 7 MSB
They are given as follows.
Table 6.1: Functionality of pins in micro controller
Dept. of ECE, B.Tech, SITAMS Page 39
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
A model described here is of low price and most frequently used in practice. It
is based on the HD44780 microcontroller (Hitachi) and can display messages in two
lines with 16 characters each. It displays all the alphabets, Greek letters, punctuation
marks, mathematical symbols etc. In addition, it is possible to display symbols that user
makes up on its own. Automatic shifting message on display (shift left and right),
appearance of the pointer, backlight etc. are considered as useful characteristics.
Fig 6.4: Miniature LCD
LCD screen:
LCD screen consists of two lines with 16 characters each. Each character
consists of 5x7 dot matrix. Contrast on display depends on the power supply voltage
and whether messages are displayed in one or two lines. For this reason, variable
voltage 0-Vdd is applied on pin marked as Vee. Trimmer potentiometer is usually used
for that purpose. Some versions of displays have built in backlight (blue or green
diodes). When used during operating, a resistor for current limitation should be used
(like with any LE diode).
Fig 6.5: LCD Screen
Dept. of ECE, B.Tech, SITAMS Page 40
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
LCD Basic Commands
Command RS RW D7 D6 D5 D4 D3 D2 D1 D0 Execution Time
Clear display 0 0 0 0 0 0 0 0 0 1 1.64mS
Cursor home 0 0 0 0 0 0 0 0 1 x 1.64mS
Entry mode set 0 0 0 0 0 0 0 1 I/D S 40uS
Display ON/OFF control
0 0 0 0 0 0 1 D U B 40uS
Cursor/Display
Shift0 0 0 0 0 1 D/C R/L x x 40uS
Function set 0 0 0 0 1 DL N F x x 40uS
Set CGRAM address
0 0 0 1 CGRAM address 40uS
Set DDRAM address
0 0 1 DDRAM address 40uS
Read “BUSY” flag (BF)
0 1 BF DDRAM address -
Write to CGRAM
or DDRAM
1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS
Read from
CGRAM1 1 D7 D6 D5 D4 D3 D2 D1 D0 40uS
Table 6.2: Basic commands of LCD
All data transferred to LCD through outputs D0-D7 will be interpreted as
commands or as data, which depends on logic state on pin RS. RS = 0 - Bits D0 - D7
Dept. of ECE, B.Tech, SITAMS Page 41
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
are commands which determine display mode. List of commands which LCD
recognizes are given in the table above:
RS = 1 - Bits D0 - D7 are addresses of characters that should be displayed. Built
in processor addresses built in “map of characters” and displays corresponding
symbols. Displaying position is determined by DDRAM address. This address is either
previously defined or the address of previously transferred character is automatically
incremented.
I/D 1 = Increment (by 1) R/L 1 = Shift right
0 = Decrement (by 1) 0 = Shift left
S 1 = Display shift on DL 1 = 8-bit interface
0 = Display shift off 0 = 4-bit interface
D 1 = Display on N 1 = Display in two lines
0 = Display off 0 = Display in one line
U 1 = Cursor on F 1 = Character format 5x10 dots
0 = Cursor off 0 = Character format 5x7dots
B 1 = Cursor blink on D/C 1 = Display shift
0 = Cursor blink off 0 = Cursor shift
LCD Connection:
Depending on how many lines are used for connection to the microcontroller,
there are 8-bit and 4-bit LCD modes. The appropriate mode is determined at the
beginning of the process in a phase called “initialization”. In the first case, the data are
transferred through outputs D0-D7 as it has been already explained. In case of 4-bit
LED mode, for the sake of saving valuable I/O pins of the microcontroller, there are
only 4 higher bits (D4-D7) used for communication, while other may be left
unconnected.
Consequently, each data is sent to LCD in two steps: four higher bits are sent
first (that normally would be sent through lines D4-D7), four lower bits are sent
Dept. of ECE, B.Tech, SITAMS Page 42
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
afterwards. With the help of initialization, LCD will correctly connect and interpret
each data received.
Besides, with regards to the fact that data are rarely read from LCD (data
mainly are transferred from microcontroller to LCD) one more I/O pin may be saved by
simple connecting R/W pin to the Ground. Even though message displaying will be
normally performed, it will not be possible to read from busy flag since it is not
possible to read from display.
LCD Initialization
Once the power supply is turned on, LCD is automatically cleared. This process
lasts for approximately 15mS. After that, display is ready to operate. The mode of
operating is set by default. This means that:
1. Display is cleared
2. Mode
DL = 1 Communication through 8-bit interface
N = 0 Messages are displayed in one line
F = 0 Character font 5 x 8 dots
3. Display/Cursor on/off
D = 0 Display off
U = 0 Cursor off
B = 0 Cursor blink off
4. Character entry
ID = 1 Addresses on display are automatically incremented by 1
S = 0 Display shift off
Automatic reset is mainly performed without any problems. If for any reason
power supply voltage does not reach full value in the course of 10mS, display will start
perform completely unpredictably. If voltage supply unit cannot meet this condition or
if it is needed to provide completely safe operating, the process of initialization by
which a new reset enabling display to operate normally must be applied.
Algorithm according to the initialization is being performed depends on
whether connection to the microcontroller is through 4- or 8-bit interface. All left over
to be done after that is to give basic commands and of course- to display messages.
Dept. of ECE, B.Tech, SITAMS Page 43
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 6.6: Procedure on 8-bit initialization
CONTRAST CONTROL:
To have a clear view of the characters on the LCD, contrast should be adjusted.
To adjust the contrast, the voltage should be varied. For this, a preset is used which can
behave like a variable voltage device. As the voltage of this preset is varied, the
contrast of the LCD can be adjusted.
Fig 6.7: Variable resistor
Potentiometer
Dept. of ECE, B.Tech, SITAMS Page 44
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Variable resistors used as potentiometers have all three terminals connected.
This arrangement is normally used to vary voltage, for example to set the switching
point of a circuit with a sensor, or control the volume (loudness) in an amplifier circuit.
If the terminals at the ends of the track are connected across the power supply, then the
wiper terminal will provide a voltage which can be varied from zero up to the
maximum of the supply.
Fig 6.8: Symbol of Potentiometer
Presets
These are miniature versions of the standard variable resistor. They are
designed to be mounted directly onto the circuit board and adjusted only when the
circuit is built. For example, to set the frequency of an alarm tone or the sensitivity of a
light-sensitive circuit. A small screwdriver or similar tool is required to adjust presets.
Presets are much cheaper than standard variable resistors so they are sometimes
used in projects where a standard variable resistor would normally be used.
Multi turn presets are used where very precise adjustments must be made. The
screw must be turned many times (10+) to move the slider from one end of the track to
the other, giving very fine control.
Fig 6.9: Preset Symbol
6.2.2 MAX232AS
Dept. of ECE, B.Tech, SITAMS Page 45
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
It runs on a single chip supply (+5 volts), and requires a few external capacitors.
There diagram below represents the modified version, the MAX233 which requires no
external parts. It is, however, a little larger physically, and also costs about 75% more
than the MAX232A.
Fig 6.10: Internal structure of MAX233AS
This is a diagram of the internals of the MAX232A. It shows a double charge
pump voltage doubler and a +10v to -10v voltage inverter. The voltages output are used
to generate the RS-232 compliant signals.
Fig 6.11: MAX 232 AS
Dept. of ECE, B.Tech, SITAMS Page 46
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
The MAX232A has provisions for two serial ports on the same physical
package. Most people only connect one of them.
6.2.3 GSM:
GSM (Global System for Mobile communications) is the technology that
underpins most of the world's mobile phone networks. The GSM platform is a hugely
successful wireless technology and an unprecedented story of global achievement and
cooperation. GSM has become the world's fastest growing communications technology
of all time and the leading global mobile standard, spanning 218 countries. GSM is an
open, digital cellular technology used for transmitting mobile voice and data services.
GSM operates in the 900MHz and 1.8GHz bands GSM supports data transfer speeds of
up to 9.6 kbps, allowing the transmission of basic data services such as SMS.
Fig 6.12: GSM block
Description
The low cost TMAS GSM Modem is ideal for a wide range of applications. The
modem can be used to make circuit switched data calls, making the unit suitable for
remote dial-up systems where a fixed phone line is not available. The SMS
functionality enables the sending and receipt of text messages. A common use for this
functionality is an SMS server for the automated sending and receipt of bulk text
messages. The modem implements the highly reliable Siemens TC35i GSM Engine.
This ensures high quality and reliable operation along with compatibility with all
standard GSM networks. The modem provides support for the Siemens TC35i AT
command list, also available for download from the RF Solutions website.
Dept. of ECE, B.Tech, SITAMS Page 47
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
The TMAS modem is supplied in a rugged extruded aluminum enclosure
making it suitable for use in a wide range of industrial and demanding environments.
The unit connects directly to a PC or terminal device via the DB-9 RS232 Cable
interface. The integral SIM card holder accepts standard SIM cards of all network
operators. The only other connections required are to 6-40Vdc power supply and
antenna (supplied separately).
Part Numbering:
Table 6.3: GSM Classification
Operating Modes:
The table below briefly summarizes the various operating modes of the TMAS
GSM terminal.
Table 6.4: Operating modes of GSM
Dept. of ECE, B.Tech, SITAMS Page 48
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
AT commands are also known as Hayes AT commands. There are different
views to understand the meanings of "AT". Some call it "Attention Telephone",
whereas others interpret it as "Attention Terminal" commands.
AT commands allow giving instructions to both mobile devices and ordinary
landline telephones. The commands are sent to the phone's modem, which can be a
GSM modem or PC modem. This article focuses on AT commands on Nokia's GSM
and WCDMA products only. Different manufacturers may have different sets of AT
commands. Many AT commands are almost same. Mobile device manufacturers may
also give attention to operators to allow or not to allow some commands on phones.
AT commands can be used for operations that are usually done from the
keypad, for instance calling a number, sending, reading, or deleting an SMS, setting the
SMSC number, looking for a GPRS access point, reading and deleting phonebook data,
reading the battery status, reading the signal strength, and so on. When you want to
make a PC-based application to interface a mobile phone using USB, IR, or Bluetooth,
these commands are needed to communicate with mobile phones. Basically such
commands are the application layer of MBUS or FBUS commands. Nokia provides an
AT command set guide, where the basic command syntax and the response of the
command in various situations can be seen.
SMS text mode
The commands that are used for communication through a GSM is given as
follows
Command Description
Dept. of ECE, B.Tech, SITAMS Page 49
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
AT+CSMS Select message serviceAT+CPMS Preferred message storageAT+CMGF Message formatAT+CSCA Service centre addressAT+CSMP Set text mode parametersAT+CSDH Show text mode parametersAT+CSCB Select cell broadcast message typesAT+CSAS Save settings
AT+CRES Restore settings
AT+CNMI New message indications to TEAT+CMGL List messagesAT+CMGR Read messageAT+CMGS Send messageAT+CMSS Send message from storage
AT+CMGW Write message to memoryAT+CMGD Delete message
Table 6.5: SMS text mode commands
SMS PDU mode
Command DescriptionAT+CMGL List MessagesAT+CMGR Read messageAT+CMGS Send messageAT+CMGW Write message to memory
Table 6.6: Commands and their description
6.2.4 LIGHT DEPENDENT RESISTOR
Dept. of ECE, B.Tech, SITAMS Page 50
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 6.13: Photo resistor
The internal components of a photoelectric control for a typical American
streetlight is given above. The photo resistor is facing rightwards, and controls whether
current flows through the heater which opens the main power contacts. At night, the
heater cools, closing the power contacts, energizing the street light. The heater/bimetal
mechanism provides a built-in light level transient filter.
A photoresistor or light dependent resistor (LDR) is a resistor whose
resistance decreases with increasing incident light intensity; in other words, it exhibits
photoconductivity. It can also be referred to as a photoconductor or CdS device, from
"cadmium sulfide," which is the material from which the device is made and that
actually exhibits the variation in resistance with light level.
A photoresistor is made of a high resistance semiconductor. If light falling on
the device is of high enough frequency, photons absorbed by the semiconductor give
bound electrons enough energy to jump into the conduction band. The resulting free
electron conducts electricity, thereby lowering resistance.
Dept. of ECE, B.Tech, SITAMS Page 51
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 6.14: The symbol for a photo resistor
`Fig 6.15: Photo Resistor
A photoelectric device can be either intrinsic or extrinsic. An intrinsic
semiconductor has its own charge carriers and is not an efficient semiconductor, e.g.
silicon. In intrinsic devices the only available electrons are in the valence band, and
hence the photon must have enough energy to excite the electron across the entire band
gap. Extrinsic devices have impurities, also called dopants, and added whose ground
state energy is closer to the conduction band; since the electrons do not have as far to
jump, lower energy photons (i.e., longer wavelengths and lower frequencies) are
sufficient to trigger the device. If a sample of silicon has some of its atoms replaced by
phosphorus atoms (impurities), there will be extra electrons available for conduction.
This is an example of an extrinsic semiconductor. Photo resistors are basically
photocells.
Applications
Photoresistors come in many different types. Inexpensive cadmium sulphide
cells can be found in many consumer items such as camera light meters, street lights,
clock radios, alarm devices, and outdoor clocks.
Dept. of ECE, B.Tech, SITAMS Page 52
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
They are also used in some dynamic compressors together with a small
incandescent lamp or light emitting diode to control gain reduction.
Lead sulphide (PbS) and indium antimonide (InSb) LDRs (light dependent
resistor) are used for the mid infrared spectral region. Ge:Cu photoconductors are
among the best far-infrared detectors available, and are used for infrared astronomy and
infrared spectroscopy.
6.2.5 TEMPERATURE SENSOR
Fig 6.16: LM35 Sensor
General Description:
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, while the LM35C is rated
for a −40° to +110°C range (−10° with improved accuracy). The LM35 series is
available packaged in hermetic TO-46 transistor packages, while the LM35C,
Dept. of ECE, B.Tech, SITAMS Page 53
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
LM35CA, and LM35D are also available in the plastic TO-92 transistor package. The
LM35D is also available in an 8-lead surface mount small outline package and a plastic
TO-220 package.
Features
Calibrated directly in ° Celsius (Centigrade)
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 for 1 mA load
6.2.6 IR SENSOR
What is an IR detection sensor?
IR detectors are little microchips with a photocell that are tuned to listen to
infrared light. They are almost always used for remote control detection - every TV and
DVD player has one of these in the front to listen for the IR signal from the clicker.
Inside the remote control is a matching IR LED, which emits IR pulses to tell the TV to
turn on, off or change channels. IR light is not visible to the human eye, which means it
takes a little more work to test a setup.
There are a few difference between these and say a CdS Photocells :
IR detectors are specially filtered for Infrared light; they are not good at
detecting visible light. On the other hand, photocells are good at detecting
yellow/green visible light, not good at IR light
Dept. of ECE, B.Tech, SITAMS Page 54
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
IR detectors have a demodulator inside that looks for modulated IR at 38 KHz.
Just shining an IR LED won’t be detected, it has to be PWM blinking at 38KHz.
Photocells do not have any sort of demodulator and can detect any frequency
(including DC) within the response speed of the photocell (which is about
1KHz)
IR detectors are digital out - either they detect 38KHz IR signal and output low
(0V) or they do not detect any and output high (5V). Photocells act like
resistors, the resistance changes depending on how much light they are exposed
to
The features relating to IR detector in the Adafruit shop also known as
PNA4602 is as follows.
Size: square, 7mm by 8mm detector area
Price: $2.00 at the Adafruit shop
Output: 0V (low) on detection of 38KHz carrier, 5V (high) otherwise
Sensitivity range: 800nm to 1100nm with peak response at 940nm. Frequency
range is 35KHz to 41KHz with peak detection at 38KHZ
Power supply: 5V DC 3mA
What can be measured?
Fig 6.17: Graphs of IR sensor
Dept. of ECE, B.Tech, SITAMS Page 55
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
From these datasheet graphs, we can observe that the peak frequency detection
is at 38 KHz and the peak LED color is 940 nm. We can use from about 35 KHz to 41
KHz but the sensitivity will drop off so that it won’t detect as well from afar. Likewise,
we can use 850 to 1100 nm LEDs but, they won’t work as well as 900 to 1000nm.
Testing IR detector
Fig 6.18: IR detector
Because there is a semiconductor/chip inside the sensor, it must be powered
with 5V to function.
Here we can connect the detector as such:
Pin 1 is the output so we wire this to a visible LED and resistor
Pin 2 is ground
Pin 3 is VCC, connect to 5V
Dept. of ECE, B.Tech, SITAMS Page 56
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
When the detector sees IR signal, it will pull the output low, turning on the
LED.
Fig 6.19: Battery
We use 4xAA 1.5V batteries so that the voltage powering the sensor is about
6V. 2 batteries (3V) are too little. Ground goes to the middle pin.
The positive (longer) head of the Red LED connects to the +6V pin and the
negative (shorter lead) connects through a 200 to 1000 ohm resistor to the first pin on
the IR sensor. Now grab any remote control like for a TV, DVD, computer, etc. and
point it at the detector while pressing some buttons, you should see the LED blink a
couple times whenever the remote is pressed.
IR remote signals
The data is sent from the IR remote to the IR receiving sensor as follows.
In this example, Sony power on/off IR code from a Sony TV remote is used.
We can look at exactly what light is being blasted out of the IR LED. We can hookup a
basic light sensor and listen in. We won't use a decoder like a PNA4602 because we
want to see the un decoded signal. The following pulses are seen:
Dept. of ECE, B.Tech, SITAMS Page 57
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Fig 6.20: Blocks of IR signal
We see pulses or IR signal. The yellow 'blocks' are when the IR LED is
transmitting and when there is only a line, the IR LED is off. The first 'block' is about
2.5ms. If we zoom into one of those blocks, we get the following.
Fig 6.21: Pulses of IR signal
We see that they're not really 'blocks' but actually very fast pulses transmitting.
Dept. of ECE, B.Tech, SITAMS Page 58
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
If we zoom still,
Fig 6.22: Zoomed Pulses of IR signal
Frequency of the IR pulses can be measured. As we can say by the cursors and
the measurements on the side, the frequency is about 37.04 KHz
The IR transmitter LED is quickly pulsed (PWM - pulse width modulated) at a
high frequency of 38 KHz and then that PWM is likewise pulsed on and off much
slower, at times that are about 1-3 ms long.
There are many reasons for why the PWM carrier is pulsing. One reason is that
this lets the LED cool off. IR LEDs can take up to 1 Amp of current. Most LEDs only
take 20mA or so. This means, IR LEDs are designed for high-power blasting but, they
can only take it for a few microseconds. By Pulse Width Modulating it, we can let the
LED cool off half the time.
Another reason is that the TV will only listen to certain frequencies of PWM.
So a Sony remote at 37 KHz won’t be able to work with a JVC DVD player that only
wants say 50 KHz. Finally, the most important reason is that by pulsing a carrier wave,
affects of ambient lighting is reduced. The TV only looks for changes in light levels
that clock in around 37 KHz.
Dept. of ECE, B.Tech, SITAMS Page 59
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
The carrier frequency is 37 KHz, looking back at the first scope picture, the first
pulse is 2.5ms. We can use the cursors to measure the remaining pulses. If we consider
12 images, the pulses are:
PWM ON OFF2.4 ms 0.6 ms1.2 ms 0.6 ms0.6 ms 0.6 ms1.2 ms 0.6 ms0.6 ms 0.6 ms1.2 ms 0.6 ms0.6 ms 0.6 ms0.6 ms 0.6 ms1.2 ms 0.6 ms0.6 ms 0.6 ms0.6 ms 0.6 ms0.6 ms 0.6 ms0.6 ms 270 ms
Fig 6.7: PWM ON and OFF modes
The IR decoder such as the PNA4602 does us one favor, it 'filters out' the 38
KHz signal so that we only get the big chunks of signal in the millisecond range. This
is much easier for a microcontroller to handle.
6.3 Applications:
Home applications
Industry applications
Office applications
Dept. of ECE, B.Tech, SITAMS Page 60
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
Dept. of ECE, B.Tech, SITAMS Page 61
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
CHAPTER 7
FUTURE DEVELOPMENTS AND CONCLUSION
7.1 Future developments
The specified home monitoring system is based on different sensors, collection
of sensors data by a central processor, comparison of activities with a standard pattern
and detection of unusual or abnormal event. In many situations, the cameras are used
for security surveillance which may be appropriate but in home monitoring applications
the privacy is not protected. The cost of the complete system may be a critical factor for
its universal use. In future, the research should be targeted to develop a low-cost system
with the sensors essential to monitor the elder people at home. The time to detect any
abnormal or unusual incident should be detected as fast as possible and the message to
the caregiver should reach as quickly as practicable.
Dept. of ECE, B.Tech, SITAMS Page 62
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
7.2 Conclusion
The security system is very helpful in day-to-day life to ensure that all situations
are under control. This plays an important role in surveillance of home. The designed
system is used to automate the security systems to ensure the security of the home at
low cost and the authorized person can also be alerted with a message. If anybody
crossed the signal established between the transmitter and receiver of IR, the GSM
which is connected to the board will automatically send a data to the authorized person
to that particular home. Therefore, it plays a crucial role in home surveillance.
Dept. of ECE, B.Tech, SITAMS Page 63
Micro controller based intelligent security system using Wireless Sensor Networks and Global System for Mobile communications
REFERENCES:
[1] Jun Zhang, Hui Wang, TianhuaMeng and Guangming Song, 2011,“Design of a
Wireless Sensor Network Based Monitoring System for Home Automation”,
International Conference on Future Computer Sciences and Application (ICFCSA), pp.
57-60, Nanjing, June 2011.
[2] K.K. Griffiths and R. Melanie,2012, "Smart Home Security" , Homebuilding &
Renovating. Retrieved University of Leeds
[3] I.K. Hwang and J.W. Baek, 2007,“Wireless Access Monitoring and Control System
based on Digital Door Lock,” IEEE Transactions on Consumer Electronics, 53(4), pp.
1724-1730, Taipei.
[4] Huiping Haung, 2010,“ A Remote Home Security System Based on Wireless
Sensor Network and GSM Technology” , Second International Conference on Network
Security Wireless Communication and Trusted Computing (NSWCTC)
Proceedings,Volume 1, Page 535-538
[5] David Crouse et al,2004 “ Wireless Home Security System” ,University of
Connecticut, ECE 209, Spring.
[6] MegalingamR.K, Nair R.N.,Prakhya S.M,Mohan M,2011 “ Low Power,
intelligent,wireless,home security sytem for elderly people”, Third International
Conference on Electronics Computer Technolohy( ICECT) Proceedings , Volume 4,
Page 320 -324.
[7] Chun-Liang HSU, Sheng-Yuan Yang and Wei-Bin Wu, 2009,“Constructing
Intelligent Home- Security System Design With Combining Phone-Net And Bluetooth
Mechanism”, Proceedings of the Eighth International Conference on Machine Learning
and Cybernetics, St. John’s University, Taiwan.
[8] Ayush Agarwal, R.C.Joshi, “ WSN and GSM based Home Security Sytems”, IJCA
Proceedings on International Conference on Recent Advances and Future Trends in
Information Technolgy ( iRAFIT 2012), Number 2.
Dept. of ECE, B.Tech, SITAMS Page 64