Vous êtes sur la page 1sur 87

Power Supply

Power supply is a reference to a source of electrical power. A device or system that supplies
electrical or other types of energy to an output load or group of loads is called a power supply unit or
PSU. The term is most commonly applied to electrical energy supplies, less often to mechanical ones,
and rarely to others

This power supply section is required to convert AC signal to DC signal and also to reduce the
amplitude of the signal. The available voltage signal from the mains is 230V/50Hz which is an AC voltage,
but the required is DC voltage(no frequency) with the amplitude of +5V and +12V for various
applications.

In this section we have Transformer, Bridge rectifier, are connected serially and voltage
regulators for +5V and +12V (7805 and 7812) via a capacitor (1000µF) in parallel are connected parallel
as shown in the circuit diagram below. Each voltage regulator output is again is connected to the
capacitors of values (100µF, 10µF, 1 µF, 0.1 µF) are connected parallel through which the corresponding
output(+5V or +12V) are taken into consideration.
Circuit Explanation

1) Transformer

A transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled electrical conductors. A changing current in the first circuit (the
primary) creates a changing magnetic field; in turn, this magnetic field induces a changing
voltage in the second circuit (the secondary). By adding a load to the secondary circuit, one can
make current flow in the transformer, thus transferring energy from one circuit to the other.

The secondary induced voltage VS, of an ideal transformer, is scaled from the primary VP
by a factor equal to the ratio of the number of turns of wire in their respective windings:

Basic principle

The transformer is based on two principles: firstly, that an electric current can produce a
magnetic field (electromagnetism) and secondly that a changing magnetic field within a coil of
wire induces a voltage across the ends of the coil (electromagnetic induction). By changing the
current in the primary coil, it changes the strength of its magnetic field; since the changing
magnetic field extends into the secondary coil, a voltage is induced across the secondary.

A simplified transformer design is shown below. A current passing through the primary
coil creates a magnetic field. The primary and secondary coils are wrapped around a core of very
high magnetic permeability, such as iron; this ensures that most of the magnetic field lines
produced by the primary current are within the iron and pass through the secondary coil as well
as the primary coil.
An ideal step-down transformer showing magnetic flux in the core

Induction law

The voltage induced across the secondary coil may be calculated from Faraday's law of
induction, which states that:

Where VS is the instantaneous voltage, NS is the number of turns in the secondary coil
and Φ equals the magnetic flux through one turn of the coil. If the turns of the coil are oriented
perpendicular to the magnetic field lines, the flux is the product of the magnetic field strength B
and the area A through which it cuts. The area is constant, being equal to the cross-sectional area
of the transformer core, whereas the magnetic field varies with time according to the excitation
of the primary. Since the same magnetic flux passes through both the primary and secondary
coils in an ideal transformer, the instantaneous voltage across the primary winding equals

Taking the ratio of the two equations for VS and VP gives the basic equation for stepping
up or stepping down the voltage
Ideal power equation

If the secondary coil is attached to a load that allows current to flow, electrical power is
transmitted from the primary circuit to the secondary circuit. Ideally, the transformer is perfectly
efficient; all the incoming energy is transformed from the primary circuit to the magnetic field
and into the secondary circuit. If this condition is met, the incoming electric power must equal
the outgoing power.

Pincoming = IPVP = Poutgoing = ISVS


giving the ideal transformer equation

Pin-coming = IPVP = Pout-going = ISVS

giving the ideal transformer equation

If the voltage is increased (stepped up) (VS > VP), then the current is decreased (stepped
down) (IS < IP) by the same factor. Transformers are efficient so this formula is a reasonable
approximation.
If the voltage is increased (stepped up) (VS > VP), then the current is decreased (stepped
down) (IS < IP) by the same factor. Transformers are efficient so this formula is a reasonable
approximation.

The impedance in one circuit is transformed by the square of the turns ratio. For
example, if an impedance ZS is attached across the terminals of the secondary coil, it appears to
the primary circuit to have an impedance of

This relationship is reciprocal, so that the impedance ZP of the primary circuit appears to
the secondary to be

Detailed operation

The simplified description above neglects several practical factors, in particular the
primary current required to establish a magnetic field in the core, and the contribution to the field
due to current in the secondary circuit.

Models of an ideal transformer typically assume a core of negligible reluctance with two
windings of zero resistance. When a voltage is applied to the primary winding, a small current
flows, driving flux around the magnetic circuit of the core. The current required to create the flux
is termed the magnetizing current; since the ideal core has been assumed to have near-zero
reluctance, the magnetizing current is negligible, although still required to create the magnetic
field.

The changing magnetic field induces an electromotive force (EMF) across each winding.
Since the ideal windings have no impedance, they have no associated voltage drop, and so the
voltages VP and VS measured at the terminals of the transformer, are equal to the corresponding
EMFs. The primary EMF, acting as it does in opposition to the primary voltage, is sometimes
termed the "back EMF". This is due to Lenz's law which states that the induction of EMF would
always be such that it will oppose development of any such change in magnetic field.

2) Bridge Rectifier

A diode bridge or bridge rectifier is an arrangement of four diodes in a bridge


configuration that provides the same polarity of output voltage for any polarity of input voltage.
When used in its most common application, for conversion of alternating current (AC) input into
direct current (DC) output, it is known as a bridge rectifier. A bridge rectifier provides full-wave
rectification from a two-wire AC input, resulting in lower cost and weight as compared to a
center-tapped transformer design, but has two diode drops rather than one, thus exhibiting
reduced efficiency over a center-tapped design for the same output voltage.
Basic Operation

When the input connected at the left corner of the diamond is positive with respect to the
one connected at the right hand corner, current flows to the right along the upper colored path to
the output, and returns to the input supply via the lower one.

When the right hand corner is positive relative to the left hand corner, current flows along
the upper colored path and returns to the supply via the lower colored path.

In each case, the upper right output remains positive with respect to the lower right one.
Since this is true whether the input is AC or DC, this circuit not only produces DC power when
supplied with AC power: it also can provide what is sometimes called "reverse polarity
protection". That is, it permits normal functioning when batteries are installed backwards or DC
input-power supply wiring "has its wires crossed" (and protects the circuitry it powers against
damage that might occur without this circuit in place).

Prior to availability of integrated electronics, such a bridge rectifier was always


