You are on page 1of 90

A PROJECT REPORT ON DETECTING POWER GRID SYNCHRONISATION FAILURE ON SENSING OUT OF RANGE FREQUENCY OR VOLTAGE Submitted in partial fulfillment

of the requirements For the award of the degree AC!E"OR OF EN#$NEER$N# $N %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% EN#$NEER$N# S& '$TTE( ) ******************** +**************, ********************* +***************, ********************* +***************,

(EPART'ENT OF %%%%%%%%%%%%%%%%%%%%%%% EN#$NEER$N# %%%%%%%%%%CO""E#E OF EN#$NEER$N# AFF$"$ATE( TO %%%%%%%%%%% &N$-ERS$T)

CERTIFICATE
1

This is to .ertif/ that the dissertation wor0 entitled DETECTING POWER GRID SYNCHRONISATION FAILURE ON SENSING OUT OF RANGE FREQUENCY OR VOLTAGE is the wor0 done in b/ partial %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%submitted

fulfillment for the award of 1 AC!E"OR OF EN#$NEER$N# + 2E,3in %%%%%%%%%%%%%%%%%%%%%%%%%%Engineering from%%%%%%%%%%%%%% College of Engineering affiliated to %%%%%%%%% &ni4ersit/5 !/derabad 2

________________ (Head of the depa t!e"t# ECE$

____________ (A%%&%ta"t P ofe%%o $

E'TERNAL E'A(INER

AC)NOWLEDGE(ENT

The satisfa.tion and euphoria that a..ompan/ the su..essful .ompletion of an/ tas0 would be in.omplete without the mentioning of the people whose .onstant guidan.e and en.ouragement made it possible2 6e ta0e pleasure in presenting before /ou5 our pro7e.t5 whi.h is result of studied blend of both resear.h and 0nowledge2 6e e8press our earnest gratitude to our internal guide5 Assistant Professor %%%%%%%%%%%%%%5 (epartment of ECE5 our pro7e.t guide5 for his .onstant support5 en.ouragement and guidan.e2 6e are grateful for his .ooperation and his 4aluable suggestions2 Finall/5 we e8press our gratitude to all other members who are in4ol4ed either dire.tl/ or indire.tl/ for the .ompletion of this pro7e.t2

DECLARATION

6e5 the undersigned5 de.lare that the pro7e.t entitled *DETECTING POWER GRID SYNCHRONISATION FAILURE ON SENSING OUT OF RANGE FREQUENCY OR VOLTAGE+5 being submitted in partial fulfillment for the award of a.helor of Engineering (egree in Ele.troni.s and Communi.ation Engineering5 affiliated to %%%%%%%%% &ni4ersit/5 is the wor0 .arried out b/ us2

%%%%%%%%%% %%%%%%%%%%

%%%%%%%%% %%%%%%%%%

%%%%%%%%% %%%%%%%%%

,- A.STRACT

This pro7e.t presents the de4elopment of a mi.ro.ontroller based islanding dete.tion for grid .onne.ted in4erter with under9o4er 4oltage and under9o4er frequen./ islanding dete.tion algorithms for predi.table bla.0out or brownouts2 The s/stem is based on a mi.ro.ontroller from Atmel A-R famil/2 The mi.ro.ontroller monitors the under9o4er 4oltage deri4ed from a set of .omparators and under9o4er frequen./ from b/ the interrupt program for the utilit/ grid and the pro.essed 4alue of 4oltage and frequen./ for turning ON9OFF the rela/ between a grid .onne.ted in4erter and the utilit/ grid2 The pro7e.t would alternati4el/ use a 4ariable frequen./ generator representing the in4erter using :::*timer for .hanging the frequen./ while a standard 4aria. shall be used to 4ar/ the input 4oltage for a.hie4ing the test .onditions b/ a lamp load +indi.ating a predi.table bla.0out, being dri4en from the mi.ro.ontroller output as stated abo4e2 The mi.ro.ontroller used in the pro7e.t is of A-R famil/ whi.h is of ; bit2 The power suppl/ .onsists of a step down transformer <=>9?<-5 whi.h steps down the 4oltage to ?<- AC2 This is .on4erted to (C using a ridge re.tifier2 The ripples are remo4ed

using a .apa.iti4e filter and it is then regulated to @:- using a 4oltage regulator A;>: whi.h is required for the operation of the mi.ro.ontroller and other .omponents2

/-INTRODUCTION TO E(.EDDED SYSTE(S

What &% e!0edded %1%te!2


An Embedded S/stem is a .ombination of .omputer hardware and software5 and perhaps additional me.hani.al or other parts5 designed to perform a spe.ifi. fun.tion2 An embedded s/stem is a mi.ro.ontroller*based5 software dri4en5 reliable5 real*time .ontrol s/stem5 autonomous5 or human or networ0 intera.ti4e5 operating on di4erse ph/si.al 4ariables and in di4erse en4ironments and sold into a .ompetiti4e and .ost .ons.ious mar0et2 An embedded s/stem is not a .omputer s/stem that is used primaril/ for pro.essing5 not a software s/stem on PC or &N$B5 not a traditional business or s.ientifi. appli.ation2 !igh*end embedded C lower end embedded s/stems2 !igh*end embedded s/stem * #enerall/ =<5 DE it Controllers used with OS2 E8amples Personal (igital Assistant and 'obile phones et. 2"ower end embedded s/stems * #enerall/ ;5?D it Controllers used with an minimal operating s/stems and hardware la/out designed for the spe.ifi. purpose2 SYSTE( DESIGN CALLS3

Figure <+a,F Embedded s/stem design .alls

E(.EDDED SYSTE( DESIGN CYCLE

Figuren <+b, G- (iagramH Cha a4te &%t&4% of E!0edded S1%te! I An embedded s/stem is an/ .omputer s/stem hidden inside a produ.t other than a .omputer2
8

The/ will en.ounter a number of diffi.ulties when writing embedded s/stem software in addition to those we en.ounter when we write appli.ations2 J J J J J J J J J J Throughput J Our s/stem ma/ need to handle a lot of data in a short period of time2 ResponseJOur s/stem ma/ need to rea.t to e4ents qui.0l/2 Testabilit/JSetting up equipment to test embedded software .an be diffi.ult2 (ebugabilit/J6ithout a s.reen or a 0e/board5 finding out what the software is doing wrong +other than not wor0ing, is a troublesome problem2 Reliabilit/ J embedded s/stems must be able to handle an/ situation without human inter4ention2 'emor/ spa.e J 'emor/ is limited on embedded s/stems5 and /ou must ma0e the software and the data fit into whate4er memor/ e8ists2 Program installation J /ou will need spe.ial tools to get /our software into embedded s/stems2 Power .onsumption J Portable s/stems must run on batter/ power5 and the software in these s/stems must .onser4e power2 Pro.essor hogs J .omputing that requires large amounts of CP& time .an .ompli.ate the response problem2 Cost J Redu.ing the .ost of the hardware is a .on.ern in man/ embedded s/stem pro7e.tsK software often operates on hardware that is barel/ adequate for the 7ob2

Embedded s/stems ha4e a mi.ropro.essor9 mi.ro.ontroller and a memor/2 Some ha4e a serial port or a networ0 .onne.tion2 The/ usuall/ do not ha4e 0e/boards5 s.reens or dis0 dri4es2

APPLICATIONS ?, 'ilitar/ and aerospa.e embedded software appli.ations < , C om mu ni .a t io n A pp li .a ti on s = , $ nd us t ri al au to ma t io n a nd p ro .e s s . on tr ol s o ft w a re E, 'astering the .omple8it/ of appli.ations2 :, Redu.tion of produ.t design time2 D, Real time pro.essing of e4er in.reasing amounts of data2
9

A, $ntelligent5 autonomous sensors2 CLASSIFICATION Real Time S/stems2 RTS is one whi.h has to respond to e4ents within a spe.ified deadline2 A right answer after the dead line is a wrong answer2

RTS CLASSIFICATION !ard Real Time S/stems Soft Real Time S/stem

HARD REAL TI(E SYSTE( L!ardL real*time s/stems ha4e 4er/ narrow response time2 E8ampleF Nu.lear power s/stem5 Cardia. pa.ema0er2

SOFT REAL TI(E SYSTE( LSoftL real*time s/stems ha4e redu.ed .onstrains on LlatenessL but still must operate 4er/ qui.0l/ and repeatable2 E8ampleF Railwa/ reser4ation s/stem J ta0es a few e8tra se.onds the data remains 4alid2

10

3. BLOCK DIAGRAM

11

Fig2 =F lo.0 (iagram of the pro7e.t

12

4. HARDWARE REQUIREMENTS

HARDWARE CO(PONENTS3

13

?2 TRANSFOR'ER +<=> J ?< - AC, <2 -O"TA#E RE#&"ATOR +"' A;>:, =2 RECT$F$ER E2 F$"TER :2 '$CROCONTRO""ER +AT'E#A ?D, D2 "$M&$( CR)STA" ($SP"A) A2 ::: T$'ER ;2 "'=:; N2 "'==N ?>2 RE"A)S ??2 P&S! &TTONS ?<2 C:EA

?=2 "E( ?E2 $NE>>A ?:2 RES$STORS ?D2 CAPAC$TORS

5-, TRANSFOR(ER
14

Transformers .on4ert AC ele.tri.it/ from one 4oltage to another with a little loss of power2 Step*up transformers in.rease 4oltage5 step*down transformers redu.e 4oltage2 'ost power supplies use a step*down transformer to redu.e the dangerousl/ high 4oltage to a safer low 4oltage2

F$# E2?F A T)P$CA" TRANSFOR'ER The input .oil is .alled the primar/ and the output .oil is .alled the se.ondar/2 There is no ele.tri.al .onne.tion between the two .oilsK instead the/ are lin0ed b/ an alternating magneti. field .reated in the soft*iron .ore of the transformer2 The two lines in the middle of the .ir.uit s/mbol represent the .ore2 Transformers waste 4er/ little power so the power out is +almost, equal to the power in2 Note that as 4oltage is stepped down and .urrent is stepped up2 The ratio of the number of turns on ea.h .oil5 .alled the turn3s ratio5 determines the ratio of the 4oltages2 A step*down transformer has a large number of turns on its primar/ +input, .oil whi.h is .onne.ted to the high 4oltage mains suppl/5 and a small number of turns on its se.ondar/ +output, .oil to gi4e a low output 4oltage2 T&RNS RAT$O O +-p 9 -s, O + Np 9 Ns , 6here5 -p O primar/ +input, 4oltage2 -s O se.ondar/ +output, 4oltage Np O number of turns on primar/ .oil Ns O number of turns on se.ondar/ .oil $p O primar/ +input, .urrent $s O se.ondar/ +output, .urrent2
15

Idea6 po7e e89at&o"

The ideal transformer as a .ir.uit element $f the se.ondar/ .oil is atta.hed to a load that allows .urrent to flow5 ele.tri.al power is transmitted from the primar/ .ir.uit to the se.ondar/ .ir.uit2 $deall/5 the transformer is perfe.tl/ effi.ientK all the in.oming energ/ is transformed from the primar/ .ir.uit to the magneti. field and into the se.ondar/ .ir.uit2 $f this .ondition is met5 the in.oming ele.tri. power must equal the outgoing powerF

gi4ing the ideal transformer equation

Transformers normall/ ha4e high effi.ien./5 so this formula is a reasonable appro8imation2 $f the 4oltage is in.reased5 then the .urrent is de.reased b/ the same fa.tor2 The impedan.e in one .ir.uit is transformed b/ the square of the turns ratio2 For e8ample5 if an impedan.e Zs is atta.hed a.ross the terminals of the se.ondar/ .oil5 it appears to the primar/ .ir.uit to ha4e an impedan.e of +Np9Ns,<Zs2 This relationship is re.ipro.al5 so that the impedan.e Zp of the primar/ .ir.uit appears to the se.ondar/ to be +Ns9Np,<Zp2
16

5-/ VOLTAGE REGULATOR :;<=

Feat9 e% I Output Current up to ?A2 I Output -oltages of :5 D5 ;5 N5 ?>5 ?<5 ?:5 ?;5 <E-2 I Thermal O4erload Prote.tion2 I Short Cir.uit Prote.tion2 I Output Transistor Safe Operating Area Prote.tion2

De%4 &pt&o" The "'A;BB9"'A;BBA series of three*terminal positi4e regulators are a4ailable in the TO*<<>9(*PAP pa.0age and with se4eral fi8ed output 4oltages5 ma0ing them useful in a 6ide range of appli.ations2 Ea.h t/pe emplo/s internal .urrent limiting5 thermal shutdown and safe operating area prote.tion5 ma0ing it essentiall/ indestru.tible2 $f adequate heat sin0ing is pro4ided5 the/ .an deli4er o4er ?A output Current2 Although designed primaril/ as fi8ed 4oltage regulators5 these de4i.es .an be used with e8ternal .omponents to obtain ad7ustable 4oltages and .urrents2

I"te "a6 .6o4> D&a? a!


17

F$# E2<+a,F "OCP ($A#RA' OF -O"TA#E RE#&"ATOR

A0%o69te (a@&!9! Rat&"?%

18

TA "E E2<+b,F RAT$N#S OF T!E -O"TA#E RE#&"ATOR

5-A RECTIFIER
A re.tifier is an ele.tri.al de4i.e that .on4erts alternating .urrent +AC,5 whi.h periodi.all/ re4erses dire.tion5 to dire.t .urrent +(C,5 .urrent that flows in onl/ one dire.tion5 a pro.ess 0nown as re.tifi.ation2 Re.tifiers ha4e man/ uses in.luding as .omponents of power supplies and as dete.tors of radio signals2 Re.tifiers ma/ be made of solid state diodes5 4a.uum tube diodes5 mer.ur/ ar. 4al4es5 and other .omponents2 The output from the transformer is fed to the re.tifier2 $t .on4erts A2C2 into pulsating (2C2 The re.tifier ma/ be a half wa4e or a full wa4e re.tifier2 $n this pro7e.t5 a bridge re.tifier is used be.ause of its merits li0e good stabilit/ and full wa4e re.tifi.ation2 $n positi4e half ./.le onl/ two diodes+ ? set of parallel diodes, will .ondu.t5 in negati4e half ./.le remaining two diodes will .ondu.t and the/ will .ondu.t onl/ in forward bias onl/2

19

5-5 FILTER
Capa.iti4e filter is used in this pro7e.t2 $t remo4es the ripples from the output of re.tifier and smoothens the (2C2 Output re.ei4ed from this filter is .onstant until the mains 4oltage and load is maintained .onstant2 !owe4er5 if either of the two is 4aried5 (2C2 4oltage re.ei4ed at this point .hanges2 Therefore a regulator is applied at the output stage2 The simple .apa.itor filter is the most basi. t/pe of power suppl/ filter2 The use of this filter is 4er/ limited2 $t is sometimes used on e8tremel/ high*4oltage5 low*.urrent power supplies for .athode*ra/ and similar ele.tron tubes that require 4er/ little load .urrent from the suppl/2 This filter is also used in .ir.uits where the power*suppl/ ripple frequen./ is not .riti.al and .an be relati4el/ high2 elow figure .an show how the .apa.itor .harges and dis.harges2

20

AVR Microcontroller A microcontroller is s a computer on a chip, or if you prefer , a single chip computer . Micro suggests that the device is small , and controller tells that the device might be used to control objects , processes , or events . Another term to describe a microcontroller is embedded controller; because the microcontroller and its support circuits are often built into, or embedded in, the device they control .

You can find microcontroller in all kinds of things these days, any device that measures, stores, control, calculate or displays information is a candidate for putting a microcontroller inside. The largest single use for microcontroller is in automobiles just about ever car manufactured today include at least one microcontroller for engine control, and often more to control additional system in the car. In desktop computers, you can find microcontrollers inside keyboards , modems , printers and other peripherals . In test e uipments, microcontroller make it easy toad features ability to add features such as ability to store measurements, to create and store user routines , and to display message and !aveforms . "onsumer products that use microcontrollers includes cameras , video recorders , compacts disk players , and ovens . And these are just fe! e#amples .

$icrocontrollers are basically LSI chips !ith millions of logic gates constituting an Arithmetic and %ogic &nit 'ALU(, accompanying registers, bus control circuitry and an instruction decoder. This is the definition in the strictest sense. $ost modern microcontrollers usually have 21

on chip RAM and ROM and a fe! peripherals such as timers, serial interfaces such as a UART'&niversal Asynchronous )eceiver Transmitter(, ports and even ADCs'Analog to *igital "onverters(. A !ide variety of microcontrollers is available today. +ome are general purpose, !hile some are optimi,ed for special applications. A fe! !ell kno!n microcontrollers are Intel-s ./01, ./.0, 2entium, $otorola-s 3./// and 3.//., Atmel-s A4) series, A$*-s Athlon, and the relatively ne! 2+o" from "ypress. This tutorial is about the Intel ./01. A !ide variety of microcontrollers are available today. +ome are general purpose, !hile some are optimi,ed for special applications. A fe! !ell kno!n microcontroller of various families are given belo!.

Intels family 8051(commercially available as 89C51), ./05, ./61 ./.0 , 2entium etc

Avr family 7 ATtiny15 , ATtiny10 , AT90S1 00(A) ! AT90S "1" ! AT8/+5656 , AT8/+5666, AT8/+5696 , AT8/+9919 , AT8/+9966 , AT8/+9969 , AT90S8515 ! !AT90S85"5 , ATmega.6 , ATmega1/6 , ATmega131 , ATmega136 ,ATmega3/6 , etc
#ic family 7 2I"13:.6 , 2I"13:.9 , #IC1$%8&A ! 2I"13;.</ , 2I"13;.<1, 2I"13;.<5 ,2I"13;.<6 , 2I"13;.<9, 2I"13;.<3 , #IC1$%8'' , 2I"13;.<6A , 2I"13;.<9A , 2I"13;.3A ,#IC1$%8''A ! 2I"13;35< , 2I"13;35. .

()y *se microcontrollers at all+ As we know basic arithmetic and logic functions be also erformed using logic gates and fli !flo s"basic storage units#$ but microcontrollers ha%e certain ad%antages& 'im ler construction and control( %o!er cost. %o! total area occupied on the circuit board. ;le#ibility "hanges can be made by simply changing the soft!are'code used to program the microcontroller(. +oft!are implementation'firm!are( is usually easier than its hard!are counterpart.

22

A fe, im-ortant terms


Word or Word size& )t is smallest grou o erations are carried out" although are instructions o erating on indi%idual *emor+ units store bits in grou s called words( A word mo%es in and out memor+ as a unit( A memor+ address location of a word of the memor+( si-e is usuall+ a multi le of 8bits( of bits u on which normal arithmetic there bits#( of is the ,ord

Arit !eti" #$d Lo%i" U$it& .his unit erforms basic arithmetic and logic functions like add$ subtract and A/0$ 12 etc$ on o erands stored in memor+ or registers(

Re%ister& A register is a collection of fli !flo s$ used to store limited amount of data" a fli !flo stores one bit# such as status information$ ointers etc(

'ro%r#! #$d D#t# Me!or(& 3rogram memor+ is that art of the memor+ where code written b+ the user is stored( )t also stores constants( .his memor+ is usuall+ the ROM and has to be rogrammed using s ecial hardware " although it can also be rogrammed in s+stem#( )t also stores a rogram called the 4bootstra loader5$ which gets the microcontroller started when ower is first turned on( 'ome o ular t+ es of 21* are EPROM$ EEPROM and more recentl+ Flash( 0ata memor+ is that art of the memor+ hierarch+ which is used to store %ariables defined b+ the user and %alues generated during rogram e6ecution( .his memor+ is the 2A*(

23

'ro%r#! Co)$ter& As mentioned re%iousl+ the user7s code is stored in the 21*( ,hile e6ecuting the rogram a s ecial register called the 3rogram 8ounter kee s track of the ne6t instruction in the rogram to be fetched( At the start of a rogram7s e6ecution the 3rogram 8ounter stores the address of the first instruction of the rogram and as each instruction is e6ecuted$ it is incremented( .his hel s the microcontroller in knowing what location to fetch the ne6t instruction from( .he 3rogram 8ounter is not alwa+s incremented( 9or e6am le when a 4 :um to location A5 kind of instruction is encountered$ the 3rogram 8ounter stores the address of 4location A5(

St#"* 'oi$ter& )n sim le words a stack is a method of storing data in a articular manner( .he data element that is first to go into a stack is the last to come out of it( .he 4to 5 of the stack is the onl+ lace in a stack where addition or deletion can take lace( )n most microcontrollers the stack is stored starting from a s ecial location in the memor+( 1ne of the uses of the stack is to store the contents of the 3rogram 8ounter when a subroutine is encountered( .he 'tack 3ointer is a register containing the address of the 4to 5 of the stack(

Addressi$% Modes& *ost of the instructions in a rogram will mention its o erands and their location i(e( addresses in memor+ or register s ace( An address ma+ not alwa+s be s ecified in absolute terms$ i(e( the address ma+ not be the address of the o erand( )n such cases the mode of addressing used in the instruction tells the microcontroller how to inter ret the address and calculate the o erand7s address( .his is done to ro%ide the user fle6ibilit+$ to shorten the instruction si-e" not ha%ing to s ecif+ the whole address$ but onl+ a art of it# etc( 9or e6am le the indirect addressing mode is used to s ecif+ a memor+ location where not the o erand but its address is stored( 24

I$terr)+ts& An interru t is a wa+ of asking the microcontroller to sto what it is doing and attend to the source of the interru t( An e6am le is that of );1 s+stems in microcontrollers( .hese );1 s+stems issue an interru t when the+ recei%e some data or ha%e com leted transmitting some data( .his hel s in sa%ing rocessing time as the microcontroller doesn7t ha%e to kee checking the );1 s+stems for an arri%al of data or com letion of transfer of data( .here can be man+ other sources of interru ts(

'orts& .he+ are basicall+ gatewa+s through which );1 transfers of a microcontroller take lace( <suall+ a ort has se%eral ins of the microcontroller dedicated to it( )n memor+ terms a ort occu ies se%eral bits$ usuall+ multi les of 8( .here are ort registers through which data is transferred in and out of orts( 3orts might be bi! directional or unidirectional(

.scillator= The microcontroller needs various clocking signals to operate its registers and other peripherals like the &A)T. The main clocking signal is provided !ith the help of an oscillator and associated circuitry.

Intro/*ction to AVR Microcontroller 01


Microcontroller0 $icrocontroller can be termed as a single on chip computer !hich includes number of peripherals like )A$, >>2)?$, Timers etc., re uired to perform some predefined task.

25

*oes this mean that the microcontroller is another name for a computer@A The ans!er is B?C The computer on one hand is designed to perform all the general purpose tasks on a single machine like you can use a computer to run a soft!are to perform calculations or you can use a computer to store some multimedia file or to access internet through the bro!ser, !hereas the microcontrollers are meant to perform only the specific tasks, for e.g., s!itching the A" off automatically !hen room temperature drops to a certain defined limit and again turning it ?B !hen temperature rises above the defined limit. There are number of popular families of microcontrollers !hich are used in different applications as per their capability and feasibility to perform the desired task, most common of these are ./01, A4) and 2I" microcontrollers. In this article !e !ill introduce you !ith AVR family of microcontrollers.

I$trod)"tio$ to ATMEL A,R !i"ro"o$tro--er


2istory of AVR
A4) !as developed in the year 1883 by Atmel "orporation. The architecture of A4) !as developed by Alf7>gil Dogen and 4egard Eollan. A4) derives its name from its developers and stands for Alf134il 5o4en Ve4ar/ (ollan RISC microcontroller, also kno!n as Advanced Virtual RI+". The AT8/+.010 !as the first microcontroller !hich !as based on AVR arc)itect*re ho!ever the first microcontroller to hit the commercial market !as AT8/+15// in the year 188<. AVR microcontrollers are available in three categories=

26

1. 5. 6.

TinyAVR %ess memory, small si,e, suitable only for simpler applications Me4aAVR These are the most popular ones having good amount of memory 'upto 503 FD(, higher 6me4aAVR &sed commercially for comple# applications, !hich re uire large program memory and

number of inbuilt peripherals and suitable for moderate to comple# applications. high speed. The follo!ing table compares the above mentioned A4) series of microcontrollers= Series 7ame TinyAVR Me4aAVR 6me4aAVR #ins 3765 5.71// 9971// %las) Memory /.07. FD 97503FD 1376.9FD S-ecial %eat*re +mall in si,e >#tended peripherals *$A , >vent +ystem included

()ats s-ecial a8o*t AVR+


They are fast= AVR microcontroller e#ecutes most of the instructions in single e#ecution cycle. A4)s are about 9 times faster than 2I"s, they consume less po!er and can be operated in different po!er saving modes. %et-s do the comparison bet!een the three most commonly used families of microcontrollers.

8051 S#339 M3M.R: ARC2IT3CT;R3 A9C Timers #(M C)annels +lo! +mall "I+" Bot 2resent Inbuilt Bot 2resent

#IC $oderate %arge )I+" Inbuilt Inbuilt Inbuilt

AVR ;ast %arge )I+" Inbuilt Inbuilt Inbuilt

A4) is an .7bit microcontroller belonging to the family of )educed Instruction +et "omputer ' RISC(. In )I+" architecture the instruction set of the computer are not only fe!er in number but also simpler and faster in operation. The other type of categori,ation is "I+" '"omple# Instruction +et "omputers(. Ee !ill e#plore more on this !hen !e !ill learn about the architecture of A4) microcontrollers in follo!ing section. %et-s see !hat all this means. Ehat is .7bitA This means that the microcontroller is capable of transmitting and receiving .7bit data. The inputGoutput registers available are of .7bits. The A4) family controllers have register based architecture !hich means that both the operands for an operation are stored in a register and the result of the operation is also stored in a register. ;ollo!ing figure sho!s a simple

27

e#ample performing ?) operation bet!een t!o input registers and storing the value in ?utput )egister.

H H H H H H H H H H H H

The "2& takes values from t!o input registers IB2&T71 and IB2&T75, performs the logical operation and stores the value into the ?&T2&T register. All this happens in 1 e#ecution cycle. In our journey !ith the A4) !e !ill be !orking on Atmega13 microcontroller, !hich is a 9/7pin I" and belongs to the megaA4) category of A4)family. +ome of the features of Atmega13 are= 13FD of ;lash memory 1FD of +)A$ 015 Dytes of >>2)?$ Available in 9/72in *I2 .7"hannel 1/7bit A*" T!o .7bit TimersG"ounters ?ne 137bit TimerG"ounter 9 2E$ "hannels In +ystem 2rogrammer 'I+2( +erial &+A)T +2I Interface *igital to Analog "omparator.

Arc)itect*re of AVR
The A4) microcontrollers are based on the advanced )I+" architecture and consist of 65 # .7bit general purpose !orking registers. Eithin one single clock cycle, A4) can take inputs from t!o general purpose registers and put them to A%& for carrying out the re uested operation, and transfer back the result to an arbitrary register. The A%& can perform arithmetic as !ell as logical operations over the inputs from the register or bet!een the register and a constant. +ingle register operations like taking a complement can also be e#ecuted in A%&. Ee can see that A4) does not have any register like accumulator as in ./01

28

family of microcontrollers; the operations can be performed bet!een any of the registers and can be stored in either of them. A4) follo!s Iarvard Architecture format in !hich the processor is e uipped !ith separate memories and buses for 2rogram and the *ata information. Iere !hile an instruction is being e#ecuted, the ne#t instruction is pre7fetched from the program memory.

+ince A4) can perform single cycle e#ecution, it means that A4) can e#ecute 1 million instructions per second if cycle fre uency is 1$I,. The higher is the operating fre uency of the controller, the higher !ill be its processing speed. Ee need to optimi,e the po!er consumption !ith processing speed and hence need to select the operating fre uency accordingly. There are t!o flavors for Atmega13 microcontroller= 1. 5. Atme4a1$=7 ?perating fre uency range is / 13 $I,. Atme4a1$<=7 ?perating fre uency range is / . $I,.

If !e are using a crystal of . $I, J . # 1/3 Iert, J . $illion cycles, then A4) can e#ecute . million instructions.

7amin4 Convention=>
The AT refers to Atmel the manufacturer, Me4a means that the microcontroller belong to $egaA4) category, 1$ signifies the memory of the controller, !hich is 13FD.

29

Arc)itect*re 9ia4ram0 Atme4a1$


;ollo!ing points e#plain the building blocks of Atme4a1$ arc)itect*re= H H I?. #orts0 Atmega13 has four '2?)TA, 2?)TD, 2?)T" and 2?)T*( 818it input7output ports. Internal Cali8rate/ .scillator0 Atmega13 is e uipped !ith an internal oscillator for driving its clock. Dy default Atmega13 is set to operate at internal calibrated oscillator of 1 $I,. The ma#imum fre uency of internal oscillator is .$h,. Alternatively, ATmega13 can be operated using an e#ternal crystal oscillator !ith a ma#imum fre uency of 13$I,. In this case you need to modify the fuse bits. ';use Dits !ill be e#plained in a separate tutorial(.

A9C Interface0 Atmega13 is e uipped !ith an . channel A*" 'Analo4 to 9i4ital Converter( !ith a resolution of 1/7bits. A*" reads the analog input for e.g., a sensor input and converts it into digital information !hich is understandable by the microcontroller.

30

Timers?Co*nters0 Atmega13 consists of t!o .7bit and one 137bit timerGcounter. Timers are useful for generating precision actions for e.g., creating time delays bet!een t!o operations.

(atc)/o4 Timer0 Eatchdog timer is present !ith internal oscillator. Eatchdog timer continuously monitors and resets the controller if the code gets stuck at any e#ecution action for more than a defined time interval.

Interr*-ts0 Atmega13 consists of 51 interrupt sources out of !hich four are e#ternal. The remaining are internal interrupts !hich support the peripherals like &+A)T, A*", Timers etc.

;SART0 ;niversal Sync)rono*s an/ Async)rono*s Receiver an/ Transmitter interface is available for interfacing !ith e#ternal device capable of communicating serially 'data transmission bit by bit(.

@eneral #*r-ose Re4isters0 Atmega13 is e uipped !ith 65 general purpose registers !hich are coupled directly !ith the Arithmetic %ogical &nit 'A%&( of "2&.

H 1.

Memory0 Atmega13 consist of three different memory sections= %las) 33#R.M= ;lash >>2)?$ or simple flash memory is used to store the program dumped or burnt by the user on to the microcontroller. It can be easily erased electrically as a single unit. ;lash memory is non7volatile i.e., it retains the program even if the po!er is cut7off. Atmega13 is available !ith 13FD of in system programmable ;lash >>2)?$.

5.

5yte A//ressa8le 33#R.M= This is also a nonvolatile memory used to store data like values of certain variables. Atmega13 has 015 bytes of >>2)?$, this memory can be useful for storing the lock code if !e are designing an application like electronic door lock.

6.

SRAM= +tatic )andom Access $emory, this is the volatile memory of microcontroller i.e., data is lost as soon as po!er is turned off. Atmega13 is e uipped !ith 1FD of internal +)A$. A small portion of +)A$ is set aside for general purpose registers used by "2& and some for the peripheral subsystems of the microcontroller.

31

IS#0 A4) family of controllers have In System #ro4ramma8le ;lash $emory !hich can be programmed !ithout removing the I" from the circuit, I+2 allo!s to reprogram the controller !hile it is in the application circuit.

S#I0 Serial #eri-)eral Interface, +2I port is used for serial communication bet!een t!o devices on a common clock source. The data transmission rate of +2I is more than that of &+A)T.

T(I0 T,o (ire Interface 'TEI( can be used to set up a net!ork of devices, many devices can be connected over TEI interface forming a net!ork, the devices can simultaneously transmit and receive and have their o!n uni ue address.

9AC0 Atmega13 is also e uipped !ith a 9i4ital to Analo4 Converter '*A"( interface !hich can be used for reverse action performed by A*". *A" can be used !hen there is a need of converting a digital signal to analog signal.

Vario*s microcontroller of Me4aAVR series0


ATmega. and Atmega65 are other members of $egaA4) series controllers. They are follo!ing table sho!s the comparison bet!een different members of $egaA4) family= uite similar to ATmega13 in architecture. %o! po!er version $egaA4) controllers are also available in markets. The

#art 7ame R.M RAM 33#R.M I?0 Timer Interr*-ts .-erationVolta4e.-eratin4 #acBa4in4 #ins freA*ency ATme4a8 ATme4a8 < ATme4a1 $ ATme4a1 $< ATme4a" ATme4a" < .FD .FD 1FD 1FD 015D 015D 015D 015D 1FD 1FD 56 56 65 65 65 65 6 6 6 6 6 6 18 18 51 51 51 51 9.070.0 4 5.<70.0 4 9.070.0 4 5.<70.0 4 9.070.0 4 5.<70.0 4 /713 $I, 5. /7. $I, 5. /713 $I, 9/ /7. $I, 9/

13FD 1FD 13FD 1FD 65FD 5FD 65FD 5FD

/713 $I, 9/ /7. $I, 9/

32

#I7 9IA@RAM 0 1

33

#in 9escri-tion0
34

#in 7o=

#in name

9escri-tion

Alternate %*nction T00 Timer0 3Dternal Co*nter In-*t= 6CC 0 ;SART 3Dternal ClocB I?. T10Timer1 3Dternal Co*nter In-*t AI700 Analo4 Com-arator #ositive I?# I7T 0 3Dternal Interr*-t In-*t AI710 Analo4 Com-arator 7e4ative I?# .C0 0 Timer0 .*t-*t Com-are Matc) .*t-*t

(6CC?T0) #50 (T1) #51

I?. #.RT5! #in 0 I?. #.RT5! #in 1 I?. #.RT5! #in I?. #.RT5! #in " I?. #.RT5! #in & I?. #.RT5! #in 5 I?. #.RT5! #in $ I?. #.RT5! #in ' Reset #in! Active <o, Reset Vcc E F5V @R.;79

" & 5 $ ' 8 9 10 11 1 1" 1& 15 1$ 1' 18 19 0 1

(I7T ?AI70) #5 (.C0?AI71) #5" (SS) #5& (M.SI) #55 (MIS.) #5$ (SCC) #5' R3S3T Vcc @79 6TA< 6TA<1 (R69) #90 (T69) #91 (I7T0) #9 (I7T1) #9" (.C15) #9& (.C1A) #95 (IC#) #9$ #9' (.C ) #C0 (SC<)

In System #ro4rammer (IS#) Serial #eri-)eral Interface (S#I)

.*t-*t to Invertin4 .scillator Am-lifier In-*t to Invertin4 .scillator Am-lifier I?. #.RT9! #in 0 ;SART Serial Comm*nication Interface I?. #.RT9! #in 1 I?. #.RT9! #in I?. #.RT9! #in " I?. #.RT9! #in & #(M C)annel .*t-*ts I?. #.RT9! #in 5 I?. #.RT9! #in $ I?. #.RT9! #in ' I?. #.RTC! #in 0 T(I Interface I?. #.RTC! #in 1 I?. #.RTC! #in Timer?Co*nter1 In-*t Ca-t*re #in Timer?Co*nter .*t-*t Com-are Matc) .*t-*t 3Dternal Interr*-t I7T0 3Dternal Interr*-t I7T1

" &

#C1 (S9A) #C (TCC)

#C" (TMS)

I?. #.RTC! #in " GTA@ Interface

#C& (T9.)

I?. #.RTC! #in &

'

#C5 (T9I)

I?. #.RTC! #in 5

35

8 9 "0

#C$ (T.SC1) #C' (T.SC ) AVcc

I?. #.RTC! #in $ I?. #.RTC! #in ' Volta4e S*--ly E Vcc for A9C

Timer .scillator #in 1 Timer .scillator #in

"1

@79

@R.;79

"

AR3%

Analo4 Reference #in for A9C

""

#A' (A9C')

I?. #.RTA! #in '

A9C C)annel '

"&

#A$ (A9C$)

I?. #.RTA! #in $

A9C C)annel $

"5

#A5 (A9C5)

I?. #.RTA! #in 5

A9C C)annel 5

"$

#A& (A9C&)

I?. #.RTA! #in &

A9C C)annel &

"'

#A" (A9C")

I?. #.RTA! #in "

A9C C)annel "

"8

#A (A9C )

I?. #.RTA! #in

A9C C)annel

"9

#A1 (A9C1)

I?. #.RTA! #in 1

A9C C)annel 1

&0

#A0 (A9C0)

I?. #.RTA! #in 0

A9C C)annel 0

5-B LIQUID CRYSTAL DISPLAY


"iquid .r/stal displa/ +"C(, has material whi.h .ombines the properties of both liquid and .r/stals2 The/ ha4e a temperature range within whi.h the mole.ules are almost as mobile as the/ would be in a liquid5 but are grouped together in an order form similar to a .r/stal2

36

Fig E2DF "C( (ispla/ 'ore mi.ro.ontroller de4i.es are using Qsmart "C(Q displa/s to output 4isual information2 The following dis.ussion .o4ers the .onne.tion of a !ita.hi "C( displa/ to a P$C mi.ro.ontroller2 "C( displa/s designed around !ita.hiQs "C( !(EEA;> module5 are ine8pensi4e5 eas/ to use5 and it is e4en possible to produ.e a readout using the ; 8 ;> pi8els of the displa/2 !ita.hi "C( displa/s ha4e a standard ASC$$ set of .hara.ters plus Japanese5 #ree0 and mathemati.al s/mbols2 For an ;*bit data bus5 the displa/ requires a @:- suppl/ plus ?? $9O lines2 For a E*bit data bus it onl/ requires the suppl/ lines plus se4en e8tra lines2 6hen the "C( displa/ is not enabled5 data lines are tri*state whi.h means the/ are in a state of high impedan.e +as though the/ are dis.onne.ted, and this means the/ do not interfere with the operation of the mi.ro.ontroller when the displa/ is not being addressed2

37

F$#F "C( ($SP"A) The "C( also requires = L.ontrolL lines from the mi.ro.ontroller Enable +E, This line allows a..ess to the displa/ through R96 and RS lines2 6hen this line is low5 the "C( is disabled and ignores signals from R96 and RS2 6hen +E, line is high5 the "C( .he.0s the state of the two .ontrol lines and responds a..ordingl/2 Read96rite +R96, This line determines the dire.tion of data between the "C( and mi.ro.ontroller2 6hen it is low5 data is written to the "C(2 6hen it is high5 Register +RS, data is read from the "C(2 sele.t 6ith the help of this line5 the "C( interprets the t/pe of data on data lines2 6hen it is low5 an instru.tion is being written to the "C(2 6hen it is high5 a .hara.ter is being written to the "C(2 Read data f o! data 6&"e% (&f &t &% ead&"?$ Reading data from the "C( is done in the same wa/5 but .ontrol line R96 has to be high2 6hen we send a high to the "C(5 it will reset and wait for instru.tions2 T/pi.al instru.tions sent to "C( displa/ after a reset areF turning on a displa/5 turning on a .ursor and writing .hara.ters from left to right2 6hen the "C( is initialiRed5 it is read/ to .ontinue re.ei4ing data or
38

instru.tions2 $f it re.ei4es a .hara.ter5 it will write it on the displa/ and mo4e the .ursor one spa.e to the right2 The Cursor mar0s the ne8t lo.ation where a .hara.ter will be written2 6hen we want to write a string of .hara.ters5 first we need to set up the starting address5 and then send one .hara.ter at a time2 Chara.ters that .an be shown on the displa/ are stored in data displa/ +((, RA'2 The siRe of ((RA' is ;> b/tes2 The "C( displa/ also possesses DE b/tes of Chara.ter*#enerator +C#, RA'2 This memor/ is used for .hara.ters defined b/ the user2 (ata in C# RA' is represented as an ;*bit .hara.ter bit*map2 Ea.h .hara.ter ta0es up ; b/tes of C# RA'5 so the total number of .hara.ters5 whi.h the user .an define5 is eight2 $n order to read in the .hara.ter bit*map to the "C( displa/5 we must first set the C# RA' address to starting point +usuall/ >,5 and then write data to the displa/2 The definition of a Qspe.ialQ .hara.ter is gi4en in the pi.ture2

efore we a..ess (( RA' after defining a spe.ial .hara.ter5 the program must set the (( RA' address2 6riting and reading data from an/ "C( memor/ is done from the last address whi.h was set up using set*address instru.tion2 On.e the address of (( RA' is set5 a new written .hara.ter will be displa/ed at the appropriate pla.e on the s.reen2 &ntil now we dis.ussed the operation of writing and reading to an "C( as if it were an ordinar/ memor/2 ut this is not so2 The "C( .ontroller needs E> to ?<> mi.rose.onds +us, for writing and reading2 Other operations .an ta0e up to : ms2 during that time5 the mi.ro.ontroller .annot a..ess the "C(5 and so a program needs to 0now when the "C( is bus/2 6e .an sol4e this in two wa/s2 One wa/ is to .he.0 the &S) bit found on data line (A2 This is not the best method be.ause "C(Qs .an get stu.05 and program will then sta/ fore4er in a loop .he.0ing the &S) bit2 The
39

other wa/ is to introdu.e a dela/ in the program2 The dela/ has to be long enough for the "C( to finish the operation in pro.ess2 $nstru.tions for writing to and reading from an "C( memor/ shown in the pre4ious table2 At the beginning we mentioned that we needed ?? $9O lines to .ommuni.ate with an "C(2 !owe4er5 we .an .ommuni.ate with an "C( through a ;*bit data bus2 The wiring for .onne.tion 4ia a ;*bit data bus is shown in the diagram below2 $n this e8ample we use an "C( displa/ with <8?D .hara.ters5 labeled "'?DB<?< b/ Japanese ma0er S!ARP2

5-: === TI(ER


The ::: Timer $C is an integrated .ir.uit +.hip, implementing a 4ariet/ of timer and multi4ibrator appli.ations2 The $C was designed b/ !ans R2 CamenRind in ?NA> and brought to mar0et in ?NA? b/ Signeti.s +later a.quired b/ Philips,2 The original name was the SE::: +metal .an,9NE::: +plasti. ($P, and the part was des.ribed as LThe $C Time 'a.hineL2 $t has been .laimed that the ::: gets its name from the three : 0S resistors used in t/pi.al earl/ implementations5T<U but !ans CamenRind has stated that the number was arbitrar/2 The part is still in wide use5 than0s to its ease of use5 low pri.e and good stabilit/2 As of <>>=5 it is estimated that ? billion units are manufa.tured e4er/ /ear2

F$# E2A+a, :::T$'ER $C (epending on the manufa.turer5 the standard ::: pa.0age in.ludes o4er <> transistors5 < diodes and ?: resistors on a sili.on .hip installed in an ;*pin mini dual*in*line pa.0age +($P*;,2
TEU

-ariants a4ailable in.lude the ::D +a ?E*pin ($P .ombining two :::s on one .hip,5 and the
40

::; +a ?D*pin ($P .ombining four slightl/ modified :::s with ($S C T!R .onne.ted internall/5 and TR falling edge sensiti4e instead of le4el sensiti4e,2 &ltra*low power 4ersions of the ::: are also a4ailable5 su.h as the A::: and T"C:::2 The A::: is designed to .ause less suppl/ glit.hing than the .lassi. ::: and the manufa.turer .laims that it usuall/ does not require a L.ontrolL .apa.itor and in man/ .ases does not require a power suppl/ b/pass .apa.itor2 The ::: has three operating modesF

'onostable modeF in this mode5 the ::: fun.tions as a Lone*shotL2 Appli.ations in.lude timers5 missing pulse dete.tion5 boun.efree swit.hes5 tou.h swit.hes5 frequen./ di4ider5 .apa.itan.e measurement5 pulse*width modulation +P6', et.2

Astable * free running modeF the ::: .an operate as an os.illator2 &ses in.lude "E( and lamp flashers5 pulse generation5 logi. .lo.0s5 tone generation5 se.urit/ alarms5 pulse position modulation5 et.2

istable mode or S.hmitt triggerF the ::: .an operate as a flip*flop5 if the ($S pin is not .onne.ted and no .apa.itor is used2 &ses in.lude boun.efree lat.hed swit.hes5 et.2

U%a?e The .onne.tion of the pins is as followsF P&" ? < = E : D A ; Na!e #N( TR$# O&T RESET CTR" T!R ($S V@5 VCC P9 po%e #round5 low le4el +> -, O&T rises5 and inter4al starts5 when this input falls below ?9= VCC2 This output is dri4en to @VCC or #N(2 A timing inter4al ma/ be interrupted b/ dri4ing this input to #N(2 LControlL a..ess to the internal 4oltage di4ider +b/ default5 <9= VCC,2 The inter4al ends when the 4oltage at T!R is greater than at CTR"2 Open .olle.tor outputK ma/ dis.harge a .apa.itor between inter4als2 Positi4e suppl/ 4oltage is usuall/ between = and ?: -2

41

F$#E2A+b, :::T$'ER P$N ($A#RA' === .a%&4% The ::: timer $C is a simple ; pin ($" pa.0age $C2 $t .anF

be used as a monostable be used as an astable sour.e or sin0 ?>>mA use suppl/ 4oltages of :4 to ?:4 disrupt the power suppl/ * use a de.oupling .apa.itorV

U%&"? the === a% a 09ffe A buffer .ir.uit allows an input .ir.uit to be .onne.ted to an output .ir.uit5 it is li0e an interfa.e between one .ir.uit and another2 The buffer .ir.uit requires 4er/ little input .urrent but should be able to suppl/ adequate output .urrent2 The ::: .an suppl/ in e8.ess of ?>>mA of .urrent and so .an be used as a .on4enient buffer for logi. gates whi.h .annot suppl/ mu.h .urrent2 The ::: .an also Qsin0Q a similar amount of .urrent2 The .ir.uit used isF

F$# E2A+.,F ::: T$'ER AS A &FFER The .ir.uit a.ts li0e an in4erter or NOT gate2 6hen the input is held low5 the output is high and will pro4ide +sour.e, .urrent2 6hen the input is held high5 the output is low and will sin0 .urrent2 Remember5 for a buffer for e4en higher power de4i.es that require e4en larger .urrents5 the ::: buffer .an be used to dri4e a rela/ or a transistor .ir.uit2 U%&"? the === a% a !o"o%ta06e The ::: .an be used as a monostable using the .ir.uit shownF

42

F$# E2A+d, :::T$'ER AS A 'ONOSTA "E

The output is normall/ low but will go high for a short length of time depending on the 4alues of the other .omponents2 R and C determine the time period of the output pulse2 The input is normall/ high and goes low to trigger the output +falling edge triggered,2 The length of the input pulse must be less than the length of the output pulse2 The EAuF .apa.itor Qde.ouplesQ the suppl/ to a4oid affe.ting other parts of the .ir.uit2 $t is standard to add a ?>nF .apa.itor from pin: to gnd2 T C ,-, R C T * se.onds5 R * ohms5 C * Farads

The minimum 4alue of R should be about ?0 to a4oid too mu.h .urrent flowing into the :::2 The ma8imum 4alue of R should be about ?' so that enough .urrent .an flow into the input of the ::: and there is also .urrent to allow for the ele.trol/ti. .apa.itors lea0age .urrent2 The minimum 4alue of C O ?>>pF to a4oid the timing equation being too far off2 The ma8imum 4alue of C should be about ?>>>WF as an/ bigger .apa.itors will dis.harge too mu.h .urrent through the .hip2 These ma8imum and minimum 4alues gi4e a minimum period of >2? Ws and a ma8imum period of ?>>>s2 U%&"? the === a% a" a%ta06e The ::: .an be used as an astable using the .ir.uit shownF

43

F$# E2A+e,F ::: T$'ER AS A ASTA "E

The output will os.illate between high and low .ontinuousl/ * the .ir.uit is not stable in an/ state Ra5 Rb and C determine the time period of the output The reset5 pin E5 must be held high for the .ir.uit to os.illate2 $f pin E is held low then the output remains low2 Pin E .an be used to turn the astable QonQ and QoffQ in effe.t The EAuF .apa.itor Qde.ouplesQ the suppl/ to a4oid affe.ting other parts of the .ir.uit $t is standard to add a ?>nF .apa.itor from pin: to gnd2 T C <-: ( Ra D /R0 $ C T * se.onds5 R * ohms5 C * Farads

As with the monostable the minimum 4alue of Ra should be about ?0 to a4oid too mu.h .urrent flowing into the :::2The ma8imum 4alue of Ra or Rb should be about ?' so that enough .urrent .an flow into the input of the ::: and there is also .urrent to allow for the ele.trol/ti. .apa.itors lea0age .urrent2 The minimum 4alue of C O ?>>pF to a4oid the timing equation being too far off2 The ma8imum 4alue of C should be about ?>>>WF as an/ bigger .apa.itors will dis.harge too
44

mu.h .urrent through the .hip2 These ma8imum and minimum 4alues gi4e a minimum frequen./ of >2>>? !R and a ma8imum frequen./ of E2; '!R +in realit/ it would not be able to attain these frequen.ies,2 Considering the os.illations in more detailF

the output is .ontrolled b/ the .harging and dis.harging of the .apa.itor2 The .apa.itor .harges through Ra and Rb2 ut dis.harges through the dis.harge pin +pin A, and thus onl/ through Rb2 The time that the .apa.itor ta0es to .harge or dis.harge is gi4en as T O >2A R C2 Thus the .harge time is >2A +Ra @ Rb, C2 The dis.harge time is >2A Rb C2 #i4ing a total time of +>2A +Ra @ Rb, C, @ +>2A Rb C, O >2A +Ra @ <Rb, C2 The time the output is high +mar0, is thus alwa/s longer than the time the output is low +spa.e,2 The ::: astable .annot produ.e a square wa4eV

Ope at&o" of the === $t is not ne.essar/ to 0now how the ::: wor0s2 $n fa.t a s/stems approa.h to ele.troni.s would ne4er .onsider how an/ su.h sub*blo.0 wor0s2 !owe4er5 a 0nowledge of how the ::: fun.tions is useful2 A mu.h simplified blo.0 diagram of the ::: timer is shownF

45

F$# E2A+f,F OPERAT$ON OF :::T$'ER

The resistors are arranged a.ross the power suppl/ to form a potential di4ider2 The 4oltages at the 7un.tions of the potential di4ider are <9= -.. and ?9= -..2 The/ are .onne.ted to the inputs to a pair of .omparators2

One .omparator5 swit.hing at <9= -.. is .ontrolled 4ia the threshold input2 The 4oltage at whi.h the threshold .omparator swit.hes .an be .hanged from <9= -.. b/ appl/ing a 4oltage to the .ontrol pin2 This pin is usuall/ de.oupled to ground 4ia a ?>nF .apa.itor and5 in this .ase5 the .omparator swit.hes at <9= -.. as e8pe.ted2

One .omparator5 swit.hing at ?9= -.. is .ontrolled 4ia the trigger input2 The outputs from the two .omparators .ontrol a set*reset flip flop +bistable,2 The reset pin of the ::: +not of the bistable, is usuall/ held high2 Ta0ing this pin momentaril/ low appl/ a 4oltage to the reset pin of the flip flop and the output falls to Rero2

The output of the flip flop is .onne.ted to the output pin 4ia a power amplifier .ir.uit whi.h in.ludes short .ir.uit prote.tion et.2 The output goes high when the trigger input is less than ?9= -..2 The output then remains high until the threshold input rises abo4e <9= -..2 6hen the output is low5 the dis.harge pin is .onne.ted to ground 4ia a transistor2 The .apa.itor .an be organiRed to dis.harge through this pin but the 4alue of the .apa.itor should be less than ?>>>WF to a4oid damaging the transistor2

5-,< RELAY
A rela/ is an electricall+ operated switch2 'an/ rela/s use an ele.tromagnet to operate a swit.hing me.hanism me.hani.all/5 but other operating prin.iples are also used2 Rela/s are used where it is ne.essar/ to .ontrol a .ir.uit b/ a low*power signal +with .omplete ele.tri.al isolation between .ontrol and .ontrolled .ir.uits,5 or where se4eral .ir.uits must be .ontrolled b/ one signal2

46

A rela/ is an ele.tri.all/ operated swit.h2 Current flowing through the .oil of the rela/ .reates a magneti. field whi.h attra.ts a le4er and .hanges the swit.h .onta.ts2 The .oil .urrent .an be on or off so rela/s ha4e two swit.h positions and most ha4e double throw +.hangeo4er, swit.h .onta.ts as shown in the diagram2

Fig E2; Rela/ showing .oil and swit.h .onta.ts Rela/s allow one .ir.uit to swit.h a se.ond .ir.uit whi.h .an be .ompletel/ separate from the first2 For e8ample a low 4oltage batter/ .ir.uit .an use a rela/ to swit.h a <=>- AC mains .ir.uit2 There is no ele.tri.al .onne.tion inside the rela/ between the two .ir.uitsK the lin0 is magneti. and me.hani.al2 The .oil of a rela/ passes a relati4el/ large .urrent5 t/pi.all/ =>mA for a ?<- rela/5 but it .an be as mu.h as ?>>mA for rela/s designed to operate from lower 4oltages2 'ost $Cs +.hips, .annot pro4ide this .urrent and a transistor is usuall/ used to amplif/ the small $C .urrent to the larger 4alue required for the rela/ .oil2 The ma8imum output .urrent for the popular ::: timer $C is <>>mA so these de4i.es .an suppl/ rela/ .oils dire.tl/ without amplifi.ation2
47

Rela/s are usuall/ SP(T or (P(T but the/ .an ha4e man/ more sets of swit.h .onta.ts5 for e8ample rela/s with E sets of .hangeo4er .onta.ts are readil/ a4ailable2 For further information about swit.h .onta.ts and the terms used to des.ribe them please see the page on swit.hes2 'ost rela/s are designed for PC mounting but /ou .an solder wires dire.tl/ to the pins pro4iding /ou ta0e .are to a4oid melting the plasti. .ase of the rela/2 The supplierQs .atalogue should show /ou the rela/Qs .onne.tions2 The .oil will be ob4ious and it ma/ be .onne.ted either wa/ round2 Rela/ .oils produ.e brief high 4oltage Qspi0esQ when the/ are swit.hed off and this .an destro/ transistors and $Cs in the .ir.uit2 To pre4ent damage /ou must .onne.t a prote.tion diode a.ross the rela/ .oil2 The figure shows a rela/ with its .oil and swit.h .onta.ts2 )ou .an see a le4er on the left being attra.ted b/ magnetism when the .oil is swit.hed on2 This le4er mo4es the swit.h .onta.ts2

48

There is one set of .onta.ts +SP(T, in the foreground and another behind them5 ma0ing the rela/ (P(T2 The rela/Qs swit.h .onne.tions are usuall/ labelled CO'5 NC and NOF

CO' O Common5 alwa/s .onne.t to thisK it is the mo4ing part of the swit.h2 NC O Normall/ Closed5 CO' is .onne.ted to this when the rela/ .oil is off2 NO O Normall/ Open5 CO' is .onne.ted to this when the rela/ .oil is on2

49

App6&4at&o"% of e6a1%
Rela/s are used to and forF

Control a high*4oltage .ir.uit with a low*4oltage signal5 as in some t/pes of modems or audio amplifiers2 Control a high*.urrent .ir.uit with a low*.urrent signal5 as in the starter solenoid of an automobile2 (ete.t and isolate faults on transmission and distribution lines b/ opening and .losing .ir.uit brea0ers2 Time dela/ fun.tions2 Rela/s .an be modified to dela/ opening or dela/ .losing a set of .onta.ts2 A 4er/ short +a fra.tion of a se.ond, dela/ would use a .opper dis0 between the armature and mo4ing blade assembl/2 Current flowing in the dis0 maintains magneti. field for a short time5 lengthening release time2 For a slightl/ longer +up to a minute, dela/5 a dashpot is used2 A dashpot is a piston filled with fluid that is allowed to es.ape slowl/2 The time period .an be 4aried b/ in.reasing or de.reasing the flow rate2 For longer time periods5 a me.hani.al .lo.0wor0 timer is installed2

5-,, PUSH .UTTONS

Fig E2??+a,F Push uttons A push*button +also spelled pushbutton, or simpl/ button is a simple swit.h me.hanism for .ontrolling some aspe.t of a ma.hine or a pro.ess2 uttons are t/pi.all/ made out of hard
50

material5 usuall/ plasti. or metal2 The surfa.e is usuall/ flat or shaped to a..ommodate the human finger or hand5 so as to be easil/ depressed or pushed2 uttons are most often biased swit.hes5 though e4en man/ un*biased buttons +due to their ph/si.al nature, require a spring to return to their un*pushed state2 (ifferent people use different terms for the LpushingL of the button5 su.h as press5 depress5 mash5 and pun.h2 U%e%3 $n industrial and .ommer.ial appli.ations push buttons .an be lin0ed together b/ a me.hani.al lin0age so that the a.t of pushing one button .auses the other button to be released2 $n this wa/5 a stop button .an Lfor.eL a start button to be released2 This method of lin0age is used in simple manual operations in whi.h the ma.hine or pro.ess ha4e no ele.tri.al .ir.uits for .ontrol2 Pushbuttons are often .olor*.oded to asso.iate them with their fun.tion so that the operator will not push the wrong button in error2 Commonl/ used .olors are red for stopping the ma.hine or pro.ess and green for starting the ma.hine or pro.ess2 Red pushbuttons .an also ha4e large heads +mushroom shaped, for eas/ operation and to fa.ilitate the stopping of a ma.hine2 These pushbuttons are .alled emergen./ stop buttons and are mandated b/ the ele.tri.al .ode in man/ 7urisdi.tions for in.reased safet/2 This large mushroom shape .an also be found in buttons for use with operators who need to wear glo4es for their wor0 and .ould not a.tuate a regular flush*mounted push button2 As an aid for operators and users in industrial or .ommer.ial appli.ations5 a pilot light is .ommonl/ added to draw the attention of the user and to pro4ide feedba.0 if the button is pushed2 T/pi.all/ this light is in.luded into the .enter of the pushbutton and a lens repla.es the pushbutton hard .enter dis02 The sour.e of the energ/ to illuminate the light is not dire.tl/ tied to the .onta.ts on the ba.0 of the pushbutton but to the a.tion the pushbutton .ontrols2 $n this wa/ a start button when pushed will .ause the pro.ess or ma.hine operation to be started and a se.ondar/ .onta.t designed into the operation or pro.ess will .lose to turn on the pilot light and signif/ the a.tion of pushing the button .aused the resultant pro.ess or a.tion to start2 $n popular .ulture5 the phrase Lthe buttonL refers to a +usuall/ fi.tional, button that a militar/ or go4ernment leader .ould press to laun.h nu.lear weapons2

51

P9%h to ON 09tto"3

Fig2E2??+b,F push on button $nitiall/ the two .onta.ts of the button are open2 6hen the button is pressed the/ be.ome .onne.ted2 This ma0es the swit.hing operation using the push button2

5-,A LED
A light*emitting diode +"E(, is a semi.ondu.tor light sour.e2 "E(s are used as indi.ator lamps in man/ de4i.es5 and are in.reasingl/ used for lighting2 6hen a light*emitting diode is forward biased +swit.hed on,5 ele.trons are able to re.ombine with holes within the de4i.e5 releasing energ/ in the form of photons2 This effe.t is .alled ele.trolumines.en.e and the .olor of the light +.orresponding to the energ/ of the photon, is determined b/ the energ/ gap of the semi.ondu.tor2 An "E( is often small in area +less than ? mm<,5 and integrated opti.al .omponents ma/ be used to shape its radiation pattern2 "E(s present man/ ad4antages o4er in.andes.ent light sour.es in.luding lower energ/ .onsumption5 longer lifetime5 impro4ed robustness5 smaller siRe5 faster swit.hing5 and greater durabilit/ and reliabilit/2

52

T1pe% of LED+S

Fig E2?=+a,F T/pes of "E( "ight*emitting diodes are used in appli.ations as di4erse as repla.ements for a4iation lighting5 automoti4e lighting as well as in traffi. signals2 The .ompa.t siRe5 the possibilit/ of narrow bandwidth5 swit.hing speed5 and e8treme reliabilit/ of "E(s has allowed new te8t and 4ideo displa/s and sensors to be de4eloped5 while their high swit.hing rates are also useful in ad4an.ed .ommuni.ations te.hnolog/2 E6e4t o"&4 S1!0o63

Fig E2?=+b,F s/mbol of "E( Co6o % a"d !ate &a6% of LED+S Con4entional "E(s are made from a 4ariet/ of inorgani. semi.ondu.tor materials5 the following table shows the a4ailable .olors with wa4elength range5 4oltage drop and material2 Wh&te LED+S "ight Emitting (iodes +"E(, ha4e re.entl/ be.ome a4ailable that are both white and bright5 so bright that the/ seriousl/ .ompete with in.andes.ent lamps in lighting appli.ations2
53

The/ are still prett/ e8pensi4e as .ompared to a #O6 lamp but draw mu.h less .urrent and pro7e.t a fairl/ well fo.used beam2 6hen run within their ratings5 the/ are more reliable than lamps as well2 Red "E(s are now being used in automoti4e and tru.0 tail lights and in red traffi. signal lights2 )ou will be able to dete.t them be.ause the/ loo0 li0e an arra/ of point sour.es and the/ go on and off instantl/ as .ompared to .on4entional in.andes.ent lamps2

Fig E2?=+.,F 6hite

"E( spe.trum

"E(s are mono.hromati. +one .olor, de4i.es2 The .olor is determined b/ the band gap of the semi.ondu.tor used to ma0e them2 Red5 green5 /ellow and blue "E(s are fairl/ .ommon2 6hite light .ontains all .olors and .annot be dire.tl/ .reated b/ a single "E(2 The most .ommon form of LwhiteL "E( reall/ isnQt white2 $t is a #allium Nitride blue "E( .oated with a phosphor that5 when e8.ited b/ the blue "E( light5 emits a broad range spe.trum that in addition to the blue emission5 ma0es a fairl/ white light2 There is a .laim that these white "E(Qs ha4e a limited life2 After ?>>> hours or so of operation5 the/ tend to /ellow and dim to some e8tent2 Running the "E(s at more than their rated .urrent will .ertainl/ a..elerate this pro.ess2 There are two primar/ wa/s of produ.ing high intensit/ white*light using "E(s2 One is to use indi4idual "E(s that emit three primar/ .olorsXred5 green5 and blueXand then mi8 all the .olors to form white light2 The other is to use a phosphor material to .on4ert mono.hromati. light from a blue or &- "E( to broad*spe.trum white light5 mu.h in the same wa/ a fluores.ent light bulb wor0s2 (ue to metamerism5 it is possible to ha4e quite different spe.tra that appear white2

5-,5 ,N5<<:
54

(iodes are used to .on4ert AC into (C these are used as half wa4e re.tifier or full wa4e re.tifier2 Three points must he 0ept in mind while using an/ t/pe of diode2 ?2 'a8imum forward .urrent .apa.it/ <2 'a8imum re4erse 4oltage .apa.it/ =2 'a8imum forward 4oltage .apa.it/

FigF ?NE>>A diodes


The number and 4oltage .apa.it/ of some of the important diodes a4ailable in the mar0et are as followsF

(iodes of number $NE>>?5 $NE>><5 $NE>>=5 $NE>>E5 $NE>>:5 $NE>>D and $NE>>A ha4e ma8imum re4erse bias 4oltage .apa.it/ of :>- and ma8imum forward .urrent .apa.it/ of ? Amp2

(iode of same .apa.ities .an be used in pla.e of one another2 esides this diode of more .apa.it/ .an be used in pla.e of diode of low .apa.it/ but diode of low .apa.it/ .annot be used in pla.e of diode of high .apa.it/2 For e8ample5 in pla.e of $NE>><K $NE>>? or $NE>>A .an be used but $NE>>? or $NE>>< .annot be used in pla.e of $NE>>A2The diode )?<:made b/ .ompan/ E" is equi4alent of diode from $NE>>? to $NE>>=2 ) ?<D is equi4alent to diodes $NE>>E to E>>D and ) ?<A is equi4alent to diode $NE>>A2

55

FigFPN Jun.tion diode

PN EUNCTION OPERATION
Now that /ou are familiar with P* and N*t/pe materials5 how these materials are 7oined together to form a diode5 and the fun.tion of the diode5 let us .ontinue our dis.ussion with the operation of the PN 7un.tion2 ut before we .an understand how the PN 7un.tion wor0s5 we must first .onsider .urrent flow in the materials that ma0e up the 7un.tion and what happens initiall/ within the 7un.tion when these two materials are 7oined together2

C9 e"t F6o7 &" the NFT1pe (ate &a6


Condu.tion in the N*t/pe semi.ondu.tor5 or .r/stal5 is similar to .ondu.tion in a .opper wire2 That is5 with 4oltage applied a.ross the material5 ele.trons will mo4e through the .r/stal 7ust as .urrent would flow in a .opper wire2 This is shown in figure ?*?:2 The positi4e potential of the batter/ will attra.t the free ele.trons in the .r/stal2 These ele.trons will lea4e the .r/stal and flow into the positi4e terminal of the batter/2 As an ele.tron lea4es the .r/stal5 an ele.tron from the negati4e terminal of the batter/ will enter the .r/stal5 thus .ompleting the .urrent path2 Therefore5 the ma7orit/ .urrent .arriers in the N*t/pe material +ele.trons, are
56

repelled b/ the negati4e side of the batter/ and mo4e through the .r/stal toward the positi4e side of the batter/2

C9 e"t F6o7 &" the PFT1pe (ate &a6


Current flow through the P*t/pe material is illustrated2 Condu.tion in the P material is b/ positi4e holes5 instead of negati4e ele.trons2 A hole mo4es from the positi4e terminal of the P material to the negati4e terminal2 Ele.trons from the e8ternal .ir.uit enter the negati4e terminal of the material and fill holes in the 4i.init/ of this terminal2 At the positi4e terminal5 ele.trons are remo4ed from the .o4alent bonds5 thus .reating new holes2 This pro.ess .ontinues as the stead/ stream of holes +hole .urrent, mo4es toward the negati4e terminal2

5-,= RESISTORS
A resistor is a two*terminal ele.troni. .omponent designed to oppose an ele.tri. .urrent b/ produ.ing a 4oltage drop between its terminals in proportion to the .urrent5 that is5 in a..ordan.e with OhmQs lawF V O IR Resistors are used as part of ele.tri.al networ0s and ele.troni. .ir.uits2 The/ are e8tremel/ .ommonpla.e in most ele.troni. equipment2 Pra.ti.al resistors .an be made of 4arious .ompounds and films5 as well as resistan.e wire +wire made of a high*resisti4it/ allo/5 su.h as ni.0el9.hrome,2 The primar/ .hara.teristi.s of resistors are their resistan.e and the power the/ .an dissipate2 Other .hara.teristi.s in.lude temperature .oeffi.ient5 noise5 and indu.tan.e2 "ess well* 0nown is .riti.al resistan.e5 the 4alue below whi.h power dissipation limits the ma8imum permitted .urrent flow5 and abo4e whi.h the limit is applied 4oltage2 Criti.al resistan.e depends upon the materials .onstituting the resistor as well as its ph/si.al dimensionsK itQs determined b/ design2 Resistors .an be integrated into h/brid and printed .ir.uits5 as well as integrated .ir.uits2

57

SiRe5 and position of leads +or terminals, are rele4ant to equipment designersK resistors must be ph/si.all/ large enough not to o4erheat when dissipating their power2

A resistor is a two*terminal passi4e ele.troni. .omponent whi.h implements ele.tri.al resistan.e as a .ir.uit element2 6hen a 4oltage - is applied a.ross the terminals of a resistor5 a .urrent $ will flow through the resistor in dire.t proportion to that 4oltage2 The re.ipro.al of the .onstant of proportionalit/ is 0nown as the resistan.e R5 sin.e5 with a gi4en 4oltage -5 a larger 4alue of R further LresistsL the flow of .urrent $ as gi4en b/ OhmQs lawF

Resistors are .ommon elements of ele.tri.al networ0s and ele.troni. .ir.uits and are ubiquitous in most ele.troni. equipment2 Pra.ti.al resistors .an be made of 4arious .ompounds and films5 as well as resistan.e wire +wire made of a high*resisti4it/ allo/5 su.h as ni.0el* .hrome,2 Resistors are also implemented within integrated .ir.uits5 parti.ularl/ analog de4i.es5 and .an also be integrated into h/brid and printed .ir.uits2 The ele.tri.al fun.tionalit/ of a resistor is spe.ified b/ its resistan.eF .ommon .ommer.ial resistors are manufa.tured o4er a range of more than N orders of magnitude2 6hen spe.if/ing that resistan.e in an ele.troni. design5 the required pre.ision of the resistan.e ma/ require attention to the manufa.turing toleran.e of the .hosen resistor5 a..ording to its spe.ifi. appli.ation2 The temperature .oeffi.ient of the resistan.e ma/ also be of .on.ern in some pre.ision appli.ations2 Pra.ti.al resistors are also spe.ified as ha4ing a ma8imum power rating whi.h must e8.eed the anti.ipated power dissipation of that resistor in a parti.ular .ir.uitF this is mainl/ of .on.ern in power ele.troni.s appli.ations2 Resistors with higher power ratings are ph/si.all/ larger and ma/ require heat sin0ing2 $n a high 4oltage .ir.uit5 attention must sometimes be paid to the rated ma8imum wor0ing 4oltage of the resistor2
58

The series indu.tan.e of a pra.ti.al resistor .auses its beha4ior to depart from ohms lawK this spe.ifi.ation .an be important in some high*frequen./ appli.ations for smaller 4alues of resistan.e2 $n a low*noise amplifier or pre*amp the noise .hara.teristi.s of a resistor ma/ be an issue2 The unwanted indu.tan.e5 e8.ess noise5 and temperature .oeffi.ient are mainl/ dependent on the te.hnolog/ used in manufa.turing the resistor2 The/ are not normall/ spe.ified indi4iduall/ for a parti.ular famil/ of resistors manufa.tured using a parti.ular te.hnolog/2 A famil/ of dis.rete resistors is also .hara.teriRed a..ording to its form fa.tor5 that is5 the siRe of the de4i.e and position of its leads +or terminals, whi.h is rele4ant in the pra.ti.al manufa.turing of .ir.uits using them2

U$its
The ohm +s/mbolF S, is the S$ unit of ele.tri.al resistan.e5 named after #eorg Simon Ohm2 An ohm is equi4alent to a 4olt per ampere2 Sin.e resistors are spe.ified and manufa.tured o4er a 4er/ large range of 4alues5 the deri4ed units of milliohm +? mS O ?> Y= S,5 0ilohm +? 0S O ?>= S,5 and megohm +? 'S O ?>D S, are also in .ommon usage2 The re.ipro.al of resistan.e R is .alled .ondu.tan.e # O ?9R and is measured in Siemens +S$ unit,5 sometimes referred to as a mho2 Thus a Siemens is the re.ipro.al of an ohmF S O S Y ?2 Although the .on.ept of .ondu.tan.e is often used in .ir.uit anal/sis5 pra.ti.al resistors are alwa/s spe.ified in terms of their resistan.e +ohms, rather than .ondu.tan.e2

5-,B CAPACITORS
A .apa.itor or .ondenser is a passi4e ele.troni. .omponent .onsisting of a pair of .ondu.tors separated b/ a diele.tri.2 6hen a 4oltage potential differen.e e8ists between the .ondu.tors5 an ele.tri. field is present in the diele.tri.2 This field stores energ/ and produ.es a me.hani.al for.e between the plates2 The effe.t is greatest between wide5 flat5 parallel5 narrowl/ separated .ondu.tors2 An ideal .apa.itor is .hara.teriRed b/ a single .onstant 4alue5 .apa.itan.e5 whi.h is measured in farads2 This is the ratio of the ele.tri. .harge on ea.h .ondu.tor to the potential differen.e between them2 $n pra.ti.e5 the diele.tri. between the plates passes a small amount of
59

lea0age .urrent2 The .ondu.tors and leads introdu.e an equi4alent series resistan.e and the diele.tri. has an ele.tri. field strength limit resulting in a brea0down 4oltage2 The properties of .apa.itors in a .ir.uit ma/ determine the resonant frequen./ and qualit/ fa.tor of a resonant .ir.uit5 power dissipation and operating frequen./ in a digital logi. .ir.uit5 energ/ .apa.it/ in a high*power s/stem5 and man/ other important aspe.ts2

A .apa.itor +formerl/ 0nown as .ondenser, is a de4i.e for storing ele.tri. .harge2 The forms of pra.ti.al .apa.itors 4ar/ widel/5 but all .ontain at least two .ondu.tors separated b/ a non*.ondu.tor2 Capa.itors used as parts of ele.tri.al s/stems5 for e8ample5 .onsist of metal foils separated b/ a la/er of insulating film2 Capa.itors are widel/ used in ele.troni. .ir.uits for blo.0ing dire.t .urrent while allowing alternating .urrent to pass5 in filter networ0s5 for smoothing the output of power supplies5 in the resonant .ir.uits that tune radios to parti.ular frequen.ies and for man/ other purposes2 A .apa.itor is a passi4e ele.troni. .omponent .onsisting of a pair of .ondu.tors separated b/ a diele.tri. +insulator,2 6hen there is a potential differen.e +4oltage, a.ross the .ondu.tors5 a stati. ele.tri. field de4elops in the diele.tri. that stores energ/ and produ.es a me.hani.al for.e
60

between the .ondu.tors2 An ideal .apa.itor is .hara.teriRed b/ a single .onstant 4alue5 .apa.itan.e5 measured in farads2 This is the ratio of the ele.tri. .harge on ea.h .ondu.tor to the potential differen.e between them2 The .apa.itan.e is greatest when there is a narrow separation between large areas of .ondu.tor5 hen.e .apa.itor .ondu.tors are often .alled LplatesL5 referring to an earl/ means of .onstru.tion2 $n pra.ti.e the diele.tri. between the plates passes a small amount of lea0age .urrent and also has an ele.tri. field strength limit5 resulting in a brea0down 4oltage5 while the .ondu.tors and leads introdu.e an undesired indu.tan.e and resistan.e2

T eor( o. o+er#tio$
Capa.itan.e

Charge separation in a parallel*plate .apa.itor .auses an internal ele.tri. field2 A diele.tri. +orange, redu.es the field and in.reases the .apa.itan.e2

A simple demonstration of a parallel*plate .apa.itor

61

A .apa.itor .onsists of two .ondu.tors separated b/ a non*.ondu.ti4e region2 The non* .ondu.ti4e region is .alled the diele.tri. or sometimes the diele.tri. medium2 $n simpler terms5 the diele.tri. is 7ust an ele.tri.al insulator2 E8amples of diele.tri. mediums are glass5 air5 paper5 4a.uum5 and e4en a semi.ondu.tor depletion region .hemi.all/ identi.al to the .ondu.tors2 A .apa.itor is assumed to be self*.ontained and isolated5 with no net ele.tri. .harge and no influen.e from an/ e8ternal ele.tri. field2 The .ondu.tors thus hold equal and opposite .harges on their fa.ing surfa.es5 and the diele.tri. de4elops an ele.tri. field2 $n S$ units5 a .apa.itan.e of one farad means that one .oulomb of .harge on ea.h .ondu.tor .auses a 4oltage of one 4olt a.ross the de4i.e2 The .apa.itor is a reasonabl/ general model for ele.tri. fields within ele.tri. .ir.uits2 An ideal .apa.itor is wholl/ .hara.teriRed b/ a .onstant .apa.itan.e C5 defined as the ratio of .harge ZM on ea.h .ondu.tor to the 4oltage - between themF

Sometimes .harge build*up affe.ts the .apa.itor me.hani.all/5 .ausing its .apa.itan.e to 4ar/2 $n this .ase5 .apa.itan.e is defined in terms of in.remental .hangesF

E$er%( stor#%e

6or0 must be done b/ an e8ternal influen.e to Lmo4eL .harge between the .ondu.tors in a .apa.itor2 6hen the e8ternal influen.e is remo4ed the .harge separation persists in the ele.tri. field and energ/ is stored to be released when the .harge is allowed to return to its equilibrium position2 The wor0 done in establishing the ele.tri. field5 and hen.e the amount of energ/ stored5 is gi4en b/F

C)rre$t/0o-t#%e re-#tio$

The .urrent i+t, through an/ .omponent in an ele.tri. .ir.uit is defined as the rate of flow of a .harge q+t, passing through it5 but a.tual .harges5 ele.trons5 .annot pass through the diele.tri. la/er of a .apa.itor5 rather an ele.tron a..umulates on the negati4e plate for ea.h one that lea4es the positi4e plate5 resulting in an ele.tron depletion and .onsequent positi4e .harge on one
62

ele.trode that is equal and opposite to the a..umulated negati4e .harge on the other2 Thus the .harge on the ele.trodes is equal to the integral of the .urrent as well as proportional to the 4oltage as dis.ussed abo4e2 As with an/ antideri4ati4e5 a .onstant of integration is added to represent the initial 4oltage 4 +t>,2 This is the integral form of the .apa.itor equation5

2 Ta0ing the deri4ati4e of this5 and multipl/ing b/ C5 /ields the deri4ati4e form5 2 The dual of the .apa.itor is the indu.tor5 whi.h stores energ/ in the magneti. field rather than the ele.tri. field2 $ts .urrent*4oltage relation is obtained b/ e8.hanging .urrent and 4oltage in the .apa.itor equations and repla.ing C with the indu.tan.e "2

63

=-SOFTWARE REQUIRE(ENTS

64

1! A%r 'tudio 2! 3on+3rog

A,R St)dio1'ro%r#! Editor2& )nstructions for 3rogramming and 8om iling 8 within A=2 'tudio 4 1 en A=2 'tudio$ +ou should be greeted with the following dialog& >it /ew

>it /ew 3ro:ect( )f this dialog does not show$ go to 3ro:ect !? /ew 3ro:ect( @ou should see the following dialog&

65

8hoose A=2 A88 for ro:ect t+ e and t+ e in a ro:ect name( .his e6am le will make a director+ called testB and a file called test(c( >it ne6t to choose +our latform "+ou can choose A=2 'imulator to be able to simulate +our ro:ect in A=2 'tudio# then hit 9inish( A new window should come u where +ou can t+ e in +our 8 code( /otice it will highlight the ro er 8 s+nta6( .+ e in a sam le rogram like the following&

66

8om ile +our file then hit 'tart 0ebugging "the la+ button#( /ow +ou can ste through +our 8 code( .o see the assembl+ code$ go to =iew !? 0isassembler( /ow +ou can ste through both at the same time( /o more need for 3rogrammers /ote ad or makefilesC

.o o en +our ro:ect again$ go to 3ro:ect !? 1 en and choose +our (a s file(

'o$('ro%& To be able to send he8 file from /our .omputer to A-R mi.ro.ontroller /ou will need to download and install Pon/Prog<>>>2 After the installation5 the first thing /ou will need to do is .onfigure Pon/Prog to wor0 with our A-R Programmer2 To do this go to LSetupL menu and sele.t L$nterfa.e SetupL2 The following window will be shown and highlighted areas show /ou e8a.tl/ whi.h options should be sele.ted

67

$n the ne8t step sele.t LA-R mi.roL and /our mi.ro.ontroller t/pe that /ou will be programming +e82 ATmega;,2

At this point Pon/Prog .onfiguration is .omplete and we .an open he8 program with whi.h A-R mi.ro.ontroller will be flashed2 #o to LFileL menu5 sele.t LOpen Program +F"AS!, File 222L5 and point to the he8 file to open it up2 )ou should see he8 numbers as shown on the s.reen below2 $f /ou ha4enQt .onne.ted A-R Programmer dongle to /our .omputerQs seri port /et5 then now is the time2 'a0e sure that A-R Programmer is ph/si.all/ .onne.ted to /our A-R mi.ro.ontroller through So.0et PC or through $CSP D*P$N .onne.tor2 Finall/ .li.0 on the
68

highlighted i.on L6rite Program 'emor/ +F"AS!,L5 or go to LCommandL menu and sele.t L6rite Program +F"AS!,L2

Cli.0 on L)esL button to .onfirm the programming2

To be able to send he8 file from /our .omputer to A-R mi.ro.ontroller /ou will need to download and install Pon/Prog<>>>2 After the installation5 the first thing /ou will need to do is .onfigure Pon/Prog to wor0 with our A-R Programmer2 To do this go to LSetupL menu and sele.t L$nterfa.e SetupL2 The following window will be shown and highlighted areas show /ou e8a.tl/ whi.h options should be sele.ted2

69

$n the ne8t step sele.t LA-R mi.roL and /our mi.ro.ontroller t/pe that /ou will be programming +e82 ATmega;,2

At this point Pon/Prog .onfiguration is .omplete and we .an open he8 program with whi.h A-R mi.ro.ontroller will be flashed2 #o to LFileL menu5 sele.t LOpen Program +F"AS!, File 222L5 and point to the he8 file to open it up2 )ou should see he8 numbers as shown on the s.reen below2 $f /ou ha4enQt .onne.ted A-R Programmer dongle to /our .omputerQs serial port /et5 then now is the time2 'a0e sure that A-R Programmer is ph/si.all/ .onne.ted to /our A-R mi.ro.ontroller through So.0et PC or through $CSP D*P$N .onne.tor2 Finall/ .li.0 on the highlighted i.on L6rite Program 'emor/ +F"AS!,L5 or go to LCommandL menu and sele.t L6rite Program +F"AS!,L2
70

Cli.0 on L)esL button to .onfirm the programming2

Now sit tight5 rela8 and wat.h the programming progress on the status bar2 Pon/Prog will program A-R mi.ro.ontroller and 4erif/ if the he8 file was transferred without an/ errors2 For /our information this pro.ess shouldnQt reall/ ta0e more than ?> to => se.onds2 This depends on the siRe of the program that /ouQre tr/ing to flash2

After programming is .ompleted L6rite su..essfulL window will be shown letting /ou 0now that A-R mi.ro.ontroller has been programmed5 and is now read/ to be used2

71

About AVR Programmer This simple A-R Programmer will allow /ou to painlessl/ transfer he8 programs to most AT'E" A-R mi.ro.ontrollers without sa.rifi.ing /our budget and time2 $t is more reliable than most other simple A-R programmers a4ailable out there and .an be built in 4er/ short amount of time2 A-R programmer .onsists of in*.ir.uit serial programmer +dongle, and small p.b with a ($P so.0et where /ou .an fit /our mi.ro.ontroller and ha4e it qui.0l/ programmed2 )ou ma/ also use this programmer as a stand alone in*.ir.uit serial programmer that .an be used to .on4enientl/ program A-R mi.ro.ontrollers without remo4ing them from the target .ir.uit2 Entire A-R programmer has been build with using .ommon parts and fits in the .ase of the serial .onne.tor2 The so.0et p.b has been .reated to fit a <;*($P A-R ATmega; mi.ro.ontroller5 but /ou .an build a so.0et p.b for an/ other A-R mi.ro.ontroller out there2 This A-R programmer is .ompatible with a popular Pon/Prog software that shows /ou a status bar of the programming progress2

3.SCHEMATIC DIAGRAM
72

73

Fig DF S.hemati. (iagram

B-, DESCRIPTION
POWER SUPPLY
The .ir.uit uses standard power suppl/ .omprising of a step*down transformer from <=>-to ?<- and E diodes forming a ridge Re.tifier that deli4ers pulsating d. whi.h is then filtered b/ an ele.trol/ti. .apa.itor of about EA>WF to ?>>>WF2 The filtered d. being unregulated5 $C "'A;>: is used to get :- (C .onstant at its pin no = irrespe.ti4e of input (C 4ar/ing from N- to ?E-2 The input d. shall be 4ar/ing in the e4ent of input a. at <=>4olts se.tion 4aries in the ratio of -?9-<ON?9N<2 The regulated :- (C is further filtered b/ a small ele.trol/ti. .apa.itor of ?>WF for an/ noise so generated b/ the .ir.uit2 One "E( is .onne.ted of this :- point in series with a resistor of ==>[ to the ground i2e25 negati4e 4oltage to indi.ate :- power suppl/ a4ailabilit/2 The ?<point is used for other appli.ations as on when required2

RESET
Pin no N is pro4ided with an RESET arrangement b/ a .ombination of an ele.trol/ti. .apa.itor and a register forming RC time .onstant2 At the time of swit.h on5 the .apa.itor gets .harged5 after .harging it beha4es as a full short .ir.uit from the positi4e to the pin number N2 After the .apa.itor gets full/ .harged the .urrent stops flowing and pin number N is pulled down b/ a ?>0 resistor to the ground2 This arrangement of reset pin N going high initiall/ and then to logi. > i2e25 low helps the program e8e.ution to start from the beginning2 $n absen.e of this the program e8e.ution .ould ha4e ta0en pla.e habituall/ an/where from the program ./.le2 A pushbutton swit.h is .onne.ted a.ross the .apa.itor so that at an/ gi4en time as desired it .an be pressed that dis.harges the .apa.itor and while released the .apa.itor starts .harging again and then pin number N goes to high and then ba.0 to low5 to enable the program e8e.ution from the

74

beginning2 This operation of high to low of the reset pin ta0es pla.e in fra.tion of a se.ond as de.ided b/ the time .onstant R and C2 For e8ampleF A ?>WF .apa.itor and a ?>0[ resistor would render a ?>>ms time to pin number N from logi. high to low5 there after the pin number N remains low2

OPERATION E'PLANATION

Wo >&"?3 $slanding of grid is .onne.ted to in4erter whi.h is basi.all/ managing two parameters2 One parameter is 4oltage and other parameter is frequen./2 Sin.e we .annot .hange the frequen./ we ha4e ta0en a ::: timer in a free running astable mode5 the frequen./ of whi.h .an be 4aried b/ R2 we 0now that b/ the R C C .ombination5 the multi*4ibrator mode of the ::: timer output .an be generated at different frequen.ies2 So5 the output is gi4en to the 'C pin =2> of port = of 'C whi.h has the pro4ision of .hanging the frequen./ E;!R J :<!R b/ 4ar/ing R2 So5 the 'C will get the .hanged frequen./ at pin =2> of port =5 we also ha4e pro4ision of fitting the dire.t frequen./ at pin =2> of port = sin.e the dire.t frequen./ we are not sure that what will be the frequen./ at that parti.ular time2 $t .ould be somewhere alwa/s awa/ from :>!R whi.h is diffi.ult to test it2 This is the reason wh/ we use a ::: timer for gi4ing pre.isel/ :!R or :> P!R or EN P!R whi.h has to be tested b/ the program2 $n the program it is so written that the output from ::: timer whi.h is fed to the 'C goes to be low E; P!R or abo4e :<!R2 The .orresponding outputs of 'C will go high and whi.h will result in swit.hing GON or OFFH a load to indi.ate that the islanding has ta0en pla.e2 +for frequen./ .on.erned,2 As per the 4oltage is .on.erned we ha4e ta0en < .omparators2 oth the .omparators are gi4en to i2e25 one for in4erting input and other for non*in4erting input whi.h are gi4en at a parti.ular 4oltage2 $nitiall/ the/ are so set that the output of these two .omparators whi.h is going to 'C pin >2? and pin >2< of port <2 For low 4oltage it is held high and for the high 4oltage it is held low2 So5 when the input 4oltage .hanges at R ; whi.h is a re.tified 4oltage whi.h is .oming from the (C 4oltage5 when the input 4oltage .hanges i2e25 if it goes high5 +it gi4en a high
75

.ommand, and if it goes low +it gi4es a low .ommand, to the mi.ro.ontroller2 That is how the low*high5 high*low .ommands are handled b/ mi.ro.ontroller then the program ta0es ones2 This program is also written that in either of these .ases whether the few is low 9 high +or, it .ould be either in high 9 low .ondition the duration will be :>5 EN5 E; >D greater than :<2 All these = .ondition3s are ta0en b/ the mi.ro.ontroller and the/ are all displa/ed in the "C( displa/ and the o9p whi.h is .onne.ted at a different port pins in at separate .ir.uit2

76

;- .ILL OF (ATERIALS
QTY PARTFREFS
Re%&%to % ? < ? ? ? ? ? = ? ? < < < < ? ? ? R? R<5R= RE R?D R?A R?; R?N R<>5R<?5R<< R<= C? C<*C= CE*C: CD*CA C;5CN &? &= &E ==>R EAP <AP ?>P D2;P E2AP :>P ?>>P ?P <2<P EA>&F ?>&F ==PF <2<&F >2?&F A;>: AT;NS:< "'==N
77

VALUE

?> R:*R?:

Capa4&to %

I"te? ated C& 49&t%

? ? ? < ?

&: &D

"'=:; ::: T$'ER E>*P$N ;*P$N ?E*P$N (?*(; $NE>>A C:EA ??2>:N<'!R "E(*RE( P&S! &TTON ?>P POT ?P POT "A'P ?<?DB< <*P$N ?<<*P$N <*P$N ?D*P$N ?D*P$N

IC .a%e%

DIODE ; ? ? < ? = ? ? ? ? ? < ? ? ? ? ? ? ? T a"%&%to % M? CR)STA"? "E(?5"E(< S? R-?*R-= R-E "? "A'P !O"(ER RE"A) "C( PC CONNECTOR TO##"E S6$TC! TRANSFOR'ER 'A"E &R#E FE'A"E &R#E FE'A"E &R#E 'A"E &R#E !EAT S$NP (&%4e66a"eo9%

78

4.CODING

79

G-/ PROGRA( CODE


\in.lude]a4r9io2h^ \in.lude]math2h^ \define ".d%Port P< t/pedef unsigned .har &C!K t/pedef unsigned int &$TK

4oid ".d%init+4oid,K 4oid ".d%.md+&C!,K 4oid ".d%data+&C!,K 4oid bus/%flg+4oid,K 4oid dela/+&C!,K 4oid Timer%init+4oid,K 4oid Counter+4oid,K 4oid !e8<(e.+&C!,K 4oid (ispla/+&$T,K 4oid 4ol%.h0+4oid,K sbit RSOP=_AK sbit R6OP=_DK sbit ENOP=_:K
80

sbit bus/%.0OP<_AK sbit $nputOP?_>K sbit OutputOP>_<K &$T .ntO>57O>K &C! temp5 aT=UK &C! f?TUOLfreq+hR, O LK &C! lTUOL"ow &C! hTUOL!igh -oltageLK -oltageLK 99used for .ounter input

&C! sTUOLStable -oltageLK int main+, ` P>%>O?K P>%?O?K 99$nputO?K OutputO>K ".d%init+,K while+?, ` Timer%init+,K Counter+,K 99 frequen./ dete.tor a a 4oid Counter+, ` TR>O?K TR?O?K while+.nt]<:>,K
81

99 high 4oltage pin

99

low 4oltage pin

99.ounter is initialiRed to .ount number of pulses 99generated b/ the output of .omparator in ? se.

TR>O>K TR?O>K .ntO>K tempO>K tempOT">K !e8<(e.+temp,K a 4oid Timer?%int+, interrupt = using ? ` .ntO?>>> *^ ?se. .ntO@@.ntK T!?O>8FCK T"?O>8FEK a 4oid !e8<(e.+&C! 4al, 99to .on4ert the he8 4al in TO register to de.imal ` double sumO>K &C! i5remO>K &$T ni0K for+iO>Ki];Ki@@, ` if++4al,C+?^^i,, sumOsum@pow+<5+double,i,K else .ontinueK a 7O>K 7O+&$T,sumK 7O79<K ni0O7K iO>K
82

99timer? $SR to in.rement the .nt 99.ntO? *^ ?ms5

while+7VO>, ` remO79?>K 7O7b?>K aTi@@UOremK dela/+?,K remO>K a ".d%.md+>8;>,K for+iO>Kf?TiUVOQc>QKi@@, ` ".d%data+f?TiU,K a ".d%data+aT?U@>8=>,K ".d%data+aT>U@>8=>,K if++ni0OO:>,dd+ni0OOEN,dd+ni0OO:?,dd+ni0OO:<,, ` ".d%.md+>8;>,K if+P>%>OO>, ` if+P>%?OO?, 99 ` OutputO>K 4ol%.h0+,K a else ` OutputO?K 4ol%.h0+,K a a
83

99

high 4oltage .he.0 low 4oltage .he.0

else ` OutputO?K 4ol%.h0+,K a a else ` OutputO?K 4ol%.h0+,K a 7O>K ni0O>K a 4oid 4ol%.h0+, ` &C! iK ".d%.md+>8C>,K if+P>%?OO>, ` for+iO>KlTiUVOQc>QKi@@, ` ".d%data+lTiU,K dela/+?,K a a else if+P>%>OO?, ` for+iO>KhTiUVOQc>QKi@@, ` ".d%data+hTiU,K
84

dela/+?,K a a else ` for+iO>KsTiUVOQc>QKi@@, ` ".d%data+sTiU,K dela/+?,K a a a 4oid Timer%init+, ` $EO>8>;K T'O(O>8?:K T!>O>8>>K T">O>8>>K T!?O>8FCK T"?O>8DAK a 4oid ".d%init+, ` ".d%.md+>8=;,K ".d%.md+>8>C,K ".d%.md+>8>?,K ".d%.md+>8>D,K a 4oid ".d%.md+&C! .h?, `
85

99 enabling timer? interrupt 99 t> is .ounter C t? is timer

99 timer? is set for ?ms duration

99 l.d initiliRation to displa/ 99 SET T!E "C( $N < "$NE C :BA 'ATR$B 'O(E 99 ($SP"A) ON C C&RSER OFF 99 C"EAR T!E "C( 99 S!$FT T!E C&RSER TO R$#!T

bus/%flg+,K ".d%PortO.h?K RSO>K R6O?K ENO>K dela/+?,K ENO?K a 4oid ".d%data+&C! .h?, ` bus/%flg+,K ".d%PortO.h?K RSO>K R6O>K ENO>K dela/+?,K ENO?K a 4oid bus/%flg+, ` RSO>K R6O?K bus/%.0O?K while+bus/%.0, ` ENO>K ENO?K a a 4oid dela/+&C! .h?, `
86

99 RS O > FOR CO''AN( 99 R6 O ? FOR REA($N# 99 ENA "E $S "O6 99 ENA "E $S !$#!

99 RS O > FOR CO''AN( 99 R6 O > FOR 6R$T$N# 99 ENA "E $S "O6 99 ENA "E $S !$#!

99 RS O > FOR CO''AN( 99 R6 O ? FOR REA($N#

99 ENA "E $S "O6 99 ENA "E $S !$#!

&C! 7K &$T iK for+7O>K7].h?K7@@, for+iO>Ki]?<A:Ki@@,K a

,<-HARDWARE TESTING

87

,<-, CONTINUITY TEST3


$n ele.troni.s5 a .ontinuit/ test is the .he.0ing of an ele.tri. .ir.uit to see if .urrent flows +that it is in fa.t a .omplete .ir.uit,2 A .ontinuit/ test is performed b/ pla.ing a small 4oltage +wired in series with an "E( or noise*produ.ing .omponent su.h as a pieRoele.tri. spea0er, a.ross the .hosen path2 $f ele.tron flow is inhibited b/ bro0en .ondu.tors5 damaged .omponents5 or e8.essi4e resistan.e5 the .ir.uit is LopenL2 (e4i.es that .an be used to perform .ontinuit/ tests in.lude multi meters whi.h measure .urrent and spe.ialiRed .ontinuit/ testers whi.h are .heaper5 more basi. de4i.es5 generall/ with a simple light bulb that lights up when .urrent flows2 An important appli.ation is the .ontinuit/ test of a bundle of wires so as to find the two ends belonging to a parti.ular one of these wiresK there will be a negligible resistan.e between the LrightL ends5 and onl/ between the LrightL ends2 This test is the performed 7ust after the hardware soldering and .onfiguration has been .ompleted2 This test aims at finding an/ ele.tri.al open paths in the .ir.uit after the soldering2 'an/ a times5 the ele.tri.al .ontinuit/ in the .ir.uit is lost due to improper soldering5 wrong and rough handling of the PC 5 improper usage of the soldering iron5 .omponent failures and presen.e of bugs in the .ir.uit diagram2 6e use a multi meter to perform this test2 6e 0eep the multi meter in buRRer mode and .onne.t the ground terminal of the multi meter to the ground2 6e .onne.t both the terminals a.ross the path that needs to be .he.0ed2 $f there is .ontinuation then /ou will hear the beep sound2

,<-/ POWER ON TEST3


This test is performed to .he.0 whether the 4oltage at different terminals is a..ording to the requirement or not2 6e ta0e a multi meter and put it in 4oltage mode2 Remember that this test
88

is performed without mi.ro.ontroller2 Firstl/5 we .he.0 the output of the transformer5 whether we get the required ?< 4 AC 4oltage2 Then we appl/ this 4oltage to the power suppl/ .ir.uit2 Note that we do this test without mi.ro.ontroller be.ause if there is an/ e8.essi4e 4oltage5 this ma/ lead to damaging the .ontroller2 6e .he.0 for the input to the 4oltage regulator i2e25 are we getting an input of ?<4 and an output of :42 This :4 output is gi4en to the mi.ro.ontrollers3 E> th pin2 !en.e we .he.0 for the 4oltage le4el at E>th pin2 Similarl/5 we .he.0 for the other terminals for the required 4oltage2 $n this wa/ we .an assure that the 4oltage at all the terminals is as per the requirement2

,A-.I.LIOGRAPHY
TE'T .OO)S REFERED
?2 GThe ;>:? 'i.ro.ontroller and Embedded s/stemsH b/ 'uhammad Ali 'aRidi and Jani.e #illispie 'aRidi 5 Pearson Edu.ation2
89

<2 AT'E" ;NS:< (ata Sheets2

WE.SITES
www2atmel2.om www2be/ondlogi.2org www2wi0ipedia2org www2howstuffwor0s2.om www2alldatasheets2.om

90

You might also like