You are on page 1of 125

INDEX

TOPICS
Certificates
Acknowledgement........
CHAPTE !" INTOD#CTION
!.! Introd$ction of t%e &ro'ect
!.( Pro'ect o)er)iew...
!.* T%esis
CHAPTE (" E+,EDDED S-STE+S
(.! Introd$ction to em.edded s/stems
(.( Need of em.edded s/stems...
(.* E0&lanation of em.edded s/stems...
(.1 A&&lications of em.edded s/stems
CHAPTE *" HAD2AE DESCIPTION
*.! Introd$ction wit% .lock diagram
*.( +icrocontroller.
*.* eg$lated &ower s$&&l/...
*.1 3ED indicator........
*.4 Energ/ +eter.........
*.5 O&toco$&ler...
*.6 7S+...
1
*.8 ela/...
*.9 3CD....
*.!: Tam&er switc%...
CHAPTE 1" SO;T2AE DESCIPTION
1.! E0&ress PC,
1.( PIC C Com&iler.
1.* Prote$s software
1.1 Proced$ral ste&s for com&ilation< sim$lation and d$m&ing..
CHAPTE 4" PO=ECT DESCIPTION
CHAPTE 5" AD>ANTA7ES< DISAD>ANTA7ES AND APP3ICATIONS
CHAPTE 6" ES#3TS< CONC3#SION< ;#T#E POSPECTS
E;EENCES
2
CHAPTE !" INTOD#CTION
!.! Introd$ction"
The purpose of this project is to design a system which helps in remote monitoring and control
of the Domestic Energy meter through simply sending an SMS. This system enables the Electricity
Department to read the meter readings regularly without the person visiting each house. This can be
achieved by the use of Microcontroller unit that continuously monitors and records the Energy Meter
readings in its permanent (non-volatile memory location. This system also ma!es use of a "SM
modem for remote monitoring and control of Energy Meter.
The modules in the project are# "SM modem for establishing communication between system
at house and electricity department$ Energy meter which continuously gives usage details$ %&D to
display current reading of meter$ 'elay to disconnect the power in case of nonpayment of bill.
The Microcontroller based system continuously records the readings and the live meter
reading and will be sent to the Electricity department on re(uest. This system also can be used to
disconnect the power supply to the house in case of non-payment of electricity bills. ) dedicated "SM
modem with S*M card is re(uired for each energy meter. The Microcontroller which acts as a
controlling unit of the whole system is loaded with intelligent software programmed using Embedded
& language.
;eat$res"
+. ,rovides user friendly remote energy meter monitoring.
-. Supports controlling of meter.
.. &an be controlled anywhere in the world.
/. 0on-volatile memory based energy-reading storing.
1. )uto disconnect feature.
!.( Pro'ect O)er)iew"
)n embedded system is a combination of software and hardware to perform a
dedicated tas!. Some of the main devices used in embedded products are Microprocessors and
Microcontrollers.
3
Microprocessors are commonly referred to as general purpose processors as they
simply accept the inputs$ process it and give the output. *n contrast$ a microcontroller not only accepts
the data as inputs but also manipulates it$ interfaces the data with various devices$ controls the data
and thus finally gives the result.
The project 2 Energ/ +eter monitoring and control s/stem $sing S+S
tec%nolog/3 using +45677) Microcontroller is an e8clusive project that can be used
!.* T%esis O)er)iew"
The thesis e8plains the implementation of 2 Energ/ +eter monitoring and
control s/stem $sing S+S tec%nolog/3 using +45677) microcontroller. The organi9ation of the
thesis is e8plained here with#
C%a&ter ! ,resents introduction to the overall thesis and the overview of the project. *n the project
overview a brief introduction of microcontrollers$ energy meter and its applications are discussed.
C%a&ter ( ,resents the topic embedded systems. *t e8plains the about what is embedded systems$
need for embedded systems$ e8planation of it along with its applications.
C%a&ter * ,resents the hardware description. *t deals with the bloc! diagram of the project and
e8plains the purpose of each bloc!. *n the same chapter the e8planation of microcontrollers$ power
supplies$ energy meter$ %&D$ "SM modem$ tamper switch$ 'elay are considered.
C%a&ter 1 ,resents the software description. *t e8plains the implementation of the project using ,*&
& &ompiler software.
C%a&ter 4 &resents the project description along with energy meter$ %&D$ "SM modem$ tamper
switch$ and 'elay modules interfacing to microcontroller.
C%a&ter 5 ,resents the advantages$ disadvantages and applications of the project.
C%a&ter 6 ,resents the results$ conclusion and future scope of the project.
4
CHAPTE (" E+,EDDED S-STE+S
(.! Em.edded S/stems"
)n embedded system is a computer system designed to perform one or a few dedicated
functions often with real-time computing constraints. *t is embedded as part of a complete device
often including hardware and mechanical parts. :y contrast$ a general-purpose computer$ such as a
personal computer (,&$ is designed to be fle8ible and to meet a wide range of end-user needs.
Embedded systems control many devices in common use today.
Embedded systems are controlled by one or more main processing cores that are
typically either microcontrollers or digital signal processors (DS,. The !ey characteristic$ however$ is
being dedicated to handle a particular tas!$ which may re(uire very powerful processors. 5or e8ample$
air traffic control systems may usefully be viewed as embedded$ even though they involve mainframe
computers and dedicated regional and national networ!s between airports and radar sites. (Each radar
probably includes one or more embedded systems of its own.
Since the embedded system is dedicated to specific tas!s$ design engineers can
optimi9e it to reduce the si9e and cost of the product and increase the reliability and performance.
Some embedded systems are mass-produced$ benefiting from economies of scale.
,hysically embedded systems range from portable devices such as digital watches and
M,. players$ to large stationary installations li!e traffic lights$ factory controllers$ or the systems
controlling nuclear power plants. &omple8ity varies from low$ with a single microcontroller chip$ to
very high with multiple units$ peripherals and networ!s mounted inside a large chassis or enclosure.
*n general$ ;embedded system; is not a strictly definable term$ as most systems have
some element of e8tensibility or programmability. 5or e8ample$ handheld computers share some
elements with embedded systems such as the operating systems and microprocessors which power
them$ but they allow different applications to be loaded and peripherals to be connected. Moreover$
even systems which don<t e8pose programmability as a primary feature generally need to support
software updates. =n a continuum from ;general purpose; to ;embedded;$ large application systems
will have subcomponents at most points even if the system as a whole is ;designed to perform one or
a few dedicated functions;$ and is thus appropriate to call ;embedded;. ) modern e8ample of
embedded system is shown in fig# -.+.
5
;ig (.!"A modern e0am&le of em.edded s/stem
%abeled parts include microprocessor (/$ ')M (4$ flash memory (7.Embedded
systems programming is not li!e normal ,& programming. *n many ways$ programming for an
embedded system is li!e programming ,& +1 years ago. The hardware for the system is usually
chosen to ma!e the device as cheap as possible. Spending an e8tra dollar a unit in order to ma!e
things easier to program can cost millions. >iring a programmer for an e8tra month is cheap in
comparison. This means the programmer must ma!e do with slow processors and low memory$ while
at the same time battling a need for efficiency not seen in most ,& applications. :elow is a list of
issues specific to the embedded field.
(.!.! Histor/"
*n the earliest years of computers in the +?.@A/@s$ computers were sometimes
dedicated to a single tas!$ but were far too large and e8pensive for most !inds of tas!s performed by
embedded computers of today. =ver time however$ the concept of programmable controllers evolved
from traditional electromechanical se(uencers$ via solid state devices$ to the use of computer
technology.
=ne of the first recogni9ably modern embedded systems was the )pollo "uidance
&omputer$ developed by &harles Star! Draper at the M*T *nstrumentation %aboratory. )t the project<s
inception$ the )pollo guidance computer was considered the ris!iest item in the )pollo project as it
employed the then newly developed monolithic integrated circuits to reduce the si9e and weight. )n
6
early mass-produced embedded system was the )utonetics D-+7 guidance computer for
the Minuteman missile$ released in +?4+. *t was built from transistor logic and had a hard dis! for
main memory. Bhen the Minuteman ** went into production in +?44$ the D-+7 was replaced with a
new computer that was the first high-volume use of integrated circuits.
(.!.( Tools"
Embedded development ma!es up a small fraction of total programming. There<s also a
large number of embedded architectures$ unli!e the ,& world where + instruction set rules$ and the
Cni8 world where there<s only . or / major ones. This means that the tools are more e8pensive. *t also
means that they<re lowering featured$ and less developed. =n a major embedded project$ at some point
you will almost always find a compiler bug of some sort.
Debugging tools are another issue. Since you can<t always run general programs on
your embedded processor$ you can<t always run a debugger on it. This ma!es fi8ing your program
difficult. Special hardware such as DT)" ports can overcome this issue in part. >owever$ if you stop
on a brea!point when your system is controlling real world hardware (such as a motor$ permanent
e(uipment damage can occur. )s a result$ people doing embedded programming (uic!ly become
masters at using serial *= channels and error message style debugging.
(.!.* eso$rces"
To save costs$ embedded systems fre(uently have the cheapest processors that can do
the job. This means your programs need to be written as efficiently as possible. Bhen dealing with
large data sets$ issues li!e memory cache misses that never matter in ,& programming can hurt you.
%uc!ily$ this won<t happen too often- use reasonably efficient algorithms to start$ and optimi9e only
when necessary. =f course$ normal profilers won<t wor! well$ due to the same reason debuggers don<t
wor! well.
Memory is also an issue. 5or the same cost savings reasons$ embedded systems usually
have the least memory they can get away with. That means their algorithms must be memory efficient
(unli!e in ,& programs$ you will fre(uently sacrifice processor time for memory$ rather than the
reverse. *t also means you can<t afford to lea! memory. Embedded applications generally use
deterministic memory techni(ues and avoid the default ;new; and ;malloc; functions$ so that lea!s
can be found and eliminated more easily. =ther resources programmers e8pect may not even e8ist.
7
5or e8ample$ most embedded processors do not have hardware 5,Cs (5loating-,oint ,rocessing
Cnit. These resources either need to be emulated in software$ or avoided altogether.
(.!.1 eal Time Iss$es"
Embedded systems fre(uently control hardware$ and must be able to respond to them
in real time. 5ailure to do so could cause inaccuracy in measurements$ or even damage hardware such
as motors. This is made even more difficult by the lac! of resources available. )lmost all embedded
systems need to be able to prioriti9e some tas!s over others$ and to be able to put offEs!ip low priority
tas!s such as C* in favor of high priority tas!s li!e hardware control.
(.( Need ;or Em.edded S/stems"
The uses of embedded systems are virtually limitless$ because every day new products
are introduced to the mar!et that utili9es embedded computers in novel ways. *n recent years$
hardware such as microprocessors$ microcontrollers$ and 5,") chips have become much cheaper. So
when implementing a new form of control$ it<s wiser to just buy the generic chip and write your own
custom software for it. ,roducing a custom-made chip to handle a particular tas! or set of tas!s costs
far more time and money. Many embedded computers even come with e8tensive libraries$ so that
;writing your own software; becomes a very trivial tas! indeed. 5rom an implementation viewpoint$
there is a major difference between a computer and an embedded system. Embedded systems are often
re(uired to provide 'eal-Time response. The main elements that ma!e embedded systems uni(ue are
its reliability and ease in debugging.
(.(.! De.$gging"
Embedded debugging may be performed at different levels$ depending on the facilities
available. 5rom simplest to most sophisticate they can be roughly grouped into the following areas#
*nteractive resident debugging$ using the simple shell provided by the embedded operating
system (e.g. 5orth and :asic
E8ternal debugging using logging or serial port output to trace operation using either a
monitor in flash or using a debug server li!e the 'emedy Debugger which even wor!s for
heterogeneous multi core systems.
8
)n in-circuit debugger (*&D$ a hardware device that connects to the microprocessor via a
DT)" or 0e8us interface. This allows the operation of the microprocessor to be controlled
e8ternally$ but is typically restricted to specific debugging capabilities in the processor.
)n in-circuit emulator replaces the microprocessor with a simulated e(uivalent$ providing full
control over all aspects of the microprocessor.
) complete emulator provides a simulation of all aspects of the hardware$ allowing all of it to
be controlled and modified and allowing debugging on a normal ,&.
Cnless restricted to e8ternal debugging$ the programmer can typically load and run software
through the tools$ view the code running in the processor$ and start or stop its operation. The
view of the code may be as assembly code or source-code.
:ecause an embedded system is often composed of a wide variety of elements$ the
debugging strategy may vary. 5or instance$ debugging a software(and microprocessor centric
embedded system is different from debugging an embedded system where most of the processing is
performed by peripherals (DS,$ 5,")$ co-processor. )n increasing number of embedded systems
today use more than one single processor core. ) common problem with multi-core development is
the proper synchroni9ation of software e8ecution. *n such a case$ the embedded system design may
wish to chec! the data traffic on the busses between the processor cores$ which re(uires very low-
level debugging$ at signalEbus level$ with a logic analy9er$ for instance.
(.(.( elia.ilit/"
Embedded systems often reside in machines that are e8pected to run continuously for
years without errors and in some cases recover by them selves if an error occurs. Therefore the
software is usually developed and tested more carefully than that for personal computers$ and
unreliable mechanical moving parts such as dis! drives$ switches or buttons are avoided.
Specific reliability issues may include#
The system cannot safely be shut down for repair$ or it is too inaccessible to repair. E8amples
include space systems$ undersea cables$ navigational beacons$ bore-hole systems$ and
automobiles.
The system must be !ept running for safety reasons. ;%imp modes; are less tolerable. =ften
bac!ups are selected by an operator. E8amples include aircraft navigation$ reactor control
9
systems$ safety-critical chemical factory controls$ train signals$ engines on single-engine
aircraft.
The system will lose large amounts of money when shut down# Telephone switches$ factory
controls$ bridge and elevator controls$ funds transfer and mar!et ma!ing$ automated sales and
service.
) variety of techni(ues are used$ sometimes in combination$ to recover from errorsF
both software bugs such as memory lea!s$ and also soft errors in the hardware#
Batchdog timer that resets the computer unless the software periodically notifies the watchdog
Subsystems with redundant spares that can be switched over to
software ;limp modes; that provide partial function
Designing with a Trusted &omputing :ase (T&: architectureG4H ensures a highly secure I
reliable system environment
)n Embedded >ypervisor is able to provide secure encapsulation for any subsystem
component$ so that a compromised software component cannot interfere with other
subsystems$ or privileged-level system software. This encapsulation !eeps faults from
propagating from one subsystem to another$ improving reliability. This may also allow a
subsystem to be automatically shut down and restarted on fault detection.
*mmunity )ware ,rogramming
(.* E0&lanation of Em.edded S/stems"
(.*.! Software Arc%itect$re"
There are several different types of software architecture in common use.
Simple &ontrol %oop#
*n this design$ the software simply has a loop. The loop calls subroutines$ each of which
manages a part of the hardware or software.
*nterrupt &ontrolled System#
Some embedded systems are predominantly interrupt controlled. This means that tas!s
performed by the system are triggered by different !inds of events. )n interrupt could be generated
10
for e8ample by a timer in a predefined fre(uency$ or by a serial port controller receiving a byte. These
!inds of systems are used if event handlers need low latency and the event handlers are short and
simple.
Csually these !inds of systems run a simple tas! in a main loop also$ but this tas! is not
very sensitive to une8pected delays. Sometimes the interrupt handler will add longer tas!s to a (ueue
structure. %ater$ after the interrupt handler has finished$ these tas!s are e8ecuted by the main loop.
This method brings the system close to a multitas!ing !ernel with discrete processes.
&ooperative Multitas!ing#
) non-preemptive multitas!ing system is very similar to the simple control loop
scheme$ e8cept that the loop is hidden in an ),*. The programmer defines a series of tas!s$ and each
tas! gets its own environment to 2run3 in. Bhen a tas! is idle$ it calls an idle routine$ usually called
2pause3$ 2wait3$ 2yield3$ 2nop3 (stands for no operation$ etc. The advantages and disadvantages are
very similar to the control loop$ e8cept that adding new software is easier$ by simply writing a new
tas!$ or adding to the (ueue-interpreter.
,rimitive Multitas!ing#
*n this type of system$ a low-level piece of code switches between tas!s or threads
based on a timer (connected to an interrupt. This is the level at which the system is generally
considered to have an ;operating system; !ernel. Depending on how much functionality is re(uired$ it
introduces more or less of the comple8ities of managing multiple tas!s running conceptually in
parallel.
)s any code can potentially damage the data of another tas! (e8cept in larger systems
using an MMC programs must be carefully designed and tested$ and access to shared data must be
controlled by some synchroni9ation strategy$ such as message (ueues$ semaphores or a non-bloc!ing
synchroni9ation scheme.
:ecause of these comple8ities$ it is common for organi9ations to buy a real-time
operating system$ allowing the application programmers to concentrate on device functionality rather
than operating system services$ at least for large systemsJ smaller systems often cannot afford the
overhead associated with a generic real time system$ due to limitations regarding memory si9e$
performance$ andEor battery life.
11
Micro!ernels )nd E8o!ernels#
) micro!ernel is a logical step up from a real-time =S. The usual arrangement is that
the operating system !ernel allocates memory and switches the &,C to different threads of e8ecution.
Cser mode processes implement major functions such as file systems$ networ! interfaces$ etc.
*n general$ micro!ernels succeed when the tas! switching and intertas! communication
is fast$ and fail when they are slow. E8o!ernels communicate efficiently by normal subroutine calls.
The hardware and all the software in the system are available to$ and e8tensible by application
programmers. :ased on performance$ functionality$ re(uirement the embedded systems are divided
into three categories#
(.*.( Stand Alone Em.edded S/stem"
These systems ta!es the input in the form of electrical signals from transducers or
commands from human beings such as pressing of a button etc..$ process them and produces desired
output. This entire process of ta!ing input$ processing it and giving output is done in standalone mode.
Such embedded systems comes under stand alone embedded systems
Eg# microwave oven$ air conditioner etc..
(.*.* eal?time em.edded s/stems"
Embedded systems which are used to perform a specific tas! or operation in a specific
time period those systems are called as real-time embedded systems. There are two types of real-time
embedded systems.
>ard 'eal-time embedded systems#
These embedded systems follow an absolute dead line time period i.e..$ if the tas!ing is
not done in a particular time period then there is a cause of damage to the entire e(uipment.
Eg# consider a system in which we have to open a valve within .@ milliseconds. *f this valve is
not opened in .@ ms this may cause damage to the entire e(uipment. So in such cases we use
embedded systems for doing automatic operations.
Soft 'eal Time embedded systems#
12
Eg# &onsider a TK remote control system$ if the remote control ta!es a few milliseconds delay it will
not cause damage either to the TK or to the remote control. These systems which will not cause damage when
they are not operated at considerable time period those systems comes under soft real-time embedded systems.
(.*.1 Network comm$nication em.edded s/stems"
) wide range networ! interfacing communication is provided by using embedded
systems.
Eg#
&onsider a web camera that is connected to the computer with internet can be used to
spread communication li!e sending pictures$ images$ videos etc..$ to another computer
with internet connection throughout anywhere in the world.
&onsider a web camera that is connected at the door loc!.
Bhenever a person comes near the door$ it captures the image of a person and sends to
the des!top of your computer which is connected to internet. This gives an alerting message with
image on to the des!top of your computer$ and then you can open the door loc! just by clic!ing the
mouse. 5ig# -.- show the networ! communications in embedded systems.
;ig (.(" Network comm$nication em.edded s/stems
13
(.*.4 Different t/&es of &rocessing $nits"
The central processing unit (c.p.u can be any one of the following microprocessor$
microcontroller$ digital signal processing.
)mong these Microcontroller is of low cost processor and one of the main advantage of
microcontrollers is$ the components such as memory$ serial communication interfaces$ analog
to digital converters etc..$ all these are built on a single chip. The numbers of e8ternal
components that are connected to it are very less according to the application.
Microprocessors are more powerful than microcontrollers. They are used in major applications
with a number of tas!ing re(uirements. :ut the microprocessor re(uires many e8ternal
components li!e memory$ serial communication$ hard dis!$ input output ports etc..$ so the
power consumption is also very high when compared to microcontrollers.
Digital signal processing is used mainly for the applications that particularly involved with
processing of signals
(.1 APP3ICATIONS O; E+,EDDED S-STE+S"
(.1.! Cons$mer a&&lications"
)t home we use a number of embedded systems which include microwave oven$
remote control$ vcd players$ dvd players$ camera etcL.
;ig(.*" A$tomatic coffee makes e@$i&ment
14
(.1.( Office a$tomation"
Be use systems li!e fa8 machine$ modem$ printer etcL

;ig(.1" ;a0 mac%ine ;ig(.4" Printing mac%ine
(.1.*. Ind$strial a$tomation"
Today a lot of industries are using embedded systems for process control. *n industries
we design the embedded systems to perform a specific operation li!e monitoring temperature$
pressure$ humidity $voltage$ current etc..$ and basing on these monitored levels we do control other
devices$ we can send information to a centrali9ed monitoring station.
;ig(.5" o.ot
*n critical industries where human presence is avoided there we can use robots which
are programmed to do a specific operation.
15
(.1.4 Com&$ter networking"
Embedded systems are used as bridges routers etc..

;ig(.6" Com&$ter networking
(.1.5 Tele comm$nications"
&ell phones$ web cameras etc.

;ig(.8" Cell P%one ;ig(.9" 2e. camera

CHAPTE *" HAD2AE DESCIPTION"
16
*.! Introd$ction#
*n this chapter the bloc! diagram of the project and design aspect of independent
modules are considered. :loc! diagram is shown in fig# ..+#
;I7 *.!" ,lock diagram of 7S+ OPEATION DI7ITA3 ENE7- +ETE
T%e main .locks of t%is &ro'ect are#
+. Micro controller (+45677)
-. 'eset button
.. &rystal oscillator
/. 'egulated power supply (',S
17
1. %ed indicator
4. Energy meter
7. =ptocoupler
6. "SM modem
?. 'elay
+@. %&D
++. Tamper switch
*.( +icro controller"
+icro controller"
;ig" *.( +icrocontrollers
*.(.! Introd$ction to +icrocontrollers"
&ircumstances that we find ourselves in today in the field of microcontrollers had their
beginnings in the development of technology of integrated circuits. This development has made it
possible to store hundreds of thousands of transistors into one chip. That was a prere(uisite for
production of microprocessors$ and the first computers were made by adding e8ternal peripherals such
as memory$ input-output lines$ timers and other. 5urther increasing of the volume of the pac!age
resulted in creation of integrated circuits. These integrated circuits contained both processor and
peripherals. That is how the first chip containing a microcomputer$ or what would later be !nown as a
microcontroller came about.
18
Microprocessors and microcontrollers are widely used in embedded systems products.
Microcontroller is a programmable device. ) microcontroller has a &,C in addition to a fi8ed amount
of ')M$ '=M$ *E= ports and a timer embedded all on a single chip. The fi8ed amount of on-chip
'=M$ ')M and number of *E= ports in microcontrollers ma!es them ideal for many applications in
which cost and space are critical.
The microcontroller used in this project is ,*&+45677). The ,*& families of
microcontrollers are developed by Microchip Technology *nc. &urrently they are some of the most
popular microcontrollers$ selling over +-@ million devices each year. There are basically four families
of ,*& microcontrollers#
,*&+-&MMM +-E+/-bit program word
,*& +4&1M +--bit program word
,*&+4&MMM and ,*&+45MMM +/-bit program word
,*&+7&MMM and ,*&+6&MMM +4-bit program word
The features$ pin description of the microcontroller used are discussed in the following sections.
*.(.( Descri&tion"
*ntroduction to PIC Microcontrollers:
,*& stands for ,eripheral *nterface &ontroller given by Microchip Technology to
identify its single-chip microcontrollers. These devices have been very successful in 6-bit
microcontrollers. The main reason is that Microchip Technology has continuously upgraded the
device architecture and added needed peripherals to the microcontroller to suit customers<
re(uirements. The development tools such as assembler and simulator are freely available on the
internet at www.microchip.com
Low - end PIC Architectres:
Microchip ,*& microcontrollers are available in various types. Bhen ,*&
microcontroller M&C was first available from "eneral *nstruments in early +?6@<s$ the
microcontroller consisted of a simple processor e8ecuting +--bit wide instructions with basic *E=
functions. These devices are !nown as low-end architectures. They have limited program memory and
19
are meant for applications re(uiring simple interface functions and small program I data memories.
Some of the low-end device numbers are
+-&1MM
+4&1M
+4&1@1
Mid r!n"e PIC Architectres:
Mid range ,*& architectures are built by upgrading low-end architectures with more number of
peripherals$ more number of registers and more dataEprogram memory. Some of the mid-range
devices are
+4&4M
+4&7M
+4567M
,rogram memory type is indicated by an alphabet.
& N E,'=M$ 5 N 5lash$ '& N Mas! '=M
,opularity of the ,*& microcontrollers is due to the following factors.
+. Speed# >arvard )rchitecture$ '*S& architecture$ + instruction cycle N / cloc! cycles.
-. *nstruction set simplicity# The instruction set consists of just .1 instructions (as opposed to +++
instructions for 6@1+.
.. ,ower-on-reset and brown-out reset. :rown-out-reset means when the power supply goes
below a specified voltage (say /K$ it causes ,*& to resetJ hence malfunction is avoided. )
watch dog timer (user programmable resets the processor if the softwareEprogram ever
malfunctions and deviates from its normal operation.
/. ,*& microcontroller has four optional cloc! sources.
%ow power crystal
Mid range crystal
>igh range crystal
20
'& oscillator (low cost.
1. ,rogrammable timers and on-chip )D&.
4. Cp to +- independent interrupt sources.
7. ,owerful output pin control (-1 m) (ma8. current sourcing capability per pin.
6. E,'=ME=T,E'=ME5lash memory option.
?. *E= port e8pansion capability.
CP# Architectre:
The &,C uses >arvard architecture with separate ,rogram and Kariable (data memory interface.
This facilitates instruction fetch and the operation on dataEaccessing of variables simultaneously.
)rchitecture of ,*& microcontroller
;ig.*.*.Arc%itect$re of PIC microcontroller
:asically$ all ,*& microcontrollers offer the following features#
'*S& instruction set with around .1 instructions O? Digital *E= ports
=n-chip timer with 6-bit prescaler.
,ower-on reset
Batchdog timer
,ower saving S%EE, mode
Direct$ indirect$ and relative addressing modes
E8ternal cloc! interface
')M data memory
E,'=M (or =T, program memory
21
,eripheral features"
>igh sin!Esource current -1m)
Timer@# 6-bit timerEcounter with 6-bit prescaler can be incremented during sleep via e8ternal
crystalEcloc!
Timer-#6-bit timerEcounter with 6-bit period register prescaler and post scalar.
&apture$ &ompare$ ,BM (&&, module
&apture is +4-bit$ ma8 resolution is +-.1ns
&ompare is +4-bit$ ma8 resolution is -@@ ns
,BM ma8$ resolution is +@-bit
6-bit 1 channel analog-to-digital converter
Synchronous serial port (SS, with S,* (MasterESlave and (Slave
Some devices offer the following additional features#
)nalogue input channels
)nalogue comparators
)dditional timer circuits
EE,'=M data memory
5lash EE,'=M program memory
E8ternal and timer interrupts
*n-circuit programming
*nternal oscillator
CS)'T serial interface
*.(.* Pin diagram"

22
;ig.*.1.PIN DIA7A+ O; PIC!5;866
,ic+4f677 is a /@ pin microcontroller. *t has 1 ports port )$ port :$ port &$ port D$ port E. )ll the pins
of the ports are for interfacing input output devices.
,ort )# *t consists of 4 pins from )@ to )1
,ort :# *t consists of 6 pins from :@ to :7
,ort &# *t consists of 6 pins from &@ to &7
,ort D# *t consists of 6 pins from D@ to D7
,ort E# *t consists of . pins from E@ to E-
The rest of the pins are mandatory pins these should not be used to connect inputEoutput devices.
,in + is M&%' (master clear pin pin also referred as reset pin.
23
,in +.$ +/ are used for crystal oscillator to connect to generate a fre(uency of about -@M>9.
,in ++$ +- and.+$ .- are used for voltage supply Kdd(Pand Kss(-
,*& +45677) Specification#
')M .46 bytes
EE,'=M -14 bytes
5lash ,rogram Memory 6! words
=perating 5re(uency D& to -@M>9
*E= port ,ort )$:$&$D$E
This is the specification for ,*&+45677) from Microchip. ) single microcontroller
which is very brilliant and useful. )lso this microcontroller is very easy to be assembled$ program and
also the price is very cheap. *t cost less than +@ dollar. The good thing is that single unit can be
purchased at that +@ dollar price. Cnli!e some other *ntegrated &ircuit that must be bought at a
minimum order (uantity such as +@@@ units or -@@@ units or else you wonQt be able to purchase it.
=ne unit of ,*&+45677) microcontroller can be programmed and erased so many times.
Some said about +@ @@@ times. *f you are doing programming and downloading your code into the
,*& -@ times a day that means you can do that for 1@@ days which is more than a yearR
The erasing time is almost unnoticeable because once new program are loaded into the ,*&$
the old program will automatically be erased immediately. During my time of Degree study$ * did not
use ,*& but * use other type of microcontroller. * have to wait for about +1 to .@ minutes to erase the
EE,'=M before * can load a new program and test the microcontroller. =ne day * can only modify
my code and test it for less than +@ times. +@8+1 minutes N +1@ minutes.
A+"
24
,*&+45677) already made with .46 bytes of 'andom )ccess Memory (')M inside it. )ny
temporary variable storage that we wrote in our program will be stored inside the ')M. Csing this
microcontroller you donQt need to buy any e8ternal ')M.
EEPO+"
-14 bytes of EE,'=M are available also inside this microcontroller. This is very useful to
store information such as ,*0 0umber$ Serial 0umber and so on. Csing EE,'=M is very important
because data stored inside EE,'=M will be retained when power supply is turn off. ')M did not
store data permanently. Data inside ')M is not retained when power supply is turn off.
The si9e of program code that can be stored is about 6! words inside ,*&+45677) '=M. +
word si9e is +/ bits. :y using the free version of the &&S & compiler only -! words of program can
be written and compiled. To write 6! words of & program you have to purchase the original &&S &
compiler and it cost less than 7@@ dollar.
Cr/stal oscillator#
The crystal oscillator speed that can be connected to the ,*& microcontroller range from D& to
-@Mh9. Csing the &&S & compiler normally -@Mh9 oscillator will be used and the price is very
cheap. The -@ M>9 crystal oscillator should be connected with about --p5 capacitor. ,lease refer to
my circuit schematic.
There are 1 inputEoutput ports on ,*& microcontroller namely port )$ port :$ port &$ port D
and port E. Each port has different function. Most of them can be used as *E= port.
*.* E7#3ATED PO2E S#PP3-"
*.*.! Introd$ction"
,ower supply is a supply of electrical power. ) 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 ,SC. The
term is most commonly applied to electrical energy supplies$ less often to mechanical ones$ and rarely
to others.
25
) power supply may include a power distribution system as well as primary or
secondary sources of energy such as
&onversion of one form of electrical power to another desired form and voltage$ typically
involving converting )& line voltage to a well-regulated lower-voltage D& for electronic devices.
%ow voltage$ low power D& power supply units are commonly integrated with the devices they
supply$ such as computers and household electronics.
:atteries.
&hemical fuel cells and other forms of energy storage systems.
Solar power.
"enerators or alternators.
*.*.( ,lock Diagram"
;ig *.*.( eg$lated Power S$&&l/
26
The basic circuit diagram of a regulated power supply (D& =E, with led connected as
load is shown in fig# ......
;ig *.*.* Circ$it diagram of eg$lated Power S$&&l/ wit% 3ed connection

The components mainly used in above figure are
-.@K )& M)*0S
T')0S5='ME'
:'*D"E 'E&T*5*E'(D*=DES
&),)&*T='
K=%T)"E 'E"C%)T='(*& 76@1
'ES*ST='
%ED(%*">T EM*TT*0" D*=DE
The detailed e8planation of each and every component mentioned above is as follows#
Transformation" The process of transforming energy from one device to another is called
transformation. 5or transforming energy we use transformers.
Transformers"
27
) transformer is a device that transfers electrical energy from one circuit to another
through inductively coupled conductors without changing its fre(uency. ) varying current in the first
or primary winding creates a varying magnetic flu8 in the transformer<s core$ and thus a
varying magnetic field through the secondary winding. This varying magnetic field induces a
varying electromotive force (EM5 or ;voltage; in the secondary winding. This effect is called mutual
induction.
*f a load is connected to the secondary$ an electric current will flow in the secondary
winding and electrical energy will be transferred from the primary circuit through the transformer to
the load. This field is made up from lines of force and has the same shape as a bar magnet.
*f the current is increased$ the lines of force move outwards from the coil. *f the current
is reduced$ the lines of force move inwards.
*f another coil is placed adjacent to the first coil then$ as the field moves out or in$ the
moving lines of force will ;cut; the turns of the second coil. )s it does this$ a voltage is induced in the
second coil. Bith the 1@ >9 )& mains supply$ this will happen 1@ times a second. This is called
MCTC)% *0DC&T*=0 and forms the basis of the transformer.
The input coil is called the ,'*M)'S B*0D*0"J the output coil is the
SE&=0D)'S B*0D*0". 5ig# ..../ shows step-down transformer.
;ig *.*.1" Ste&?Down Transformer
The voltage induced in the secondary is determined by the TC'0S ')T*=.
28
5or e8ample$ if the secondary has half the primary turnsJ the secondary will have half
the primary voltage.
)nother e8ample is if the primary has 1@@@ turns and the secondary has 1@@ turns$ then
the turnQs ratio is +@#+.
*f the primary voltage is -/@ volts then the secondary voltage will be 8 +@ smaller N -/
volts. )ssuming a perfect transformer$ the power provided by the primary must e(ual the power ta!en
by a load on the secondary. *f a -/-watt lamp is connected across a -/ volt secondary$ then the
primary must supply -/ watts.
To aid magnetic coupling between primary and secondary$ the coils are wound on a
metal &='E. Since the primary would induce power$ called EDDS &C''E0TS$ into this core$ the
core is %)M*0)TED. This means that it is made up from metal sheets insulated from each other.
Transformers to wor! at higher fre(uencies have an iron dust core or no core at all.
0ote that the transformer only wor!s on )&$ which has a constantly changing current
and moving field. D& has a steady current and therefore a steady field and there would be no
induction.
Some transformers have an electrostatic screen between primary and secondary. This is
to prevent some types of interference being fed from the e(uipment down into the mains supply$ or in
the other direction. Transformers are sometimes used for *M,ED)0&E M)T&>*0".
Be can use the transformers as step up or step down.
Ste& #& transformer"
*n case of step up transformer$ primary windings are every less compared to secondary
winding.
:ecause of having more turns secondary winding accepts more energy$ and it releases
more voltage at the output side.
Ste& down transformer"
29
*ncase of step down transformer$ ,rimary winding induces more flu8 than the
secondary winding$ and secondary winding is having less number of turns because of that it accepts
less number of flu8$ and releases less amount of voltage.
,atter/ &ower s$&&l/"
) battery is a type of linear power supply that offers benefits that traditional line-
operated power supplies lac!# mobility$ portability and reliability. ) battery consists of multiple
electrochemical cells connected to provide the voltage desired. 5ig# ....1 shows >i-Batt ?K battery

;ig *.*.4" Hi?2att 9> ,atter/
The most commonly used dry-cell battery is the carbon-9inc dry cell battery. Dry-cell
batteries are made by stac!ing a carbon plate$ a layer of electrolyte paste$ and a 9inc plate alternately
until the desired total voltage is achieved. The most common dry-cell batteries have one of the
following voltages# +.1$ .$ 4$ ?$ --.1$ /1$ and ?@. During the discharge of a carbon-9inc battery$ the
9inc metal is converted to a 9inc salt in the electrolyte$ and magnesium dio8ide is reduced at the
carbon electrode. These actions establish a voltage of appro8imately +.1 K.
The lead-acid storage battery may be used. This battery is rechargeableJ it consists of
lead and leadEdio8ide electrodes which are immersed in sulfuric acid. Bhen fully charged$ this type of
battery has a -.@4--.+/ K potential () +- volt car battery uses 4 cells in series. During discharge$ the
lead is converted to lead sulfate and the sulfuric acid is converted to water. Bhen the battery is
charging$ the lead sulfate is converted bac! to lead and lead dio8ide ) nic!el-cadmium battery has
become more popular in recent years. This battery cell is completely sealed and rechargeable. The
electrolyte is not involved in the electrode reaction$ ma!ing the voltage constant over the span of the
batteries long service life. During the charging process$ nic!el o8ide is o8idi9ed to its higher o8idation
state and cadmium o8ide is reduced. The nic!el-cadmium batteries have many benefits. They can be
30
stored both charged and uncharged. They have a long service life$ high current availabilities$ constant
voltage$ and the ability to be recharged. 5ig# ....4 shows pencil battery of +.1K.
;ig *.*.5" Pencil ,atter/ of !.4>
ectification"
The process of converting an alternating current to a pulsating direct current is called
as rectification. 5or rectification purpose we use rectifiers.
ectifiers"
) rectifier is an electrical device that converts alternating current ()& to direct current
(D&$ a process !nown as rectification. 'ectifiers have many uses including as components of power
supplies and as detectors of radio signals. 'ectifiers may be made of solid-state diodes$ vacuum tube
diodes$ mercury arc valves$ and other components.
) device that it can perform the opposite function (converting D& to )& is !nown as
an inverter.
Bhen only one diode is used to rectify )& (by bloc!ing the negative or positive
portion of the waveform$ the difference between the term diode and the term rectifier is merely one
of usage$ i.e.$ the term rectifier describes a diode that is being used to convert )& to D&. )lmost all
rectifiers comprise a number of diodes in a specific arrangement for more efficiently converting )& to
D& than is possible with only one diode. :efore the development of silicon semiconductor rectifiers$
vacuum tube diodes and copper (* o8ide or selenium rectifier stac!s were used.
,ridge f$ll wa)e rectifier"
31
The :ridge rectifier circuit is shown in fig# ....7$ which converts an ac voltage to dc
voltage using both half cycles of the input ac voltage. The :ridge 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.
5or the positive half cycle of the input ac voltage$ diodes D+ and D. conduct$ whereas
diodes D- and D/ remain in the =55 state. The conducting diodes will be in series with the load
resistance '% and hence the load current flows through '%.
5or the negative half cycle of the input ac voltage$ diodes D- and D/ conduct
whereas$ D+ and D. remain =55. The conducting diodes D- and D/ will be in series with the load
resistance '% and hence the current flows through '% in the same direction as in the previous half
cycle. Thus a bi-directional wave is converted into a unidirectional wave.
*nput =utput

;ig *.*.6" ,ridge rectifier" a f$ll?wa)e rectifier $sing 1 diodes
D,!:6"
0ow -a -days :ridge rectifier is available in *& with a number of D:+@7. *n our project
we are using an *& in place of bridge rectifier. The picture of D: +@7 is shown in fig# ....6.
;eat$res"
32
"ood for automation insertion
Surge overload rating - .@ amperes pea!
*deal for printed circuit board
'eliable low cost construction utili9ing molded
"lass passivated device
,olarity symbols molded on body
Mounting position# )ny
Beight# +.@ gram

;ig *.*.8" D,!:6
;iltration"
The process of converting a pulsating direct current to a pure direct current using filters
is called as filtration.
;ilters"
Electronic filters are electronic circuits$ which perform signal-processing functions$
specifically to remove unwanted fre(uency components from the signal$ to enhance wanted ones.
Introd$ction to Ca&acitors"
33
The &apacitor or sometimes referred to as a &ondenser is a passive device$ and one
which stores energy in the form of an electrostatic field which produces a potential (static voltage
across its plates. *n its basic form a capacitor consists of two parallel conductive plates that are not
connected but are electrically separated either by air or by an insulating material called the Dielectric.
Bhen a voltage is applied to these plates$ a current flows charging up the plates with electrons giving
one plate a positive charge and the other plate an e(ual and opposite negative charge This flow of
electrons to the plates is !nown as the &harging &urrent and continues to flow until the voltage across
the plates (and hence the capacitor is e(ual to the applied voltage Kcc. )t this point the capacitor is
said to be fully charged and this is illustrated below. The construction of capacitor and an electrolytic
capacitor are shown in figures ....? and ....+@ respectively.
;ig *.*.9"Constr$ction Of a Ca&acitor ;ig *.*.!:"Electrol/tic Ca&aticor
Cnits of &apacitance#
Microfarad (T5 +T5 N +E+$@@@$@@@ N @.@@@@@+ N +@
-4
5
0anofarad (n5 +n5 N +E+$@@@$@@@$@@@ N @.@@@@@@@@+ N +@
-?
5
,ico farad (p5 +p5 N +E+$@@@$@@@$@@@$@@@ N @.@@@@@@@@@@@+ N +@
-+-
5
O&eration of Ca&acitor"
34
Thin! of water flowing through a pipe. *f we imagine a capacitor as being a storage
tan! with an inlet and an outlet pipe$ it is possible to show appro8imately how an electronic capacitor
wor!s.
5irst$ let<s consider the case of a ;coupling capacitor; where the capacitor is used to
connect a signal from one part of a circuit to another but without allowing any direct current to flow.
*f the current flow is alternating between 9ero and a ma8imum$
our ;storage tan!; capacitor will allow the current waves to pass
through.
>owever$ if there is a steady current$ only the initial short burst
will flow until the ;floating ball valve; closes and stops further
flow.
So a coupling capacitor allows ;alternating current; to pass through because the ball
valve doesn<t get a chance to close as the waves go up and down. >owever$ a steady current (uic!ly
fills the tan! so that all flow stops.
) capacitor will pass alternating current but (apart from an initial surge it will not pass
d.c.
Bhere a capacitor is used to decouple a circuit$ the effect is to
;smooth out ripples;. )ny ripples$ waves or pulses of current are
passed to ground while d.c. 5lows smoothly.
35
eg$lation"
The process of converting a varying voltage to a constant regulated voltage is called as
regulation. 5or the process of regulation we use voltage regulators.
>oltage eg$lator"
) voltage regulator (also called a UregulatorQ with only three terminals appears to be a
simple device$ but it is in fact a very comple8 integrated circuit. *t converts a varying input voltage
into a constant UregulatedQ output voltage. Koltage 'egulators are available in a variety of outputs li!e
1K$ 4K$ ?K$ +-K and +1K. The %M76MM series of voltage regulators are designed for positive input.
5or applications re(uiring negative input$ the %M7?MM series is used. Csing a pair of Uvoltage-
dividerQ resistors can increase the output voltage of a regulator circuit.
*t is not possible to obtain a voltage lower than the stated rating. Sou cannot use a +-K
regulator to ma!e a 1K power supply. Koltage regulators are very robust. These can withstand over-
current draw due to short circuits and also over-heating. *n both cases$ the regulator will cut off before
any damage occurs. The only way to destroy a regulator is to apply reverse voltage to its input.
'everse polarity destroys the regulator almost instantly. 5ig# ....++ shows voltage regulator.
;ig *.*.!!" >oltage eg$lator
36
esistors"
) resistor is a two-terminal electronic component that produces a voltage across its terminals
that is proportional to the electric current passing through it in accordance with =hm<s law#
V $ IR
'esistors are elements of electrical networ!s and electronic circuits and are ubi(uitous in most
electronic e(uipment. ,ractical resistors can be made of various compounds and films$ as well as
resistance wire (wire made of a high-resistivity alloy$ such as nic!elEchrome.
The primary characteristics of a resistor are the resistance$ the tolerance$ ma8imum wor!ing
voltage and the power rating. =ther characteristics include temperature coefficient$ noise$ and
inductance. %ess well-!nown is critical resistance$ the value below which power dissipation limits the
ma8imum permitted current flow$ and above which the limit is applied voltage. &ritical resistance is
determined by the design$ materials and dimensions of the resistor.
'esistors can be made to control the flow of current$ to wor! as Koltage dividers$ to
dissipate power and it can shape electrical waves when used in combination of other components.
:asic unit is ohms.
T%eor/ of o&eration"
O%mAs law"
The behavior of an ideal resistor is dictated by the relationship specified in =hm<s law#
K N *'
=hm<s law states that the voltage (K across a resistor is proportional to the current (*
through it where the constant of proportionality is the resistance ('.
Power dissi&ation"
The power dissipated by a resistor (or the e(uivalent resistance of a resistor networ! is
calculated using the following#
37

;ig *.*.!(" esistor ;ig *.*.!*" Color ,ands In esistor
*.1. 3ED"
) light-emitting diode (%ED is a semiconductor light source. %EDQs are used as
indicator lamps in many devices$ and are increasingly used for lighting. *ntroduced as a practical
electronic component in +?4-$ early %EDQs emitted low-intensity red light$ but modern versions are
available across the visible$ ultraviolet and infrared wavelengths$ with very high brightness. The
internal structure and parts of a led are shown in figures ../.+ and ../.- respectively.

38
;ig *.1.!" Inside a 3ED ;ig *.1.(" Parts of a 3ED
2orking"
The structure of the %ED light is completely different than that of the light bulb.
)ma9ingly$ the %ED has a simple and strong structure. The light-emitting semiconductor material is
what determines the %ED<s color. The %ED is based on the semiconductor diode.
Bhen a diode is forward biased (switched on$ electrons are able to recombine with
holes within the device$ releasing energy in the form of photons. This effect is called
electroluminescence and the color of the light (corresponding to the energy of the photon is
determined by the energy gap of the semiconductor. )n %ED is usually small in area (less than
+ mm
-
$ and integrated optical components are used to shape its radiation pattern and assist in
reflection. %EDQs present many advantages over incandescent light sources including lower energy
consumption$ longer lifetime$ improved robustness$ smaller si9e$ faster switching$ and greater
durability and reliability. >owever$ they are relatively e8pensive and re(uire more precise current and
heat management than traditional light sources. &urrent %ED products for general lighting are more
e8pensive to buy than fluorescent lamp sources of comparable output. They also enjoy use in
applications as diverse as replacements for traditional light sources in automotive lighting
(particularly indicators and in traffic signals. The compact si9e of %EDQs has allowed new te8t and
video displays and sensors to be developed$ while their high switching rates are useful in advanced
communications technology. The electrical symbol and polarities of led are shown in fig# ../...
;ig *.1.*" Electrical S/m.ol B Polarities of 3ED
39
%ED lights have a variety of advantages over other light sources#
>igh-levels of brightness and intensity
>igh-efficiency
%ow-voltage and current re(uirements
%ow radiated heat
>igh reliability (resistant to shoc! and vibration
0o CK 'ays
%ong source life
&an be easily controlled and programmed
)pplications of %ED fall into three major categories#
Kisual signal application where the light goes more or less directly from the %ED to the human
eye$ to convey a message or meaning.
*llumination where %ED light is reflected from object to give visual response of these objects.
"enerate light for measuring and interacting with processes that do not involve the human
visual system.
*.4 ENE7- +ETE"
)n electric meter or energ/ meter is a device that measures the amount of electrical energy
consumed by a residence$ business$ or an electrically-powered device.
Electric meters are typically calibrated in billing units$ the most common one being the !ilowatt hour.
,eriodic readings of electric meters establish billing cycles and energy used during a cycle.
*n settings when energy savings during certain periods are desired$ meters may measure demand$ the
ma8imum use of power in some interval. *n some areas$ the electric rates are higher during certain
40
times of day$ to encourage reduction in use. )lso$ in some areas meters have relays to turn off
nonessential e(uipment
*.4.! T%eor/"
The first accurate$ recording electricity consumption meter was a D& meter by Dr >ermann )ron$
who patented it in +66.. >ugo >irst of the "eneral Electric &ompany introduced it commercially into
"reat :ritain from +666.
G-H
Meters had been used prior to this$ but they measured the rate of power
consumption at that particular moment. )ron<s meter recorded the total energy used over time$ and
showed it on a series of cloc! dials.
The prototype of the world<s first !ilowatt-hour meter$ inventor# =ttV :lWthy. Made in "an9
&ompany$ >ungary in +66?
The first specimen of the )& !ilowatt-hour meter produced on the basis of >ungarian =ttV :lWthy<s
patent and named after him was presented by the "an9 Bor!s at the 5ran!furt 5air in the autumn of
+66?$ and the first induction !ilowatt-hour meter was already mar!eted by the factory at the end of the
same year. These were the first alternating-current wattmeterQs$ !nown by the name of :lWthy-meters
41
Cnit of measurement
,anel-mounted solid state electricity meter$ connected to a - MK) electricity substation. 'emote
current and voltage sensors can be read and programmed remotely by modem and locally by infra-red.
The circle with two dots is the infra-red port. Tamper-evident seals can be seen.
The most common unit of measurement on the electricity meter is the !ilowatt hour$ which is e(ual to
the amount of energy used by a load of one !ilowatt over a period of one hour$ or .$4@@$@@@ joules.
Some electricity companies use the S* mega joule instead.
Demand is normally measured in watts$ but averaged over a period$ most often a (uarter or half hour.
'eactive power is measured in ;Kolt-amperes reactive;$ (varh in !ilovar-hours. :y convention$ a
;lagging; or inductive load$ such as a motor$ will have positive reactive power. ) ;leading;$ or
capacitive load$ will have negative reactive power.
G/H
Kolt-amperes measures all power passed through a distribution networ!$ including reactive and actual.
This is e(ual to the product of root-mean-s(uare volts and amperes.
Distortion of the electric current by loads is measured in several ways. ,ower factor is the ratio of
resistive (or real power to volt-amperes. ) capacitive load has a leading power factor$ and an
inductive load has a lagging power factor. ) purely resistive load (such as a filament lamp$ heater or
!ettle e8hibits a power factor of +. &urrent harmonics are a measure of distortion of the wave form.
42
5or e8ample$ electronic loads such as computer power supplies draw their current at the voltage pea!
to fill their internal storage elements. This can lead to a significant voltage drop near the supply
voltage pea! which shows as a flattening of the voltage waveform. This flattening causes odd
harmonics which are not permissible if they e8ceed specific limits$ as they are not only wasteful$ but
may interfere with the operation of other e(uipment. >armonic emissions are mandated by law in EC
and other countries to fall within specified limits.
=ther units of measurement
*n addition to metering based on the amount of energy used$ other types of metering are available.
Meters which measured the amount of charge (coulombs used$ !nown as ampere-hour meters$ were
used in the early days of electrification. These were dependent upon the supply voltage remaining
constant for accurate measurement of energy usage$ which was not a li!ely circumstance with most
supplies.
Some meters measured only the length of time for which charge flowed$ with no measurement of the
magnitude of voltage or current is made. These were only suited for constant-load applications.
0either type is li!ely to be used today.
*.4.( T/&es of energ/ meters"
!. Electromec%anical ind$ction meter
43
Mechanism of electromechanical induction meter# X - Koltage coil - many turns of fine wire encased
in plastic$ connected in parallel with load. X - &urrent coil - three turns of thic! wire$ connected in
series with load. X - Stator - concentrates and confines magnetic field. X - )luminum rotor disc. X -
rotor bra!e magnets. X - spindle with worm gear. X - display dials - note that the +E+@$ +@ and +@@@
dials rotate cloc!wise while the +$ +@@ and +@@@@ dials rotate counter-cloc!wise.
Electricity meters operate by continuously measuring the instantaneous voltage (volts and current
(amperes and finding the product of these to give instantaneous electrical power (watts which is then
integrated against time to give energy used (joules$ !ilowatt-hours etc. Meters for smaller services
( such as small residential customers can be connected directly in-line between source and customer.
5or larger loads$ more than about -@@ amps of load$ current transformers are used$ so that the meter
can be located other than in line with the service conductors. The meters fall into two basic categories$
electromechanical and electronic.
(. Electromec%anical meters
This mechanical electricity meter has every other dial rotating counter-cloc!wise.
The most common type of electricity meter is the Thomson or electromechanical induction watt-hour
meter$ invented by Elihu Thomson in +666.The electromechanical induction meter operates by
counting the revolutions of an aluminum disc which is made to rotate at a speed proportional to the
power. The number of revolutions is thus proportional to the energy usage. *t consumes a small
amount of power$ typically around - watts.
The metallic disc is acted upon by two coils. =ne coil is connected in such a way that it produces a
magnetic flu8 in proportion to the voltage and the other produces a magnetic flu8 in proportion to the
current. The field of the voltage coil is delayed by ?@ degrees using a lag coil.
G7H
This produces eddy
currents in the disc and the effect is such that a force is e8erted on the disc in proportion to the product
44
of the instantaneous current and voltage. ) permanent magnet e8erts an opposing force proportional to
the speed of rotation of the disc. The e(uilibrium between these two opposing forces results in the disc
rotating at a speed proportional to the power being used. The disc drives a register mechanism which
integrates the speed of the disc over time by counting revolutions$ much li!e the odometer in a car$ in
order to render a measurement of the total energy used over a period of time.
The type of meter described above is used on a single-phase )& supply. Different phase
configurations use additional voltage and current coils.
*. Single &%ase energ/ meter
Three-phase electromechanical induction meter$ metering +@@ ) -.@E/@@ K supply. >ori9ontal
aluminum rotor disc is visible in center of meter
The aluminum disc is supported by a spindle which has a worm gear which drives the register. The
register is a series of dials which record the amount of energy used. The dials may be of the
cyclometer type$ an odometer-li!e display that is easy to read where for each dial a single digit is
shown through a window in the face of the meter$ or of the pointer type where a pointer indicates each
digit. Bith the dial pointer type$ adjacent pointers generally rotate in opposite directions due to the
gearing mechanism.
45
The amount of energy represented by one revolution of the disc is denoted by the symbol Kh which is
given in units of watt-hours per revolution. The value 7.- is commonly seen. Csing the value of Kh$
one can determine their power consumption at any given time by timing the disc with a stopwatch. *f
the time in seconds ta!en by the disc to complete one revolution is t$ then the power in watts is
. 5or e8ample$ if Kh N 7.-$ as above$ and one revolution too! place in +/./
seconds$ the power is +6@@ watts. This method can be used to determine the power consumption of
household devices by switching them on one by one.
Most domestic electricity meters must be read manually$ whether by a representative of the power
company or by the customer. Bhere the customer reads the meter$ the reading may be supplied to the
power company by telephone$ post or over the internet. The electricity company will normally re(uire
a visit by a company representative at least annually in order to verify customer-supplied readings and
to ma!e a basic safety chec! of the meter.
*n an induction type meter$ creep is a phenomenon that can adversely affect accuracy$ that occurs
when the meter disc rotates continuously with potential applied and the load terminals open circuited.
) test for error due to creep is called a creep test.
Two standards govern meter accuracy$ )0S* &+-.-@ for 0orth )merica and *E& 4-@1..
1. Electronic meters
Electronic meters display the energy used on an %&D or %ED display$ and can also transmit readings
to remote places. *n addition to measuring energy used$ electronic meters can also record other
parameters of the load and supply such as ma8imum demand$ power factor and reactive power used
etc. They can also support time-of-day billing$ for e8ample$ recording the amount of energy used
during on-pea! and off-pea! hours.
46
Solid state electricity meter used in a home in the 0etherlands.
Electronic meters now use %ow ,ower 'adio$ "SM$ ",'S$ :luetooth$ *rD)$ as well as 'S-/61
wired lin!. The meters can now store the entire usage profiles with time stamps and relay them at a
clic! of a button. The demand readings stored with the profiles accurately indicate the load
re(uirements of the customer. This load profile data is processed at the utilities for billing and
planning purposes.
)M' ()utomatic Meter 'eading and 'M' ('emote Meter 'eading describe various systems that
allow meters to be chec!ed without the need to send a meter reader out. )n electronic meter can
transmit its readings by telephone line or radio to a central billing office. )utomatic meter reading can
be done with "SM ("lobal System for Mobile &ommunications modems$ one is attached to each
meter and the other is placed at the central utility office.
47
4. Solid?state design
:asic bloc! diagram of an electronic energy meter
)s in the bloc! diagram$ the meter has a power supply$ a metering engine$ ) processing and
communication engine (i.e. a microcontroller$ and other add-on modules such as 'T&$ %&D display$
communication portsEmodules and so on.
The metering engine is given the voltage and current inputs and has a voltage reference$ samplers and
(uanti9es followed by an )D& section to yield the digiti9ed e(uivalents of all the inputs. These inputs
are then processed using a Digital Signal Processor to calculate the various metering parameters such
as powers$ energies etc.
The largest source of long-term errors in the meter is drift in the preamp$ followed by the precision of
the voltage reference. :oth of these vary with temperature as well$ and vary wildly because most
meters are outdoors. &haracteri9ing and compensating for these is a major part of meter design.
The processing and communication section has the responsibility of calculating the various derived
(uantities from the digital values generated by the metering engine. This also has the responsibility of
communication using various protocols and interface with other addon modules connected as slaves to
it.
'T& and other add-on modules are attached as slaves to the processing and communication section
for various inputEoutput functions. =n a modern meter most if not all of this will be implemented
48
inside the microprocessor$ such as the 'eal Time &loc! ('T&$ %&D controller$ temperature sensor$
memory and analog to digital converters.
5. +$lti&le tariff C)aria.le rateD meters
Electricity retailers may wish to charge customers different tariffs at different times of the day to
better reflect the costs of generation and transmission. Since it is not possible to store electricity
during a period of low demand for use during a period of high demand$ costs will vary significantly
depending on the time of day. %ow cost generation capacity (baseload such as coal can ta!e many
hours to start$ meaning a surplus in times of low demand$ whereas high cost but fle8ible generating
capacity (such as gas turbines must be !ept available to respond at a moment<s notice (spinning
reserve to pea! demand$ perhaps being used for a few minutes per day$ which is very e8pensive.
Some multiple tariff meters use different tariffs for different amounts of demand. These are usually
industrial meters.
Domestic $sage
Domestic variable-rate meters generally permit two to three tariffs (;pea!;$ ;off-pea!; and ;shoulder;
and in such installations a simple electromechanical time switch may be used. >istorically$ these have
often been used in conjunction with electrical storage heaters or hot water storage systems.
Multiple tariffs are made easier by time of use (T=C meters which incorporate or are connected to a
time switch and which have multiple registers.
Switching between the tariffs may happen via a radio-activated switch rather than a time switch to
prevent tampering with a sealed time switch to obtain cheaper electricity.
#nited Eingdom
49
Economy 7 Meter and Tele switcher
'adio-activated switching is common in the CY$ with a nightly data signal sent within the long wave
carrier of ::& 'adio /$ +?6 !>9. The time of off-pea! usage is between +-..@am - 7..@am$ and this
is designed to power storage heaters and immersion heaters. *n the CY$ such tariffs are branded
Economy 7 or Bhite Meter. The popularity of such tariffs has declined in recent years$ at least in the
domestic mar!et$ due to the (perceived or real deficiencies of storage heaters and the low cost of
natural gas.
Some

meters using Economy 7 switch the entire electricity supply to the cheaper rate during the 7
hour night time period$ not just the storage heater circuit. The downside of this is that the daytime rate
will be a touch higher$ and standing charges may be a little higher too. 5or instance$ normal rate
electricity may be 7p per !Bh$ whereas Economy 7<s daytime rate might be 7.1p per !Bh$ but only
-.6p per !Bh at night. Timer switches installed on washing machines$ tumble dryers$ dishwashers and
immersion heaters may be set so that they switch on only when the rate is lower.
Commercial $sage
%arge commercial and industrial premises may use electronic meters which record power usage in
bloc!s of half an hour or less. This is because most electricity grids have demand surges throughout
the day$ and the power company may wish to give price incentives to large customers to reduce
demand at these times. These demand surges often correspond to meal times or$ famously$ to
advertisements in popular television programmers.
A&&liance energ/ meters
,lug in electricity meters (or ;,lug load; meters measure energy used by individual appliances. The
meter is plugged into an outlet$ and the appliance to be measured is plugged into the meter. Such
meters can help in energy conservation by identifying major energy users$ or devices that consume
e8cessive standby power. ) power meter can often be borrowed from the local power authorities or a
local public library.
50
!. In?%ome energ/ $se dis&la/s
) potentially powerful means to reduce household energy consumption is to provide convenient real-
time feedbac! to users so they can change their energy using behavior. 'ecently$ low-cost energy
feedbac! displays have become available. ) study using a consumer-readable meter in 1@@ =ntario
homes by Hydro One showed an average 4.1Z drop in total electricity use when compared with a
similarly si9ed control group. Hydro One subse(uently offered free power monitors to .@$@@@
customers based on the success of the pilot.
G+/H
,rojects such as "oogle ,ower Meter$ ta!e information
from a smart meter and ma!e it more readily available to users to help encourage conservation.
(. Smart meters
Smart meters go a step further than simple )M' (automatic meter reading. They offer additional
functionality including a real-time or near real-time reads$ power outage notification$ and power
(uality monitoring. They allow price setting agencies to introduce different prices for consumption
based on the time of day and the season.
These price differences can be used to reduce pea!s in demand (load shifting or pea! lopping$
reducing the need for additional power plants and in particular the higher polluting and costly to
operate natural gas powered pea!er plants. The feedbac! they provide to consumers has also been
shown to cut overall energy consumption.
Gcitation neededH
)nother type of smart meter uses no intrusive load monitoring to automatically determine the number
and type of appliances in a residence$ how much energy each uses and when. This meter is used by
electric utilities to do surveys of energy use. *t eliminates the need to put timers on all of the
appliances in a house to determine how much energy each uses.
*. Pre&a/ment meters
51
,repayment meter and magnetic stripe to!ens$ from a rented accommodation in the CY The button
labeled A displays information and statistics such as current tariff and remaining credit. The button
labeled , activates a small amount of emergency credit should the customer run out
1. A &re&a/ment ke/
The standard business model of electricity retailing involves the electricity company billing the
customer for the amount of energy used in the previous month or (uarter. *n some countries$ if the
retailer believes that the customer may not pay the bill$ a prepayment meter may be installed. This
re(uires the customer to ma!e advance payment before electricity can be used. *f the available credit
is e8hausted then the supply of electricity is cut off by a relay.
*n the CY$ mechanical prepayment meters used to be common in rented accommodation.
Disadvantages of these included the need for regular visits to remove cash$ and ris! of theft of the
cash in the meter.
Modern solid-state electricity meters$ in conjunction with smart cards$ have removed these
disadvantages and such meters are commonly used for customers considered to be a poor credit ris!.
*n the CY$ one system is the ,ay ,oint networ!$ where rechargeable to!ens ([uantum cards for
natural gas$ or plastic ;!eys; for electricity can be loaded with whatever money the customer has
available.
'ecently smartcards are introduced as much reliable to!ens that allows two way data e8change
between meter and the utility.
*n South )frica and 0orthern *reland prepaid meters are recharged by entering a uni(ue$ encoded
twenty digit number using a !eypad. This ma!es the to!ens$ essentially a slip of paper$ very cheap to
produce.
)round the world$ e8periments are going on$ especially in developing countries$ to test pre-payment
systems. *n some cases$ prepayment meters have not been accepted by customers. There are various
52
groups$ such as the Standard Transfer Specification (STS association$ which promote common
standards for prepayment metering systems across manufacturers. >owever in spite of these efforts
prepayment meter mar!et had not spread e8cept in South )frica.
*.5" OPTOCO#P3E"
)n optocoupler-isolated power supply is often the safest and most practical way to go when it comes
to performance and protection. >ereQs the basic on todayQs %EDEphoto detector isolators and what you
need to !now to apply them to your system.
The junior system designer often places the systemQs power re(uirements at the end of the list$ and
thus overloo!s the importance of an isolated$ versus non-isolated )&E)&$ )&ED&$ D&E)&$ or D&ED&
converter. True isolation (transformer at the input$ optoisolator in the supplyQs feedbac! control loops
virtually removes any direct conductive path between the power supplyQs input stage and its output
terminalsEload. ThatQs especially important in the high-power density applications that are becoming
more the rule than the e8ception$ and for more demanding system re(uirements
That often place power supplies in e8plosive or otherwise ha9ardous environments.
The use of an optocoupler also acts to brea! ground loops$ and this functionality is valuable in
eliminating common-mode noise$ especially for systems wor!ing at the higher operating voltages.
Bhen different power supplies in a system are tied together$ ground loop currents tend to be induced
due to slight differences in ground potential.
*n addition$ power supplies tend to see transient noise in e(uipment that switches between various
power states (todayQs optocouplers are able to withstand up to /@ !KEmicrosecond transient common-
mode voltage. Typical optocouplers for performing this so-called galvanic isolation functionFin
essence to connect intrinsically safe circuitry to circuits that pose a safety ris!Fcomprise an %ED$ a
photo detector$ and appropriate connecting circuitry in the supplyQs output-to-input feedbac! %oop.
*n general circuit operation$ the optocoupler$ driven by the supplyQs ,BM$ serves as the lin! to
maintain the supplyQs desired output voltage Bhen the output voltage deviates either due to line
andEor load changes$ the supplyQs error amplifier attempts to compensate. *t compares its input with a
reference voltage$ and the error signal thus controls the output of the ,BM. *n turn$ the ,BM directs
the primary- side
53
,ower M=S5ETs via the optocoupler
T%e standards
'egulatory agencies such as C% in the Cnited States$ &E0E%E& in Europe$ &S) in &anada$ and T**S
in Dapan$ set the power level needed to ma!e circuitry intrinsically safe. *n essence$ the standards set
the re(uirements for the galvanic isolation barrier between the 2safe3 circuitry and the outside world.
5or best results$ choose optocouplers with
)dditional reinforced insulation as suggested by *E& E0-4@7/7- 1--. 'einforced insulation ensures
protection from electric shoc! as well as provides a failsafe mode. 5ail-safe techni(ues terminate
system operation and leaves system processes and components in a secure state when a failure occurs.
The input-voltage level usually defines the insulation voltage rating$ which typically ranges from 1@@
volts for some telecom applications to .1@@ volts for universal line-voltage capability. The regulations
you need to !now about$ and the specs you should study$ include *E&4@?1@$ E011@--$ and *E&
4+@@@. *E& 4+@@@ in particular covers electromagnetic compatibility (EM&$ and part
/ of that document (*E&4+@@@- /-/ covers fast transientEburst Electrical 5ast Transient (E5T testing
discussed in part /./ addresses interference simulated in inductively loaded switches. *n this standard$
the modules will be subjected to the following test levels$ depending on the designed environment#
%evel + (Bell protectedJ %evel - (,rotectedJ %evel . (Typical *ndustrial EnvironmentJ and %evel /
(Severe *ndustrial Environment$ where test voltage pea!s at the power supply ports are @.1 !K (1!>9
repetition rate$ + !K (1!>9$ - !K (1!>9$ and / !K (-.1!>9$ respectively.
A&&lications"
54
&omputer terminals
System appliances$ measuring instruments
'egisters$ copiers$ automatic vending machines
Electric home appliances$ such as fan heaters$ etc
Signal transmission between circuits of different potentials and impedances
*.6 7S+
7lo.al S/stem for +o.ile Comm$nication C7S+D
Definition"
"SM$ which stands for "lobal System for Mobile communications$ reigns (important as the
worldQs most widely used cell phone technology. &ell phones use a cell phone service carrierQs "SM
networ! by searching for cell phone towers in the nearby area. "lobal system for mobile
communication ("SM is a globally accepted standard for digital cellular communication.
"SM is the name of a standardi9ation group established in +?6- to create a
common European mobile telephone standard that would formulate specifications for a pan-European
mobile cellular radio system operating at ?@@ M>9. *t is estimated that many countries outside of
Europe will join the "SM partnership.
55
+ODE+ SPECI;ICATIONS"
The S*M.@@ is a complete Tri-band "SM solution in a compact plug-in module.
5eaturing an industry-standard interface$ the S*M.@@ delivers "SME",'S?@@E+6@@E+?@@Mh9
performance for voice$ SMS$ data and 5a8 in a small form factor and with low power consumption.
The leading features of S*M.@@ ma!e it deal fir virtually unlimited application$ such as B%%
applications (5i8ed &ellular Terminal$ M-M application$ handheld devices and much more.
+. Tri-band "SME",'S module with a si9e of /@8..8-.61
-. &ustomi9ed MM* and !eypadE%&D support
.. )n embedded powerful T&,E*, protocol stac!
/. :ased upon mature and field proven platform$ bac!ed up by our support service$ from
definition to design and production.
56
7eneral ;eat$res"
Tri-band "SME",'S?@@E+6@@E+?@@Mh9
",'S multi-slot class +@
",'S mobile station class A:
&omplaint to "SM phase -E-P
i. -class /(-B \?@@M>9
ii. -class +(+B \E+6@@+?@@M>9
Dimensions# /@8..8-.61 mm
Beight# 6gm
7. &ontrol via )T commands
("SM @7.@7$ @7.@1 and S*M&=M enhanced )T commands
S*M application tool !it
supply voltage range ..1LL./.1 v
%ow power consumption
0ormal operation temperature# --@ Q& to P11 U&
'estricted operation temperature # --@ Q& to --1 U& and P11 Q& to P7@ U&
storage temperature# -/@ U& to P6@ U&
S&ecifications for ;a0"
"roup . and class +
S&ecifications for Data"
",'S class +@# ma8 61.4 !bps (downlin!
,:&&> support
coding schemes &s +$-$.$/
&SD upto +/./ !bps
CSSD
57
0on transperant mode
,,,-stac!

S&ecifications for S+S )ia 7S+F7PS"


,oint to point M= and MT
SMS cell broadcast
Te8t and ,DC mode
Com&ati.ilit/"
)t cellular command interface
S&ecifications for )oice"
+. Tricodec
->alf rate (>'
-5ull rate (5'
-Enhanced full rate (E5'
-. >ands free operation
(Echo cancellation
Dri)ers"
Microsoft windows mobile '*% driver
MCM driver
Interfaces"
*nterface to e8ternal S*M .v +.6v
4@ pins board-to-board connector
58
Two analog audio interfaces
Yeypad interfaces
%&D interface
'T& bac!up
)T commands via serial interface
Dual-Serial interfaces
)ntenna connector and antenna pad
A&&ro)als"
5T)
%ocal type approval
&E
Need of 7S+"
The "SM study group aimed to provide the followings through the "SM#
*mproved spectrum efficiency.
*nternational roaming.
%ow-cost mobile sets and base stations (:S
>igh-(uality speech
&ompatibility with *ntegrated Services Digital 0etwor! (*SD0 and other telephone company
services.
Support for new services.
7S+ G Arc%itect$re"
) "SM networ! consists of several functional entities whose functions and interfaces are
defined. The "SM networ! can be divided into following broad parts.
The Mobile Station (MS
The :ase Station Subsystem (:SS
59
The 0etwor! Switching Subsystem (0SS
The =peration Support Subsystem (=SS
5ollowing fig shows the simple architecture diagram of "SM 0etwor!.

5ig# "SM 0etwor!.
The added components of the "SM architecture include the functions of the databases and messaging
systems#
>ome %ocation 'egister (>%'
Kisitor %ocation 'egister (K%'
E(uipment *dentity 'egister (E*'
)uthentication &enter ()u&
SMS Serving &enter (SMS S&
"ateway MS& ("MS&
60
&hargebac! &enter (&:&
Transcoder and )daptation Cnit (T')C
5ollowing fig shows the diagram of "SM 0etwor! along with added elements.

5ig# "SM 0etwor! along with added elements.
The MS and the :SS communicate across the Cm interface$ also !nown as the air interface or
radio lin!. The :SS communicates with the 0etwor! Service Switching center across the ) interface.
7S+ network areas"
*n a "SM networ!$ the following areas are defined#
Cell" &ell is the basic service area$ one :TS covers one cell. Each cell is given a &ell "lobal *dentity
(&"*$ a number that uni(uely identifies the cell.
3ocation Area" ) group of cells form a %ocation )rea. This is the area that is paged when a
subscriber gets an incoming call. Each %ocation )rea is assigned a %ocation )rea *dentity (%)*. Each
%ocation )rea is served by one or more :S&s.
MS&EK%' Service )rea# The area covered by one MS& is called the MS&EK%' service area.
P3+N" The area covered by one networ! operator is called ,%M0. ) ,%M0 can contain one or
more MS&s.
61
T%e 7S+ networks &arts are e0&lained as follows#
!D +o.ile Station"
The mobile station (MS consists of the physical e(uipment$ such as the radio
transceiver$ display and digital signal processors$ and a smart card called the Subscriber *dentity
Module (S*M. The S*M provides personal mobility$ so that the user can have access to all
subscribed services irrespective of both the location of the terminal and the use of a specific terminal.
:y inserting the S*M card into another "SM cellular phone$ the user is able to receive calls at that
phone$ ma!e calls from that phone$ or receive other subscribed services.
The mobile e(uipment is uni(uely identified by the *nternational Mobile E(uipment *dentity
(*ME*. The S*M card contains the *nternational Mobile Subscriber *dentity (*MS*$ identifying the
subscriber$ a secret !ey for authentication$ and other user information. The *ME* and the *MS* are
independent$ thereby providing personal mobility. The S*M card may be protected against
unauthori9ed use by a password or personal identity number.
(D ,ase Station S$.s/stem"
The :ase Station Subsystem is composed of two parts$ the :ase Transceiver Station (:TS
and the :ase Station &ontroller (:S&. These communicate across the specified )bis interface$
allowing (as in the rest of the system operation between components made by different suppliers.
The :ase Transceiver Station houses the radio transceivers that define a cell and handles the
radio lin! protocols with the Mobile Station. *n a large urban area$ there will potentially be a large
number of :TSs deployed. The re(uirements for a :TS are ruggedness$ reliability$ portability$ and
minimum cost.
The :ase Station &ontroller manages the radio resources for one or more :TSs. *t
handles radio channel setup$ fre(uency hopping$ and handovers$ as described below. The :S& is the
connection between the mobile and the Mobile service Switching &enter (MS&. The :S& also
translates the +. !bps voice channel used over the radio lin! to the standard 4/ !bps channel used by
the ,ublic Switched Telephone 0etwor! or *SD0.
62
*D Network S$.s/stem"
The central component of the 0etwor! Subsystem is the Mobile
services Switching &enter (MS&. *t acts li!e a normal switching node of
the ,ST0 or *SD0$ and in addition provides all the functionality needed to
handle a mobile subscriber$ such as registration$ authentication$ location updating$ handovers$ and call
routing to a roaming subscriber. These services are provided in conjunction with several functional
entities$ which together form the 0etwor! Subsystem. The MS& provides the connection to the
public fi8ed networ! (,ST0 or *SD0$ and signaling between functional entities uses the *TCT
Signaling System 0umber 7 (SS7$ used in *SD0 and widely used in current public networ!s.
The >ome %ocation 'egister (>%' and Kisitor %ocation 'egister (K%'$ together with the
MS&$ provide the call routing and (possibly international roaming capabilities of "SM. The >%'
contains all the administrative information of each subscriber registered in the corresponding "SM
networ!$ along with the current location of the mobile. The current location of the mobile is in the
form of a Mobile Station 'oaming 0umber (MS'0 which is a regular *SD0 number used to route a
call to the MS& where the mobile is currently located. There is logically one >%' per "SM
networ!$ although it may be implemented as a distributed database.
The Kisitor %ocation 'egister contains selected administrative information from the >%'$
necessary for call control and provision of the subscribed services$ for each mobile currently located
in the geographical area controlled by the K%'. )lthough each functional entity can be implemented
as an independent unit$ most manufacturers of switching e(uipment implement one K%' together
with one MS&$ so that the geographical area controlled by the MS& corresponds to that controlled by
the K%'$ simplifying the signaling re(uired. 0ote that the MS& contains no information about
particular mobile stations - this information is stored in the location registers.
The other two registers are used for authentication and security purposes. The E(uipment
*dentity 'egister (E*' is a database that contains a list of all valid mobile e(uipment on the networ!$
where each mobile station is identified by its *nternational Mobile E(uipment *dentity (*ME*. )n
*ME* is mar!ed as invalid if it has been reported stolen or is not type approved. The )uthentication
63
&enter is a protected database that stores a copy of the secret !ey stored in each subscriber<s S*M card$
which is used for authentication and ciphering of the radio channel.
7S+ ? T%e ,ase Station S$.s/stem C,SSD"
The :SS is composed of two parts#
The :ase Transceiver Station (:TS
The :ase Station &ontroller (:S&
The :TS and the :S& communicate across the specified )bis interface$ enabling operations
between components that are made by different suppliers. The radio components of a :SS may
consist of four to seven or nine cells. ) :SS may have one or more base stations. The :SS uses the
)bis interface between the :TS and the :S&. ) separate high-speed line (T+ or E+ is then connected
from the :SS to the Mobile MS&.

T%e ,ase Transcei)er Station C,TSD"
The :TS houses the radio transceivers that define a cell and handles the radio lin! protocols
with the MS. *n a large urban area$ a large number of :TSs may be deployed.
64

The :TS corresponds to the transceivers and antennas used in each cell of the networ!. )
:TS is usually placed in the center of a cell. *ts transmitting power defines the si9e of a cell. Each
:TS has between + and +4 transceivers$ depending on the density of users in the cell. Each :TS
serves a single cell. *t also includes the following functions#
Encoding$ encrypting$ multiple8ing$ modulating$ and feeding the '5 signals to the antenna.
Transcoding and rate adaptation
Time and fre(uency synchroni9ing
Koice through full- or half-rate services
Decoding$ decrypting$ and e(uali9ing received signals
'andom access detection
Timing advances
Cplin! channel measurements
T%e ,ase Station Controller C,SCD"
The :S& manages the radio resources for one or more :TSs. *t handles radio channel
setup$ fre(uency hopping$ and handovers. The :S& is the connection between the mobile and the
MS&. The :S& also translates the +. Ybps voice channel used over the radio lin! to the standard 4/
Ybps channel used by the ,ublic Switched Telephone 0etwor! (,SD0 or *SD0.
65
*t assigns and releases fre(uencies and time slots for the MS. The :S& also handles intercell
handover. *t controls the power transmission of the :SS and MS in its area. The function of the :S&
is to allocate the necessary time slots between the :TS and the MS&. *t is a switching device that
handles the radio resources. )dditional functions include#
&ontrol of fre(uency hopping
,erforming traffic concentration to reduce the number of lines from the MS&
,roviding an interface to the =perations and Maintenance &enter for the :SS
'eallocation of fre(uencies among :TSs
Time and fre(uency synchroni9ation
,ower management
Time-delay measurements of received signals from the MS
T%e Network Switc%ing S$.s/stem CNSSD"
The 0etwor! switching system (0SS$ the main part of which is the Mobile Switching
&enter (MS&$ performs the switching of calls between the mobile and other fi8ed or mobile networ!
users$ as well as the management of mobile services such as authentication.

66
The switching system includes the following functional elements.
Home 3ocation egister CH3D"
The >%' is a database used for storage and management of subscriptions. The >%' is
considered the most important database$ as it stores permanent data about subscribers$ including a
subscriber<s service profile$ location information$ and activity status. Bhen an individual buys a
subscription in the form of S*M then all the information about this subscription is registered in the
>%' of that operator.
+o.ile Ser)ices Switc%ing Center C+SCD"
The central component of the 0etwor! Subsystem is the MS&. The MS& performs the
switching of calls between the mobile and other fi8ed or mobile networ! users$ as well as the
management of mobile services such as such as registration$ authentication$ location updating$
handovers$ and call routing to a roaming subscriber. *t also performs such functions as toll tic!eting$
networ! interfacing$ common channel signaling$ and others. Every MS& is identified by a uni(ue *D.
>isitor 3ocation egister C>3D"
The K%' is a database that contains temporary information about subscribers that is needed
by the MS& in order to service visiting subscribers. The K%' is always integrated with the MS&.
Bhen a mobile station roams into a new MS& area$ the K%' connected to that MS& will re(uest data
about the mobile station from the >%'. %ater$ if the mobile station ma!es a call$ the K%' will have
the information needed for call setup without having to interrogate the >%' each time.
A$t%entication Center CA#CD"
The )uthentication &enter is a protected database that stores a copy of the secret !ey stored
in each subscriber<s S*M card$ which is used for authentication and ciphering of the radio channel. The
)C& protects networ! operators from different types of fraud found in today<s cellular world.
E@$i&ment Identit/ egister CEID"
67
The E(uipment *dentity 'egister (E*' is a database that contains a list of all valid mobile
e(uipment on the networ!$ where its *nternational Mobile E(uipment *dentity (*ME* identifies each
MS. )n *ME* is mar!ed as invalid if it has been reported stolen or is not type approved.
1D T%e O&eration S$&&ort S$.s/stem COSSD"
The operations and maintenance center (=M& is connected to all e(uipment in the switching
system and to the :S&. The implementation of =M& is called the operation and support system
(=SS.
>ere are some of the =M& functions#
)dministration and commercial operation (subscription$ end terminals$ charging and
statistics.
Security Management.
0etwor! configuration$ =peration and ,erformance Management.
Maintenance Tas!s.
The operation and Maintenance functions are based on the concepts of the Telecommunication
Management 0etwor! (TM0 which is standardi9ed in the *TC-T series M..@.
5ollowing is the figure which shows how =M& system covers all the "SM elements.

68
The =SS is the functional entity from which the networ! operator monitors and controls the
system. The purpose of =SS is to offer the customer cost-effective support for centrali9ed$ regional
and local operational and maintenance activities that are re(uired for a "SM networ!. )n important
function of =SS is to provide a networ! overview and support the maintenance activities of different
operation and maintenance organi9ations.
T%e 7S+ S&ecifications"
Specifications for different ,ersonal &ommunication Services (,&S systems vary among the
different ,&S networ!s. The "SM specification is listed below with important characteristics.
+od$lation"
Modulation is a form of change process where we change the input information into a suitable
format for the transmission medium. Be also changed the information by demodulating the signal at
the receiving end.
The "SM uses "aussian Minimum Shift Yeying ("MSY modulation method.
Access +et%ods"
:ecause radio spectrum is a limited resource shared by all users$ a method must be devised to
divide up the bandwidth among as many users as possible.
"SM chose a combination of TDM)E5DM) as its method. The 5DM) part involves the
division by fre(uency of the total -1 M>9 bandwidth into +-/ carrier fre(uencies of -@@ !>9
bandwidth.
=ne or more carrier fre(uencies are then assigned to each :S. Each of these carrier
fre(uencies is then divided in time$ using a TDM) scheme$ into eight time slots. =ne time slot is used
for transmission by the mobile and one for reception. They are separated in time so that the mobile
unit does not receive and transmit at the same time.
Transmission ate"
69
The total symbol rate for "SM at + bit per symbol in "MSY produces -7@.6.. Y
symbolsEsecond. The gross transmission rate of the time slot is --.6 Ybps.
"SM is a digital system with an over-the-air bit rate of -7@ !bps.
;re@$enc/ ,and"
The uplin! fre(uency range specified for "SM is ?.. - ?4@ M>9 (basic ?@@ M>9 band only.
The downlin! fre(uency band 6?@ - ?+1 M>9 (basic ?@@ M>9 band only.
C%annel S&acing" This indicates separation between adjacent carrier fre(uencies. *n "SM$ this is
-@@ !>9.
S&eec% Coding"
"SM uses linear predictive coding (%,&. The purpose of %,& is to reduce the bit rate. The
%,& provides parameters for a filter that mimics the vocal tract. The signal passes through this filter$
leaving behind a residual signal. Speech is encoded at +. !bps.
D$&le0 Distance"
The duple8 distance is 6@ M>9. Duple8 distance is the distance between the uplin! and
downlin! fre(uencies. ) channel has two fre(uencies$ 6@ M>9 apart.
+isc"
5rame duration# /.4+1 ms
Duple8 Techni(ue# 5re(uency Division Duple Ming (5DD access mode previously !nown as
B&DM).
Speech channels per '5 channel# 6.
Ad)antages of 7S+"
70
"SM is already used worldwide with over /1@ million subscribers.
*nternational roaming permits subscribers to use one phone throughout Bestern Europe.
&DM) will wor! in )sia$ but not 5rance$ "ermany$ the C.Y. and other popular European
destinations.
"SM is mature$ having started in the mid-6@s. This maturity means a more stable networ!
with robust features. &DM) is still building its networ!.
"SM<s maturity means engineers cut their teeth on the technology$ creating an unconscious
preference.
The availability of Subscriber *dentity Modules$ which are smart cards that provide secure data
encryption give "SM m-commerce advantages.
7S+ CO++ANDS"
&ommands always start with )T (which means )ttention and finish with a ]&'^ character.
Information res&onses and res$lt codes
'esponses start and end with ]&'^]%5^$ e8cept for the )TK@ D&E response format and the )T[+
(result code suppression commands.
O *f command synta8 is incorrect$ an EO string is returned.
O *f command synta8 is correct but with some incorrect parameters$ the HC+E EO"
]Err^ or HC+S EO" ]Sms Err^ strings are returned with different error codes.
O *f the command line has been performed successfully$ an OE string is returned.
*n some cases$ such as 2)TP&,*0_3 or (unsolicited incoming events$ the product does not return the
OE string as a response.
*n the following e8amples ]&'^ and ]&'^]%5^ are intentionally omitted.
!. +an$fact$rer identification HC7+I
(. e@$est model identification HC7++
71
*. e@$est re)ision identification HC7+
1. Prod$ct Serial N$m.er HC7SN
4. Dial command D
ATDIn.J where ]nb^ is the destination phone number.
,lease note that for an international n$m.er$ the local international prefi8 does not need to be set
(usually @@ but does need to be replaced by the KHL character.
E8ample# to set up a voice call to Bavecom offices from another country$ the )T command is#
2ATDH**!15(9:8::MN
0ote that some countries may have specific numbering rules for their "SM handset numbering. The
response to the )TD command is one of the following#
5. Hang?#& command H
Descri&tion"
The )T> (or )T>@ command disconnects the remote user. *n the case of multiple calls$ all calls are
released (active$ on-hold and waiting calls. The specific Bavecom )T>+ command has been
appended to disconnect the current outgoing call$ only in dialing or alerting state (ie. )T>+ can be
used only after the )TD command$ and before its terminal response (=Y$ 0= &)''*E'$ .... *t can
be useful in the case of multiple calls.
S/nta0"
&ommand synta8# )T>
6. Answer a call A
Descri&tion"
Bhen the product receives a call$ it sets the ingInd signal and sends the )S&** 2IN73 or
2HCIN7" It/&eJ3 string to the application (P&'*0" if the cellular result code P&'& is enabled.
Then it waits for the application to accept the call with the )T) command.
S/nta0"
72
&ommand synta8# )T)
8. edial last tele&%one n$m.er ATD3
Descri&tion"
This command redials the last number used in the )TD command. The last number dialed is displayed
followed by 2J3 for voice calls only
S/nta0"
&ommand synta8# )TD%
9. Preferred +essage ;ormat HC+7;
Descri&tion"
The message formats supported are te8t mode and ,DC mode. *n ,DC mode$ a complete SMS
Message including all header information is given as a binary string (in he8adecimal format.
Therefore$ only the following set of characters is allowed# `U@Q$Q+Q$Q-Q$Q.Q$Q/Q$Q1Q$Q4Q$Q7Q$Q6Q$Q?Q$ U)Q$
U:Q$Q&Q$QDQ$QEQ$Q5Qa. Each pair or characters are converted to a byte (e.g.# U/+Q is converted to the
)S&** character U)Q$ whose )S&** code is @8/+ or 41. *n Te8t mode$ all commands and responses
are in )S&** characters. The format selected is stored in EE,'=M by the P&S)S command.
S/nta0"
&ommand synta8# )TP&M"5
!:. ead message HC+7
Descri&tion"
This command allows the application to read stored messages. The messages are read from the
memory selected by HCP+S command.
S/nta0"
&ommand synta8# )TP&M"'N]inde8^
!!. Send message HC+7S
Descri&tion"
73
The ]address^ field is the address of the terminal to which the message is sent. To send the message$
simply type$ ]ctrl-b^ character ()S&** -4. The te8t can contain all e8isting characters e8cept ]ctrl-
b^ and ]ES&^ ()S&** -7. This command can be aborted using the ]ES&^ character when entering
te8t. *n ,DC mode$ only he8adecimal characters are used (U@QLQ?Q$Q)QLQ5Q.
S/nta0"
)TP&M"SN ]length^ ]&'^
,DC is entered ]ctrl-b E ES& ^
!(. Delete message HC+7D
Descri&tion"
This command deletes one or several messages from preferred message storage (2:M3 SMS &:
U')M storageQ$ 2SM3 SMS,, storage US*M storageQ or 2S'3 SMS Status-'eport storage.
S/nta0"
&ommand synta8# )TP&M"DN]*nde8^ G$]Del5alg^H
*.8 ela/"
) rela/ is an electrically operated switch. Many relays use an electromagnet to operate a
switching mechanism$ but other operating principles are also used. 'elays find applications where it is
necessary to control a circuit by a low-power signal$ or where several circuits must be controlled by
one signal. The first relays were used in long distance telegraph circuits$ repeating the signal coming
in from one circuit and re-transmitting it to another. 'elays found e8tensive use in telephone
e8changes and early computers to perform logical operations. ) type of relay that can handle the high
power re(uired to directly drive an electric motor is called a contactor. Solid-state relays control
power circuits with no moving parts$ instead using a semiconductor device triggered by light to
perform switching. 'elays with calibrated operating characteristics and sometimes multiple operating
74
coils are used to protect electrical circuits from overload or faultsJ in modern electric power systems
these functions are performed by digital instruments still called ;protection relays;.
*.8.! T/&es of rela/s"
!. Sim&le electromec%anical rela/"
75
) simple electromagnetic relay$ such as the one ta!en from a car in the first picture$ is an adaptation of
an electromagnet. *t consists of a coil of wire surrounding a soft iron core$ an iron yo!e$ which
provides a low reluctance path for magnetic flu8$ a movable iron armature$ and a set$ or sets$ of
contactsJ two in the relay pictured. The armature is hinged to the yo!e and mechanically lin!ed to a
moving contact or contacts. *t is held in place by a spring so that when the relay is de-energi9ed there
is an air gap in the magnetic circuit. *n this condition$ one of the two sets of contacts in the relay
pictured is closed$ and the other set is open. =ther relays may have more or fewer sets of contacts
depending on their function. The relay in the picture also has a wire connecting the armature to the
yo!e. This ensures continuity of the circuit between the moving contacts on the armature$ and the
circuit trac! on the printed circuit board (,&: via the yo!e$ which is soldered to the ,&:.
,asic design and o&eration"
Bhen an electric current is passed through the coil$ the resulting magnetic field attracts the armature
and the conse(uent movement of the movable contact or contacts either ma!es or brea!s a connection
with a fi8ed contact. *f the set of contacts was closed when the relay was De-energi9ed$ then the
movement opens the contacts and brea!s the connection$ and vice versa if the contacts were open.
Bhen the current to the coil is switched off$ the armature is returned by a force$ appro8imately half as
strong as the magnetic force$ to its rela8ed position. Csually this force is provided by a spring$ but
gravity is also used commonly in industrial motor starters. Most relays are manufactured to operate
(uic!ly. *n a low voltage application$ this is to reduce noise. *n a high voltage or high current
application$ this is to reduce arcing.
*f the coil is energi9ed with D&$ a diode is fre(uently installed across the coil$ to dissipate the energy
from the collapsing magnetic field at deactivation$ which would otherwise generate a voltage spi!e
dangerous to circuit components. Some automotive relays already include a diode inside the relay
case. )lternatively a contact protection networ!$ consisting of a capacitor and resistor in series$ may
absorb the surge. *f the coil is designed to be energi9ed with )&$ a small copper ring can be crimped
76
to the end of the solenoid. This ;shading ring; creates a small out-of-phase current$ which increases
the minimum pull on the armature during the )& cycle.
:y analogy with the functions of the original electromagnetic device$ a solid-state relay is made with
a thyristor or other solid-state switching device. To achieve electrical isolation an opt coupler can be
used which is a light-emitting diode (%ED coupled with a photo transistor. Small relay as used in
electronics
(. 3atc%ing rela/
%atching relay$ dust cover removed$ showing pawl and ratchet mechanism. The ratchet operates a
cam$ which raises and lowers the moving contact arm$ seen edge-on just below it. The moving and
fi8ed contacts are visible at the left side of the image.
) latc%ing rela/ has two rela8ed states (bi stable. These are also called ;impulse;$ ;!eep;$ or ;stay;
relays. Bhen the current is switched off$ the relay remains in its last state. This is achieved with a
solenoid operating a ratchet and cam mechanism$ or by having two opposing coils with an over-center
spring or permanent magnet to hold the armature and contacts in position while the coil is rela8ed$ or
with a remnant core. *n the ratchet and cam e8ample$ the first pulse to the coil turns the relay on and
the second pulse turns it off. *n the two coil e8ample$ a pulse to one coil turns the relay on and a pulse
to the opposite coil turns the relay off. This type of relay has the advantage that it consumes power
only for an instant$ while it is being switched$ and it retains its last setting across a power outage. )
remnant core latching relay re(uires a current pulse of opposite polarity to ma!e it change state.
77
*. eed rela/
) reed rela/ has a set of contacts inside a vacuum or inert gas filled glass tube$ which protects the
contacts against atmospheric corrosion. The contacts are closed by a magnetic field generated when
current passes through a coil around the glass tube. 'eed relays are capable of faster switching speeds
than larger types of relays$ but have low switch current and voltage ratings.
1. +erc$r/?wetted rela/
) merc$r/?wetted reed rela/ is a form of reed relay in which the contacts are wetted with mercury.
Such relays are used to switch low-voltage signals (one volt or less because of their low contact
resistance$ or for high-speed counting and timing applications where the mercury eliminates contact
bounce. Mercury wetted relays are position-sensitive and must be mounted vertically to wor!
properly. :ecause of the to8icity and e8pense of li(uid mercury$ these relays are rarely specified for
new e(uipment. See also mercury switch.
4. PolariOed rela/
) &olariOed rela/ placed the armature between the poles of a permanent magnet to increase
sensitivity. ,olari9ed relays were used in middle -@th &entury telephone e8changes to detect faint
pulses and correct telegraphic distortion. The poles were on screws$ so a technician could first adjust
them for ma8imum sensitivity and then apply a bias spring to set the critical current that would
operate the relay.
5. +ac%ine tool rela/
) mac%ine tool rela/ is a type standardi9ed for industrial control of machine tools$ transfer machines$
and other se(uential control. They are characteri9ed by a large number of contacts (sometimes
e8tendable in the field which are easily converted from normally-open to normally-closed status$
78
easily replaceable coils$ and a form factor that allows compactly installing many relays in a control
panel. )lthough such relays once were the bac!bone of automation in such industries as automobile
assembly$ the programmable logic controller (,%& mostly displaced the machine tool relay from
se(uential control applications.
6. Contactor rela/
) contactor is a very heavy-duty relay used for switching electric motors and lighting loads.
&ontinuous current ratings for common contactors range from +@ amps to several hundred amps.
>igh-current contacts are made with alloys containing silver. The unavoidable arcing causes the
contacts to o8idi9eJ however$ silver o8ide is still a good conductor. Such devices are often used for
motor starters. ) motor starter is a contactor with overload protection devices attached. The overload
sensing devices are a form of heat operated relay where a coil heats a bi-metal strip$ or where a solder
pot melts$ releasing a spring to operate au8iliary contacts. These au8iliary contacts are in series with
the coil. *f the overload senses e8cess current in the load$ the coil is de-energi9ed. &ontactor relays
can be e8tremely loud to operate$ ma!ing them unfit for use where noise is a chief concern.
8. Solid?state rela/
Solid state relay$ which has no moving parts
79
-1 ) or /@ ) solid state contactors
) solid state rela/ (SS is a solid state electronic component that provides a similar function to an
electromechanical relay but does not have any moving components$ increasing long-term reliability.
Bith early SS'<s$ the tradeoff came from the fact that every transistor has a small voltage drop across
it. This voltage drop limited the amount of current a given SS' could handle. )s transistors improved$
higher current SS'<s$ able to handle +@@ to +$-@@ )mperes$ have become commercially available.
&ompared to electromagnetic relays$ they may be falsely triggered by transients.
9. Solid state contactor rela/
) solid state contactor is a very heavy-duty solid state relay$ including the necessary heat sin!$ used
for switching electric heaters$ small electric motors and lighting loadsJ where fre(uent onEoff cycles
are re(uired. There are no moving parts to wear out and there is no contact bounce due to vibration.
They are activated by )& control signals or D& control signals from ,rogrammable logic controller
(,%&s$ ,&s$ Transistor-transistor logic (TT% sources$ or other microprocessor and microcontroller
controls.
!:. ,$c%%olO rela/
) ,$c%%olO rela/ is a safety device sensing the accumulation of gas in large oil-filled transformers$
which will alarm on slow accumulation of gas or shut down the transformer if gas is produced rapidly
in the transformer oil.
!!. ;orced?g$ided contacts rela/
) forced?g$ided contacts rela/ has relay contacts that are mechanically lin!ed together$ so that when
the relay coil is energi9ed or de-energi9ed$ all of the lin!ed contacts move together. *f one set of
contacts in the relay becomes immobili9ed$ no other contact of the same relay will be able to move.
The function of forced-guided contacts is to enable the safety circuit to chec! the status of the relay.
5orced-guided contacts are also !nown as ;positive-guided contacts;$ ;captive contacts;$ ;loc!ed
contacts;$ or ;safety relays;.
80
!(. O)erload &rotection rela/
Electric motors need over current protection to prevent damage from over-loading the motor$ or to
protect against short circuits in connecting cables or internal faults in the motor windings. =ne type of
electric motor overload protection relay is operated by a heating element in series with the electric
motor. The heat generated by the motor current heats a bimetallic strip or melts solder$ releasing a
spring to operate contacts. Bhere the overload relay is e8posed to the same environment as the motor$
a useful though crude compensation for motor ambient temperature is provided.
+.. ,ole and throw#
&ircuit symbols of relays. ;&; denotes the common terminal in S,DT and D,DT types.
The diagram on the pac!age of a D,DT )& coil relay
Since relays are switches$ the terminology applied to switches is also applied to relays. ) relay will
switch one or more poles$ each of whose contacts can be thrown by energi9ing the coil in one of three
ways#
81
0ormally-open (NO contacts connect the circuit when the relay is activatedJ the circuit is
disconnected when the relay is inactive. *t is also called a ;orm A contact or ;ma!e; contact.
0ormally-closed (NC contacts disconnect the circuit when the relay is activatedJ the circuit is
connected when the relay is inactive. *t is also called a ;orm , contact or ;brea!; contact.
&hange-over (CO$ or double-throw (DT$ contacts control two circuits# one normally-open
contact and one normally-closed contact with a common terminal. *t is also called a ;orm C
contact or ;transfer; contact (;brea! before ma!e;. *f this type of contact utili9es3 ma!e
before brea!; functionality$ then it is called a ;orm D contact.
The following designations are commonly encountered#
SPST A Single ,ole Single Throw. These have two terminals which can be connected or
disconnected. *ncluding two for the coil$ such a relay has four terminals in total. *t is
ambiguous whether the pole is normally open or normally closed. The terminology ;S,0=;
and ;S,0&; is sometimes used to resolve the ambiguity.
SPDT A Single ,ole Double Throw. ) common terminal connects to either of two others.
*ncluding two for the coil$ such a relay has five terminals in total.
DPST A Double ,ole Single Throw. These have two pairs of terminals. E(uivalent to two
S,ST switches or relays actuated by a single coil. *ncluding two for the coil$ such a relay has
si8 terminals in total. The poles may be 5orm ) or 5orm : (or one of each.
DPDT A Double ,ole Double Throw. These have two rows of change-over terminals.
E(uivalent to two S,DT switches or relays actuated by a single coil. Such a relay has eight
terminals$ including the coil.
The ;S; or ;D; may be replaced with a number$ indicating multiple switches connected to a single
actuator. 5or e8ample /,DT indicates a four pole double throw relay (with +/ terminals.
82
*.8.( A&&lications of ela/s"
&ontrol a high-voltage circuit with a low-voltage signal$ as in some types of modems or audio
amplifiers$
&ontrol a high-current circuit with a low-current signal$ as in the starter solenoid of an
automobile$
Detect and isolate faults on transmission and distribution lines by opening and closing circuit
brea!ers (protection relays$
) D,DT )& coil relay with ;ice cube; pac!aging
*solate the controlling circuit from the controlled circuit when the two are at different
potentials$ for e8ample when controlling a mains-powered device from a low-voltage switch.
The latter is often applied to control office lighting as the low voltage wires are easily installed
in partitions$ which may be often moved as needs change. They may also be controlled by
room occupancy detectors in an effort to conserve energy$
%ogic functions. 5or e8ample$ the :oolean )0D function is reali9ed by connecting normally
open relay contacts in series$ the =' function by connecting normally open contacts in
parallel. The change-over or 5orm & contacts perform the M=' (e8clusive or function.
Similar functions for 0)0D and 0=' are accomplished using normally closed contacts. The
%adder programming language is often used for designing relay logic networ!s.
83
o Early computing. :efore vacuum tubes and transistors$ relays were used as logical
elements in digital computers. See )'') (computer$ >arvard Mar! **$ buse b-$ and
buse b..
o Safety-critical logic. :ecause relays are much more resistant than semiconductors to
nuclear radiation$ they are widely used in safety-critical logic$ such as the control
panels of radioactive waste-handling machinery.
Time delay functions. 'elays can be modified to delay opening or delay closing a set of
contacts. ) very short (a fraction of a second delay would use a copper dis! between the
armature and moving blade assembly. &urrent flowing in the dis! maintains magnetic field for
a short time$ lengthening release time. 5or a slightly longer (up to a minute delay$ a dashpot is
used. ) dashpot is a piston filled with fluid that is allowed to escape slowly. The time period
can be varied by increasing or decreasing the flow rate. 5or longer time periods$ a mechanical
cloc!wor! timer is installed.
Ad)antages of rela/s"
'elays can switch AC and DC$ transistors can only switch D&.
'elays can switch %ig% )oltages$ transistors cannot.
'elays are a better choice for switching large c$rrents (^ 1).
'elays can switch man/ contacts at once.
Disad)antages of rela/s"
'elays are .$lkier than transistors for switching small currents.
'elays cannot switc% ra&idl/ (e8cept reed relays$ transistors can switch many times per
second.
'elays $se more &ower due to the current flowing through their coil.
'elays re@$ire more c$rrent t%an man/ ICs can &ro)ide$ so a low power transistor may be
needed to switch the current for the relay<s coil.
84
*.8.* ela/ Dri)er"
The current needed to operate the relay coil is more than can be supplied by most chips (op.
amps etc$ so a transistor is usually needed$ as shown in the diagram below.
Cse :&+@?& or similar. ) resistor of about /!7 will probably be alright. The diode is needed
to short circuit the high voltage 2bac! emf3 induced when current flowing through the coil is suddenly
switched off.
;ig. 6.( ela/ Dri)er
85
*.9 3CD DISP3A-
3CD ,ackgro$nd"
=ne of the most common devices attached to a micro controller is an %&D display. Some of the most
common %&DQs connected to the many microcontrollers are +48- and -@8- displays. This means +4
characters per line by - lines and -@ characters per line by - lines$ respectively.
,asic !50 ( C%aracters 3CD
;ig$re !" 3CD Pin diagram
Pin descri&tion"
Pin No. Name Descri&tion
,in no. + >SS ,ower supply ("0D
86
,in no. - >CC ,ower supply (P1K
,in no. . >EE &ontrast adjust
,in no. / S
@ N *nstruction input
+ N Data input
,in no. 1 F2
@ N Brite to %&D module
+ N 'ead from %&D module
,in no. 4 EN Enable signal
,in no. 7 D: Data bus line @ (%S:
,in no. 6 D! Data bus line +
,in no. ? D( Data bus line -
,in no. +@ D* Data bus line .
,in no. ++ D1 Data bus line /
,in no. +- D4 Data bus line 1
,in no. +. D5 Data bus line 4
,in no. +/ D6 Data bus line 7 (MS:
Ta.le !" C%aracter 3CD &ins wit% +icrocontroller
The %&D re(uires . control lines as well as either / or 6 *E= lines for the data bus. The user may
select whether the %&D is to operate with a /-bit data bus or an 6-bit data bus. *f a /-bit data bus is
used the %&D will re(uire a total of 7 data lines (. control lines plus the / lines for the data bus. *f an
6-bit data bus is used the %&D will re(uire a total of ++ data lines (. control lines plus the 6 lines for
the data bus.
The three control lines are referred to as EN$ S$ and 2.
The EN line is called ;Enable.; This control line is used to tell the %&D that we are sending it data. To
send data to the %&D$ our program should ma!e sure this line is low (@ and then set the other two
control lines andEor put data on the data bus. Bhen the other lines are completely ready$ bring EN
87
high (+ and wait for the minimum amount of time re(uired by the %&D datasheet (this varies from
%&D to %&D$ and end by bringing it low (@ again.
The S line is the ;'egister Select; line. Bhen 'S is low (@$ the data is to be treated as a
command or special instruction (such as clear screen$ position cursor$ etc.. Bhen 'S is high (+$ the
data being sent is te8t data which should be displayed on the screen. 5or e8ample$ to display the letter
;T; on the screen we would set 'S high.
The 2 line is the ;'eadEBrite; control line. Bhen 'B is low (@$ the information on the data
bus is being written to the %&D. Bhen 'B is high (+$ the program is effectively (uerying (or
reading the %&D. =nly one instruction (;"et %&D status; is a read command. )ll others are write
commands--so 'B will almost always be low.
5inally$ the data bus consists of / or 6 lines (depending on the mode of operation selected by
the user. *n the case of an 6-bit data bus$ the lines are referred to as D:@$ D:+$ D:-$ D:.$ D:/$
D:1$ D:4$ and D:7.
Sc%ematic"
Circ$it Descri&tion"
88
)bove is the (uite simple schematic. The %&D panel<s Enable and 'egister Select is connected
to the &ontrol ,ort. The &ontrol ,ort is an open collector E open drain output. Bhile most ,arallel
,orts have internal pull-up resistors$ there is a few which don<t. Therefore by incorporating the two
+@Y e8ternal pull up resistors$ the circuit is more portable for a wider range of computers$ some of
which may have no internal pull up resistors.
Be ma!e no effort to place the Data bus into reverse direction. Therefore we hard wire the
'EB line of the %&D panel$ into write mode. This will cause no bus conflicts on the data lines. )s a
result we cannot read bac! the %&D<s internal :usy 5lag which tells us if the %&D has accepted and
finished processing the last instruction. This problem is overcome by inserting !nown delays into our
program.
The +@! ,otentiometer controls the contrast of the %&D panel. 0othing fancy here. )s with
all the e8amples$ *<ve left the power supply out. Be can use a bench power supply set to 1v or use an
onboard P1 regulator. 'emember a few de-coupling capacitors$ especially if we have trouble with the
circuit wor!ing properly.
SET, 2
>andling the E0 control line#
)s we mentioned above$ the E0 line is used to tell the %&D that we are ready for it to e8ecute
an instruction that we<ve prepared on the data bus and on the other control lines. 0ote that the E0 line
must be raisedE lowered beforeEafter each instruction sent to the %&D regardless of whether that
instruction is read or write te8t or instruction. *n short$ we must always manipulate E0 when
communicating with the %&D. E0 is the %&D<s way of !nowing that we are tal!ing to it. *f we don<t
raiseElower E0$ the %&D doesn<t !now we<re tal!ing to it on the other lines.
Thus$ before we interact in any way with the %&D we will always bring the EN line low with
the following instruction#
C3 EN
89
)nd once we<ve finished setting up our instruction with the other control lines and data bus lines$
we<ll always bring this line high#
SET, EN
The line must be left high for the amount of time re(uired by the %&D as specified in its
datasheet. This is normally on the order of about -1@ nanoseconds$ but chec!s the datasheet. *n the
case of a typical microcontroller running at +- M>9$ an instruction re(uires +.@6 microseconds to
e8ecute so the E0 line can be brought low the very ne8t instruction. >owever$ faster microcontrollers
(such as the DS6?&/-@ which e8ecutes an instruction in ?@ nanoseconds given an ++.@1?- M>9
crystal will re(uire a number of 0=,s to create a delay while E0 is held high. The number of 0=,s
that must be inserted depends on the microcontroller we are using and the crystal we have selected.
The instruction is e8ecuted by the %&D at the moment the E0 line is brought low with a final
&%' E0 instruction.
C%ecking t%e .$s/ stat$s of t%e 3CD"
)s previously mentioned$ it ta!es a certain amount of time for each instruction to be e8ecuted
by the %&D. The delay varies depending on the fre(uency of the crystal attached to the oscillator input
of the %&D as well as the instruction which is being e8ecuted.
Bhile it is possible to write code that waits for a specific amount of time to allow the %&D to
e8ecute instructions$ this method of ;waiting; is not very fle8ible. *f the crystal fre(uency is changed$
the software will need to be modified. ) more robust method of programming is to use the ;"et %&D
Status; command to determine whether the %&D is still busy e8ecuting the last instruction received.
The ;"et %&D Status; command will return to us two tidbits of informationJ the information
that is useful to us right now is found in D:7. *n summary$ when we issue the ;"et %&D Status;
command the %&D will immediately raise D:7 if it<s still busy e8ecuting a command or lower D:7 to
indicate that the %&D is no longer occupied. Thus our program can (uery the %&D until D:7 goes
low$ indicating the %&D is no longer busy. )t that point we are free to continue and send the ne8t
command.
A&&lications"
90
Medical e(uipment
Electronic test e(uipment
*ndustrial machinery *nterface
Serial terminal
)dvertising system
E,=S
'estaurant ordering systems
"aming bo8
Security systems
'ID Test units
&limati9ing units
,%& *nterface
Simulators
Environmental monitoring
%ab development
Student projects
>ome automation
,& e8ternal display
>M* operator interface.
*.!! Tam&er Switc%
P#SH ,#TTONF CONTO3 S2ITCH"
) push-button (also spelled pushbutton (press-button in the CY or simply button is a simple
switch mechanism for controlling some aspect of a machine or a process. :uttons are typically made
out of hard material$ usually plastic or metal. The surface is usually flat or shaped to accommodate the
human finger or hand$ so as to be easily depressed or pushed. :uttons are most often biased switches$
though even many un-biased buttons (due to their physical nature re(uire a spring to return to their
un-pushed state. Different people use different terms for the ;pushing; of the button$ such as press$
depress$ mash$ and punch.
91
#ses"
The ;push-button; has been utili9ed in calculators$ push-button telephones$ !itchen appliances$
and various other mechanical and electronic devices$ home and commercial.
*n industrial and commercial applications$ push buttons can be lin!ed together by a mechanical
lin!age so that the act of pushing one button causes the other button to be released. *n this way$ a stop
button can ;force; a start button to be released. This method of lin!age is used in simple manual
operations in which the machine or process have no electrical circuits for control.
,ushbuttons are often color-coded to associate them with their function so that the operator
will not push the wrong button in error. &ommonly used colors are red for stopping the machine or
process and green for starting the machine or process.
'ed pushbuttons can also have large heads (called mushroom heads for easy operation and to
facilitate the stopping of a machine. These pushbuttons are called emergency stop buttons and are
mandated by the electrical code in many jurisdictions for increased safety. This large mushroom shape
can also be found in buttons for use with operators who need to wear gloves for their wor! and could
not actuate a regular flush-mounted push button. )s an aid for operators and users in industrial or
commercial applications$ a pilot light is commonly added to draw the attention of the user and to
provide feedbac! if the button is pushed. Typically this light is included into the center of the
pushbutton and a lens replaces the pushbutton hard center dis!. The source of the energy to illuminate
the light is not directly tied to the contacts on the bac! of the pushbutton but to the action the
pushbutton controls. *n this way a start button when pushed will cause the process or machine
operation to be started and a secondary contact designed into the operation or process will close to
turn on the pilot light and signify the action of pushing the button caused the resultant process or
action to start.
*n popular culture$ the phrase ;the button; (sometimes capitali9ed refers to a (usually
fictional button that a military or government leader could press to launch nuclear weapons.
) %oad control switch is a remotely controlled relay that is placed on home appliances which
consume large amounts of electricity$ such as air conditioner units and electric water heaters.
92
Most load control switches consist of a communication module and the relay switch and
can be used as part of a demand response energy efficiency system such as a smart grid. Such a switch
operates similarly to a pager$ receiving signals from the power company or electrical fre(uency shift
to turn off or reduce power to the appliance during times of pea! electrical demand. Csually$ the
device has a timer that will automatically reset the switch bac! on after a preset time. Some operation
intolerant appliances$ such as dryers$ use switches that can reduce or shut off power to their heating
coils yet still tumble until signaled to resume full power G+H.
CHAPTE 1" SO;T2AE DESCIPTION
This project is implemented using following softwareQs#
E8press ,&: A for designing circuit
,*& & compiler - for compilation part
,roteus 7 (Embedded & A for simulation part
1.! E0&ress PC,"
:readboards are great for prototyping e(uipment as it allows great fle8ibility to modify
a design when neededJ however the final product of a project$ ideally should have a neat ,&:$ few
cables$ and survive a sha!e test. 0ot only is a proper ,&: neater but it is also more durable as there
are no cables which can yan! loose.
E8press ,&: is a software tool to design ,&:s specifically for manufacture by the
company E8press ,&: (no other ,&: ma!er accepts E8press ,&: files. *t is very easy to use$ but it
does have several limitations.
*t can be li!ened to more of a toy then a professional &)D program.
*t has a poor part library (which we can wor! around
*t cannot import or e8port files in different formats
*t cannot be used to ma!e prepare boards for D*S production
E8press ,&: has been used to design many ,&:s (some layered and with surface-mount
parts. ,rint out ,&: patterns and use the toner transfer method with an Etch 'esistant ,en to ma!e
93
boards. >owever$ E8press ,&: does not have a nice print layout. >ere is the procedure to design in
E8press ,&: and clean up the patterns so they print nicely.
1.!.! Pre&aring E0&ress PC, for ;irst #se"
E8press ,&: comes with a less then e8citing list of parts. So before any project is
started head over to )udio logical and grab the additional parts by morsel$ ppl$ and tangent$ and
e8tract them into your E8press ,&: directory. )t this point start the program and get ready to setup
the wor!space to suit your style.
&lic! Kiew -^ =ptions. *n this menu$ setup the units for 2mm3 or 2in3 depending on
how you thin!$ and clic! 2see through the top copper layer3 at the bottom. The standard color scheme
of red and green is generally used but it is not as pleasing as red and blue.
1.!.( T%e Interface"
Bhen a project is first started you will be greeted with a yellow outline. This yellow
outline is the dimension of the ,&:. Typically after positioning of parts and traces$ move them to their
final position and then crop the ,&: to the correct si9e. >owever$ in designing a board with a certain
si9e constraint$ crop the ,&: to the correct si9e before starting.
5ig# /.+ show the toolbar in which the each button has the following functions#
;ig 1.!" Tool .ar necessar/ for t%e interface
The select tool# *t is fairly obvious what this does. *t allows you to move and manipulate
parts. Bhen this tool is selected the top toolbar will show buttons to move traces to the top E
bottom copper layer$ and rotate buttons.
The 9oom to selection tool# does just that.
The place pad# button allows you to place small soldier pads which are useful for board
connections or if a part is not in the part library but the part dimensions are available. Bhen
94
this tool is selected the top toolbar will give you a large selection of round holes$ s(uare holes
and surface mount pads.
The place component# tool allows you to select a component from the top toolbar and then by
clic!ing in the wor!space places that component in the orientation chosen using the buttons
ne8t to the component list. The components can always be rotated afterwards with the select
tool if the orientation is wrong.
The place trace# tool allows you to place a solid trace on the board of varying thic!nesses. The
top toolbar allows you to select the top or bottom layer to place the trace on.
The *nsert &orner in trace# button does e8actly what it says. Bhen this tool is selected$
clic!ing on a trace will insert a corner which can be moved to route around components and
other traces.
The remove a trace button is not very important since the delete !ey will achieve the same
result.
1.!.* Design Considerations"
:efore starting a project there are several ways to design a ,&: and one must be
chosen to suit the projectQs needs.
Bhen ma!ing a ,&: you have the option of ma!ing a single sided board$ or a double
sided board. Single sided boards are cheaper to produce and easier to etch$ but much harder to
design for large projects. *f a lot of parts are being used in a small space it may be difficult to ma!e
a single sided board without jumpering over traces with a cable. Bhile thereQs technically nothing
wrong with this$ it should be avoided if the signal travelling over the traces is sensitive (e.g. audio
signals.
) double sided board is more e8pensive to produce professionally$ more difficult to
etch on a D*S board$ but ma!es the layout of components a lot smaller and easier. *t should be noted
that if a trace is running on the top layer$ chec! with the components to ma!e sure you can get to its
pins with a soldering iron.
95
%arge capacitors$ relays$ and similar parts which donQt have a8ial leads can 0=T have traces on top
unless boards are plated professionally.
Bhen using a double sided board you must consider which traces should be on what side of the
board. "enerally$ put power traces on the top of the board$ jumping only to the bottom if a part
cannot be soldiered onto the top plane (li!e a relay$ and vice- versa.
Some projects li!e power supplies or amps can benefit from having a solid plane to use
for ground. *n power supplies this can reduce noise$ and in amps it minimi9es the distance between
parts and their ground connections$ and !eeps the ground signal as simple as possible. >owever$
care must be ta!en with stubborn chips such as the T,)4+-@ amplifier from T*. The T,)4+-@
datasheet specifies not to run a ground plane under the pins or signal traces of this chip as the
capacitance generated could effect performance negatively.
1.( PIC Com&iler"
,*& compiler is software used where the machine language code is written and
compiled. )fter compilation$ the machine source code is converted into he8 code which is to be
dumped into the microcontroller for further processing. ,*& compiler also supports & language code.
*tQs important that you !now & language for microcontroller which is commonly
!nown as Embedded &. )s we are going to use ,*& &ompiler$ hence we also call it ,*& &. The ,&:$
,&M$ and ,&> are separate compilers. ,&: is for +--bit opcodes$ ,&M is for +/-bitopcodes$ and
,&> is for +4-bit opcode ,*& microcontrollers. Due to many similarities$ all three compilers are
covered in this reference manual. 5eatures and limitations that apply to only specific microcontrollers
are indicated within. These compilers are specifically designed to meet the uni(ue needs of the ,*&
microcontroller. This allows developers to (uic!ly design applications software in a more readable$
high-level language. Bhen compared to a more traditional & compiler$ ,&:$ ,&M$ and ,&> have
some limitations. )s an e8ample of the limitations$ function recursion is not allowed.
This is due to the fact that the ,*& has no stac! to push variables onto$ and also
because of the way the compilers optimi9e the code. The compilers can efficiently implement normal
& constructs$ inputEoutput operations$ and bit twiddling operations. )ll normal & data types are
supported along with pointers to constant arrays$ fi8ed point decimal$ and arrays of bits.
,*& & is not much different from a normal & program. *f you !now assembly$ writing
a & program is not a crisis. *n ,*&$ we will have a main function$ in which all your application
96
specific wor! will be defined. *n case of embedded &$ you do not have any operating system running
in there. So you have to ma!e sure that your program or main file should never e8it. This can be done
with the help of simple while (+ or for (JJ loop as they are going to run infinitely.
Be have to add header file for controller you are using$ otherwise you will not be able
to access registers related to peripherals.
Xinclude ]+45677).h^ EE header file for ,*& +45677)FF
1.* Prote$s"
,roteus is software which accepts only he8 files. =nce the machine code is converted
into he8 code$ that he8 code has to be dumped into the microcontroller and this is done by the ,roteus.
,roteus is a programmer which itself contains a microcontroller in 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 he8 file
from the pic compiler and dumps this he8 file into the microcontroller which is to be programmed. )s
the ,roteus programmer re(uires power supply to be operated$ this power supply is given from the
power supply circuit designed and connected to the microcontroller in proteus. The program which is
to be dumped in to the microcontroller is edited in proteus and is compiled and e8ecuted to chec! any
errors and hence after the successful compilation of the program the program is dumped in to the
microcontroller using a dumper.
1.1 Proced$ral ste&s for com&ilation< sim$lation and d$m&ing"
1.1.! Com&ilation and sim$lation ste&s"
5or ,*& microcontroller$ ,*& & compiler is used for compilation. The compilation
steps are as follows#
=pen ,*& & compiler.
97
Sou will be prompted to choose a name for the new project$ so create a separate folder where
all the files of your project will be stored$ choose a name and clic! save.
;ig 1.!" Pict$re of o&ening a new file $sing PIC C com&iler
&lic! ,roject< 0ew$ and something the bo8 named <Te8t+< is where your code should be
written later.
0ow you have to clic! <5ile$ Save as< and choose a file name for your source code ending with
the letter <.c<. Sou can name as <project.c< for e8ample and clic! save. Then you have to add
this file to your project wor!.
98
;ig 1.(" Pict$re of com&iling a new file $sing PIC C com&iler
;ig 1.*" Pict$re of com&iling a &ro'ect.c file $sing PIC C com&iler
99
Sou can then start to write the source code in the window titled <project.c< then before testing
your source codeJ you have to compile your source code$ and correct eventual synta8 errors.
;ig 1.1" Pict$re of c%ecking errors and warnings $sing PIC C com&iler
:y clic!ing on compile option .he8 file is generated automatically.
This is how we compile a program for chec!ing errors and hence the compiled program is
saved in the file where we initiated the program.
100
;ig 1.4" Pict$re of .%e0 file e0isting $sing PIC C com&iler
)fter compilation$ ne8t step is simulation. >ere first circuit is designed in E8press ,&:
using ,roteus 7 software and then simulation ta!es place followed by dumping. The simulation steps
are as follows#
=pen ,roteus 7 and clic! on *S+S4.
0ow it displays ,&: where circuit is designed using microcontroller. To design circuit
components are re(uired. So clic! on component option.
+@. 0ow clic! on letter QpQ$ then under that select ,*&+45677) $other components related to the
project and clic! =Y. The ,*& +45677) will be called your 2'Target device, which is the final
destination of your source code.

101
1.1.( D$m&ing ste&s"
The steps involved in dumping the program edited in proteus 7 to microcontroller are
shown below#
+. *nitially before connecting the program dumper to the microcontroller !it the window is
appeared as shown below.
;ig 1.5" Pict$re of &rogram d$m&er window
-. Select Tools option and clic! on &hec! &ommunication for establishing a connection as shown
in below window
102

;ig 1.6" Pict$re of c%ecking comm$nications .efore d$m&ing &rogram into microcontroller
.. )fter connecting the dumper properly to the microcontroller !it the window is appeared as shown
below.
103
;ig 1.8" Pict$re after connecting t%e d$m&er to microcontroller
104
/. )gain by selecting the Tools option and clic!ing on &hec! &ommunication the microcontroller
gets recogni9ed by the dumper and hence the window is as shown below.
105

;ig 1.9" Pict$re of d$m&er recognition to microcontroller
106
1. *mport the program which is U.he8Q file from the saved location by selecting 5ile option and
clic!ing on U*mport >e8Q as shown in below window.
107
108
;ig 1.!:" Pict$re of &rogram im&orting into t%e microcontroller
4. )fter clic!ing on U*mport >e8Q option we need to browse the location of our program and clic! the
Uprog.he8Q and clic! on UopenQ for dumping the program into the microcontroller.

;ig 1.!!" Pict$re of &rogram .rowsing w%ic% is to .e d$m&ed
7. )fter the successful dumping of program the window is as shown below.
109
;ig 1.!(" Pict$re after &rogram d$m&ed into t%e microcontroller
110
CHAPTE 4" PO=ECT DESCIPTION
*n this chapter$ schematic diagram and interfacing of ,*&+45677) microcontroller
with each module is considered.
;ig 4.!" sc%ematic diagram of Energ/ meter monitoring and control s/stem $sing S+S
tec%nolog/
111
The above schematic diagram of Energy meter monitoring and control system using SMS technology
e8plains the interfacing section of each component with micro controller and energy meter. The
crystal oscillator is connected to +.
th
and +/
th
pins of micro controller and regulated power supply is
also connected to micro controller and %EDQs also connected to micro controller through resistors
The detailed e8planation of each module interfacing with microcontroller is as follows#
4.( Interfacing cr/stal oscillator wit% micro controller"
5ig 1.-# e8plains crystal oscillator and reset button which are connected to micro
controller. The two pins of oscillator are connected to the +.
th
and +/
th
pins of micro controllerJ the
purpose of e8ternal crystal oscillator is to speed up the e8ecution part of instructions per cycle and
here the crystal oscillator having -@ M>9 fre(uency. The +
st
pin of the microcontroller is referred as
M&%' ie..$ master clear pin or reset input pin is connected to reset button or power-on-reset.
112
5ig 1.-# crystal oscillator and reset button interfacing with micro controller
CHAPTE 5" AD>ANTA7ES AND DISAD>ANTA7ES
Ad)antages"
113
+. Energy conservation can be monitored on %&D display.
-. The system alerts through SMS
.. Efficient and low cost design.
/. %ow power consumption.
1. 5ast and accurate result.
Disad)antages"
+. *nterfacing energy meter to the Micro controller is sensitive.
-. *t uses wired mechanism.
.. Depends on networ! signal strength
A&&lications"
This system can be practically implemented in real time in industries and domestic houses.
+. >ouse electrical systems.
-. 'ailway electrical systems.
.. 'emote controlling systems.
/. ,hone :illing systems.
CHAPTE 6" ES#3TS
6.! es$lt"

The project 2Energ/ meter monitoring and control s/stem $sing S+S tec%nolog/3 was
designed such that to design a system which helps in remote monitoring and control of the Domestic
Energy meter through simply sending an SMS. The system monitors the power consumption by the
114
load and controls the load based on the power being consumed daily and the reading of the energy
meter is displayed on %&D. The system alerts through SMS messages using "SM.
6.( Concl$sion"
*ntegrating features of all the hardware components used have been developed in it.
,resence of every module has been reasoned out and placed carefully$ thus contributing to the best
wor!ing of the unit. Secondly$ using highly advanced *&Qs with the help of growing technology$ the
project has been successfully implemented. Thus the project has been successfully designed and
tested.
6.* ;$t$re Sco&e"
=ur project 2Energ/ meter monitoring and control s/stem $sing S+S tec%nolog/3 is
mainly intended to design a system which helps in continuous monitoring of energy meter reading and
to alert when meter reading goes beyond a set level. This system has an energy meter$ load$ and %&D
and "SM modem interfaced to the micro controller. The micro controller is programmed in such a
way that the energy meter always gives the reading to the controller which is displayed on the %&D.
The system also alerts through SMS messages using "SM.
This project can be e8tended by eliminating wired mechanism by interfacing a bigbee
module$ which helps in monitoring multiple energy meter readings on ,&. "SM module can also be
interfaced to monitor as well as to control the energy meter from anywhere in the world.
E;EENCES
The sites which were used while doing this project#
115
+. www.wi!ipedia.com
-. www.allaboutcircuits.com
.. www.microchip.com
/. www.howstuffwor!s.com
,ooks referred"
+. 'aj !amal AMicrocontrollers )rchitecture$ ,rogramming$ *nterfacing and System Design.
-. Ma9idi and Ma9idi AEmbedded Systems.
.. ,&: Design Tutorial ADavid.%.Dones.
/. ,*& Microcontroller Manual A Microchip.
1. ,yroelectric Sensor Module- Murata.
4. Embedded & AMichael.D.,ont.
APPENDIX
Program Code"
The program code which is dumped in the microcontroller of our project is shown
below.
Xinclude ]+45677).h^
Xinclude ]string.h^
Xinclude ]lcd.c^
116
Xinclude ]sms.c^
Xuse delay (cloc!N-@@@@@@@
Xuse rs-.- (baud N ?4@@$ 8mitN,*0O:@$rcvN,*0O:+$streamN"SM
char ch N @J
char dataG+1@HJ EEfor SMS message storage
char helpGH N ` ;help;aJ
char onGH N ` ;pson; aJ EEresume power supply to consumer
char cutGH N ` ;pscut; aJ EEdisconnect power supply
char getGH N ` ;get; aJ EEget the meter reading
char ebGH N ` ;E:c;aJ EEE:c-./c show the power bill amount on %&D ('s.-./
char noebGH N ` ;E:&;aJ EE&lear power bill pay message
char numG+.HJ EEfor storing phone number
int count N @J
void showObillOpayOmessage(char billGH
`
lcdOputc(<df<J EEclear lcd
lcdOgoto8y(+$+J
printf(lcdOputc$;,ay ,ower :ill#;J
lcdOgoto8y(+$-J
117
printf(lcdOputc$;'s.Zs;$billJ
delayOms(+1@@J EEdisplay duration
a
void start(
`
lcdOputc(<df<J EE&lear %&D Display
lcdOgoto8y(+$+J
printf(lcdOputc$; "SM based ;J
lcdOgoto8y(+$-J
printf(lcdOputc$; Energy Meter;J
delayOms(.@@@J
a
void sendingsms(
`
lcdOgoto8y(+$-J
printf(lcdOputc$;Sending SMS...;J
a
void shownum(
`
lcdOputc(<df<J
lcdOgoto8y(+$+J
printf(lcdOputc$;num N Zs;$numJ
118
a
void showOmessage(
`
lcdOputc(<df<J
lcdOgoto8y(+$+J
printf(lcdOputc$;'eceived Message;J
lcdOgoto8y(+$-J
printf(lcdOputc$;from#Zs;$numJ
a
void initOgsm(
`
fprintf("SM$;)Tdrdn;J
delayOms(-@@@J
fprintf("SM$;)TP&M"5N+drdn;J
delayOms(-@@@J
a
void showOpowerOcutOmessage(
`
lcdOputc(<df<J
lcdOgoto8y(+$+J
printf(lcdOputc$; ,ower Supply;J
119
lcdOgoto8y(+$-J
printf(lcdOputc$; Disconnected;J
delayOms(+1@@J
lcdOgoto8y(+$+J
printf(lcdOputc$;,lease ,ay your;J
lcdOgoto8y(+$-J
printf(lcdOputc$;Electricity :ill;J
delayOms(+1@@J
a
void main(
`
float energy N @J
float totalOenergy N @.@J
unsigned int pulseOcount N @J
int powercut N @J
char billG+7HJ
int ebflag N @J

int i N @J
int j N @J

lcdOinit(J
120
start(J

outputOhigh(,*0O&.J
delayOms(+@@@J
outputOlow(,*0O&.J
delayOms(+@@@J
outputOhigh(,*0O&.J
delayOms(+@@@J
outputOlow(,*0O&.J

outputOhigh(,*0O&/J
delayOms(+@@J
outputOlow(,*0O&/J


setOtimer@(@J

lcdOputc(<df<J
lcdOgoto8y(+$+J
printf(lcdOputc$; *nitialising;J
lcdOgoto8y(+$-J
printf(lcdOputc$; "SM Modem;J
delayOms(.@@@J

outputOhigh(,*0O&.J EE%ED *ndicator
121
initOgsm(J


totalOenergy N energy P 'E)DO5'=MOEE,'=M(J EE'ead the e8isting value from EE,'=M

while(+
`
readOem(pulse J
outputOtoggle(,*0O&.J EE%ED *ndicator
lcdOputc(<df<J EE&lear %&D Display

lcdOputc(<df<J
lcdOgoto8y(+$+J

readOem(pulse J EE calculate em in YB>

printf(lcdOputc$; YB> N Z/./f;$totalOenergyJ
delayOms(+@@@J

count N @J
dataGcountH N @J
122

fgets(data$"SMJ EEread SMS message from Modem

fprintf("SM$;)TP&M"DN+drdn;J EESMS available in variable data. now delete sms
getOsmsOnum(num$dataJ EEe8tract num from sms data

beep(1@@J EEbeep indicates message arrival

showOmessage(J EEdisplay sms message info
delayOms(1@@@J EEfor 1 seconds

if(strstr(data$on
`
fprintf("SM$;,ower Supply 'esumed to &onsumer.drdn;J EEsms contents
a
else if(strstr(data$cut
`
outputOlow(,*0O&7J
fprintf("SM$;,ower Supply Disconnected to &onsumer.drdn;J
a
else if(strstr(data$get
`
lcdOputc(<df<J
lcdOgoto8y(+$+J
printf(lcdOputc$;Message 'eceived;J
123
lcdOgoto8y(+$-J
printf(lcdOputc$; get;J
fprintf("SM$;Energy Meter %ive 'eading# Z/./f YB> drdn;$totalOenergyJ
fprintf("SM$; ,ower Supply Disconnected.drdn;J
a

else if(strstr(data$help
`
fprintf("SM$;)TP&M"SNd;Zsd;drdn;$numJ
fprintf("SM$;Send d;psond; =' d;pscutd; to resume or disconnect power supplydrdn;J
fprintf("SM$;Send d;E:crupeescd; for sending billdrdn;J
fprintf("SM$;Send d;E:&d; to clear bill pay message.drdn;J
fprintf("SM$;Send d;getd; to get the YB> reading.drdn;J
fputc(@8+)$"SMJ
a
else
`
lcdOputc(<df<J
lcdOgoto8y(+$+J
printf(lcdOputc$;*nvalid Message;J
delayOms(.@@@J
a
a
a
124