constructed from discrete components. Since about 1950, a single four-terminal component
containing the four diodes connected in the bridge configuration became a standard commercial
component and is now available with various voltage and current ratings.

Output smoothing (Using Capacitor)

For many applications, especially with single phase AC where the full-wave bridge
serves to convert an AC input into a DC output, the addition of a capacitor may be important
because the bridge alone supplies an output voltage of fixed polarity but pulsating magnitude
(see diagram above).
The function of this capacitor, known as a reservoir capacitor (aka smoothing capacitor)
is to lessen the variation in (or 'smooth') the rectified AC output voltage waveform from the
bridge. One explanation of 'smoothing' is that the capacitor provides a low impedance path to the
AC component of the output, reducing the AC voltage across, and AC current through, the
resistive load. In less technical terms, any drop in the output voltage and current of the bridge
tends to be cancelled by loss of charge in the capacitor.

This charge flows out as additional current through the load. Thus the change of load
current and voltage is reduced relative to what would occur without the capacitor. Increases of
voltage correspondingly store excess charge in the capacitor, thus moderating the change in
output voltage / current. Also see rectifier output smoothing.

The simplified circuit shown has a well deserved reputation for being dangerous,
because, in some applications, the capacitor can retain a lethal charge after the AC power source
is removed. If supplying a dangerous voltage, a practical circuit should include a reliable way to
safely discharge the capacitor. If the normal load can not be guaranteed to perform this function,
perhaps because it can be disconnected, the circuit should include a bleeder resistor connected as
close as practical across the capacitor. This resistor should consume a current large enough to
discharge the capacitor in a reasonable time, but small enough to avoid unnecessary power
waste.

Because a bleeder sets a minimum current drain, the regulation of the circuit, defined as
percentage voltage change from minimum to maximum load, is improved. However in many
cases the improvement is of insignificant magnitude.

The capacitor and the load resistance have a typical time constant τ = RC where C and R
are the capacitance and load resistance respectively. As long as the load resistor is large enough
so that this time constant is much longer than the time of one ripple cycle, the above
configuration will produce a smoothed DC voltage across the load.

In some designs, a series resistor at the load side of the capacitor is added. The smoothing
can then be improved by adding additional stages of capacitor–resistor pairs, often done only for
sub-supplies to critical high-gain circuits that tend to be sensitive to supply voltage noise.

The idealized waveforms shown above are seen for both voltage and current when the
load on the bridge is resistive. When the load includes a smoothing capacitor, both the voltage
and the current waveforms will be greatly changed. While the voltage is smoothed, as described
above, current will flow through the bridge only during the time when the input voltage is greater
than the capacitor voltage. For example, if the load draws an average current of n Amps, and the
diodes conduct for 10% of the time, the average diode current during conduction must be 10n
Amps. This non-sinusoidal current leads to harmonic distortion and a poor power factor in the
AC supply.

In a practical circuit, when a capacitor is directly connected to the output of a bridge, the
bridge diodes must be sized to withstand the current surge that occurs when the power is turned
on at the peak of the AC voltage and the capacitor is fully discharged. Sometimes a small series
resistor is included before the capacitor to limit this current, though in most applications the
power supply transformer's resistance is already sufficient.

Output can also be smoothed using a choke and second capacitor. The choke tends to
keep the current (rather than the voltage) more constant. Due to the relatively high cost of an
effective choke compared to a resistor and capacitor this is not employed in modern equipment.

Some early console radios created the speaker's constant field with the current from the
high voltage ("B +") power supply, which was then routed to the consuming circuits, (permanent
magnets were considered too weak for good performance) to create the speaker's constant
magnetic field. The speaker field coil thus performed 2 jobs in one: it acted as a choke, filtering
the power supply, and it produced the magnetic field to operate the speaker.

3) Voltage Regulator

A voltage regulator is an electrical regulator designed to automatically maintain a


constant voltage level.

The 78xx (also sometimes known as LM78xx) series of devices is a family of self-
contained fixed linear voltage regulator integrated circuits. The 78xx family is a very popular
choice for many electronic circuits which require a regulated power supply, due to their ease of
use and relative cheapness. When specifying individual ICs within this family, the xx is replaced
with a two-digit number, which indicates the output voltage the particular device is designed to
provide (for example, the 7805 has a 5 volt output, while the 7812 produces 12 volts). The 78xx
line is positive voltage regulators, meaning that they are designed to produce a voltage that is
positive relative to a common ground. There is a related line of 79xx devices which are
complementary negative voltage regulators. 78xx and 79xx ICs can be used in combination to
provide both positive and negative supply voltages in the same circuit, if necessary.

78xx ICs have three terminals and are most commonly found in the TO220 form factor,
although smaller surface-mount and larger TrO3 packages are also available from some
manufacturers. These devices typically support an input voltage which can be anywhere from a
couple of volts over the intended output voltage, up to a maximum of 35 or 40 volts, and can
typically provide up to around 1 or 1.5 amps of current (though smaller or larger packages may
have a lower or higher current rating).
2.2 MICROCONTROLLER:

2.2.1 Brief history of 8051:

Figure2.2.1:embedded systems

INTRODUCTION TO EMBEDDED SYSTEMS:

An embedded system can be defined as a computing device that does a specific focused job.
Appliances such as the air-conditioner, VCD player, DVD player, printer, fax machine, mobile
phone etc. are examples of embedded systems. Each of these appliances will have a processor
and special hardware to meet the specific requirement of the application along with the
embedded software that is executed by the processor for meeting that specific requirement. The
embedded software is also called “firm ware”. The desktop/laptop computer is a general purpose
computer. You can use it for a variety of applications such as playing games, word processing,
accounting, software development and so on. In contrast, the software in the embedded systems
is always fixed listed below:

Embedded systems do a very specific task, they cannot be programmed to do different


things. Embedded systems have very limited resources, particularly the memory. Generally, they
do not have secondary storage devices such as the CDROM or the floppy disk. Embedded
systems have to work against some deadlines. A specific job has to be completed within a
specific time. In some embedded systems, called real-time systems, the deadlines are stringent.
Missing a deadline may cause a catastrophe-loss of life or damage to property. Embedded
systems are constrained for power. As many embedded systems operate through a battery, the
power consumption has to be very low.Some embedded systems have to operate in extreme
environmental conditions such as very high temperatures and humidity.

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, 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),
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!

