You are on page 1of 21

DPR

Introduction:

Nowdays,marketingdemandsareincreasingcontinuously.Ifyoucantsatisfydemandthen
youwillknockoutoftherace.Thereisnotimelimitforwork.Soinmodernindustry,itneeds
togivealignmentwithoutgoingonfield.Ourprojectsatisfiesthisneedbyusingadata
analysisbymakinguseofhighendtechnology.
Theproposeddesignistoprovideindustrialautomationisusefulformonitoringthedevices
fromanydistance.Amicrocontrollerisusedwhichmonitorsarethecomponentsaccordingto
thegivenmessage,withthesensedinformationsentfromthesensors.Thispaperdiscussesthe
workingoftemperatureaheatcontrollingdevices.Astheautomationismicrocontrollerbased
itautomaticallyregulatesthetemperaturechanges.
MostofthetimesCEOorheadofthecompanywontknowtheexactfloorproductiondetail,
thatswhycompanycanlosshugeamountofprofitduetomachineproblemorrawdata
problem.Thisprojectwillhelpfultotakequickdecisionatthehighlevelmanagement.This
projectishelpfultomaintainproductionsmoothlyaswellastosavelotofwastageofmoney
onproductionfloor.
Description:
Consideronecase,thatyouarefieldengineer,companywillstartat9oclock.Butyouhaveto
turnonboilerat7oclocktostartworkingat9oclock.Inthiscaseyouhavetogoat7oclock.
ButbyusingthisprojectyoucanstartboilerbyjustsendingSMScommandfromyourmobile.
Boilerisjustexampleyoucanturnonorturnoffanycontrollingdevice.Nowconsideranother
case,youneedtomonitorfewparametersintheindustry,sayHumidityinapaintshop
machineoracriticalthinglikeLPGgasleakage,thenyouneedtobepresentinthe
industry/plant.Thesecondpartofourprojectmeetsthisrequirement,itmonitorsthe
parametersontheLCDandatthesametimesendsanotificationwhentheseparameterscross
thresholdlimit.
Thecircuitunitconsistsoftemperaturesensorswhichareconnectedtomicrocontrollerunit
whichmeasurestheradiationsemittedfromhotbroilers.Asignalconditioningcircuitisused
forenergizingthesignalcomingfromthesensors.Afeedbackcircuitisprovidedinorderto
reducetheisolationbetweentheaclineandoutput.Themicrocontrollerbaseddesignarevery
advantageousinprotectingthecircuitfromleakagecurrentsandhighvoltagesandpower
losses.WecandesigntheautomationcircuitbyusingopampsorICvoltageregulatorbutthey
dontgivequickresponsesandnotthatefficientasamicrocontrollerbaseddesign.Thekeil
softwareisveryadvantageousinprogrammingflashmemories.Itprovidesaninterfacefor
connectingtargetviaserialline.
BlockDiagram

LCD
Power supply

Analog Serial
Machines 89s52 Communication
Microcontroller

Digital
Machines Internet
Interfacing
89S52MICROCONTROLLER
Pindiagram:

PINDESCRIPTION:

VCC:Supplyvoltage.
GND:ground.
PORT0:

Port0isan8bitopendrainbidirectionalI/Oport.Asanoutputport,eachpincansinkeight
TTLinputs.When1sarewrittentoport0pins,thepinscanbeusedashigh
impedanceinputs.Port0canalsobeconfiguredtobethemultiplexedloworder
address/databusduringaccessestoexternalprogramanddatamemory.Inthismode,P0has
internalpullups.Port0alsoreceivesthecodebytesduringFlashprogrammingandoutputs
thecodebytesduringprogramverification.Externalpullupsarerequiredduringprogram
verification.

PORT1:
Port1isan8bitbidirectionalI/Oportwithinternalpullups.ThePort1outputbufferscan
sink/sourcefourTTLinputs.When1sarewrittentoPort1pins,theyare pulled
highbytheinternalpullupsandcanbeusedasinputs.Asinputs,Port1pinsthatare
externallybeingpulledlowwillsourcecurrent(IIL)becauseoftheinternalpullups.In
addition,P1.0andP1.1canbeconfiguredtobethetimer/counter2external
countinput(P1.0/T2)andthetimer/counter2triggerinput(P1.1/T2EX),respectively,as
showninthefollowinggtable
PORTPINALTERNATEFUNCTIONS
P1.0T2(externalcountinputtoTimer/Counter2),clockout
P1.1
T2EX(Timer/Counter2capture/reloadtriggeranddirection
control)

P1.5MOSI(usedforInSystemProgramming)
P1.6MISO(usedforInSystemProgramming)
P1.7SCK(usedforInSystemProgramming)

PORT2:
Port2isan8bitbidirectionalI/Oportwithinternalpullups.ThePort2outputbufferscan
sink/sourcefourTTLinputs.When1sarewrittentoPort2pins,theyare pulled
highbytheinternalpullupsandcanbeusedasinputs.Asinputs,Port2pinsthatare
externallybeingpulledlowwillsourcecurrent(IIL)becauseoftheinternalpullups.Port2
emitsthehighorderaddressbyteduringfetchesfromexternalprogrammemory
andduringaccessestoexternaldatamemorythatuses16bitaddresses
Inthisapplication,Port2usesstronginternalpullupswhenemitting1s.Duringaccessesto
externaldatamemoriesthatuse8bitaddresses(MOVX@RI),Port2emitsthecontentsof
theP2SpecialFunctionRegister.Port2alsoreceivesthehighorder addressbitsand
somecontrolsignalsduringFlashprogramming.

