Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Technical Specifications
Technical Specifications:
Crystal : 11.0592MHz
Security Channels : 5
Phone : 040-64646363,
www.WineYardTechnologies.com
ABSTRACT
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. The alarm is also fitted
with a so-called 'panic button'.
The project is built around the AT89S52 micro controller from Atmel. This micro
controller provides all the functionality . 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 5 sensors can be connected to the buzzer. 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.
When the buzzer is armed, the LED 'alarm armed' will flash during the exit-delay. After
the exit-delay, the LED will light continuously. The LED 'alarm triggered LED' flashes during
the entry-delay and will turn on continuously once an actual alarm has been generated. 'Alarm
triggered LED’ turns off only when the alarm is switched off with key switch Sw1. When an
alarm has taken place, it can be determined afterwards which sensor (or tamper input) caused the
alarm to trigger. The LED 'tamper' lights up when the tamper input is opened. This LED will also
continue to be on until the alarm is switched off.
The uniqueness of this project is, it sends an caution SMS to four mobile numbers. This
numbers can be changed at any time by the user using a 4X4 key pad. These numbers are stored
in EEPROM.
This project uses regulated 5V, 750mA 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.
BLOCK DIAGRAM
Block Diagram:
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.
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.
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.
(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.
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!
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
· Communication interfaces
· Application-specific circuitry
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 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 design in such a way that the power
consumption is minimized.
BLOCK DESCRIPTION
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.
230V AC
50Hz D.C
Output
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.
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.
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.
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
AT89S52 Microcontroller
MICROCONTROLLERS:
The Intel 8051 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 8051-
compatible processor cores that are manufactured by more than 20 independent manufacturers
including Atmel, Infineon Technologies and Maxim Integrated Products.
8051 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. 8051
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,
proload tool has been used to burn the program onto the microcontroller.
The features, pin description of the microcontroller and the software tools used are
discussed in the following sections.
FEATURES OF AT89S52:
Description:
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.
PIN DIAGRAM:
AT89SS52
PIN DESCRIPTION:
Vcc
Pin 40 provides supply voltage to the chip. The voltage source is +5V.
GND
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be
configured for use as an on-chip oscillator, as shown in Figure 11. Either a quartz crystal or
ceramic resonator may be used. To drive the device from an external clock source, XTAL2
should be left unconnected while XTAL1 is driven, as shown in the below figure. 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
RESET
Pin9 is the reset pin. It is an input and is active high. Upon applying a high pulse to this pin, the
microcontroller will reset and terminate all the activities. This is often referred to as a power-on
reset.
EA (External access)
Pin 31 is EA. It is an active low signal. It is an input pin and must be connected to either Vcc or
GND but it cannot be left unconnected.
The 8051 family members all come with on-chip ROM to store programs. In such cases,
the EA pin is connected to Vcc. If the code is stored on an external ROM, the EA pin must be
connected to GND to indicate that the code is stored externally.
Ports 0, 1, 2 and 3
The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports upon
RESET are configured as input, since P0-P3 have value FFH on them.
Port 0(P0)
Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. ALE
indicates if P0 has address or data. When ALE=0, it provides data D0-D7, but when ALE=1, it
has address A0-A7. Therefore, ALE is used for demultiplexing address and data with the help of
an internal latch.
With no external memory connection, both P1 and P2 are used as simple I/O. With external
memory connections, port 2 must be used along with P0 to provide the 16-bit address for the
external memory. Port 2 is designated as A8-A15 indicating its dual function. While P0 provides
the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the address.
Port 3
Port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or output. P3 does
not need any pull-up resistors, the same as port 1 and port 2. Port 3 has an additional function of
providing some extremely important signals such as interrupts.
The CPU takes a certain number of clock cycles to execute an instruction. In the 8051 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 8051 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
8051 based system compatible with the serial port of the IBM PC.
In the original version of 8051, one machine cycle lasts 12 oscillator periods. Therefore, to
calculate the machine cycle for the 8051, the calculation is made as 1/12 of the crystal frequency
and its inverse is taken.
The assembly language program is written and this program has to be dumped into the
microcontroller for the hardware kit to function according to the software. The program dumped
in the microcontroller is stored in the Flash memory in the microcontroller. Before that, this
ALE/PROG
Address Latch Enable 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. 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
It is the read strobe to external program memory. When the AT89S8252 is executing code from
external program memory, PSEN is activated twice each machine cycle, except that two PSEN
EA must be strapped to GND in order to enable the device to fetch code from external program
memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is
programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal
program executions. This pin also receives the 12-volt programming enable voltage (VPP)
Ports 0, 1, 2 and 3
The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports upon
RESET are configured as input, since P0-P3 have value FFH on them.
Port 0(P0)
Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. ALE
indicates if P0 has address or data. When ALE=0, it provides data D0-D7, but when ALE=1, it
has address A0-A7. Therefore, ALE is used for de multiplexing address and data with the help of
an internal latch.
Port 1
Port 1 is an 8-bit bi-directional 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
Some Port 1 pins provide additional functions. 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. Furthermore, P1.4, P1.5, P1.6, and P1.7 can be configured as the SPI slave port
select, data input/output and shift clock input/output pins. Port 1 also receives the low-order
A 50% duty cycle clock can be programmed to come out on P1.0. This pin, besides being a
regular I/0 pin, has two alternate functions. It can be programmed to input the external clock for
Timer/Counter 2 or to output a 50% duty cycle clock ranging from 61 Hz to 4 MHz (for a 16-
Port 2
With no external memory connection, P2 are used as simple I/O. With external memory
connections, port 2 must be used along with P0 to provide the 16-bit address for the external
memory. Port 2 is designated as A8-A15 indicating its dual function. While P0 provides the
lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the address.
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 bi-directional I/O port with internal pull-ups. The Port 3 output buffers
can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled
low will source current because of the pull-ups. Port 3 receives some control signals for Flash
programming and verification.
Port 3 also serves the functions of various special features of the AT89S8252, as shown
in the following table.
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 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 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 6.5 How does the microcontroller handle external memory depend on the pin EA logic state?
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
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 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.
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 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.
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.
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.
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 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.
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).
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)
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.
Description:
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.
The CPU takes a certain number of clock cycles to execute an instruction. In the 8051 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 8051 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
8051 based system compatible with the serial port of the IBM PC.
In the original version of 8051, one machine cycle lasts 12 oscillator periods. Therefore, to
calculate the machine cycle for the 8051, the calculation is made as 1/12 of the crystal frequency
and its inverse is taken.
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:
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
A model described here is for its low price and great possibilities most frequently used in
practice. It is based on the HD44780 microcontroller (Hitachi) and can display messages in two
lines with 16 characters each . It displays all the alphabets, Greek letters, punctuation marks,
mathematical symbols etc. In addition, it is possible to display symbols that user makes up on its
own. Automatic shifting message on display (shift left and right), appearance of the pointer,
PINS FUNCTIONS
There are pins along one side of the small printed board used for connection to the
microcontroller. There are total of 14 pins marked with numbers (16 in case the background light
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 that reason, variable voltage 0-Vdd is applied on pin marked as
Vee. Trimmer potentiometer is usually used for that purpose. Some versions of displays have
built in backlight (blue or green diodes). When used during operating, a resistor for current
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 are commands which determine display mode. List of commands which
LCD recognizes are given in the table below:
Execution
Command RS RW D7 D6 D5 D4 D3 D2 D1 D0
Time
Clear display 0 0 0 0 0 0 0 00 1 1.64mS
Cursor home 0 0 0 0 0 0 0 01 x 1.64mS
I/
Entry mode set 0 0 0 0 0 0 0 1 S 40uS
D
Display on/off control 0 0 0 0 0 0 1 D U B 40uS
Cursor/Display Shift 0 0 0 0 0 1 D/C R/L x x 40uS
Function set 0 0 0 0 1 DL N F x x 40uS
Set CGRAM address 0 0 0 1 CGRAM address 40uS
Set DDRAM address 0 0 1 DDRAM address 40uS
Read “BUSY” flag (BF) 0 1 BF DDRAM address -
Write to CGRAM or
1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM
Read from CGRAM or
1 1 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM
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
Consequently, each data is sent to LCD in two steps: four higher bits are sent first (that
normally would be sent through lines D4-D7), four lower bits are sent afterwards. With the help
of initialization, LCD will correctly connect and interpret each data received. Besides, with
regards to the fact that data are rarely read from LCD (data mainly are transferred from
microcontroller to LCD) one more I/O pin may be saved by simple connecting R/W pin to the
Ground. Such saving has its price. Even though message displaying will be normally performed,
it will not be possible to read from busy flag since it is not possible to read from display.
LCD INITIALIZATION
Once the power supply is turned on, LCD is automatically cleared. This process lasts for
approximately 15mS. After that, display is ready to operate. The mode of operating is set by
1. Display is cleared
2. Mode
3. Display/Cursor on/off
D = 0 Display off
U = 0 Cursor off
4. Character entry
Automatic reset is mainly performed without any problems. Mainly but not always! If for
any reason power supply voltage does not reach full value in the course of 10mS, display will
start perform completely unpredictably. If voltage supply unit can not meet this condition or if it
is needed to provide completely safe operating, the process of initialization by which a new reset
connection to the microcontroller is through 4- or 8-bit interface. All left over to be done after
CONTRAST CONTROL:
To have a clear view of the characters on the LCD, contrast should be adjusted. To adjust
the contrast, the voltage should be varied. For this, a preset is used which can behave like a
variable voltage device. As the voltage of this preset is varied, the contrast of the LCD can be
adjusted.
Potentiometer
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.
Multiturn presets are used where very precise adjustments must be made. The screw must be
turned many times (10+) to move the slider from one end of the track to the other, giving very
fine control.
4 (RS) 1 Vcc
P2.0
P2.1 5 (R/W) 2
P2.2 6(EN) 3 Gnd
LCD
PRESET
(CONTRAST
CONTROL)
89C51 P1.0 D0
P1.1 D1
P1.2 D2
P1.3 D3
P1.4 D4
P1.5 D5 15 Vcc
P1.6 D6 16 Gnd FOR
P1.7 D7 BACKLIGHT
PURPOSE
WIRELESS COMMUNICATION
(GLOBAL SYSTEM FOR MOBILE COMMUNICATION)
GSM-Introduction
• Architecture
• Technical Specifications
• Frame Structure
• Channels
• Security
• Characteristics and features
• Applications
Definition:
GSM-History
GSM IN WORLD
GSM IN INDIA
GSM SERVICES
Fig 8.2 GSM IN INDIA
Tele-services
Bearer or Data Services
Supplementary services
Tele-services
Include various data services for information transfer between GSM and other networks
like PSTN, ISDN etc at rates from 300 to 9600 bps
Short Message Service (SMS)
– up to 160 character alphanumeric data transmission to/from the mobile terminal
Unified Messaging Services(UMS)
Group 3 fax
Voice mailbox
Electronic mail
Supplementary services
Mobile Equipment
Base Station Subsystem is composed of two parts that communicate across the standardized Abis
interface allowing operation between components made by different suppliers
- Location Updating
- Inter BSS and inter MSC call handoff
MSC does gateway function while its customer roams to other network by using
HLR/VLR.
- Permanent database about mobile subscribers in a large service area (generally one per GSM
network operator)
Database contains IMSI, MS ISDN, prepaid/postpaid, roaming restrictions, and supplementary
services.
GSM Specifications-1
RF Spectrum
GSM 900
Mobile to BTS (uplink): 890-915 Mhz
BTS to Mobile(downlink):935-960 Mhz
Bandwidth : 2* 25 Mhz
GSM 1800
Mobile to BTS (uplink): 1710-1785 Mhz
BTS to Mobile(downlink) 1805-1880 Mhz
Bandwidth : 2* 75 Mhz
GSM Specification-II
Carrier Separation : 200 Khz
Duplex Distance : 45 Mhz
No. of RF carriers : 124
Access Method : TDMA/FDMA
Modulation Method : GMSK
Modulation data rate : 270.833 Kbps
OPERATION OF GSM
Call Routing
Call Originating from MS
Call termination to MS
Incoming Call
Handovers
Inter MSC
Security in GSM
Capacity increases
Reduced RF transmission power and longer battery life.
International roaming capability.
Better security against fraud (through terminal validation and user authentication).
Encryption capability for information security and privacy.
Compatibility with ISDN,leading to wider range of services
GSM Applications
Mobile telephony
GSM-R
Telemetry System
- Fleet management
- Automatic meter reading
- Toll Collection
- Remote control and fault reporting of DG sets
Value Added Services
Future Of GSM
2nd Generation
GSM -9.6 Kbps (data rate)
SERIAL COMMUNICATION
SERIAL COMMUNICATION
1. Microcontroller
2. PC
3. RS 232 cable
4. MAX 232 IC
5. HyperTerminal
When the pins P3.0 and P3.1 of microcontroller are set, UART, which is inbuilt in the
microcontroller, will be enabled to start the serial communication.
TIMERS:
The 8051 has two timers: Timer 0 and Timer 1. They can be used either as timers to
generate a time delay or as counters to count events happening outside the microcontroller.
Both Timer 0 and Timer 1 are 16-bit wide. Since the 8051 has an 8-bit architecture, each
16-bit timer is accessed as two separate registers of low byte and high byte. Lower byte register
of Timer 0 is TL0 and higher byte is TH0. Similarly lower byte register of Timer1 is TL1 and
higher byte register is TH1.
Both timers 0 and 1 use the same register TMOD to set the various operation modes.TMOD is an
8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4 bits for Timer 1.
In each case, the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the
operation.
(MSB) (LSB)
TIMER 1 TIMER 0
GATE:
Every timer has a means of starting and stopping. Some timers do this by software, some
by hardware and some have both software and hardware controls. The timers in the 8051 have
both. The start and stop of the timer are controlled by the way of software by the TR (timer start)
bits TR0 and TR1. These instructions start and stop the timers as long as GATE=0 in the TMOD
register. The hardware way of starting and stopping the timer by an external source is achieved
by making GATE=1 in the TMOD register.
C/T:
Timer or counter selected. Cleared for timer operation and set for counter operation.
M1 :
Mode bit 1
M0 :
Mode bit 0
it overflows
This mode 2 is an 8-bit timer and therefore it allows only values of 00H to FFH to be
loaded into the timer’s register TH. After TH is loaded with the 8-bit value, the 8051 give a copy
of it to TL. When the timer starts, it starts to count up by incrementing the TL register. It counts
up until it reaches its limit of FFH. When it rolls over from FFH to 00H, it sets high the TF
(timer flag). If Timer 0 is used, TF0 goes high and if Timer 1 is used, TF1 goes high. When the
TL register rolls from FFH to 0 and TF is set to 1, TL is reloaded automatically with the original
value kept by the TH register.
Computers transfer data in two ways: parallel and serial. In parallel data transfers, often 8
or more lines are used to transfer data to a device that is only a few feet away. Although a lot of
data can be transferred in a short amount of time by using many wires
in parallel, the distance cannot be great. To transfer to a device located many meters
away, the serial method is best suitable. In serial communication, the data is sent one bit at a
time. The 8051 has serial communication capability built into it, thereby making possible fast
data transfer using only a few wires.
The fact that serial communication uses a single data line instead of the 8-bit data line
instead of the 8-bit data line of parallel communication not only makes it cheaper but also
enables two computers located in two different cities to communicate over the telephone.
Serial data communication uses two methods, asynchronous and synchronous. The
synchronous method transfers a block of data at a time, while the asynchronous method transfers
a single byte at a time. With synchronous communications, the two devices initially synchronize
themselves to each other, and then continually send characters to stay in sync. Even when data is
not really being sent, a constant flow of bits allows each device to know where the other is at any
given time. That is, each character that is sent is either actual data or an idle character.
Synchronous communications allows faster data transfer rates than asynchronous methods,
because additional bits to mark the beginning and end of each data byte are not required. The
serial ports on IBM-style PCs are asynchronous devices and therefore only support asynchronous
serial communications.
Asynchronous means "no synchronization", and thus does not require sending and
receiving idle characters. However, the beginning and end of each byte of data must be identified
by start and stop bits. The start bit indicates when the data byte is about to begin and the stop bit
signals when it ends. The requirement to send these additional two bits causes asynchronous
communication to be slightly slower than synchronous however it has the advantage that the
processor does not have to deal with the additional idle characters.
There are special IC chips made by many manufacturers for serial data communications.
These chips are commonly referred to as UART(universal asynchronous receiver-transmitter)
and USART(universal synchronous-asynchronous receiver-transmitter). The 8051 has a built-in
UART.
In the asynchronous method, the data such as ASCII characters are packed between a
start and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The
start bit is always a 0 (low) and stop bit (s) is 1 (high). This is called framing.
The rate of data transfer in serial data communication is stated as bps (bits per second).
Another widely used terminology for bps is baud rate. The data transfer rate of a given computer
system depends on communication ports incorporated into that system. And in asynchronous
serial data communication, this baud rate is generally limited to 100,000bps. The baud rate is
fixed to 9600bps in order to interface with the microcontroller using a crystal of 11.0592 MHz.
RS232 CABLE:
MAX 232:
To ensure data transfer between PC and microcontroller, the baud rate and voltage levels
of Microcontroller and PC should be the same. The voltage levels of microcontroller are logic1
and logic 0 i.e., logic 1 is +5V and logic 0 is 0V. But for PC, RS232 voltage levels are
considered and they are: logic 1 is taken as -3V to -25V and logic 0 as +3V to +25V. So, in order
to equal these voltage levels, MAX232 IC is used. Thus this IC converts RS232 voltage levels to
microcontroller voltage levels and vice versa.
The SCON register is an 8-bit register used to program the start bit, stop bit and data bits of data
framing.
cleared by software.
cleared by software.
SM0 SM1
0 0 Serial Mode 0
1 0 Serial Mode 2
1 1 Serial Mode 3
Of the four serial modes, only mode 1 is widely used. In the SCON register, when serial
mode 1 is chosen, the data framing is 8 bits, 1 stop bit and 1 start bit, which makes it compatible
with the COM port of IBM/ compatible PC’s. And the most important is serial mode 1 allows the
baud rate to be variable and is set by Timer 1 of the 8051. In serial mode 1, for each character a
total of 10 bits are transferred, where the first bit is the start bit, followed by 8 bits of data and
13 3
RxD (P3.0) Tx
10 12
0 R1in R1out
LED INTERFACING:
This current limiting resistor is connected to protect the port pins from sudden flow of
high currents from the power supply.
Thus in order to glow the LED, first there should be a current flow through the LED. In
order to have a current flow, a voltage difference should exist between the LED terminals. To
ensure the voltage difference between the terminals and as the positive terminal of LED is
connected to power supply Vcc, the negative terminal has to be connected to ground. Thus this
ground value is provided by the microcontroller port pin. This can be achieved by writing an
instruction “CLR P1.0”. With this, the port pin P1.0 is initialized to zero and thus now a voltage
difference is established between the LED terminals and accordingly, current flows and therefore
the LED glows. LED and switches can be connected to any one of the four port pins.
Vcc
P1.0
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 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).
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.
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.
EEPROM has several advantages over other memory devices, such as the fact that its method of
erasure is electrical and therefore instant. In addition, in EEPROM one can select which byte to
be erased, in contrast to flash , in which the entire contents of ROM are erased. The main
advantage of EEPROM is that one can program and erase its contents while it is in system board.
It does not require physical removal of the memory chip from its socket. In general, the cost per
bit for EEPROM is much higher when compared to other devices.
DESCRIPTION
When writing data to the memory it responds to the 8 bits received by asserting an acknowledge
bit during the 9th bit time. When data is read by the bus master, it acknowledges the receipt of
the data bytes in the same way. Data transfers are terminated with a STOP condition.
SIGNAL DESCRIPTIONS
Serial Clock (SCL).
The SCL input pin is used to synchronize all data in and out of the memory. A resistor can be
connected from the SCL line to VCC to act as a pull up.
Mode (MODE).
The MODE input is available on pin 7 and may be driven dynamically. It must be at VIL or VIH
for the Byte Write mode, VIH for Multibyte Write mode or VIL for Page Write mode. When
unconnected, the MODE input is internally read as VIH (Multibyte Write mode).
DEVICE OPERATION
I2C Bus Background
The ST24/25x04 supports the I2C protocol. This protocol defines any device that sends data onto
the bus as a transmitter and any device that reads the data as a receiver. The device that controls
the data transfer is known as the master and the other as the slave. The master will always initiate
a data transfer and will provide the serial clock for synchronization.
The ST24/25x04 is always slave devices in all communications.
Start Condition.
START is identified by a high to low transition of the SDA line while the clock SCL is stable in
the high state. A START condition must precede any command for data transfer. Except during a
programming cycle, the ST24/25x04 continuously monitor the SDA and SCL signals for a
START condition and will not respond unless one is given.
Stop Condition.
STOP is identified by a low to high transition of the SDA line while the clock SCL is stable in
the high state. A STOP condition terminates communication between the ST24/25x04 and the
bus master. A STOP condition at the end of a Read command, after and only after a No
Acknowledge, forces the standby state. A STOP condition at the end of a Write command
triggers the internal EEPROM write cycle.
Data Input.
During data input the ST24/25x04 sample the SDA bus signal on the rising edge of the clock
SCL. Note that for correct device operation the SDA signal must be stable during the clock low
to high transition and the data must change ONLY when the SCL line is low.
Memory Addressing.
To start communication between the bus master and the slave ST24/25x04, the master must
initiate a START condition. Following this, the master sends onto the SDA bus line 8 bits (MSB
first) corresponding to the device select code (7 bits) and a READ or WRITE bit. The 4 most
significant bits of the device select code are the device type identifier, corresponding to the I2C
bus definition. For these memories the 4 bits are fixed as 1010b. The following 2 bits identify the
specific memory on the bus. They are matched to the chip enable signals E2, E1. Thus up to 4 x
4K memories can be connected on the same bus giving a memory capacity total of 16 Kilobits.
After a START condition any memory on the bus will identify the device code and compare the
following 2 bits to its chip enable inputs E2, E1. The 7th bit sent is the block number (one block
= 256 bytes). The 8th bit sent is the read or write bit (RW), this bit is set to ’1’ for read and ’0’
for write operations. If a match is found, the corresponding memory will acknowledge the
identification on the SDA bus during the 9th bit time.
Write Operations
The Multibyte Write mode (only available on the ST24/25C04 versions) is selected when the
MODE pin is at VIH and the Page Write mode when MODE pin is at VIL. The MODE pin may
be driven dynamically with CMOS input levels. Following a START condition the master sends
a device select code with the RW bit reset to ’0’. The memory acknowledges this and waits for a
byte address. The byte address of 8 bits provides access to one block of 256 bytes of the
memory. After receipt of the byte address the device again responds with an acknowledge. For
the ST24/25W04 versions, any write command with WC = 1 will not modify the memory
content.
Byte Write.
In the Byte Write mode the master sends one data byte, which is acknowledged by the memory.
The master then terminates the transfer by generating a STOP condition. The Write mode is
independent of the state of the MODE pin which could be left floating if only this mode was to
be used. However it is not a recommended operating mode, as this pin has to be connected to
either VIH or VIL, to minimize the stand-by current.
Multibyte Write.
For the Multibyte Write mode, the MODE pin must be at VIH. The Multibyte Write mode can be
started from any address in the memory. The master sends from one up to 4 bytes of data, which
are each acknowledged by the memory. The transfer is terminated by the master generating a
STOP condition. The duration of the write cycle is Tw = 10ms maximum except when bytes are
accessed on 2 rows (that is have different values for the 6 most significant address bits A7-A2),
the programming time is then doubled to a maximum of 20ms. Writing more than 4 bytes in the
Multibyte Write mode may modify data bytes in an adjacent row (one row is 8 bytes long).
However, the Multibyte Write can properly write up to 8 consecutive bytes as soon as the first
address of these 8 bytes is the first address of the row, the 7 following bytes being written in the
7 following bytes of this same row.
Page Write.
For the Page Write mode, the MODE pin must be at VIL. The Page Write mode allows up to 8
bytes to be written in a single write cycle, provided that they are all located in the same ’row’ in
the memory: that is the 5 most significant memory address bits (A7-A3) are the same inside one
block. The master sends from one up to 8 bytes of data, which are each acknowledged by the
memory. After each byte is transferred, the internal byte address counter (3 least significant bits
only) is incremented. The transfer is terminated by the master generating a STOP condition. Care
must be taken to avoid address counter ’roll-over’ which could result in data being overwritten.
Note that, for any write mode, the generation by the master of the STOP condition starts the
internal memory program cycle. All inputs are disabled until the completion of this cycle and the
memory will not respond to any request.
Data in the upper block of 256 bytes of the memory may be write protected. The memory is
write protected between a boundary address and the top of memory (address 1FFh) when the
PRE input pin is taken high and when the Protect Flag (bit b2 in location 1FFh) is set to ’0’. The
boundary address is user defined by writing it in the Block Address Pointer. The Block Address
Pointer is an 8 bit EEPROM register located at the address 1FFh. It is composed by 5 MSBs
Address Pointer, which defines the bottom boundary address and 3 LSBs which must be
programmed at ’0’. This Address Pointer can therefore address a boundary in steps of 8 bytes.
Read Operations
Read operations are independent of the state of the MODE pin. On delivery, the memory content
is set at all "1’s" (or FFh).
Sequential Read.
This mode can be initiated with either a Current Address Read or a Random Address Read.
However, in this case the master DOES acknowledge the data byte output and the memory
continues to output the next byte in sequence. To terminate the stream of bytes, the master must
NOT acknowledge the last byte output, but MUST generate a STOP condition. The output data
is from consecutive byte addresses, with the internal byte address counter automatically
incremented after each byte output. After a count of the last memory address, the address counter
will ’roll- over’ and the memory will continue to output data.
KEYPAD
KEYPAD:
Keypads and LCDs are the most widely used input/output devices of the 8051 and a basic
understanding of them is essential. The keypads are mainly three types:
1. 4*3 keypad
2. 4*4 keypad
3. 4*8 keypad.
At the lowest level, keyboards are organized in a matrix of rows and columns. The CPU accesses
both rows and columns through ports. Therefore, with two 8-bit ports, an 8*8 matrix of keys can
be connected to a microprocessor. When a key is pressed, a row and a column make a contact,
otherwise there is no connection between rows and columns. A single microcontroller
(consisting of a microprocessor, RAM, EPROM and several ports all on a single chip) takes care
of hardware and software interfacing of the keypad. In such systems, it is the function of
programs stored in EPROM of the microcontroller to scan the keys continuously, identify which
one has been activated and present it to the motherboard.
The rows are connected to an output port and the columns are connected to an input port. If no
key has been pressed, reading the input port will yield 1s for all columns since they are all
connected to high (Vcc). If all the rows are grounded and a key is pressed, one of the columns
will have 0 since the key pressed provides the path to ground. It is the function of the
microcontroller to scan the keypad continuously to detect and identify the key pressed.
To detect a pressed key, the microcontroller grounds all rows by providing 0 (zero) to the output
latch, then it reads the columns. If the data read from the columns is D2-D0 =111, no key has
been pressed and the process continues until a key press is detected. However, if one of the
column bits has a zero, this means that a key press has occurred i.e., for example, if D2-D0=110,
this means that a key in the D0 column has been pressed. After a key press is detected, the
microcontroller will go through a process of identifying the key. Starting with the top row, the
microcontroller grounds it by providing a low to row D0 only and then it reads the columns. If
the data read is all 1s, no key in that row is activated and the process is moved to the next row. It
grounds the next row, reads the columns and checks for any zero. This process continues until
the row is identified. After identification of the row in which the key has been pressed, the next
task is to find out which column the pressed key belongs to. Now this will be easy since the
microcontroller knows at any time which row and column are being accessed.
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.
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 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.
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 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:
2. Free from contamination, and are safe to use in harsh industrial and explosive
environments.
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.
Vibration Detector:
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.
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.
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.
The response of this switch is monitored by the microcontroller and the corresponding action
takes place.
IR Section:
IR Tx.:
Fig 11.4 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
Applications
Infrared remote control units with high power requirements
Free air transmission systems
Infrared source for optical counters and card readers
IR source for smoke detectors.
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
• 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
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
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.
WORKING
WORKING PROCEDURE:
6. If ever we want to change the numbers that are stored in our EEPROM,
then we will switch ON the TOGGLE SWITCH and select the particular mode and
enter the number through KEYPAD.
In this way, we are able to provide full-fledged security to our homes, industries etc….
Software Tools
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.
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.
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.
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 AT89S52.
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 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 software called Proload.
ABOUT KEIL:
5. Save the Project by typing suitable project name with no extension in u r own folder
sited in either C:\ or D:\
14. Now double click on the Target1, you would get another option “Source group 1”
as shown in next page.
15. Click on the file option from menu bar and select “new”
16. The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
18. For a program written in Assembly, then save it with extension “. asm” and for
“C” based program save it with extension “ .C”
19. Now right click on Source group 1 and click on “Add files to Group Source”
20. Now you will get another window, on which by default “C” files will appear.
20. Now select as per your file extension given while saving the file
22. Now Press function key F7 to compile. Any error will appear if so happen.
26. Now Click on the Peripherals from menu bar, and check your required port as
shown in fig below
27. Drag the port a side and click in the program file.
28. Now keep Pressing function key “F11” slowly and observe.
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.
Source Code
SOURCE CODE:
#include"reg52.h"
#include"string.h"
#include"intrins.h"
#include"EEPROM.h"
#include"GSM.h"
sbit rs = P2^0;
sbit rw = P2^1;
sbit en = P2^2;
sbit ir = P3^3;
sbit m1 = P3^4;
sbit m2 = P3^5;
sbit lock = P3^7;
sbit alt = P3^2;
sbit SCL=P2^7;
sbit SDA=P2^6;
bit receive,received = 0;
unsigned char buffer[35],Pno[10],ch,i,t,count,alert=1,vib=1;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
void sms_function(void)
{
unsigned char j=0,use=0;
message(0x80,"ENTER THE KEY ");
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
command(0x01);
if(lock==1)
{
message(0x80," UNAUTHORISED ");
message(0xC0," PERSON IN ROOM ");
buzzer=0;
buzzer1=1;
delay(100);
if(use==0)
{
sms_init();
use=1;
}
send_com("ate0");
new_line();
longdelay();
longdelay();
for(i=0;i<=9;i++)
{
Pno[i]=read(i);
delay(100);
}
send_msg(Pno);
delay(500);
delay(500);
delay(500);
delay(500);
delay1(1000);
for(i=10,j=0;i<=19;i++,j++)
{
Pno[j]=read(i);
delay(100);
}
send_msg(Pno);
delay(500);
delay(500);
delay(500);
delay(500);
delay1(1000);
for(i=20,j=0;i<=29;i++,j++)
{
Pno[j]=read(i);
delay(100);
}
send_msg(Pno);
delay(500);
delay(500);
delay(500);
delay(500);
delay1(1000);
for(i=30,j=0;i<=39;i++,j++)
{
Pno[j]=read(i);
delay(100);
}
send_msg(Pno);
delay(500);
delay(500);
delay(500);
delay1(1000);
while(1);
}
else
{
message(0X80," KEY ENTERED ");
message(0XC0," SUCCESSFULLY ");
while(1);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
void command(unsigned char value)
{
ldata = value;
rs = 0;
rw = 0;
en = 1;
delay(1);
en = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
t=x/10;
d1=x%10;
d2=t%10;
d2=d2+0x30;
lcddata(d2);
d1=d1+0x30;
lcddata(d1);
delay(5);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
void lcd_init(void)
{
command(0x38);
command(0x80);
command(0x0e);
command(0x01);
command(0x06);
command(0x0c);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
void main(void)
{
TH1 = 0xFA;
TMOD = 0X20;
SCON = 0X50;
TR1 = 1;
buzzer=1;
buzzer1=0;
lcd_init();
t=0;
message(0X80,"PRESS #");
message(0xc0,"TO CHANGE NO1");
myfunction1(0);
message(0X80,"PRESS #");
message(0xc0,"TO CHANGE NO2");
myfunction1(10);
message(0X80,"PRESS #");
message(0xc0,"TO CHANGE NO3");
myfunction1(20);
message(0X80,"PRESS #");
message(0xc0,"TO CHANGE NO4");
myfunction1(30);
message(0X80,"SYSTEM ACTIVATED");
message(0XC0,"LOCK THE KEY ");
while(lock==0);
message(0X80,"SYSTEM ACTIVATED");
message(0XC0," ");
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
longdelay();
message(0XC0,"--------------------");
alert=1;
vib=1;
while(1)
{
if(alt==0)
{
alert=0;
}
command(0XC0);
/////////////////////////////////
if(m1==1)
{
alert=0;
/////////////////////////////////
if(m2==1)
{
alert=0;
/////////////////////////////////
if(ir==1)
alert=0;
/////////////////////////////////
if(alert==0)
{
sms_function();
}
if(vib==0)
{
sms_function();
}
/////////////////////////////////
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////
Advantages:
1) Sophisticated security
2) Monitors all hazards and threats
3) Alert message to mobile phone for remote information
4) Mobile number can be changed at any time
Applications:
1) Banks
2) Offices
3) Industries
4) Jeweler Shops and Home Applications
CONCLUSION
CONCLUSION:
In this project work, we have studied and implemented a complete working model using a
Microcontroller. The programming and interfacing of microcontroller has been mastered during
the implementation. This work includes the study of GSM modem using sensors.
The biggest advantage of using this project is , whatever the sensor is activated we will
be getting the acknowledgement from GSM modem to our mobile numbers which are stored in
EEPROM and GSM network operators have roaming facilities, user can often continue to use
there mobile phones when they travel to other countries etc..
REFERENCE
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