Overview of Embedded System Architecture:

Fig2.2.2:layout architecture of 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 operating system.
The same architecture is applicable to any computer including a desktop computer. However,
there are significant differences. It is not compulsory to have an operating system in every
embedded system. For small appliances such as remote control units, air conditioners, toys etc.,
there is no need for an operating system and you can write only the software specific to that
application. For applications involving complex processing, it is advisable to have an operating
system. In such a case, you need to integrate the application software with the operating system
and then transfer the entire software on to the memory chip. Once the software is transferred to
the memory chip, the software will continue to run for a long time you don’t need to reload new
software.

Now, let us see the details of the various building blocks of the hardware of an embedded
system. As shown in Fig. the building blocks are;

· Central Processing Unit (CPU)

· Memory (Read-only Memory and Random Access Memory)

· Input Devices

· Output devices

· Communication interfaces

· Application-specific circuitry
fig2.2.3:building blocks of embedded system

Central Processing Unit (CPU):

The Central Processing Unit (processor, in short) can be any of the following: microcontroller,
microprocessor or Digital Signal Processor (DSP). A micro-controller is a low-cost processor. Its
main attraction is that on the chip itself, there will be many other components such as memory,
serial communication interface, analog-to digital converter etc. So, for small applications, a
micro-controller is the best choice as the number of external components required will be very
less. On the other hand, microprocessors are more powerful, but you need to use many external
components with them. D5P is used mainly for applications in which signal processing is
involved such as audio and video processing.

Memory:

The memory is categorized as Random Access 11emory (RAM) and Read Only Memory
(ROM). The contents of the RAM will be erased if power is switched off to the chip, whereas
ROM retains the contents even if the power is switched off. So, the firmware is stored in the
ROM. When power is switched on, the processor reads the ROM; the program is program is
executed.
Input devices:

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.
2.2.2 Description of AT89S52 Microcontroller:

Fig2.2.4:AT89S52 Microcontroller

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.

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 discussed in the following sections.
2.2.3FEATURES OF THE MICROCONTROLLER:
• 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 and power off flag

DESCRIPTION:

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 pinout. The on-chip Flash allows the program memory to be
reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a
versatile 8-bit CPU with 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 following standard features: 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.
2.2.4 BLOCK DIAGRAM:

Fig2.2.5:block diagram of microcontroller


2.2.5PIN DESCRIPTION OF MICROCONTROLLER:

Fig2.2.6:pin diagram of microcontroller


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 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.
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 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 will source current (IIL) 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.
RST:

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:

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. Note, however, that one
ALE pulse is skipped during each access to external data memory. If desired, ALE operation can
be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a
MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable
bit has no effect if the microcontroller is in external execution mode.
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:

External Access Enable. EA must be strapped to GND in order to enable the device to
fetch code from external program memory locations starting at 0000H up to FFFFH. Note,
however, that if lock bit 1 is programmed, EA will be internally latched on reset.EA should be
strapped to VCC for internal program executions. This pin also receives the 12-volt
programming enable voltage (VPP) during Flash programming.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2

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. 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 and low time specifications must be observed.
Fig2.2.7: Oscillator Connections

C1, C2 = 30 pF ± 10 pF for Crystals


= 40 pF ± 10 pF for Ceramic Resonators

Fig2.2.8: External Clock Drive Configuration


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 (still referring to the whole 8052 microcontroller family) 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. 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 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).
How does the microcontroller handle external memory depend on the pin EA logic state?
Fig 2.2.9:microcontroller external memory in 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 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

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

Fig2.2.10: Microcontroller internal structure


Fig2.2.11:address map of microcontroller
How to extend memory?

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

Fig2.2.12:Interfacing of external memory chips to 8051


From the users’ perspective, everything functions quite simple if properly connected
because the most operations are performed by the microcontroller itself. 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 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 microcontroller
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 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

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.
2.2.6SFRs (Special Function Registers):

SFRs are a kind of control table used for running and monitoring microcontroller’s
operating. Each of these registers, even each bit they include, has its name, address in the scope
of RAM and clearly defined purpose ( for example: timer control, interrupt, serial connection
etc.). Even though there are 128 free memory locations intended for their storage, the basic core,
shared by all types of 8052 controllers, has only 21 such registers. Rest of locations is
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 8052 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:

The AT89S52 is a low-voltage, high-performance CMOS 8-bit microcomputer 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.

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.

2.3INTERFACING OF LCD TO PROJECT:


LCD (Liquid Cristal Display)

Introduction:

A liquid crystal display (LCD) is a thin, flat display device made up of any number of
color or monochrome pixels arrayed in front of a light source or reflector. Each pixel consists of a
column of liquid crystal molecules suspended between two transparent electrodes, and two polarizing
filters, the axes of polarity of which are perpendicular to each other. Without the liquid crystals
between them, light passing through one would be blocked by the other. The liquid crystal twists the
polarization of light entering one filter to allow it to pass through the other.

A program must interact with the outside world using input and output devices that
communicate directly with a human being. One of the most common devices attached to an controller is
an LCD display. Some of the most common LCDs connected to the contollers are 16X1, 16x2 and 20x2
displays. This means 16 characters per line by 1 line 16 characters per line by 2 lines and 20 characters
per line by 2 lines, respectively.

Many microcontroller devices use 'smart LCD' displays to output visual information. LCD displays
designed around LCD NT-C1611 module, are inexpensive, easy to use, and it is even possible to produce
a readout using the 5X7 dots plus cursor of the display. They have a standard ASCII set of characters and
mathematical symbols. For an 8-bit data bus, the display requires a +5V supply plus 10 I/O lines (RS RW
D7 D6 D5 D4 D3 D2 D1 D0). For a 4-bit data bus it only requires the supply lines plus 6 extra lines(RS
RW D7 D6 D5 D4). When the LCD display is not enabled, data lines are tri-state and they do not interfere
with the operation of the microcontroller.

Shapes and S
Features:

(1) Interface with either 4-bit or 8-bit microprocessor.

(2) Display data RAM

(3) 80x 8 bits (80 characters).

(4) Character generator ROM

(5). 160 different 5 7 dot-matrix character patterns.

(6). Character generator RAM