PORT3:
Port3isan8bitbidirectionalI/Oportwithinternalpullups.ThePort3 output
bufferscansink/sourcefourTTLinputs.When1sarewrittentoPort3pins,theyarepulled
highbytheinternalpullupsandcanbeusedasinputs.Asinputs,Port3pinsthatare
externallybeingpulledlowwillsourcecurrent(IIL)becauseofthepullups.Port3receives
somecontrolsignalsforFlashprogrammingandverification.Port3
alsoservesthefunctionsofvariousspecialfeaturesoftheAT89S52,asshown i n t h e followin
gtable
P3.0RXD(serialinputport)
P3.1TXD(serialoutputport)
P3.2INT0(externalinterrupt0)
P3.3INT1(externalinterrupt1)
P3.4T0(timer0externalinput)
P3.5T1(timer1externalinput)
.6WR(externaldatamemorywritestrobe)
P3.7RD(externaldatamemoryreadstrobe)
Port3alsoreceivessomecontrolsignalsforFlashprogrammingandverification.

RST
Resetinput.Ahighonthispinfortwomachinecycleswhiletheoscillatorisrunningresetsthe
device.Thispindriveshighfor96oscillatorperiodsafterthewatchdogtimesout.

ALE/PROG:
AddressLatchEnableisanoutputpulseforlatchingthelowbyteoftheaddress
duringaccessestoexternalmemory.Thispinisalsotheprogrampulse
input(PROG)duringprogramming.Innormaloperation,ALEisemittedataconstant
rateof1/6ththeoscillatorfrequencyandmaybeusedforexternaltimingor
clockingpurposes.
Notehowever,thatoneALEpulseisskippedduringeachaccesstoexternaldatamemory.
Ifdesired,ALEoperationcanbedisabledbysettingbit0ofSFRlocation8EH.Withthebitset,
ALEisactiveonlyduringaMOVXorMOVCinstruction.Otherwise,thepinisweaklypulled
high.SettingtheALEdisablebithasnoeffectifthemicrocontrollerisinexternalexecution
mode.

PSEN:
ProgramStoreEnableisthereadstrobetoexternalprogrammemory.WhentheAT89S52is
executingcodefromexternalprogrammemory,PSENisactivatedtwiceeachmachinecycle,
exceptthattwoPSENactivationsareskippedduringeachaccesstoexternaldatamemory.

EA/VPP:
ExternalAccessEnable.EAmustbestrappedtoGNDinordertoenablethedevicetofetchcode
fromexternalprogrammemorylocationsstartingat0000HuptoFFFFH.Howeverthatiflock
bit1isprogrammed,EAwillbeinternallylatchedonreset.E A s h o u l d b e s t r a p p e d t o
V C C f o r i n t e r n a l p r o g r a m e x e c u t i o n s . T h i s p i n a l s o t h e n receives12volt
programmingenablevoltage(VPP)duringFlashprogrammingwhen12voltProgrammingis
selected.

XTAL1:
Inputtotheinvertingoscillatoramplifierandinputtotheinternalclockoperatingcircuit.

XTAL2:Outputfromtheinvertingoscillatoramplifier.

Blockdiagram:

TheAT89S52isdesignedwithstaticlogicforoperationdowntozerofrequencyandsupports
twosoftwareselectablepowersavingmodes.TheIdleModestopstheCPUwhileallowingthe
RAM;timer/counters,serialport,andinterruptsystemtocontinuefunctioning.ThePower
downmodesavestheRAMcontentsbutfreezestheoscillatordisablingallotherchipfunctionsuntil
thenexthardwarereset

SPECIALFUNCTIONREGISTERS:
TheAT89S52operationsthatdonotusetheinternal256byteRAMaddressesfrom00hto7fh
aredonebyagroupofspecificinternalregisters,eachcalledaspecialfunctionregister(SFR),
whichmaybeaddressedmuchlikeinternalRAM,usingaddressesfrom80htoffh.SomeSFRs
arealsobitaddressable,asisthecaseforthebitareaofRAM.Thisfeatureallowsthe
programmertochangeonlywhatneedstobealtered,leavingtheremainingbitsinthatSFR
unchanged.Notalloftheaddressesfrom80htoffhareusedforSFRs,andattemptingtouse
anaddressthatisnotdefinedoremptyresultsinunpredictableresults.PCisnotpartofthe
SFRandhasnointernalRAMaddress.ThenamesoftheSFRsandtheirfunctionsaregivenin
thefollowinglist.

NameFunction
AAccumulator
BArithmetic
DPHaddressingexternalmemory
DPLaddressingexternalmemory
IEInterruptenablescontrol
IPInterruptpriority
P0Input/outputportlatch
P1Input/outputportlatch
P2Input/outputportlatch
P3Input/outputportlatch
PCONPowercontrol
PSWProgramstatusword
SCONSerialportcontrol
SBUFSerialportdatabuffer
SPStackpointer
TMODTimer/countermodecontrol
TCONTimer/countercontrol
TL0Timer0lowbyte
TH0Timer0highbyte
TL1Timer1lowbyte
TH1Timer1highbyte

INTERRUPTS:
AcomputerprogramhasonlytwowaystodeterminetheconditionthatexistinInternaland
externalcircuits.OnemethodusessoftwareinstructionsthatjumptoSubroutinesonthestates
offlagsandportpins.ThesecondmethodrespondstohardwareSignals,calledinterruptsthat
forcetheprogramtocallasubroutine.Softwaretechniquesuseprocessortimethatcouldbe
devotedtoothertasks,interruptstakeprocessortime
onlywhenactionbytheprogramisneeded.Mostapplicationsofmicrocontrollersinvolve
respondingtoeventsquicklyenoughtocontroltheenvironmentthatgenerates
heevents.Interruptsareoftentheonlywayinwhichrealtimeprogrammingcanbedone
successfully.Interruptsmaybegeneratedbyinternalchipoperationsorprovidedbyexternal
Sources.Anyinterruptcancausethemicrocontrollertoperformahardwarecalltoan
Interrupthandlingsubroutinethatislocatedatapredetermineabsoluteaddress
inProgrammemory.8interruptsareprovidedin89s52.Threeofthesearegeneratedautomatical
lybyinternaloperations:timerflag0,timerflag1andtheserialport.TheAT89S52hasatotal
ofsixinterruptvectors:twoexternalinterrupts(INT0andINT1),threetimerinterrupts
(Timers0,1,and2),andtheserialportinterrupt.Eachoftheseinterruptsourcescanbe
individuallyenabledordisabledbysettingorclearingabitinSpecialFunctionRegisterIE.IE
alsocontainsaglobaldisablebit,EA,whichdisablesallinterruptsatonce.Allinterrupt
functionsareunderthecontroloftheprogram.Theprogrammerisabletoalterthecontrol
bitsintheInterruptEnableregister(IE),theInterruptPriorityregister(IP),andtheTimer
Controlregister(TCON).Theprogramcanblockalloranycombinationoftheinterruptsfrom
actingontheprogrambysuitablysettingorclearingbitsintheseregisters.Aftertheinterrupt
hasbeenhandledbytheinterruptsubroutine,which
isplacedbytheprogrammerattheinterruptlocationintheprogrammemory,theinterrupted
programmustresumeoperationattheinstructionwheretheinterrupttookplace.Program
resumptionisdonebystoringtheinterruptedPCaddressonthestackinRAMbeforechanging
thePCtotheinterruptaddressinROM.ThePCaddresswillberestoredfromthestackafter
anRET1instructionisexecutedattheendoftheinterruptsubroutine.

Timerflaginterrupt
Whenatimer/counteroverflowsthecorrespondingtimerflagTF0orTF1issetto1.Theflag
isclearedto0whentheresultinginterruptgeneratesaprogramcalltotheappropriatetimer
subroutineinmemory.Serialportinterrupt:Ifadatabyteisreceived,aninterruptbit.RIisset
to1intheSCONregister.Whenadatabytehasbeentransmittedaninterruptbit,T1,issetin
SCON.TheseareORedtogethertoprovideasingleinterrupttotheprocessorwhichisthe
serialportinterrupt.Thesebitsarenotclearedwhentheinterruptgeneratedprogramcallis
madebytheprocessor.TheprogramthathandlesserialdatacommunicationmustresetR1or
T1to0toenablethenextdatacommunicationoperation.
Externalinterrupts
:PinsINT0andINT1areusedbyexternalcircuitry.Inputsonthesepinscansettheinterrupt
flagsIE0andIE1intheTCONregisterto1bytwodifferentmethods.TheIEXflagsmaybeset
whentheINTXpinsignalreachesalowlevel,ortheflagsmaybesetwhenahightolow
transitiontakesplaceontheINTXpin.BitsIT0andIT1inTCONprogramtheINTXpinsfor
lowlevelinterruptwhensetto0andprogramtheINTXpinsfortransitioninterruptwhenset
to1.FlagsIEXwillberesetwhenatransitiongeneratedinterruptisacceptedbytheprocessor
andtheinterruptsubroutineisaccessed.Itistheresponsibilityofthesystemdesignerand
programmertoresetanylevelgeneratedexternalinterruptswhentheyareservicedbythe
program.TheexternalcircuitmustremovethelowlevelbeforeanRET1isexecuted.Failureto
removethelowwillresultinanimmediateinterruptafterRET1,fromthesamesource.

RESET:
Aresetcanbeconsideredtobetheultimateinterruptbecausetheprogrammaynotblockthe
actionofthevoltageontheRSTpin.Thistypeofinterruptisoftencallednonmakeable,
becausenocombinationofbitsinanyregistercanstop,ormask,
theresetaction.Unlikeotherinterrupts,thePCisnotstoredforlaterprogramresumption.A
resetisanabsolutecommandtojumptoprogramaddress0000handcommencerunningfrom
there.WheneverahighlevelisappliedtotheRSTpin,themicrocontrollerentersareset
condition.InternalRAMcontentsmaychangeduringreset.AlsothestatesoftheinternalRAM
byteswhenpowerisfirstappliedtomicrocontrollerarerandom.Registerbank0is
selectedonresetasallbitsinPSWare0