(7) 8 different user programmed 5 7 dot-matrix patterns.

(8).Display data RAM and character generator RAM may be

Accessed by the microprocessor.

(9) Numerous instructions

(10) .Clear Display, Cursor Home, Display ON/OFF, Cursor ON/OFF,

Blink Character, Cursor Shift, Display Shift.

(11). Built-in reset circuit is triggered at power ON.

(12). Built-in oscillator.

Data can be placed at any location on the LCD. For 16×1 LCD, the address locations are:
Fig : Address locations for a 1x16 line LCD

Shapes and sizes:


Even limited to character based modules,there is still a wide variety of shapes and sizes available.
Line lenghs of 8,16,20,24,32 and 40 charecters are all standard, in one, two and four line versions.

Several different LC technologies exists. “supertwist” types, for example, offer Improved contrast and
viewing angle over the older “twisted nematic” types. Some modules are available with back lighting, so
so that they can be viewed in dimly-lit conditions. The back lighting may be either “electro-
luminescent”, requiring a high voltage inverter circuit, or simple LED illumination.
Electrical blockdiagram:

Power supply for lcd driving:

PIN DESCRIPTION:
Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are
extra in both for back-light LED connections).

Fig: pin diagram of 1x16 lines lcd


CONTROL LINES:

EN:

Line is called "Enable." This control line is used to tell the LCD that you are sending it
data. To send data to the LCD, your program should make sure this line is low (0) and then set
the other two control lines and/or put data on the data bus. When the other lines are completely
ready, bring EN high (1) and wait for the minimum amount of time required by the LCD
datasheet (this varies from LCD to LCD), and end by bringing it low (0) again.

RS:

Line is the "Register Select" line. When RS is low (0), the data is to be treated as a
command or special instruction (such as clear screen, position cursor, etc.). When RS is high (1),
the data being sent is text data which sould be displayed on the screen. For example, to display
the letter "T" on the screen you would set RS high.

RW:
Line is the "Read/Write" control line. When RW is low (0), the information on the data
bus is being written to the LCD. When RW is high (1), the program is effectively querying (or
reading) the LCD. Only one instruction ("Get LCD status") is a read command. All others are
write commands, so RW will almost always be low.

Finally, the data bus consists of 4 or 8 lines (depending on the mode of operation selected
by the user). In the case of an 8-bit data bus, the lines are referred to as DB0, DB1, DB2, DB3,
DB4, DB5, DB6, and DB7.

Logic status on control lines:

• E - 0 Access to LCD disabled

- 1 Access to LCD enabled

• R/W - 0 Writing data to LCD

- 1 Reading data from LCD

• RS - 0 Instructions

- 1 Character

Writing data to the LCD:

1) Set R/W bit to low

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

Read data from data lines (if it is reading)on LCD:


1) Set R/W bit to high

2) Set RS bit to logic 0 or 1 (instruction or character)

3) Set data to data lines (if it is writing)

4) Set E line to high

5) Set E line to low

Entering Text:

First, a little tip: it is manually a lot easier to enter characters and commands in hexadecimal
rather than binary (although, of course, you will need to translate commands from binary couple of sub-
miniature hexadecimal rotary switches is a simple matter, although a little bit into hex so that you know
which bits you are setting). Replacing the d.i.l. switch pack with a of re-wiring is necessary.

The switches must be the type where On = 0, so that when they are turned to the zero position,
all four outputs are shorted to the common pin, and in position “F”, all four outputs are open circuit.

All the available characters that are built into the module are shown in Table 3. Studying the
table, you will see that codes associated with the characters are quoted in binary and hexadecimal, most
significant bits (“left-hand” four bits) across the top, and least significant bits (“right-hand” four bits)
down the left.

Most of the characters conform to the ASCII standard, although the Japanese and Greek
characters (and a few other things) are obvious exceptions. Since these intelligent modules were
designed in the “Land of the Rising Sun,” it seems only fair that their Katakana phonetic symbols should
also be incorporated. The more extensive Kanji character set, which the Japanese share with the Chinese,
consisting of several thousand different characters, is not included!

Using the switches, of whatever type, and referring to Table 3, enter a few characters onto the
display, both letters and numbers. The RS switch (S10) must be “up” (logic 1) when sending the
characters, and switch E (S9) must be pressed for each of them. Thus the operational order is: set RS high,
enter character, trigger E, leave RS high, enter another character, trigger E, and so on.

The first 16 codes in Table 3, 00000000 to 00001111, ($00 to $0F) refer to the CGRAM. This is
the Character Generator RAM (random access memory), which can be used to hold user-defined
graphics characters. This is where these modules really start to show their potential, offering such
capabilities as bar graphs, flashing symbols, even animated characters. Before the user-defined
characters are set up, these codes will just bring up strange looking symbols.

Codes 00010000 to 00011111 ($10 to $1F) are not used and just display blank characters. ASCII
codes “proper” start at 00100000 ($20) and end with 01111111 ($7F). Codes 10000000 to 10011111 ($80
to $9F) are not used, and 10100000 to 11011111 ($A0 to $DF) are the Japanese characters.
Initialization by Instructions:
If the power conditions for the normal operation of the internal reset circuit are
not satisfied, then executing a series of instructions must initialize LCD unit. The procedure
for this initialization process is as above show.

LDR(LIGHT DEPENDENT REGISTER)

Introduction:

A photo resistor or Light Dependent Resistor or CdS (Cadmium Sulphide) Cell is a resistor
whose resistance decreases with increasing incident light intensity. It can also be referred to as a
photoconductor.

A photo resistor 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 (and its hole partner)
conduct electricity, thereby lowering resistance.
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, added whose ground state
energy is closer to the conduction band; since the electrons don't 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.

conduction band
band

band valence
bands
gap

Cadmium sulphide cells:

(CdS) cells rely on the material's ability to vary its resistance according to the amount of
light striking the cell. The more light that strikes the cell, the lower the resistance. though not
accurate, even a simple CdS cell can have a wide range of resistance from less than 100 Ω in
bright light to in excess of 10 MΩ in darkness.

Standard cadmium based LDRs have a frequency response that varies according to light
level, but typical fall times range from 15ms to 25ms and typical rise times range from 50ms to
70ms, so they may be unsuitable for data links and picture scanning. Probably the best known
LDR is the ORP12. Smaller cheaper devices are more popular today.
A sample LDR light sencor circuit:

When the light level is low the resistance of the LDR is high. This prevents current from
flowing to the base of the transistors. Consequently the LED does not light.
However, when light shines onto the LDR its resistance falls and current flows into the base of
the first transistor and then the second transistor. The LED lights.

The preset resistor can be turned up or down to increase or decrease resistance, in this way it can
make the circuit more or less sensitive.

Applications:

Photo resistors come in many different types. Inexpensive cadmium sulfide cells can be
found in many consumer items such as camera light meters, clock radios, security alarms, street
lights and outdoor clocks.

They are also used in some dynamic compressors together with a small incandescent lamp or
light emitting diode to control gain reduction.

Lead sulfide and indium antimonite LDRs 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.

ZIGBEE
Introduction:
When you hold the TV remote and wish to use it you have to necessarily point your control at
the device. This one-way, line-of-sight, short-range communication uses infrared (IR) sensors to
enable communication and control and it is possible to operate the TV remotely only with its
control unit.

Add other home theatre modules, an air- conditioner and remotely enabled fans and lights to
your room, and you become a juggler who has to handle not only these remotes, but also more
numbers that will accompany other home appliances you are likely to use.

Some remotes do serve to control more than one device after ‘memorizing' access codes, but this
interoperability is restricted to LOS, that too only for a set of related equipment, like the different
units of a home entertainment system
Now picture a home with entertainment units, security systems including fire alarm, smoke
detector and burglar alarm, air-conditioners and kitchen appliances all within whispering
distance from each other and imagine a single unit that talks with all the devices, no longer
depending on line-of-sight, and traffic no longer being one-way.

This means that the devices and the control unit would all need a common standard to enable
intelligible communication. ZigBee is such a standard for embedded application software and
has been ratified in late 2004 under IEEE 802.15.4 Wireless Networking Standards.

ZigBee is an established set of specifications for wireless personal area networking (WPAN),
i.e., digital radio connections between computers and related devices. This kind of network
eliminates use of physical data buses like USB and Ethernet cables. The devices could include
telephones, hand-held digital assistants, sensors and controls located within a few meters of each
other.

ZigBee is one of the global standards of communication protocol formulated by the relevant task
force under the IEEE 802.15 working group. The fourth in the series, WPAN Low Rate/ZigBee
is the newest and provides specifications for devices that have low data rates, consume very low
power and are thus characterized by long battery life. Other standards like Bluetooth and IrDA
address high data rate applications such as voice, video and LAN communications.

The ZigBee Alliance has been set up as “an association of companies working together to enable
reliable, cost-effective, low-power, wirelessly networked, monitoring and control products based
on an open global standard”.

Once a manufacturer enrolls in this Alliance for a fee, he can have access to the standard and
implement it in his products in the form of ZigBee chipsets that would be built into the end
devices. Philips, Motorola, Intel, HP are all members of the Alliance . The goal is “to provide the
consumer with ultimate flexibility, mobility, and ease of use by building wireless intelligence
and capabilities into every day devices. ZigBee technology will be embedded in a wide range of
products and applications across consumer, commercial, industrial and government markets
worldwide. For the first time, companies will have a standards-based wireless platform
optimized for the unique needs of remote monitoring and control applications, including
simplicity, reliability, low-cost and low-power”.

The target networks encompass a wide range of devices with low data rates in the Industrial,
Scientific and Medical (ISM) radio bands, with building-automation controls like intruder/fire
alarms, thermostats and remote (wireless) switches, video/audio remote controls likely to be the
most popular applications. So far sensor and control devices have been marketed as proprietary
items for want of a standard. With acceptance and implementation of ZigBee, interoperability
will be enabled in multi-purpose, self-organizing mesh networks

Architecture:
Though WPAN implies a reach of only a few meters, 30 feet in the case of ZigBee, the network
will have several layers, so designed as to enable intrapersonal communication within the
network, connection to a network of higher level and ultimately an uplink to the Web.

The ZigBee Standard has evolved standardized sets of solutions, called ‘layers'. These layers
facilitate the features that make ZigBee very attractive: low cost, easy implementation, reliable
data transfer, short-range operations, very low power consumption and adequate security
features.

1. Network and Application Support layer : The network layer permits growth of network
sans high power transmitters. This layer can handle huge numbers of nodes. This level in the
ZigBee architecture includes the ZigBee Device Object (ZDO), user-defined application
profile(s) and the Application Support (APS) sub-layer.

The APS sub-layer's responsibilities include maintenance of tables that enable matching between
two devices and communication among them, and also discovery, the aspect that identifies other
devices that operate in the operating space of any device.

The responsibility of determining the nature of the device (Coordinator / FFD or RFD) in the
network, commencing and replying to binding requests and ensuring a secure relationship
between devices rests with the ZDO (Zigbee Define Object). The user-defined application refers
to the end device that conforms to the ZigBee Standard.

2. Physical (PHY) layer : The IEEE802.15.4 PHY physical layer accommodates high levels of
integration by using direct sequence to permit simplicity in the analog circuitry and enable
cheaper implementations.

3. Media access control (MAC) layer : The IEEE802.15.4 MAC media access control layer
permits use of several topologies without introducing complexity and is meant to work with large
numbers of devices.
Figure 1: IEEE 802.15.4 / ZigBee Stack Architecture

Device Types:
There are three different ZigBee device types that operate on these layers in any self-organizing
application network.

These devices have 64-bit IEEE addresses, with option to enable shorter addresses to reduce
packet size, and work in either of two addressing modes – star and peer-to-peer.

1. The ZigBee coordinator node : There is one, and only one, ZigBee coordinator in each
network to act as the router to other networks, and can be likened to the root of a (network) tree.
It is designed to store information about the network.

2. The full function device FFD : The FFD is an intermediary router transmitting data from
other devices. It needs lesser memory than the ZigBee coordinator node, and entails lesser
manufacturing costs. It can operate in all topologies and can act as a coordinator.

3. The reduced function device RFD : This device is just capable of talking in the network; it
cannot relay data from other devices. Requiring even less memory, (no flash, very little ROM
and RAM), an RFD will thus be cheaper than an FFD. This device talks only to a network
coordinator and can be implemented very simply in star topology.