INTERRUPTCONTROL
Theprogrammustbeable,atcriticaltimes,toinhibittheactionofsomeorallofthe
interruptssothatcriticaloperationscanbefinished.TheIEregisterholdsthe
programmablebitsthatcanenableordisablealltheinterruptsasagroup,orifthegroupis
enabled,eachindividualinterruptsourcecanbeenabledordisabled.Itisdesirabletobeable
tosetprioritiesamongcompetinginterruptsthatmayconceivablyoccursimultaneously.TheIP
registerbitsmaybesetbytheprogramtoassigntheprioritiesamongvariousinterruptsources
sothatmoreimportantinterruptscanbeservicedfirstshouldbetwoormoreinterruptsoccur
atthesametime.
INTERRUPTENABLE/DISABLE
BitsintheIEregisteraresetto1ifthecorrespondinginterruptsourceistobeenabledandset
to0todisabletheinterruptsource.BitEAisthemaster,orglobalbitthatcanenableordisable
alltheinterrupts.
INTERRUPTPRIORITY
RegisterIPbitsdetermineifanyinterruptistohaveahighorlowpriority.Bitssetto1givethe
accompanyinginterruptahighpriority;0assignsalowpriority.Interruptswithahighpriority
caninterruptanotherinterruptwithalowpriority.Thelowpriorityinterruptcontinuesafter
thehigherisfinished.
SOFTWAREGENERATEDINTERRUPTS
:Whenanyinterruptflagissetto1byanymeans,aninterruptisgeneratedunlessblocked.
Thismeansthattheprogramitselfcancauseinterruptsofanykindtobegeneratedsimplyby
settingthedesiredinterruptflagto1usingaprograminstruction
PROGRAMCOUNTERANDDATAPOINTER
:TheAT89S52containstwo16bitregisters,theprogramcounter(PC)andthedatapointer
(DPTR).Eachisusedtoholdtheaddressofabyteinmemory.Programinstructionsbytesare
fetchedfromlocationsinmemorythatareaddressedbythePC.ProgramROMmaybeonthe
chipataddresses0000hto0FFFh,externaltothechipforaddressesthatexceed0FFFh,or
totallyexternalforalladdressesfrom0000htoFFFFh.ThePCisautomaticallyincremented
aftereveryinstructionbyteisfetchedandmayalsobealteredbycertaininstructions.ThePCis
theonlyregisterthatdoesnothaveaninternaladdress.TheDPTRregisterismadeupoftwo
8bitregisters,namedDPHandDPL,whichareusedtofurnishmemoryaddressesforinternal
andexternalcodeaccessandexternaldataaccess.TheDPTRisunderthecontrolofprogram
instructionsandcanbespecifiedbyits16bitname,DPTR,orbyeachindividualbytename,
DPHandDPL.DPTRdoesnothaveasingleinternaladdress;DPHandDPLareeachassigned
anaddress.
AANDBCPUREGISTERS
:AT89S52contains34generalpurpose,orworkingregisters.Twoof
theseregistersAandB,holdresultsofmanyinstructions,particularlymathandlogicaloperatio
ns,ofthe8052centralprocessingunit.Theother32arearrangedaspartofinternalRAMin
fourbanks,B0toB3of8registersandcomprisethemathematicalcore.TheA(accumulator)
registeristhemostversatileofthetwoCPUregistersandisusedformanyoperations,
includingaddition,subtraction,integermultiplicationanddivision,andBooleanbit
manipulations.TheAregisterisalsousedforalldatatransfersbetweenthe8052andany
externalmemory.TheBregisterisusedwiththeAregisterformultiplicationanddivision
operationsandhasnootherfunctionotherthanasalocationwheredatamaybestored.

FLAGSANDTHEPROGRAMSTATUSWORD(PSW):
Flagsare1bitregistersprovidedtostoretheresultsofcertainprograminstructions.Other
instructionscantesttheconditionoftheflagsandmakedecisionsbasedontheflagstates.In
orderthattheflagsmaybeconvenientlyaddresses,theyaregroupedinsidetheprogramstatus
word(PSW)andthepowercontrol(PCON)registers.TheAT89S52has4mathflagsthat
respondautomaticallytotheoutcomesofmathoperationsand3generalpurposeuserflags
thatcanbesetto1orclearedto0bytheprogrammerasdesired.Themathflagsincludecarry
(C),auxiliarycarry(AC),overflow(OV)andparity(P).UserflagsarenamedF0,GF0andGF1.
Theyaregeneralpurposeflagsthatmaybeusedbytheprogrammertorecordsomeeventin
theprogram.Howevermathflagsarealsoaffectedbythemathoperations.ThePSWcontains
themathflags,userprogramflag(F0)andtheregisterselectbitsthatidentifywhichofthe
fourgeneralpurposeregisterbanksiscurrentlyusedbytheprogram.Theremaining2user
flags,GF0andGF1arestoredinPCON.

INTERNALRAMANDROM:
The256byteinternalRAMisorganizedinto3distinctareas.32bytesfrom00hto1Fhthat
makeup32workingregistersareorganizedas4banksof8registerseach.The4register
banksarenumbered0to3andaremadeupof8registersR0toR7.Eachregistercanbe
addressedbythenameofthebankorbyitsRAMaddress.ThusR0ofbank3isR0(ifbank3is
currentlyselected)oraddress18h(whetherbank3isselectedornot).BitsRS0andRS1inthe
PSWdeterminewhichbankofregistersiscurrentlyinuseatanytimewhentheprogramis
running.RegisterbanksnotselectedcanbeusedasgeneralpurposeRAM.Bank0isselected
onreset.Abitaddressableareaof16bytesoccupiesRAMbyteaddresses20hto2Fh,forminga
totalof128addressablebits.Anaddressablebitmaybespecifiedbyitsbitaddressof00hto
7Fh,or8bitsmayformanybyteaddressfrom20hto2Fh.Addressablebitsareusefulwhenthe
programneedonlyrememberabinaryevent.TheAT89S52isorganizedsothatdatamemory
andprogramcorememorycanbeintwoentirelydifferentphysicalmemoryentities.Eachhas
the
sameaddressranges.Thecorrespondingblockofinternalprogramcode,containedinanintern
alROM,occupiescodeaddressspace0000hto0FFFh.ThePCisordinarilyusedto
addressprogramcodebytesfromaddresses0000htoFFFFh.Programaddresseshigherthan
0FFFh,whichexceedtheinternalROMcapacity,willcausethemicrocontrollerto
automaticallyfetchprogramcodebytesfromexternalprogrammemory.ThePCdoesnotcare
wherethecodeis,whetheritisininternalROMtotallyortotallyinexternalROMorina
combinationofinternalandexternalROM.

STACKANDSTACKPOINTER
:ThestackreferstoanareaofinternalRAMthatisusedinconjunctionwithcertainopcodesto
storeandretrievedataquickly.The8bitstackpointer(SP)registerisusedbythemicro
controllertoholdaninternalRAMaddressthatiscalledthetopofthestack.Theaddressheld
intheSPregisteristhelocationintheinternalRAMwiththelastbyteofdatawasstoredby
thestackoperation.Whendataistobeplacedonthestack,theSPincrementsbeforestoring
dataonthestacksothatthestackgrowsupasthedataisstored.Asthedataisretrievedfrom
thestacktheASCET.ECE.dept28

byteisreadfromthestack,andthentheSPdecrementstopointtothenextavailablebyteof
storeddata.TheSPissetto07hwhenthemicrocontrollerisresetandcanbechangedtoany
internalRAMaddressbytheprogrammer,usingadatamovecommand.Thestackisnormally
placedhighininternalRAM,byanappropriatechoiceofthenumberplacedinSPregister,to
avoidconflictwiththeregister,bitandscratchpadinternalRAMareas.

TheheartoftheAT89S52isthecircuitrythatgeneratestheclockpulsesbywhichallinternal
operationsaresynchronized.PinsXTAL1andXTAL2areprovidedforASCET.ECE.dept29
Temperaturesensor:

Description
TheLM35seriesareprecisionintegratedcircuittemperaturedeviceswithanoutputvoltage
linearlyproportionaltotheCentigradetemperature.TheLM35devicehasanadvantageover
lineartemperaturesensorscalibratedinKelvin,astheuserisnotrequiredtosubtractalarge
constantvoltagefromtheoutputtoobtainconvenientCentigradescaling.TheLM35device
doesnotrequireanyexternalcalibrationortrimmingtoprovidetypicalaccuraciesofCat
roomtemperatureandCoverafull55Cto150Ctemperaturerange.Lowercostis
assuredbytrimmingandcalibrationatthewaferlevel.Thelowoutputimpedance,linear
output,andpreciseinherentcalibrationoftheLM35devicemakesinterfacingtoreadoutor
controlcircuitryespeciallyeasy.Thedeviceisusedwithsinglepowersupplies,orwithplus
andminussupplies.AstheLM35devicedrawsonly60Afromthesupply,ithasverylowself
heatingoflessthan0.1Cinstillair.TheLM35deviceisratedtooperateovera55Cto
150Ctemperaturerange,whiletheLM35Cdeviceisratedfora40Cto110Crange(10
withimprovedaccuracy).TheLM35seriesdevicesareavailablepackagedinhermeticTO
transistorpackages,whiletheLM35C,LM35CA,andLM35Ddevicesareavailableintheplastic
TO92transistorpackage.TheLM35Ddeviceisavailableinan8leadsurfacemountsmall
outlinepackageandaplasticTO220package.

Features
CalibratedDirectlyinCelsius(Centigrade)
Linear+10mV/CScaleFactor
0.5CEnsuredAccuracy(at25C)
RatedforFull55Cto150CRange
SuitableforRemoteApplications
LowCostDuetoWaferLevelTrimming
Operatesfrom4Vto30V
Lessthan60ACurrentDrain
LowSelfHeating,0.08CinStillAir
NonLinearityOnlyCTypical
LowImpedanceOutput,0.1for1mALoad
SerialCommunication

Oneofthe8051smanypowerfulfeaturesisitsintegratedUART,otherwiseknownasaserial
port.Thefactthatthe8051hasanintegratedserialportmeansthatyoumayveryeasilyread
andwritevaluestotheserialport.Ifitwerenotfortheintegratedserialport,writingabyteto
aseriallinewouldbearathertediousprocessrequringturningonandoffoneoftheI/Olines
inrapidsuccessiontoproperly"clockout"eachindividualbit,includingstartbits,stopbits,
andparitybits.