ZigBee Characteristics:
The focus of network applications under the IEEE 802.15.4 / ZigBee standard include the
features of low power consumption, needed for only two major modes (Tx/Rx or Sleep), high
density of nodes per network, low costs and simple implementation.

These features are enabled by the following characteristics. 2.4GHz and 868/915 MHz dual
PHY modes. This represents three license-free bands: 2.4-2.4835 GHz, 868-870 MHz and 902-
928 MHz. The number of channels allotted to each frequency band is fixed at sixteen (numbered
11-26), one (numbered 0) and ten (numbered 1-10) respectively. The higher frequency band is
applicable worldwide, and the lower band in the areas of North America, Europe, Australia and
New Zealand .

• Low power consumption, with battery life ranging from months to years. Considering the
number of devices with remotes in use at present, it is easy to see that more numbers of batteries
need to be provisioned every so often, entailing regular (as well as timely), recurring
expenditure. In the ZigBee standard, longer battery life is achievable by either of two means:
continuous network connection and slow but sure battery drain, or intermittent connection and
even slower battery drain.
• Maximum data rates allowed for each of these frequency bands are fixed as 250 kbps @2.4
GHz, 40 kbps @ 915 MHz, and 20 kbps @868 MHz.

• High throughput and low latency for low duty-cycle applications (<0.1%)

• Channel access using Carrier Sense Multiple Access with Collision Avoidance (CSMA - CA)

• Addressing space of up to 64 bit IEEE address devices, 65,535 networks

• 50m typical range

• Fully reliable “hand-shaked” data transfer protocol.

• Different topologies as illustrated below: star, peer-to-peer, mesh

Figure 2: ZigBee Topologies

Traffic Types:

ZigBee/IEEE 802.15.4 addresses three typical traffic types. IEEE 802.15.4 MAC can
accommodate all the types.

1. Data is periodic. The application dictates the rate, and the sensor activates, checks for data and
deactivates.

2. Data is intermittent. The application, or other stimulus, determines the rate, as in the case of
say smoke detectors. The device needs to connect to the network only when communication is
necessitated. This type enables optimum saving on energy.
3. Data is repetitive, and the rate is fixed a priori. Depending on allotted time slots, called GTS
(guaranteed time slot), devices operate for fixed durations.

ZigBee employs either of two modes, beacon or non-beacon to enable the to-and-fro data traffic.
Beacon mode is used when the coordinator runs on batteries and thus offers maximum power
savings, whereas the non-beacon mode finds favour when the coordinator is mains-powered.

In the beacon mode, a device watches out for the coordinator's beacon that gets transmitted at
periodically, locks on and looks for messages addressed to it. If message transmission is
complete, the coordinator dictates a schedule for the next beacon so that the device ‘goes to
sleep'; in fact, the coordinator itself switches to sleep mode.

While using the beacon mode, all the devices in a mesh network know when to communicate
with each other. In this mode, necessarily, the timing circuits have to be quite accurate, or wake
up sooner to be sure not to miss the beacon. This in turn means an increase in power
consumption by the coordinator's receiver, entailing an optimal increase in costs.

Figure 1: Beacon Network Communication

The non-beacon mode will be included in a system where devices are ‘asleep' nearly always, as
in smoke detectors and burglar alarms. The devices wake up and confirm their continued
presence in the network at random intervals.

On detection of activity, the sensors ‘spring to attention', as it were, and transmit to the ever-
waiting coordinator's receiver (since it is mains-powered). However, there is the remotest of
chances that a sensor finds the channel busy, in which case the receiver unfortunately would
‘miss a call'.
Figure 2: Non-Beacon Network Communication

Network Model:

The functions of the Coordinator, which usually remains in the receptive mode, encompass
network set-up, beacon transmission, node management, storage of node information and
message routing between nodes.