However,wedonothavetodothis.Instead,wesimplyneedtoconfiguretheserialports
operationmodeandbaudrate.Onceconfigured,allwehavetodoiswritetoanSFRtowritea
valuetotheserialportorreadthesameSFRtoreadavaluefromtheserialport.The8051
willautomaticallyletusknowwhenithasfinishedsendingthecharacterwewroteandwill
alsoletusknowwheneverithasreceivedabytesothatwecanprocessit.Wedonothaveto
worryabouttransmissionatthebitlevelwhichsavesusquiteabitofcodingandprocessing
time.
SettingtheSerialPortMode
Thefirstthingwemustdowhenusingthe8051sintegratedserialportis,obviously,configure
it.Thisletsustellthe8051howmanydatabitswewant,thebaudratewewillbeusing,and
howthebaudratewillbedetermined.
First,letspresentthe"SerialControl"(SCON)SFRanddefinewhateachbitoftheSFR
represents:
Nam Bit
Bit ExplanationofFunction
e Addres
7 SM0 9Fh Serialportmodebit0
6 SM1 9Eh Serialportmodebit1.
5 SM2 9Dh MutliprocessorCommunicationsEnable(explainedlater)
ReceiverEnable.Thisbitmustbesetinordertoreceive
4 REN 9Ch
characters.
3 TB8 9Bh Transmitbit8.The9thbittotransmitinmode2and3.
2 RB8 9Ah Receivebit8.The9thbitreceivedinmode2and3.
TransmitFlag.Setwhenabytehasbeencompletely
1 TI 99h
transmitted.
0 RI 98h ReceiveFlag.Setwhenabytehasbeencompletelyreceived.

Additionally,itisnecessarytodefinethefunctionofSM0andSM1byanadditionaltable:
SM SM Serial
Explanation BaudRate
0 1 Mode
8bitShift
0 0 0 Oscillator/12
Register
SetbyTimer1
0 1 1 8bitUART
(*)
Oscillator/32
1 0 2 9bitUART
(*)
SetbyTimer1
1 1 3 9bitUART
(*)

(*)Note:ThebaudrateindicatedinthistableisdoubledifPCON.7(SMOD)isset.
TheSCONSFRallowsustoconfiguretheSerialPort.Thus,wellgothrougheachbitand
reviewitsfunction.
Thefirstfourbits(bits4through7)areconfigurationbits.
BitsSM0andSM1letussettheserialmodetoavaluebetween0and3,inclusive.Thefour
modesaredefinedinthechartimmediatelyabove.Asyoucansee,selectingtheSerialMode
selectsthemodeofoperation(8bit/9bit,UARTorShiftRegister)andalsodetermineshow
thebaudratewillbecalculated.Inmodes0and2thebaudrateisfixedbasedonthe
oscillatorsfrequency.Inmodes1and3thebaudrateisvariablebasedonhowoftenTimer1
overflows.WelltalkmoreaboutthevariousSerialModesinamoment.
Thenextbit,SM2,isaflagfor"Multiprocessorcommunication."Generally,wheneverabyte
hasbeenreceivedthe8051willsetthe"RI"(ReceiveInterrupt)flag.Thisletstheprogram
knowthatabytehasbeenreceivedandthatitneedstobeprocessed.However,whenSM2is
setthe"RI"flagwillonlybetriggeredifthe9thbitreceivedwasa"1".Thatistosay,ifSM2is
setandabyteisreceivedwhose9thbitisclear,theRIflagwillneverbeset.Thiscanbeuseful
incertainadvancedserialapplications.Fornowitissafetosaythatyouwillalmostalways
wanttoclearthisbitsothattheflagissetuponreceptionofanycharacter.
Thenextbit,REN,is"ReceiverEnable."Thisbitisverystraightforward:Ifyouwanttoreceive
dataviatheserialport,setthisbit.Youwillalmostalwayswanttosetthisbit.
Thelastfourbits(bits0through3)areoperationalbits.Theyareusedwhenactuallysending
andreceivingdatatheyarenotusedtoconfiguretheserialport.
TheTB8bitisusedinmodes2and3.Inmodes2and3,atotalofninedatabitsare
transmitted.Thefirst8databitsarethe8bitsofthemainvalue,andtheninthbitistaken
fromTB8.IfTB8issetandavalueiswrittentotheserialport,thedatasbitswillbewrittento
theseriallinefollowedbya"set"ninthbit.IfTB8iscleartheninthbitwillbe"clear."
TheRB8alsooperatesinmodes2and3andfunctionsessentiallythesamewayasTB8,buton
thereceptionside.Whenabyteisreceivedinmodes2or3,atotalofninebitsarereceived.In
thiscase,thefirsteightbitsreceivedarethedataoftheserialbytereceivedandthevalueof
theninthbitreceivedwillbeplacedinRB8.
TImeans"TransmitInterrupt."Whenaprogramwritesavaluetotheserialport,acertain
amountoftimewillpassbeforetheindividualbitsofthebyteare"clockedout"theserialport.
Iftheprogramweretowriteanotherbytetotheserialportbeforethefirstbytewas
completelyoutput,thedatabeingsentwouldbegarbled.Thus,the8051letstheprogram
knowthatithas"clockedout"thelastbytebysettingtheTIbit.WhentheTIbitisset,the
programmayassumethattheserialportis"free"andreadytosendthenextbyte.
Finally,theRIbitmeans"ReceiveInterrupt."Itfuncionssimilarlytothe"TI"bit,butitindicates
thatabytehasbeenreceived.Thatistosay,wheneverthe8051hasreceivedacompletebyte
itwilltriggertheRIbittolettheprogramknowthatitneedstoreadthevaluequickly,before
anotherbyteisread.

SettingtheSerialPortBaudRate
OncetheSerialPortModehasbeenconfigured,asexplainedabove,theprogrammust
configuretheserialportsbaudrate.ThisonlyappliestoSerialPortmodes1and3.TheBaud
Rateisdeterminedbasedontheoscillatorsfrequencywheninmode0and2.Inmode0,the
baudrateisalwaystheoscillatorfrequencydividedby12.Thismeansifyourecrystalis
11.059Mhz,mode0baudratewillalwaysbe921,583baud.Inmode2thebaudrateisalways
theoscillatorfrequencydividedby64,soa11.059Mhzcrystalspeedwillyieldabaudrateof
172,797.
Inmodes1and3,thebaudrateisdeterminedbyhowfrequentlytimer1overflows.Themore
frequentlytimer1overflows,thehigherthebaudrate.Therearemanywaysonecancause
timer1tooverflowataratethatdeterminesabaudrate,butthemostcommonmethodisto
puttimer1in8bitautoreloadmode(timermode2)andsetareloadvalue(TH1)thatcauses
Timer1tooverflowatafrequencyappropriatetogenerateabaudrate.
TodeterminethevaluethatmustbeplacedinTH1togenerateagivenbaudrate,wemayuse
thefollowingequation(assumingPCON.7isclear).
TH1=256((Crystal/384)/Baud)
IfPCON.7issetthenthebaudrateiseffectivelydoubled,thustheequationbecomes:
TH1=256((Crystal/192)/Baud)
Forexample,ifwehavean11.059Mhzcrystalandwewanttoconfiguretheserialportto
19,200baudwetrypluggingitinthefirstequation:
TH1=256((Crystal/384)/Baud)
TH1=256((11059000/384)/19200)
TH1=256((28,799)/19200)
TH1=2561.5=254.5
Asyoucansee,toobtain19,200baudona11.059MhzcrystalwedhavetosetTH1to254.5.
Ifwesetitto254wewillhaveachieved14,400baudandifwesetitto255wewillhave
achieved28,800baud.Thuswerestuck...
Butnotquite...toachieve19,200baudwesimplyneedtosetPCON.7(SMOD).Whenwedo
thiswedoublethebaudrateandutilizethesecondequationmentionedabove.Thuswehave:
TH1=256((Crystal/192)/Baud)
TH1=256((11059000/192)/19200)
TH1=256((57699)/19200)
TH1=2563=253
Hereweareabletocalculateanice,evenTH1value.Therefore,toobtain19,200baudwith
an11.059MHzcrystalwemust:
1.ConfigureSerialPortmode1or3.
2.ConfigureTimer1totimermode2(8bitautoreload).
3.SetTH1to253toreflectthecorrectfrequencyfor19,200baud.
4.SetPCON.7(SMOD)todoublethebaudrate.
PowerSupply

Therearemanytypesofpowersupply.MostaredesignedtoconverthighvoltageACmains
electricitytoasuitablelowvoltagesupplyforelectroniccircuitsandotherdevices.Apower
supplycanbybrokendownintoaseriesofblocks,eachofwhichperformsaparticular
function.
Forexamplea5Vregulatedsupply:

Eachoftheblocksisdescribedinmoredetailbelow:
TransformerstepsdownhighvoltageACmainstolowvoltageAC.
RectifierconvertsACtoDC,buttheDCoutputisvarying.
SmoothingsmoothestheDCfromvaryinggreatlytoasmallripple.
RegulatoreliminatesripplebysettingDCoutputtoafixedvoltage.

Powersuppliesmadefromtheseblocksaredescribedbelowwithacircuitdiagramandagraph
oftheiroutput:

Transformeronly
Transformer+Rectifier
Transformer+Rectifier+Smoothing
Transformer+Rectifier+Smoothing+Regulator

Transformeronly
ThelowvoltageACoutputissuitableforlamps,heatersandspecialACmotors.Itisnot
suitableforelectroniccircuitsunlesstheyincludearectifierandasmoothingcapacitor.

Transformer+Rectifier
ThevaryingDCoutputissuitableforlamps,heatersandstandardmotors.Itisnotsuitablefor
electroniccircuitsunlesstheyincludeasmoothingcapacitor.

Transformer+Rectifier+Smoothing
ThesmoothDCoutputhasasmallripple.Itissuitableformostelectroniccircuits.

Transformer+Rectifier+Smoothing+Regulator
TheregulatedDCoutputisverysmoothwithnoripple.Itissuitableforallelectroniccircuits.

Thefig.aboveshowsthecircuitdiagramofthepowersupplyunit.Thisblockmainlyconsists
ofatworegulatingIC7805andabridgerectifiedanditprovidesaregulatedsupply
approximately5V.