The network node, however, is meant to save energy (and so ‘sleeps' for long periods) and its
functions include searching for network availability, data transfer, checks for pending data and
queries for data from the coordinator.
Figure 1: ZigBee Network Model

For the sake of simplicity without jeopardising robustness, this particular IEEE standard defines
a quartet frame structure and a super-frame structure used optionally only by the coordinator.

The four frame structures are

 Beacon frame for transmission of beacons


 Data frame for all data transfers
 Acknowledgement frame for successful frame receipt confirmations
 MAC command frame

These frame structures and the coordinator's super-frame structure play critical roles in security
of data and integrity in transmission.

All protocol layers contribute headers and footers to the frame structure, such that the total
overheads for each data packet range are from 15 octets (for short addresses) to 31 octets (for 64-
bit addresses).

The coordinator lays down the format for the super-frame for sending beacons after every 15.38
ms or/and multiples thereof, up to 252s. This interval is determined a priori and the coordinator
thus enables sixteen time slots of identical width between beacons so that channel access is
contention-less. Within each time slot, access is contention-based. Nonetheless, the coordinator
provides as many as seven GTS (guaranteed time slots) for every beacon interval to ensure better
quality.

Technology Comparisons:
The “Why ZigBee” question has always had an implied, but never quite worded follower phrase
“…when there is Bluetooth”. A comparative study of the two can be found in The bandwidth of
Bluetooth is 1 Mbps, ZigBee's is one-fourth of this value. The strength of Bluetooth lies in its
ability to allow interoperability and replacement of cables, ZigBee's, of course, is low costs and
long battery life.

In terms of protocol stack size, ZigBee's 32 KB is about one-third of the stack size necessary in
other wireless technologies (for limited capability end devices, the stack size is as low as 4 KB).

Most important in any meaningful comparison are the diverse application areas of all the
different wireless technologies. Bluetooth is meant for such target areas as wireless USB's,
handsets and headsets, whereas ZigBee is meant to cater to the sensors and remote controls
market and other battery operated products.

In a gist, it may be said that they are neither complementary standards nor competitors, but just
essential standards for different targeted applications. The earlier Bluetooth targets interfaces
between PDA and other device (mobile phone / printer etc) and cordless audio applications.

The IEEE 802.15.4–based ZigBee is designed for remote controls and sensors, which are very
many in number, but need only small data packets and, mainly, extremely low power
consumption for (long) life. Therefore they are naturally different in their approach to their
respective application arenas.

ZigBee Applications:
The ZigBee Alliance targets applications "across consumer, commercial, industrial and
government markets worldwide".

Unwired applications are highly sought after in many networks that are characterized by
numerous nodes consuming minimum power and enjoying long battery lives.

ZigBee technology is designed to best suit these applications, for the reason that it enables
reduced costs of development, very fast market adoption, and rapid ROI.

Airbee Wireless Inc has tied up with Radio crafts AS to deliver "out-of-the-box" ZigBee-ready
solutions; the former supplying the software and the latter making the module platforms. With
even light controls and thermostat producers joining the ZigBee Alliance, the list is growing
healthily and includes big OEM names like HP, Philips, Motorola and Intel.
With ZigBee designed to enable two-way communications, not only will the consumer be able to
monitor and keep track of domestic utilities usage, but also feed it to a computer system for data
analysis.

A recent analyst report issued by West Technology Research Solutions estimates that by the year
2008, "annual shipments for ZigBee chipsets into the home automation segment alone will
exceed 339 million units," and will show up in "light switches, fire and smoke detectors,
thermostats, appliances in the kitchen, video and audio remote controls, landscaping, and
security systems."

Futurists are sure to hold ZigBee up and say, "See, I told you so". The ZigBee Alliance is nearly
200 strong and growing, with more OEM's signing up. This means that more and more products
and even later, all devices and their controls will be based on this standard. Since Wireless
personal Area Networking applies not only to household devices, but also to individualized
office automation applications, ZigBee is here to stay. It is more than likely the basis of future
home-networking solutions.

Energy Meter

Definition: The meter which is used for measuring the energy utilises by the electric load is
known as the energy meter. The energy is the total power consumed and utilised by the load at
a particular interval of time. It is used in domestic and industrial AC circuit for measuring the
power consumption. The meter is less expensive and accurate.

The expenses incurred on electricity consumption are one of those expenses which one has to
bear on a regular basis. Every month you receive a bill of the electricity which you have
consumed through different appliances. When the bill is surprisingly higher in a certain month,
you start thinking, “How come my bill is so high than the previous month, given that my
electricity consumption pattern has been the same?” In fact, some people are also of the opinion
that electronic meters run faster than electromechanical meters. So is it true? No.

If you have come across this situation, then let us assure you that you are not the only one who
felt like this. In fact, we at Bijli Bachao regularly receive queries regarding the same issue
wherein people say that despite their electricity usage being the same as the previous month,
their electricity bills have spiked. A very important reason for this lies with the electricity meters.

What are electricity meters (energy meters)?

An electricity meter is a device which measures the total electrical energy (or electricity)
consumed by the appliances which draw electrical energy from the main power supply at a house
or an official space and so on. Electricity meters are a common sight in the households today.
When you look at a meter, what do you see? You see a few digits on it. What do these digits
signify? These numbers (the reading on the meter) tell you how many units of electricity
(mentioned as kWh in the meter) have you consumed so far. And your electricity bill is entirely
dependent on this meter.

The reading on the meter is cumulative. So to determine the consumption reading of a particular
month, the difference between the readings of that month and the previous month is calculated.
The value which you get is the electricity consumption of that particular month. Now if this
reading is small, it means that your consumption is low and consequently your electricity bill
will be lower and if the reading is large, it means that your consumption is high and consequently
your electricity bill will also be high.

Types of electricity meters

The electricity meters come in different types. These are:

1. Electromechanical meter: Electromechanical meters were very common in India few


years ago. They still are very popular in the rural areas where the penetration of the modern
technology is not as high as it is in the urban areas. The working of electromechanical meters
is fairly simple. There is a non-magnetic metallic disc attached to it internally which rotates
depending upon the power passing through it. So if the power passing through is high, then
the disc rotates faster and when the passage of the power is low, the disc rotates slower. The
rate of the rotation in turn decides the reading on the electricity meter. Higher the number of
rotation, higher is the reading and vice-versa. Since there is rotation of a disc involved, it is
bound to consume some electrical energy itself to facilitate the rotations. The power of
around 2 Watts is consumed to make it rotate and this power consumption is not registered on

the meter.

2. Electronic meter: Electronic meters are becoming increasingly popular now-a-days in urban
areas. An electronic meter has a LED/LCD display on which the readings of the electricity
consumption of the connected appliances. The readings are digital in the electronic meters in
contrast to the electromechanical meters. These are much more efficient than the
electromechanical meters in the sense that they do register every small unit of electricity

consumed.
3. Smart meter: Smart meters are the newest addition to the type of electricity meters. They
look similar to electronic meters but they are better than both the electromechanical meters
and the electronic meters in the sense that in addition to providing the usual services of a
regular meter, they are connected back to the utility through the internet. It means that there is
no need of an official from the utility (which provides you electricity) to come at your
doorstep and take the meter readings. The readings are automatically sent by the internet.

Problems with the electromechanical meter

Although the electromechanical meters have been quite common in the past years, there are
certain problems that are attributed to them. Since electromechanical meters consist of moving
parts, they are bound to undergo some wear and tear with the passage of time.

In a study conducted by Analog Devices Inc. USA, it was found that the accuracy of a
electromechanical meter deteriorates subject to the various environmental factors such as
humidity, dust and dirt which significantly affect the operating accuracy of the electromechanical
meter. Factors like corrosion, worn out gears and insects can render the electromechanical meter
unable to capture the electricity consumption of a property accurately. The mechanical gear
lubricants may dry up resulting in the breaking in the gear teeth which adversely affects the gear
ratio. Also, the electromechanical meters may get mis-calibrated if they experience a sudden
shock or vibration which may cause a jolt or a sudden stoppage of the rotating disk.

Energy Meter

Definition: The meter which is used for measuring the energy utilises by the electric load is
known as the energy meter. The energy is the total power consumed and utilised by the load at
a particular interval of time. It is used in domestic and industrial AC circuit for measuring the
power consumption. The meter is less expensive and accurate.

Construction of Energy Meter

The construction of the single phase energy meter is shown in the figure below.
The energy meter has four main parts. They are the

1. Driving System
2. Moving System
3. Braking System
4. Registering System

The detail explanation of their parts is written below.

1. Driving System – The electromagnet is the main component of the driving system. It is the
temporary magnet which is excited by the current flow through their coil. The core of the
electromagnet is made up of silicon steel lamination. The driving system has two electromagnets.
The upper one is called the shunt electromagnet, and the lower one is called series
electromagnet.

The series electromagnet is excited by the load current flow through the current coil. The coil of
the shunt electromagnet is directly connected with the supply and hence carry the current
proportional to the shunt voltage. This coil is called the pressure coil.

The centre limb of the magnet has the copper band. These bands are adjustable. The main
function of the copper band is to align the flux produced by the shunt magnet in such a way that
it is exactly perpendicular to the supplied voltage.

2. Moving System – The moving system is the aluminium disc mounted on the shaft of the
alloy. The disc is placed in the air gap of the two electromagnets. The eddy current is induced in
the disc because of the change of the magnetic field. This eddy current is cut by the magnetic
flux. The interaction of the flux and the disc induces the deflecting torque.

When the devices consume power, the aluminium disc starts rotating, and after some number of
rotations, the disc displays the unit used by the load. The number of rotations of the disc is
counted at particular interval of time. The disc measured the power consumption in kilowatt
hours

3. Braking system – The permanent magnet is used for reducing the rotation of the aluminium
disc. The aluminium disc induces the eddy current because of their rotation. The eddy current cut
the magnetic flux of the permanent magnet and hence produces the braking torque.

This braking torque opposes the movement of the disc, thus reduces their speed. The permanent
magnet is adjustable due to which the braking torque is also adjusted by shifting the magnet to
the other radial position.

4. Registration (Counting Mechanism) – The main function of the registration or counting


mechanism is to record the number of rotations of the aluminium disc. Their rotation is directly
proportional to the energy consumed by the loads in the kilowatt hour.
The rotation of the disc is transmitted to the pointers of the different dial for recording the
different readings. The reading in kWh is obtained by multiply the number of rotations of the
disc with the meter constant. The figure of the dial is shown below.

Working of the Energy Meter

The energy meter has the aluminium disc whose rotation determines the power consumption of
the load. The disc is placed between the air gap of the series and shunt electromagnet. The shunt
magnet has the pressure coil, and the series magnet has the current coil.

The pressure coil creates the magnetic field because of the supply voltage, and the current coil
produces it because of the current.

The field induces by the voltage coil is lagging by 90º on the magnetic field of the current coil
because of which eddy current induced in the disc. The interaction of the eddy current and the
magnetic field causes torque, which exerts a force on the disc. Thus, the disc starts rotating.
The force on the disc is proportional to the current and voltage of the coil. The permanent
magnet controls Their rotation. The permanent magnet opposes the movement of the disc and
equalises it on the power consumption. The cyclometer counts the rotation of the disc.

Theory of Energy Meter

The pressure coil has the number of turns which makes it more inductive. The reluctance path of
their magnetic circuit is very less because of the small length air gap. The current Ip flows
through the pressure coil because of the supply voltage, and it lags by 90º.

The Ip produces the two Φp which is again divided into Φp1 and Φp2. The major portion of the
flux Φp1 passes through the side gap because of low reluctance. The flux Φp2 goes through the
disc and induces the driving torque which rotates the aluminium disc.

The flux Φp is proportional to the applied voltage, and it is lagged by an angle of 90º. The flux is
alternating and hence induces an eddy current Iep in the disc.

The load current passes through the current coil induces the flux Φs. This flux causes the eddy
current Ies on the disc. The eddy current Ies interacts with the flux Φp, and the eddy current
Iep interacts with Φs to produce the another torque. These torques are opposite in direction, and
the net torque is the difference between these two.

The phasor diagram of the energy meter is shown in the figure below.

Let
V – applied voltage
I – load current
∅ – the phase angle of load current
Ip – pressure angle of load
Δ – the phase angle between supply voltage and pressure coil flux
f – frequency
Z – impedance of eddy current
∝ – the phase angle of eddy current paths
Eep – eddy current induced by flux
Iep – eddy current due to flux
Eev – eddy current due to flux
Ies – eddy current due to flux

The net driving torque of the dis is expressed as

where K1 – constant

Φ1 and Φ2 are the phase angle between the fluxes. For energy meter, we take Φp and Φs.

β – phase angle between fluxes Φp and Φp = (Δ – Φ), therefore

If f, Z and α are constants,

If N is steady speed, braking torque


At steady state, the speed of the driving torque is equal to the braking torque.

If Δ = 90º,

Speed,

The speed of the rotation is directly proportional to the power.

If Δ = 90º, total number of revolutions

The three phase energy meter is used for measuring the large power consumption.

Keil Software

Installing the Keil software on a Windows PC


 Insert the CD-ROM in your computer’s CD drive
 On most computers, the CD will “auto run”, and you will see the Keil installation menu.
If the menu does not appear, manually double click on the Setup icon, in the root
directory: you will then see the Keil menu.
 On the Keil menu, please select “Install Evaluation Software”. (You will not require a
license number to install this software).
 Follow the installation instructions as they appear.

Loading the Projects

The example projects for this book are NOT loaded automatically when you install the Keil
compiler.
These files are stored on the CD in a directory “/Pont”. The files are arranged by chapter: for
example, the project discussed in Chapter 3 is in the directory “/Pont/Ch03_00-Hello”.

Rather than using the projects on the CD (where changes cannot be saved), please copy the
files from CD onto an appropriate directory on your hard disk.

Note: you will need to change the file properties after copying: file transferred from the CD will
be ‘read only’.

Configuring the Simulator


Open the Keil Vision2

Go to Project – Open Project and browse for Hello in Ch03_00 in Pont and open it.

Go to Project – Select Device for Target ‘Target1’


Select 8052(all variants) and click OK
Now we need to check the oscillator frequency:

Go to project – Options for Target ‘Target1’


Make sure that the oscillator frequency is 12MHz.

Building the Target

Build the target as illustrated in the figure below


Running the Simulation

Having successfully built the target, we are now ready to start the debug session and run the
simulator.
First start a debug session
The flashing LED we will view will be connected to Port 1. We therefore want to observe the
activity on this port
To ensure that the port activity is visible, we need to start the ‘periodic window update’ flag
Go to Debug - Go

While the simulation is running, view the performance analyzer to check the delay durations.
Go to Debug – Performance Analyzer and click on it

Double click on DELAY_LOOP_Wait in Function Symbols: and click Define button


Source code:

Result:

Vous aimerez peut-être aussi