Thetransformerusedinthiscircuithassecondaryratingof7.5V.Themainfunctionofthe
transformeristostepdowntheACvoltageavailablefromthemain.Themainconnectionsare
giventoitsprimarywindingthroughaswitchconnectedtoaphaseline.Thetransformer
providesa7.5VACoutputatitssecondaryterminalsandthemaximumcurrentthatcanbe
drawnformthetransformeris1Ampwhichiswellabovetherequiredlevelforthecircuit.
ThebridgerectifiedtheACvoltageavailablefromthesecondaryofthetransformer,i.e.the
bridgerectifierconverttheACpoweravailableintoDCpowerbutthisDCvoltageavailableis
notconstant.Itisaunidirectionalvoltagewithvaryingamplitude.
Toregulatethevoltagefromthebridgerectifier,capacitorsareconnected.CapacitorsC1filter
theoutputvoltageoftherectifierbuttheiroutputisnotregulatedandhence7805is
connectedwhichisspeciallydesignedforthispurpose.

Althoughvoltageregulatorscanbedesignedusingopamps,itisquickerandeasiertouseIC
voltageregulator.Furthermore,ICvoltageregulatorsareavailablewithfeaturessuchas
programmableoutputcurrent/voltageboosting,internalshortcircuitcurrentlimiting,thermal
shutdownandfloatingoperationforhighvoltageapplications.

The78XXseriesconsistsofthreeterminalsviz,input,output&ground.Thisisagroupof
fixedpositivevoltageregulatortogiveandoutputvoltagerangingform5Vto24V.TheseIC's
aredesignedasfixedvoltageregulatorsandwithadequateheatsinking,candeliveryoutput
currentinexcessof1Ampalthoughthesedevicesdonotrequireexternalcomponentsand
suchcomponentscanbeusedtoobtainadjustablevoltageandcurrentlimiting.Inaddition,
thedifferencebetweentheinputandoutputvoltages(VinVo)calledthedropoutvoltagemust
betypically2Vevenfromapowersupplyfilter.CapacitorsC2,C3,C4,andC5aresmallfilters
whichareusedforextrafiltering.LED1&LED2areusedforPowerONindicatorforIC1and
IC2,currentlimitingresistorsR2&R4,whichpreventstheLED'sfromgettingheatedandthus
damaged.

LM7805SeriesVoltageRegulators

VOLTAGEREGULATOR:Avoltageregulatorisanelectricalregulatordesignedtoautomatically
maintainaconstantvoltagelevel.Itmayuseanelectromechanicalmechanism,orpassiveor
activeelectroniccomponents.Dependingonthedesign,itmaybeusedtoregulateoneor
moreACorDCvoltages.Withtheexceptionofshuntregulators,allvoltageregulatorsoperate
bycomparingtheactualoutputvoltagetosomeinternalfixedreferencevoltage.Any
differenceisamplifiedandusedtocontroltheregulationelement.Thisformsanegative
feedbackservocontrolloop.Iftheoutputvoltageistoolow,theregulationelementis
commandedtoproduceahighervoltage.Iftheoutputvoltageistoohigh,theregulation
elementiscommandedtoproducealowervoltage.Inthisway,theoutputvoltageisheld
roughlyconstant.

GeneralDescription

TheLM78XXseriesofthreeterminalregulatorsisavailablewithseveralfixedoutput
voltagesmakingthemusefulinawiderangeofapplications.Oneoftheseislocaloncard
regulation,eliminatingthedistributionproblemsassociatedwithsinglepointregulation.The
voltagesavailableallowtheseregulatorstobeusedinlogicsystems,instrumentation,HiFi,
andothersolidstateelectronicequipment.Althoughdesignedprimarilyasfixedvoltage
regulatorsthesedevicescanbeusedwithexternalcomponentstoobtainadjustablevoltages
andcurrents.
TheLM78XXseriesisavailableinanaluminumTO3package,whichwillallowover1.0Aload
currentifadequateheatsinkingisprovided.Currentlimitingisincludedtolimitthepeak
outputcurrenttoasafevalue.Safeareaprotectionfortheoutputtransistorisprovidedtolimit
internalpowerdissipation.Ifinternalpowerdissipationbecomestoohighfortheheatsinking
provided,thethermalshutdowncircuittakesoverpreventingtheICfromoverheating.
ConsiderableeffortwasexpandedtomaketheLM78XXseriesofregulatorseasytouseand
minimizethenumberofexternalcomponents.Itisnotnecessarytobypasstheoutput,
althoughthisdoesimprovetransientresponse.Inputbypassingisneededonlyiftheregulator
islocatedfarfromthefiltercapacitorofthepowersupply.Foroutputvoltageotherthan5V,
12Vand15VtheLM117seriesprovidesanoutputvoltagerangefrom1.2Vto57V.

FEATURES

Outputcurrentinexcessof1A
Internalthermaloverloadprotection
Noexternalcomponentsrequired
Outputtransistorsafeareaprotection
Applicationsandfuturescope:

Applicationsandfuturescopethesetypeofautomationsystemcanusedinhomes,industries
etc.Byusingthisautomationdesign,wecanreducetheusageofmanpower,andthedamage
ofdevicescanalsobereduces.Byusingtransmissionunitswecancontroltheequipmentfrom
longdistances.Thuswecanconcludethatthiskindofdevicesisveryusefulforregulatingthe
temperaturechangesintheequipment.