GSM Based Fault Detection in Transmission Line and Distance Calculation
GSM Based Fault Detection in Transmission Line and Distance Calculation
ANDDISTANCECALCULATION
CHAPTER1
INTRODUCTION
INTRODUCTION:
TheprojectusesthestandardconceptofOhmslawi.e.,whenalowDCvoltageisapplied
atthefeederendthroughaseriesresistor(lines),thencurrentwouldvarydependinguponthe
locationoffaultinthecable.Incasethereisashortcircuit(LinetoGround),thevoltageacross
seriesresistorschangesaccordingly,whichisthenfedtoanADCtodevelopprecisedigitaldata
whichtheprogrammedmicrocontrollerof8051familywoulddisplayinkilometers.
TheprojectisassembledwithasetofresistorsrepresentingcablelengthinKMsand
faultcreationismadebyasetofswitchesateveryknownKMtocrosschecktheaccuracyofthe
same.ThefaultoccurringataparticulardistanceandtherespectivephaseisdisplayedonaLCD
interfacedtothemicrocontroller.
GSMmoduleisusedtosendasmstothesubstationaboutphasefaultanddistance
calculated.
CHAPTER2
ELECTRICALCOMPONENTS
2.1.Powersupply
The power supplies are designed to convert high voltage AC mains electricity to a
suitablelowvoltagesupplyforelectronicscircuitsandotherdevices.Apowersupplycanby
brokendownintoaseriesofblocks,eachofwhichperformsaparticularfunction.Ad.cpower
supplywhichmaintainstheoutputvoltageconstantirrespectiveofa.cmainsfluctuationsorload
variationsisknownasRegulatedD.CPowerSupply
Forexamplea5Vregulatedpowersupplysystemasshownbelow:
2.2.1.Transformer:
Atransformerisanelectricaldevicewhichisusedtoconvertelectricalpowerfromone
Electricalcircuittoanotherwithoutchangeinfrequency.
TransformersconvertACelectricityfromonevoltagetoanotherwithlittlelossofpower.
TransformersworkonlywithACandthisisoneofthereasonswhymainselectricityisAC.
Stepup transformers increase in output voltage, stepdown transformers decrease in output
voltage.Mostpowersuppliesuseastepdowntransformertoreducethedangerouslyhighmains
voltagetoasaferlowvoltage.Theinputcoiliscalledtheprimaryandtheoutputcoiliscalled
thesecondary.Thereisnoelectricalconnectionbetweenthetwocoils;insteadtheyarelinkedby
analternatingmagneticfieldcreatedinthesoftironcoreofthetransformer.Thetwolinesinthe
middleofthecircuitsymbolrepresentthecore. Transformerswasteverylittlepowersothe
poweroutis(almost)equaltothepowerin.Notethatasvoltageissteppeddowncurrentis
steppedup.Theratioofthenumberofturnsoneachcoil,calledtheturnsratio,determinesthe
ratioofthevoltages.Astepdowntransformerhasalargenumberofturnsonitsprimary(input)
coilwhichisconnectedtothehighvoltagemainssupply,andasmallnumberofturnsonits
secondary(output)coiltogivealowoutputvoltage.
AnElectricalTransformer
Turnsratio=Vp/VS=Np/NS
PowerOut=PowerIn
VSXIS=VPXIP
Vp=primary(input)voltage
Np=numberofturnsonprimarycoil
Ip=primary(input)current
2.2.2.RECTIFIER:
Acircuitwhichisusedtoconverta.ctodcisknownasRECTIFIER.Theprocessof
conversiona.ctod.ciscalledrectification
TYPESOFRECTIFIERS:
HalfwaveRectifier
Fullwaverectifier
1.Centretapfullwaverectifier.
2.Bridgetypefullbridgerectifier.
Comparisonofrectifiercircuits:
TypeofRectifier
Parameter
Numberofdiodes
PIVofdiodes
D.Coutputvoltage
Vdc,at
noload
Ripplefactor
Ripple
frequency
Rectification
efficiency
Transformer
Utilization
Factor(TUF)
HalfwaveFullwaveBridge
2
4
1
2Vm
Vm
Vm
Vm/
2Vm/
2Vm/
0.318Vm
0.636Vm
0.636Vm
1.21
0.406
0.287
0.482
2f
0.812
0.482
2f
0.812
0.693
0.812
RMSvoltageVrms
Vm/2
Vm/2
Vm/2
FullwaveRectifier:
Fromtheabovecomparisionwecametoknowthatfullwavebridgerectifierasmoreadvantages
thantheothertworectifiers.So,inourprojectweareusingfullwavebridgerectifiercircuit.
BridgeRectifier:Abridgerectifiermakesuseoffourdiodesinabridgearrangementtoachieve
fullwaverectification. This is awidely usedconfiguration,both withindividual diodes
wired as shown and with single component bridges where the diode bridge is wired
internally.
Abridgerectifiermakesuseoffourdiodesinabridgearrangementasshowninfig(a)to
achievefullwaverectification.Thisisawidelyusedconfiguration,bothwithindividualdiodes
wiredasshownandwithsinglecomponentbridgeswherethediodebridgeiswiredinternally.
Fig(A)
2.2.3.Operation:
Duringpositivehalfcycleofsecondary,thediodesD2andD3areinforwardbiasedwhileD1
andD4areinreversebiasedasshowninthefig(b).Thecurrentflowdirectionisshowninthe
fig(b)withdottedarrows.
Fig(B)
Duringnegativehalfcycleofsecondaryvoltage,thediodesD1andD4areinforwardbiased
whileD2andD3areinreversebiasedasshowninthefig(c).Thecurrentflowdirectionis
showninthefig(c)withdottedarrows.
Fig(C)
Filter:
AFilterisadevicewhichremovesthea.ccomponentofrectifieroutputbutallowsthe
d.ccomponenttoreachtheload
CapacitorFilter:
Wehaveseenthattheripplecontentintherectifiedoutputofhalfwaverectifieris121%or
thatoffullwaveorbridgerectifierorbridgerectifieris48%suchhighpercentagesofripplesis
8
notacceptableformostoftheapplications.Ripplescanberemovedbyoneofthefollowing
methodsoffiltering.
a) Acapacitor,inparalleltotheload,providesaneasierbypassfortheripplesvoltage
thoughitduetolowimpedance.Atripplefrequencyandleavethed.c.toappearstheload.
b) Aninductor,inserieswiththeload,preventsthepassageoftheripplecurrent(dueto
highimpedanceatripplefrequency)whileallowingthed.c(duetolowresistancetod.c)
c) variouscombinationsofcapacitor andinductor,such asLsection filter
section
filter,multiplesectionfilteretc.whichmakeuseofboththepropertiesmentionedin(a)
and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and
anotherwithfullwaverectifier.
FilteringisperformedbyalargevalueelectrolyticcapacitorconnectedacrosstheDC
supplytoactasareservoir,supplyingcurrenttotheoutputwhenthevaryingDCvoltagefrom
therectifierisfalling.ThecapacitorchargesquicklynearthepeakofthevaryingDC,andthen
dischargesasitsuppliescurrenttotheoutput.FilteringsignificantlyincreasestheaverageDC
voltagetoalmostthepeakvalue(1.4RMSvalue).
Tocalculatethevalueofcapacitor(C),
C=*3*f*r*Rl
Where,
f=supplyfrequency,
r=ripplefactor,
Rl=loadresistance
Note:Inourcircuitweareusing1000FHencelargevalueofcapacitorisplacedto
reduceripplesandtoimprovetheDCcomponent.
2.2.4.Regulator:
VoltageregulatorICsisavailablewithfixed(typically5,12and15V)orvariableoutput
voltages.Themaximumcurrenttheycanpassalsoratesthem.Negativevoltageregulatorsare
available,mainlyforuseindualsupplies.Mostregulatorsincludesomeautomaticprotection
fromexcessivecurrent('overloadprotection')andoverheating('thermalprotection'). Manyof
9
thefixedvoltageregulatorICshave3leadsandlooklikepowertransistors,suchasthe7805
+5V1Aregulatorshownontheright.TheLM7805issimpletouse.Yousimplyconnectthe
positiveleadofyourunregulatedDCpowersupply(anythingfrom9VDCto24VDC)tothe
Inputpin,connectthenegativeleadtotheCommonpinandthenwhenyouturnonthepower,
yougeta5voltsupplyfromtheoutputpin.
Fig6.1.6AThreeTerminalVoltageRegulator
78XX:
TheBayLinearLM78XXisintegratedlinearpositiveregulatorwiththreeterminals.The
LM78XXofferseveralfixedoutputvoltagesmakingthemusefulinwiderangeofapplications.
Whenusedasazenerdiode/resistorcombinationreplacement,theLM78XXusuallyresultsinan
effectiveoutputimpedanceimprovementoftwoordersofmagnitude,lowerquiescentcurrent.
TheLM78XXisavailableintheTO252,TO220&TO263packages
Features:
OutputCurrentof1.5A
OutputVoltageToleranceof5%
Internalthermaloverloadprotection
InternalShortCircuitLimited
NoExternalComponent
OutputVoltage5.0V,6V,8V,9V,10V,12V,15V,18V,24V
OfferinplasticTO252,TO220&TO263
DirectReplacementforLM78XX
10
2.3.TheMicroController
Amicrocontrollerisageneralpurposedevice,butthatismeanttoreaddata,perform
limitedcalculationsonthatdataandcontrolitsenvironmentbasedonthosecalculations.The
primeuseofamicrocontrolleristocontroltheoperationofamachineusingafixedprogramthat
isstoredinROMandthatdoesnotchangeoverthelifetimeofthesystem.
The microcontroller design uses a much more limited set of single and double byte
instructions that are used to move data and code from internal memory to the ALU. The
microcontrollerisconcernedwithgettingdatafromandtoitsownpins;thearchitectureand
instructionsetareoptimizedtohandledatainbitandbytesize.
TheAT89C51isalowpower,highperformanceCMOS8bitmicrocontrollerwith4k
bytes of Flash Programmable and erasable read only memory (EROM). The device is
manufactured usingAtmels highdensitynonvolatilememorytechnologyandisfunctionally
compatible withtheindustrystandard80C51microcontroller instructionsetandpinout.By
combining versatile 8bit CPU with Flash on a monolithic chip, the Atmels AT89c51 is a
powerfulmicrocomputer,whichprovidesahighflexibleandcosteffectivesolutiontomany
embeddedcontrolapplications.
2.3.1.AT89C51MICROCONTROLLER
FEATURES
80C51basedarchitecture
4KbytesofonchipReprogrammableFlashMemory
128x8RAM
Two16bitTimer/Counters
Fullduplexserialchannel
Booleanprocessor
Four8bitI/Oports,32I/Olines
Memoryaddressingcapability
11
64KROMand64KRAM
Powersavemodes:
Idleandpowerdown
Sixinterruptsources
Mostinstructionsexecutein0.3us
CMOSandTTLcompatible
Maximumspeed:40MHz@Vcc=5V
Industrialtemperatureavailable
Packagesavailable:
40pinDIP
44pinPLCC
44pinPQFP
Pinconfiguration:
12
AT89C51BlockDiagram
13
PINDESCRIPTION:
14
VCC
Supplyvoltage
GND
Ground
Port0
Port0isan8bitopendrainbidirectionalI/Oport.Asanoutputport,eachpincansinkeight
TTLinputs.When1sarewrittentoport0pins,thepinscanbeusedashighimpedanceinputs.
Port0canalsobeconfiguredtobethemultiplexedloworderaddress/databusduring
accesstoexternalprogramanddatamemory.Inthismode,P0hasinternalpullups.Port0also
receivesthecodebytesduringFlashprogrammingandoutputsthecodebytesduringprogram
verification.Externalpullupsarerequiredduringprogramverification.
Port1
Port1isan8bitbidirectionalI/Oportwithinternalpullups.Theport1outputbuffers
cansink/sourcefourTTLinputs.When1sarewrittentoport1pins,theyarepulledhighbythe
internalpullupscanbeusedasinputs.Asinputs,Port1pinsthatareexternallybeingpulledlow
willsourcecurrent(1)becauseoftheinternalpullups.
Port2
Port2isan8bitbidirectionalI/Oportwithinternalpullups.Theport2outputbuffers
cansink/sourcefourTTLinputs.When1sarewrittentoport2pins,theyarepulledhighbythe
internalpullupscanbeusedasinputs.Asinputs,Port2pinsthatareexternallybeingpulledlow
willsourcecurrentbecauseoftheinternalpullups.
Port2emitsthehighorderaddressbyteduringfetchesfromexternalprogrammemory
andduringaccesstoDPTR.InthisapplicationPort2usesstronginternalpullupswhenemitting
1s.Duringaccessestoexternaldatamemorythatuse8bitdataaddress(MOVX@R1),Port2
emits the contents of the P2 Special Function Register. Port 2 also receives the highorder
addressbitsandsomecontrolsignalsduringFlashprogrammingandverification.
Port3
15
Port3isan8bitbidirectionalI/Oportwithinternalpullups.Theport3outputbuffers
cansink/sourcefourTTLinputs.When1sarewrittentoport3pins,theyarepulledhighbythe
internalpullupscanbeusedasinputs.Asinputs,Port3pinsthatareexternallybeingpulledlow
willsourcecurrentbecauseoftheinternalpullups.
Port3alsoreceivessomecontrolsignalsforFlashProgrammingandverification.
Portpin
AlternateFunctions
P3.0
RXD(serialinputport)
P3.1
TXD(serialinputport)
P3.2
INT0(externalinterrupt0)
P3.3
INT1(externalinterrupt1)
P3.4
T0(timer0externalinput)
P3.5
T1(timer1externalinput)
P3.6
WR(externaldatamemorywritestrobe)
P3.7
RD(externaldatamemoryreadstrobe)
RST
RestinputAonthispinfortwomachinecycleswhiletheoscillatorisrunningresetsthedevice.
ALE/PROG:
AddressLatchEnableisanoutputpulseforlatchingthelowbyteoftheaddressduring
access to external memory. This pin is also the program pulse input (PROG) during Flash
programming.
InnormaloperationALEisemittedataconstantrateof1/16theoscillatorfrequencyandmaybe
usedforexternaltimingorclockingpurpose.Note,however,thatoneALEpulseisskipped
duringeachaccesstoexternalDatamemory.
PSEN
16
ProgramStoreEnableisthereadstrobetoexternalprogrammemorywhentheAT89c51
isexecutingcodefromexternalprogrammemoryPSENisactivatedtwiceeachmachinecycle,
exceptthattwoPSENactivationsareskippedduringeachaccesstoexternaldatamemory.
EA/VPP
ExternalAccessEnable(EA)mustbestrappedtoGNDinordertoenablethedeviceto
fetch code from external program memory locations starting at 0000h up to FFFFH. Note,
however,thatiflockbit1isprogrammedEAwillbeinternallylatchedonreset.EAshouldbe
strappedtoVccforinternalprogramexecutions.Thispinalsoreceivesthe12voltprogramming
enablevoltage(Vpp)duringFlashprogrammingwhen12voltprogrammingisselected.
XTAL1
Inputtotheinvertingoscillatoramplifierandinputtotheinternalclockoperatingcircuit.
XTAL2
Outputfromtheinvertingoscillatoramplifier.
OPERATINGDESCRIPTION
ThedetaildescriptionoftheAT89C51includedinthisdescriptionis:
MemoryMapandRegisters
Timer/Counters
InterruptSystem
MEMORYMAPANDREGISTERS
Memory
TheAT89C51hasseparateaddressspacesforprogramanddatamemory.Theprogram
anddatamemorycanbeupto64Kbyteslong.Thelower4Kprogrammemorycanresideon
chip.TheAT89C51has128bytesofonchipRAM.
The lower 128 bytes can be accessed either by direct addressing or by indirect
addressing.Thelower128bytesofRAMcanbedividedinto3segmentsaslistedbelow
17
1.RegisterBanks03:locations00Hthrough1FH(32bytes).Thedeviceafterresetdefaultsto
registerbank0.Tousetheotherregisterbanks,theusermustselecttheminsoftware.Each
registerbankcontainseight1byteregistersR0R7.Resetinitializesthestackpointtolocation
07H,andisincrementedoncetostartfrom08H,whichisthefirstregisterofthesecondregister
bank.
2.BitAddressableArea:16byteshavebeenassignedforthissegment20H2FH.Eachoneof
the128bitsofthissegmentcanbedirectlyaddressed(07FH).Eachofthe16bytesinthis
segmentcanalsobeaddressedasabyte.
3. ScratchPadArea: 30H7FHareavailabletotheuserasdataRAM.However,ifthedata
pointerhasbeeninitializedtothisarea,enoughbytesshouldbeleftasidetopreventSPdata
destruction.
SPECIALFUNCTIONREGISTERS:
TheSpecialFunctionRegisters(SFR's)arelocatedinupper128Bytesdirectaddressing
area.TheSFRMemoryMapinshowsthat.
18
Notalloftheaddressesareoccupied.Unoccupiedaddressesarenotimplementedonthe
chip.Readaccessestotheseaddressesingeneralreturnrandomdata,andwriteaccesseshaveno
effect.Usersoftwareshouldnotwrite1stotheseunimplementedlocations,sincetheymaybe
usedinfuturemicrocontrollerstoinvokenewfeatures.Inthatcase,theresetorinactivevaluesof
thenewbitswillalwaysbe0,andtheiractivevalueswillbe1.
ThefunctionsoftheSFRsareoutlinedinthefollowingsections.
Accumulator(ACC)
ACC is the Accumulator register. The mnemonics for Accumulatorspecific instructions,
however,refertotheAccumulatorsimplyasA.
BRegister(B)
TheBregisterisusedduringmultiplyanddivideoperations.Forotherinstructionsitcanbe
treatedasanotherscratchpadregister.
ProgramStatusWord(PSW)
ThePSWregistercontainsprogramstatusinformation.
StackPointer(SP)
TheStackPointerRegisteriseightbitswide.Itisincremented beforedataisstoredduring
PUSHandCALLexecutions.WhilethestackmayresideanywhereinonchipRAM,theStack
Pointerisinitializedto07Hafterareset.Thiscausesthestacktobeginatlocation08H.
DataPointer(DPTR)
TheDataPointerconsistsofahighbyte(DPH)andalowbyte(DPL).Itsfunctionistoholda
16bitaddress.Itmaybemanipulatedasa16bitregisterorastwoindependent8bitregisters.
SerialDataBuffer(SBUF)
TheSerialDataBufferisactuallytwoseparateregisters,atransmitbufferandareceivebuffer
register.WhendataismovedtoSBUF,itgoestothetransmitbuffer,whereitisheldforserial
transmission.(MovingabytetoSBUFinitiatesthetransmission.)Whendataismovedfrom
SBUF,itcomesfromthereceivebuffer.
TimerRegisters
19
Registerpairs(TH0,TL0)and(TH1,TL1)arethe16bitCounterregistersforTimer/Counters0
and1,respectively.
ControlRegisters
SpecialFunctionRegistersIP,IE,TMOD,TCON,SCON,andPCONcontaincontrolandstatus
bitsfortheinterruptsystem,theTimer/Counters,andtheserialport.
TIMER/COUNTERS
TheIS89C51hastwo16bitTimer/Counterregisters:Timer0andTimer1.Alltwocan
be configured to operate either as Timers or event counters. As a Timer, the register is
incrementedeverymachinecycle.Thus,theregistercountsmachinecycles.Sinceamachine
cycleconsistsof12oscillatorperiods,thecountrateis1/12oftheoscillatorfrequency.
As a Counter, the register is incremented in response to a 1to0 transition at its
correspondingexternalinputpin,T0andT1.TheexternalinputissampledduringS5P2ofevery
machinecycle.Whenthesamplesshowahighinonecycleandalowinthenext
cycle,thecountisincremented.ThenewcountvalueappearsintheregisterduringS3P1ofthe
cyclefollowingtheoneinwhichthetransitionwasdetected.Sincetwomachinecycles(24
oscillatorperiods)arerequiredtorecognizea1to0transition,themaximumcountrateis1/24
oftheoscillatorfrequency.Therearenorestrictions onthedutycycleoftheexternal input
signal,butitshouldbeheldforatleastonefullmachinecycletoensurethatagivenlevelis
sampledatleastoncebeforeitchanges.
InadditiontotheTimerorCounterfunctions,Timer0andTimer1havefouroperatingmodes:
13bittimer,16bittimer,8bitautoreload,splittimer.
TIMERS:
OSCILLATOR
FREQUENCY
12D
TLX
TR
SFRSUSEDINTIMERS
Thespecialfunctionregistersusedintimersare,
20
THX
TFX
TMODRegister
TCONRegister
Timer(T0)&timer(T1)Registers
(i)TMODRegister:
TMODisdedicatedsolelytothetwotimers(T0&T1).
ThetimermodeSFRisusedtoconfigurethemodeofoperation ofeachofthetwo
timers.UsingthisSFRyourprogrammayconfigureeachtimertobea16bittimer,or13
bittimer,8bitautoreloadtimer,ortwoseparatetimers.Additionallyyoumayconfigure
thetimerstoonlycountwhenanexternalpinisactivatedortocounteventsthatare
indicatedonanexternalpin.
Itcanconsiderastwoduplicate4bitregisters,eachofwhichcontrolstheactionofone
ofthetimers.
(ii)TCONRegister:
ThetimercontrolSFRisusedtoconfigureandmodifythewayinwhichthe8051stwo
timersoperate.ThisSFRcontrolswhethereachofthetwotimersisrunningorstopped
andcontainsaflagtoindicatethateachtimerhasoverflowed.Additionally,somenon
timerrelatedbitsarelocatedinTCONSFR.
These bits are used to configure the way in which the external interrupt flags are
activated,whicharesetwhenanexternalinterruptoccurs.
(iii)TIMER0(T0):
TO(Timer0low/high,address8A/8Ch)
ThesetwoSFRstakentogetherrepresenttimer0.Theirexactbehaviordepends
onhowthetimerisconfiguredintheTMODSFR;however,thesetimersalwayscount
up.Whatisconfigurableishowandwhentheyincrementinvalue.
T H0
T L0
(iv)TIMER1(T1):
21
T1(Timer1Low/High,address8B/8Dh)
ThesetwoSFRs,takentogether,representtimer1.Theirexactbehaviordependsonhowthe
timer is configured in the TMOD SFR; however, these timers always count up. What is
Configurableishowandwhentheyincrementinvalue.
TheTimerorCounterfunctionisselectedbycontrolbitsC/TintheSpecialFunctionRegister
TMOD.ThesetwoTimer/Countershavefouroperatingmodes,whichareselectedbybitpairs
(M1,M0)inTMOD.Modes0,1,and2arethesameforbothTimer/Counters,butMode3is
different.
Thefourmodesaredescribedinthefollowingsections.
Mode0:
BothTimersinMode0are8bitCounterswithadivideby32prescalar.Figure8shows
theMode0operationasitappliestoTimer1.Inthismode,theTimerregisterisconfiguredasa
13bitregister.Asthecountrollsoverfromall1stoall0s,itsetstheTimerinterruptflagTF1.
ThecountedinputisenabledtotheTimerwhenTR1=1andeitherGATE=0orINT1=1.
SettingGATE=1allowstheTimertobecontrolledbyexternalinputINT1,tofacilitatepulse
widthmeasurements.TR1isacontrolbitintheSpecialFunctionRegisterTCON.Gateisin
TMOD.
The13bitregisterconsistsofalleightbitsofTH1andthelowerfivebitsofTL1.The
upperthreebitsofTL1areindeterminateandshouldbeignored.Settingtherunflag(TR1)does
notcleartheregisters.
Mode0operationisthesameforTimer0asforTimer1,exceptthatTR0,TF0andINT0
replacethecorrespondingTimer1signals.TherearetwodifferentGATEbits,oneforTimer1
(TMOD.7)andoneforTimer0(TMOD.3).
Mode1
Mode1isthesameasMode0,exceptthattheTimerregisterisrunwithall16bits.The
clockisappliedtothecombinedhighandlowtimerregisters(TL1/TH1).Asclockpulsesare
22
received,thetimercountsup:0000H,0001H,0002H,etc.AnoverflowoccursontheFFFFHto
0000Hoverflowflag.Thetimercontinuestocount.TheoverflowflagistheTF1bitinTCON
thatisreadorwrittenbysoftware
Mode2
Mode2configurestheTimerregisterasan8bitCounter(TL1)withautomaticreload,as
shownin Figure 10.Overflow from TL1 not onlysets TF1,but also reloads TL1 with the
contentsofTH1,whichispresetbysoftware.ThereloadleavestheTH1unchanged.Mode2
operationisthesameforTimer/Counter0.
Mode3
Timer1inMode3simplyholdsitscount.TheeffectisthesameassettingTR1=0.
Timer0inMode3establishesTL0andTH0astwoseparatecounters.ThelogicforMode3on
Timer0isshowninFigure11.TL0usestheTimer0controlbits:C/T,GATE,TR0,INT0,and
TF0.TH0islockedintoatimerfunction(countingmachinecycles)andovertheuseofTR1and
TF1fromTimer1.Thus,TH0nowcontrolstheTimer1interrupt.
Mode3isforapplicationsrequiringanextra8bittimerorcounter.WithTimer0in
Mode3,theAT89C51canappeartohavethreeTimer/Counters.WhenTimer0isinMode3,
Timer1canbeturnedonandoffbyswitchingitoutofandintoitsownMode3.Inthiscase,
Timer1canstillbeusedbytheserialportasabaudrategeneratororinanyapplicationnot
requiringaninterrupt.
2.5.INTERRUPTSYSTEM
An interrupt is an external or internal event that suspends the operation of micro
controllertoinformitthatadeviceneedsitsservice.Ininterruptmethod,wheneveranydevice
needsitsservice,thedevicenotifiesthemicrocontrollerbysendingitaninterruptsignal.Upon
receivinganinterruptsignal,themicrocontrollerinterruptswhateveritisdoingandservesthe
device. The program associated with interrupt is called as interrupt service subroutine
(ISR).Mainadvantagewithinterruptsisthatthemicrocontrollercanservemanydevices.
BaudRate
23
ThebaudrateinMode0isfixedasshowninthefollowingequation.Mode0BaudRate
=OscillatorFrequency/12thebaudrateinMode2dependsonthevalueoftheSMODbitin
SpecialFunctionRegisterPCON.IfSMOD=0thebaudrateis1/64oftheoscillatorfrequency.
IfSMOD=1,thebaudrateis1/32oftheoscillatorfrequency.
Mode2BaudRate=2SMODx(OscillatorFrequency)/64.
IntheIS89C51,theTimer1overflowratedeterminesthebaudratesinModes1and3.
NUMBEROFINTERRUPTSIN89C51:
Therearebasicallyfiveinterruptsavailabletotheuser.Resetisalsoconsideredasan
interrupt.Therearetwointerruptsfortimer,twointerruptsforexternalhardwareinterruptand
oneinterruptforserialcommunication.
MemorylocationInterruptname
0000HReset
0003HExternalinterrupt0
000BHTimerinterrupt0
0013HExternalinterrupt1
001BHTimerinterrupt1
0023HSerialCOMinterrupt
Lowerthevector,higherthepriority.TheExternalInterruptsINT0andINT1caneachbe
eitherlevelactivatedortransitionactivated,dependingonbitsIT0andIT1inRegisterTCON.
TheflagsthatactuallygeneratetheseinterruptsaretheIE0andIE1bitsinTCON.Whenthe
serviceroutineisvectored,hardwareclearstheflagthatgeneratedanexternalinterruptonlyif
the interrupt was transitionactivated. If the interrupt was levelactivated, then the external
requestingsource(ratherthantheonchiphardware)controlstherequestflag.
TheTimer0andTimer1InterruptsaregeneratedbyTF0andTF1,whicharesetbya
rolloverintheirrespectiveTimer/Counterregisters(exceptforTimer0inMode3).Whenatimer
interruptisgenerated,theonchiphardwareclearstheflagthatisgenerated.
TheSerialPortInterruptisgeneratedbythelogicalORofRIandTI.Theserviceroutine
normallymustdeterminewhetherRIorTIgeneratedtheinterrupt,andthebitmustbeclearedin
software.
24
Allofthebitsthatgenerateinterruptscanbesetorclearedbysoftware,withthesame
resultasthoughtheyhadbeensetorclearedbyhardware.Thatis,interruptscanbegenerated
andpendinginterruptscanbecanceledinsoftware.
Eachoftheseinterruptsourcescanbeindividually enabledordisabledbysettingor
clearingabitinSpecialFunctionRegisterIE(interruptenable)ataddress0A8H.Thereisa
globalenable/disablebitthatisclearedtodisableallinterruptsortosettheinterrupts.
IE(Interruptenableregister):
Stepsinenablinganinterrupt:
BitD7oftheIEregistermustbesettohightoallowtherestofregistertotakeeffect.If
EA=1,interruptsareenabledandwillberespondedtoiftheircorrespondingbitsinIEarehigh.
IfEA=0,nointerruptwillberespondedtoeveniftheassociatedbitintheIEregisterishigh.
DescriptionofeachbitinIEregister:
D7bit:Disablesallinterrupts.IfEA=0,nointerruptisacknowledged,ifEA=1each
interruptsourceisindividuallyenabledordisabledbysettingorclearingitsenablebit.
D6bit:Reserved.
D5bit:Enablesordisablestimer2overflowinterrupt(in8052).
D4bit:Enablesordisablesserialportinterrupt.
D3bit:Enablesordisablestimer1overflowinterrupt.
D2bit:Enablesordisablesexternalinterrupt1.
D1bit:Enablesordisablestimer0overflowinterrupt.
D0bit:Enablesordisablesexternalinterrupt0.
Interruptpriorityin89C51:
ThereisonemoreSRFtoassignprioritytotheinterruptswhichisnamedasinterrupt
priority(IP).Userhasgiventheprovisiontoassignprioritytooneinterrupt.Writingonetothat
particularbitintheIPregisterfulfilsthetaskofassigningthepriority.
DescriptionofeachbitinIPregister:
D7bit:Reserved.
D6bit:Reserved.
D5bit:Timer2interruptprioritybit(in8052).
25
D4bit:Serialportinterruptprioritybit.
D3bit:Timer1interruptprioritybit.
D2bit:Externalinterrupt1prioritybit.
D1bit:Timer0interruptprioritybit.
D0bit:Externalinterrupt0prioritybit.
ComplexInstructionSetComputer(CISC)
CISC,whichstandsfor ComplexInstruction SetComputer, isaphilosophyfordesigning
chipsthatareeasytoprogramandwhichmakeefficientuseofmemory.Eachinstructionina
CISCinstructionsetmightperformaseriesofoperationsinsidetheprocessor.Thisreducesthe
numberofinstructionsrequiredtoimplementagivenprogram,andallowstheprogrammerto
learnasmallbutflexiblesetofinstructions.
TheadvantagesofCISC
Atthetimeoftheirinitialdevelopment,CISCmachinesusedavailabletechnologiestooptimize
computerperformance.
expensivethanhardwiringacontrolunit.
TheeaseofmicrocodingnewinstructionsalloweddesignerstomakeCISCmachines
upwardlycompatible:anewcomputercouldrunthesameprogramsasearliercomputersbecause
thenewcomputerwouldcontainasupersetoftheinstructionsoftheearliercomputers.
Aseachinstructionbecamemorecapable,fewerinstructionscouldbeusedtoimplement
agiventask.Thismademoreefficientuseoftherelativelyslowmainmemory.
Becausemicroprograminstructionsetscanbewrittentomatchtheconstructsofhigh
levellanguages,thecompilerdoesnothavetobeascomplicated.
ThedisadvantagesofCISC
Still,designerssoonrealizedthattheCISCphilosophyhaditsownproblems,including:
Earliergenerationsofaprocessorfamilygenerallywerecontainedasasubsetinevery
newversionsoinstructionset&chiphardwarebecomemorecomplexwitheachgeneration
ofcomputers.
26
Sothatasmanyinstructionsaspossiblecouldbestoredinmemorywiththeleastpossible
wastedspace,individualinstructionscouldbeofalmostanylengththismeansthatdifferent
instructions will take different amounts of clock time to execute, slowing down the overall
performanceofthemachine.
Manyspecializedinstructionsaren'tusedfrequentlyenoughtojustifytheirexistence
approximately20%oftheavailableinstructionsareusedinatypicalprogram.
CISCinstructionstypicallysettheconditioncodesasasideeffectoftheinstruction.Not
onlydoessettingtheconditioncodestaketime,butprogrammershavetoremembertoexamine
theconditioncodebitsbeforeasubsequentinstructionchangesthem.
MemoryArchitecture
Theretwodifferenttypesmemoryarchitecturesthereare:
HarvardArchitecture
VonNeumannArchitecture
27
HarvardArchitecture
Computershaveseparatememoryareasforprograminstructionsanddata.Therearetwoormore
internaldatabuses,whichallowsimultaneousaccesstobothinstructionsanddata.TheCPU
fetchesprograminstructionsontheprogrammemorybus.
TheHarvardarchitectureisacomputerarchitecturewithphysicallyseparatestorageandsignal
pathwaysforinstructionsanddata.Thetermoriginatedfromthe HarvardMarkI relaybased
computer, which stored instructions on punched tape (24 bits wide) and data in electro
mechanicalcounters.Theseearlymachineshadlimiteddatastorage,entirelycontainedwithin
thecentralprocessingunit,andprovidednoaccesstotheinstructionstorageasdata.Programs
neededtobeloadedbyanoperator,theprocessorcouldnotbootitself.
Fig2.8:HarvardArchitecture
ModernusesoftheHarvardarchitecture:
TheprincipaladvantageofthepureHarvardarchitecturesimultaneousaccesstomorethanone
memorysystemhasbeenreducedbymodifiedHarvardprocessorsusingmodern CPUcache
systems.RelativelypureHarvardarchitecturemachinesareusedmostlyinapplicationswhere
tradeoffs,suchasthecostandpowersavingsfromomittingcaches,outweightheprogramming
penaltiesfromhavingdistinctcodeanddataaddressspaces.
video processing algorithms. They avoid caches because their behavior must be extremely
reproducible.Thedifficultiesofcopingwithmultipleaddressspacesareofsecondaryconcernto
speedofexecution.Asaresult,someDSPshavemultipledatamemories indistinctaddress
spacestofacilitateSIMDandVLIWprocessing.TexasInstrumentsTMS320C55xprocessors,
28
asoneexample,havemultipleparalleldatabusses(twowrite,threeread)andoneinstruction
bus.
Microcontrollersarecharacterizedbyhavingsmallamountsofprogram(flashmemory)
anddata(SRAM)memory,withnocache,andtakeadvantageoftheHarvardarchitectureto
speed processing byconcurrent instruction and data access.The separate storage means the
program and data memories can have different bit depths, for example using 16bit wide
instructionsand8bitwidedata.Theyalsomeanthatinstructionprefetchcanbeperformedin
parallelwithotheractivities.Examplesinclude,theAVRbyAtmelCorp,thePICbyMicrochip
Technology, Inc. and the ARM CortexM3 processor (not all ARM chips have Harvard
architecture).
Eveninthesecases,itiscommontohavespecialinstructionstoaccessprogrammemoryasdata
forreadonlytables,orforreprogramming.
VonNeumannArchitecture
Acomputerhasasingle,commonmemoryspaceinwhichbothprograminstructionsanddata
arestored.Thereisasingleinternaldatabusthatfetchesbothinstructionsanddata.Theycannot
beperformedatthesametime
The vonNeumannarchitecture isadesignmodelforastoredprogram digitalcomputer that
usesacentralprocessingunit(CPU)andasingleseparatestoragestructure("memory")tohold
bothinstructionsanddata.Itisnamedafterthemathematicianandearlycomputerscientist
John
vonNeumann.Suchcomputersimplementa universalTuringmachine andhavea sequential
architecture.
Astoredprogramdigitalcomputerisonethatkeepsitsprogrammedinstructions,aswellasits
data, in readwrite, randomaccess memory (RAM). Storedprogram computers were
advancementovertheprogramcontrolledcomputersofthe1940s,suchastheColossusandthe
ENIAC,whichwereprogrammedbysettingswitchesandinsertingpatchleadstoroutedataand
tocontrolsignalsbetweenvariousfunctionalunits.Inthevastmajorityofmoderncomputers,the
samememoryisusedforbothdataandprograminstructions.Themechanismsfortransferring
the data and instructions between the CPU and memory are, however, considerably more
complexthantheoriginalvonNeumannarchitecture.
29
The terms "von Neumann architecture" and "storedprogram computer" are generally used
interchangeably,andthatusageisfollowedinthisarticle.
Fig2.8.SchematicoftheVonNeumannArchitecture.
BasicDifferencebetweenHarvardandVonNeumannArchitecture
TheprimarydifferencebetweenHarvardarchitectureandtheVonNeumannarchitecture
WhereastheHarvardarchitecturestoresdataandprogramsinseparatememorydevices
andtheyarehandledbydifferentsubsystems.
InacomputerusingtheVonNeumannarchitecturewithoutcache;thecentralprocessing
unit(CPU)caneitherbereadingandinstructionorwriting/readingdatato/fromthememory.
Bothoftheseoperationscannotoccursimultaneouslyasthedataandinstructionsusethesame
systembus.
InacomputerusingtheHarvardarchitecturetheCPUcanbothreadaninstructionand
accessdatamemoryatthesametimewithoutcache.ThismeansthatacomputerwithHarvard
architecture canpotentially befasterforagivencircuit complexity becausedataaccessand
instructionfetchesdonotcontendforuseofasinglememorypathway.
Today,thevastmajorityofcomputersaredesignedandbuiltusingtheVonNeumann
architecturetemplateprimarilybecauseofthedynamiccapabilitiesandefficienciesgainedin
designing, implementing, operating one memory system as opposed to two. Von Neumann
architecture may be somewhat slower than the contrasting Harvard Architecture for certain
specifictasks,butitismuchmoreflexibleandallowsformanyconceptsunavailabletoHarvard
architecturesuchasselfprogramming,wordprocessingandsoon.
30
2.5.RELAYS
Relayisanelectricallyoperatedswitch.Currentflowingthroughthecoiloftherelaycreatesa
magneticfieldwhichattractsaleverandchangestheswitchcontacts.Thecoilcurrentcanbeon
oroffsorelayshavetwoswitchpositionsandtheyaredoublethrow(changeover)switches.
Relaysallowonecircuittoswitchasecondcircuitwhichcanbecompletelyseparate
fromthefirst.Forexamplealowvoltagebatterycircuitcanusearelaytoswitcha230VAC
mainscircuit.Thereisnoelectricalconnectioninsidetherelaybetweenthetwocircuits;thelink
ismagneticandmechanical.
Thecoilofarelaypassesarelativelylargecurrent,typically30mAfora12Vrelay,butit
canbeasmuchas100mAforrelaysdesignedtooperatefromlowervoltages.MostICs(chips)
cannotprovidethiscurrentandatransistorisusuallyusedtoamplifythesmallICcurrenttothe
largervaluerequiredfortherelaycoil.Themaximumoutputcurrentforthepopular555timer
ICis200mAsothesedevicescansupplyrelaycoilsdirectlywithoutamplification.
RelaysareusuallySPDTorDPDTbuttheycanhavemanymoresetsofswitchcontacts,
for example relays with 4 sets of changeover contacts are readily available. For further
informationaboutswitchcontactsandthetermsusedtodescribethempleaseseethepageon
switches.
31
MostrelaysaredesignedforPCBmountingbutyoucansolderwiresdirectlytothepins
providingyoutakecaretoavoidmeltingtheplasticcaseoftherelay.Thesupplier'scatalogue
shouldshowyoutherelay'sconnections.Thecoilwillbeobviousanditmaybeconnectedeither
wayround.Relaycoilsproducebriefhighvoltage'spikes'whentheyareswitchedoffandthis
candestroytransistorsandICsinthecircuit.Topreventdamageyoumustconnectaprotection
diodeacrosstherelaycoil.
Theanimatedpictureshowsaworkingrelaywithitscoilandswitchcontacts.Youcan
seealeverontheleftbeingattractedbymagnetismwhenthecoilisswitchedon.Thislever
movestheswitchcontacts.Thereisonesetofcontacts(SPDT)intheforegroundandanother
behindthem,makingtherelayDPDT.
Therelay'sswitchconnectionsareusuallylabelledCOM,NCandNO:
COM=Common,alwaysconnecttothis,itisthemovingpartoftheswitch.
NC=NormallyClosed,COMisconnectedtothiswhentherelaycoilisoff.
NO=NormallyOpen,COMisconnectedtothiswhentherelaycoilison.
ConnecttoCOMandNOifyouwanttheswitchedcircuittobeonwhentherelaycoilis
on.
ConnecttoCOMandNCifyouwanttheswitchedcircuittobeonwhentherelaycoilis
off.
32
Choosingarelay
Youneedtoconsiderseveralfeatureswhenchoosingarelay:
1. PhysicalsizeandpinarrangementIfyouarechoosingarelayforanexistingPCByou
willneedtoensurethatitsdimensionsandpinarrangementaresuitable.Youshouldfind
thisinformationinthesupplier'scatalogue.
2. Coilvoltagetherelay'scoilvoltageratingandresistancemustsuitthecircuitpowering
therelaycoil.Manyrelayshaveacoilratedfora12Vsupplybut5Vand24Vrelaysare
alsoreadilyavailable.Somerelaysoperateperfectlywellwithasupplyvoltagewhichis
alittlelowerthantheirratedvalue.
3. Coilresistancethecircuitmustbeabletosupplythecurrentrequiredbytherelaycoil.
YoucanuseOhm's
lawtocalculatethecurrent:
Relaycoilcurrent=
supplyvoltage
coilresistance
4. Forexample:A12Vsupplyrelaywithacoilresistanceof400 passesacurrentof
30mA.ThisisOKfora555timerIC(maximumoutputcurrent200mA),butitistoo
muchformostICsandtheywillrequireatransistortoamplifythecurrent.
5. Switchratings(voltageandcurrent)therelay'sswitchcontactsmustbesuitableforthe
circuittheyaretocontrol.Youwillneedtocheckthevoltageandcurrentratings.Note
thatthevoltageratingisusuallyhigherforAC,forexample:"5Aat24VDCor125V
AC".
6. Switchcontactarrangement(SPDT,DPDTetc).
MostrelaysareSPDTorDPDTwhichareoftendescribedas"singlepolechangeover"
(SPCO)or"doublepolechangeover"(DPCO).Forfurtherinformationpleaseseethe
pageonswitches
33
Protectiondiodesforrelays
TransistorsandICs(chips)mustbeprotectedfromthebriefhighvoltage'spike'producedwhen
therelaycoilisswitchedoff.Thediagramshowshowasignaldiode(eg1N4148)isconnected
acrosstherelaycoiltoprovidethisprotection.Notethatthediodeisconnected'backwards'so
thatitwillnormallynotconduct.Conductiononlyoccurswhentherelaycoilisswitchedoff,at
this moment currenttries tocontinue flowingthroughthe coilanditisharmlessly diverted
through the diode. Without the diode no current could flow and the coil would produce a
damaginghighvoltage'spike'initsattempttokeepthecurrentflowing.
Reedrelays
Reedrelaysconsistofacoilsurroundingareedswitch.Reedswitchesarenormallyoperated
withamagnet,butinareedrelaycurrentflowsthroughthecoiltocreateamagneticfieldand
closethereedswitch.
Reed relays generally have higher coil resistances than standard relays (1000 for
example) and a wide range of supply voltages (920V for example). They are capable of
switchingmuchmorerapidlythanstandardrelays,uptoseveralhundredtimespersecond;but
theycanonlyswitchlowcurrents(500mAmaximumforexample).
Relaysandtransistorscompared
34
Likerelays,transistorscanbeusedasanelectricallyoperatedswitch.Forswitchingsmall
DC currents (< 1A) at low voltage they are usually a better choice than a relay. However
transistorscannotswitchACorhighvoltages(suchasmainselectricity)andtheyarenotusually
agoodchoiceforswitchinglargecurrents(>5A).Inthesecasesarelaywillbeneeded,butnote
thatalowpowertransistormaystillbeneededtoswitchthecurrentfortherelay'scoil!Themain
advantagesanddisadvantagesofrelaysarelistedbelow:
Advantagesofrelays:
RelayscanswitchACandDC,transistorscanonlyswitchDC.
Relayscanswitchhighvoltages,transistorscannot.
Relaysareabetterchoiceforswitchinglargecurrents(>5A).
Relayscanswitchmanycontactsatonce.
Disadvantagesofrelays:
Relaysarebulkierthantransistorsforswitchingsmallcurrents.
Relayscannotswitchrapidly(exceptreedrelays),transistorscanswitchmanytimesper
second.
Relaysusemorepowerduetothecurrentflowingthroughtheircoil.
Relaysrequiremorecurrentthanmanychipscanprovide,soalowpowertransistor
maybeneededtoswitchthecurrentfortherelay'scoil.
35
2.7.MAX232:
TheMAX232fromMaximwasthefirstICwhichinonepackagecontainsthenecessary
drivers(two)andreceivers(alsotwo),toadapttheRS232signalvoltagelevelstoTTLlogic.It
becamepopular,becauseitjustneedsonevoltage(+5V)andgeneratesthenecessaryRS232
voltagelevels(approx.10Vand+10V)internally.Thisgreatlysimplifiedthedesignofcircuitry.
Circuitrydesignersnolongerneedtodesignandbuildapowersupplywiththreevoltages(e.g.
12V,+5V,and+12V),butcouldjustprovideone+5Vpowersupply,e.g.withthehelpofa
simple78x05voltageconverter.
TheMAX232hasasuccessor,theMAX232A.TheICsarealmostidentical,however,the
MAX232Aismuchmoreoftenused(andeasiertoget)thantheoriginalMAX232,andthe
MAX232Aonlyneedsexternalcapacitors1/10ththecapacityofwhattheoriginalMAX232
needs.
ItshouldbenotedthattheMAX232(A)isjustadriver/receiver.Itdoesnotgeneratethe
necessaryRS232sequenceofmarksandspaceswiththerighttiming,itdoesnotdecodetheRS
232signal,itdoesnotprovideaserial/parallelconversion.Allitdoesistoconvertsignal
voltagelevels.Generatingserialdatawiththerighttiminganddecodingserialdatahastobe
donebyadditionalcircuitry,e.g.bya16550UARToroneofthesesmallmicrocontrollers(e.g.
AtmelAVR,MicrochipPIC)gettingmoreandmorepopular.
TheMAX232andMAX232AwereonceratherexpensiveICs,buttodaytheyarecheap.
Ithasalsohelpedthatmanycompaniesnowproduceclones(ie.Sipex).Theseclonessometimes
needdifferentexternalcircuitry,e.g.thecapacitiesoftheexternalcapacitorsvary.Itis
recommendedtocheckthedatasheetoftheparticularmanufacturerofanICinsteadofrelying
onMaxim'soriginaldatasheet.
Theoriginalmanufacturer(andnowsomeclonemanufacturers,too)offersalargeseries
ofsimilarICs,withdifferentnumbersofreceiversanddrivers,voltages,builtinorexternal
capacitors,etc.E.g.TheMAX232andMAX232Aneedexternalcapacitorsfortheinternal
36
voltagepump,whiletheMAX233hasthesecapacitorsbuiltin.TheMAX233isalsobetween
threeandtentimesmoreexpensiveinelectronicshopsthantheMAX232Abecauseofits
internalcapacitors.ItisalsomoredifficulttogettheMAX233thanthegardenvariety
MAX232A.
ATypicalApplication
TheMAX232(A)hastworeceivers(convertsfromRS232toTTLvoltagelevels)andtwo
drivers(convertsfromTTLlogictoRS232voltagelevels).ThismeansonlytwooftheRS232
signalscanbeconvertedineachdirection.TheoldMC1488/1498comboprovidedfourdrivers
andreceivers.
Typicallyapairofadriver/receiveroftheMAX232isusedfor
TXandRX
Andthesecondonefor
CTSandRTS.
Therearenotenoughdrivers/receiversintheMAX232toalsoconnecttheDTR,DSR,andDCD
signals.Usuallythesesignalscanbeomittedwhene.g.communicatingwithaPC'sserial
interface.IftheDTEreallyrequiresthesesignalseitherasecondMAX232isneeded,orsome
otherICfromtheMAX232familycanbeused(ifitcanbefoundinconsumerelectronicshops
atall).AnalternativeforDTR/DSRisalsogivenbelow.
Maxim'sdatasheetexplainstheMAX232familyingreatdetail,includingthepinconfiguration
andhowtoconnectsuchanICtoexternalcircuitry.Thisinformationcanbeusedasisinown
designtogetaworkingRS232interface.Maxim'sdatajustmissesonecriticalpieceof
information:HowexactlytoconnecttheRS232signalstotheIC.Sohereisonepossible
example:
37
MAX232toRS232DB9ConnectionasaDCE
MAX232PinNbr. MAX232PinName Signal Voltage DB9Pin
7
T2out
CTS
RS232 7
R2in
RTS
RS232 8
R2out
RTS
TTL
n/a
10
T2in
CTS
TTL
n/a
11
T1in
TX
TTL
n/a
12
R1out
RX
TTL
n/a
13
R1in
TX
RS232 3
14
T1out
RX
RS232 2
15
GND
GND
InadditiononecandirectlywireDTR(DB9pin4)toDSR(DB9pin6)withoutgoingthrough
anycircuitry.Thisgivesautomatic(braindead)DSRacknowledgmentofanincomingDTR
signal.
Sometimespin6oftheMAX232ishardwiredtoDCD(DB9pin1).Thisisnotrecommended.
Pin6istherawoutputofthevoltagepumpandinverterforthe10Vvoltage.Drawingcurrents
fromthepinleadstoarapidbreakdownofthevoltage,andasaconsequencetoabreakdownof
theoutputvoltageofthetwoRS232drivers.Itisbettertousesoftwarewhichdoesn'tcareabout
DCD,butdoeshardwarehandshakingviaCTS/RTSonly.
ThecircuitryiscompletedbyconnectingfivecapacitorstotheICasitfollows.TheMAX232
needs1.0Fcapacitors,theMAX232Aneeds0.1Fcapacitors.MAX232clonesshowsimilar
differences.Itisrecommendedtoconsultthecorrespondingdatasheet.Atleast16Vcapacitor
38
typesshouldbeused.Ifelectrolyticortantaliccapacitorsareused,thepolarityhastobe
observed.Thefirstpinaslistedinthefollowingtableisalwayswherethepluspoleofthe
capacitorshouldbeconnectedto.
MAX232(A)externalCapacitors
Capacitor +Pin Pin Remark
C1
C2
C3
16
C4
GND 6
C5
16
Thislooksnonintuitive,butbecausepin6is
on10V,GNDgetsthe+connector,andnotthe
GND
The5Vpowersupplyisconnectedto
+5V:Pin16
GND:Pin15
Features
MeetorExceedTIA/EIA232FandITU
RecommendationV.28
OperateWithSingle5VPowerSupply
OperateUpto120kbit/s
TwoDriversandTwoReceivers
30VInputLevels
39
LowSupplyCurrent...8mATypical
DesignedtobeInterchangeableWith
MaximMAX232
ESDProtectionExceedsJESD22
2000VHumanBodyModel(A114A)
Applications
TIA/EIA232F
BatteryPoweredSystems
Terminals
Modems
Computers
Description/orderinginformation
TheMAX232isadualdriver/receiverthatincludesacapacitivevoltagegeneratorto
supplyEIA232voltagelevelsfromasingle5Vsupply.EachreceiverconvertsEIA232inputs
to 5V TTL/CMOS levels. These receivers have a typical threshold of 1.3 V and a typical
hysteresisof0.5V,andcanaccept30Vinputs.EachdriverconvertsTTL/CMOSinputlevels
intoEIA232levels.Thedriver,receiver,andvoltagegeneratorfunctionsareavailableascells
intheTexasInstrumentsLinASIC? library.
40
41
42
43
44
2.8.Liquidcrystaldisplay
Liquidcrystaldisplays(LCDs)havematerials,whichcombinethepropertiesofboth
liquidsandcrystals.Ratherthanhavingameltingpoint,theyhaveatemperaturerangewithin
whichthemoleculesarealmostasmobileastheywouldbeinaliquid,butaregroupedtogether
inanorderedformsimilartoacrystal.
AnLCDconsistsoftwoglasspanels,withtheliquidcrystalmaterialsandwitchedin
betweenthem.Theinnersurfaceoftheglassplatesarecoatedwithtransparentelectrodeswhich
definethecharacter,symbolsorpatternstobedisplayedpolymericlayersarepresentinbetween
theelectrodesandtheliquidcrystal,whichmakestheliquidcrystalmoleculestomaintaina
definedorientationangle.
Oneeachpolarisersarepastedoutsidethetwoglasspanels.Thesepolariserswouldrotate
thelightrayspassingthroughthemtoadefiniteangle,inaparticulardirection.
WhentheLCDisintheoffstate,lightraysarerotatedbythetwopolarisersandthe
liquidcrystal,suchthatthelightrayscomeoutoftheLCDwithoutanyorientation,andhence
theLCDappearstransparent.
Whensufficientvoltageisappliedtotheelectrodes,theliquidcrystalmoleculeswouldbe
alignedinaspecificdirection.ThelightrayspassingthroughtheLCDwouldberotatedbythe
polarisers,whichwouldresultinactivating/highlightingthedesiredcharacters.
The LCDs are lightweight with only a few millimeters thickness. Since the LCDs
consumelesspower,theyarecompatiblewithlowpowerelectroniccircuits,andcanbepowered
forlongdurations.
TheLCDsdontgeneratelightandsolightisneededtoreadthedisplay.Byusing
backlighting,readingispossibleinthedark.TheLCDshavelonglifeandawideoperating
temperaturerange.
ChangingthedisplaysizeorthelayoutsizeisrelativelysimplewhichmakestheLCDs
morecustomersfriendly.
45
TheLCDsusedexclusivelyinwatches,calculatorsandmeasuringinstrumentsarethe
simplesevensegmentdisplays,havingalimitedamountofnumericdata.Therecentadvancesin
technologyhaveresultedinbetterlegibility,moreinformationdisplayingcapabilityandawider
temperature range. These have resulted in the LCDs being extensively used in
telecommunicationsandentertainmentelectronics.TheLCDshaveevenstartedreplacingthe
cathode ray tubes (CRTs) used for the display of text and graphics, and also in small TV
applications.
ThissectiondescribestheoperationmodesofLCDsthendescribehowtoprogramand
interfaceanLCDto8051usingAssemblyandC.
LCDoperation
InrecentyearstheLCDisfindingwidespreadusereplacingLEDs(sevensegmentLEDs
orothermultisegmentLEDs).Thisisduetothefollowingreasons:
1.
ThedecliningpricesofLCDs.
2.
Theabilitytodisplaynumbers,charactersandgraphics.Thisisin
contracttoLEDs,whicharelimitedtonumbersandafewcharacters.
3.
IncorporationofarefreshingcontrollerintotheLCD,thereby
relievingtheCPUofthetaskofrefreshingtheLCD.Inthecontrast,
theLEDmustberefreshedbytheCPUtokeepdisplayingthedata.
4.
Easeofprogrammingforcharactersandgraphics.
LCDpindescription
TheLCDdiscussedinthissectionhas14pins.Thefunctionofeachpinsisgivenin
table.
46
TABLE1:PindescriptionforLCD:
Pin
symbol
I/O
Description
Vss
Ground
Vcc
+5Vpowersupply
VEE
Powersupplytocontrolcontrast
RS
R/W
R/W=0forwrite
R/W=1forread
I/O
Enable
DB0
I/O
The8bitdatabus
DB1
I/O
The8bitdatabus
DB2
I/O
The8bitdatabus
10
DB3
I/O
The8bitdatabus
11
DB4
I/O
The8bitdatabus
12
DB5
I/O
The8bitdatabus
13
DB6
I/O
The8bitdatabus
14
DB7
I/O
The8bitdatabus
TABLE2:LCDCommandCodes
Code
CommandtoLCDInstruction
(hex)
Register
47
Cleardisplayscreen
Returnhome
Decrementcursor
Incrementcursor
Shiftdisplayright
Shiftdisplayleft
Displayoff,cursoroff
Displayoff,cursoron
Displayon,cursoroff
Displayon,cursoron
Displayon,cursorblinking
10
Shiftcursorpositiontoleft
14
Shiftcursorpositiontoright
18
Shifttheentiredisplaytotheleft
1C
Shifttheentiredisplaytotheright
80
Forcecursortobeginningof1stline
C0
Forcecursortobeginningof2ndline
38
2linesand5x7matrix
Uses:
TheLCDsusedexclusivelyinwatches,calculatorsandmeasuringinstrumentsare
the simple sevensegment displays, having a limited amount of numeric data. The recent
advancesintechnologyhaveresultedinbetterlegibility,moreinformationdisplayingcapability
and a wider temperature range. These have resulted in the LCDs being extensively used in
telecommunicationsandentertainmentelectronics.TheLCDshaveevenstartedreplacingthe
cathode ray tubes (CRTs) used for the display of text and graphics, and also in small TV
applications.
48
LCDINTERFACING
SendingcommandsanddatatoLCDswithatimedelay:
Fig21:InterfacingofLCDtoamicrocontroller
Tosendanycommandfromtable2totheLCD,makepinRS=0.
fordata,makeRS=1.ThensendahightolowpulsetotheEpintoenabletheinternallatchof
theLCD.
49
50
mobile subscriber can currently be reached. The MSRN is a temporary number that is
valid only for the duration of a single call.
The HLR generates a response message, which includes the MSRN, and sends it back
across the SS7 network to the MSC. Finally, the MSC attempts to complete the call
using the MSRN provided
international roaming capability, giving consumers a seamless service. This has been a
vital driver in growth, with around 300 million. In the Americas, today's 7 million
subscribers are set to grow rapidly, with market potential of 500 million in population,
due to the introduction of GSM 800, which allows operators using the 800 MHz band
to have access to GSM technology too.
GSM security issues such as theft of service, privacy, and legal interception continue
to raise significant interest in the GSM community. The purpose of this portal is to
raise awareness of these issues with GSM security.
The mobile communications has become one of the driving forces of the
digital revolution. Everyday, millions of people are making phone calls by pressing a
few buttons. Little is known about how one person's voice reaches the other person's
phone that is thousands of miles away. Even less is known about the security
measures and protection behind the system. The complexity of the cell phone is
increasing as people begin sending text messages and digital pictures to their friends
and family. The cell phone is slowly turning into a handheld computer. All the
features and advancements in cell phone technology require a backbone to support it.
The system has to provide security and the capability for growth to accommodate
future enhancements. General System for Mobile Communications, GSM, is one of
the many solutions out there. GSM has been dubbed the "Wireless Revolution" and it
doesn't take much to realize why GSM provides a secure and confidential method of
communication.
Digital containers offer an alternative way of securely delivering content
to consumers. They can offer many advantages, particularly for content delivery over
mobile phone networks:
Scalability
Micro transactions/Micro payments compatibility
Content channel neutrality (heterogeneous networks, unicast /multicast/broadcast etc)
Possibility of DRM
52
Consumer anonymity
Etc.
GSM Modems
A GSM modem can be an external modem device, such as the Wavecom FASTRACK
Modem. Insert a GSM SIM card into this modem, and connect the modem to an
available serial port on your computer.
A GSM modem can be a PC Card installed in a notebook computer, such as the Nokia
Card Phone.
A GSM modem could also be a standard GSM mobile phone with the appropriate
cable and software driver to connect to a serial port on your computer. Phones such
as the Nokia 7110 with a DLR-3 cable, or various Ericsson phones, are often used for
this purpose.
A dedicated GSM modem (external or PC Card) is usually preferable to a GSM
mobile phone. This is because of some compatibility issues that can exist with mobile
phones. For example, if you wish to be able to receive inbound MMS messages with
your gateway, and you are using a mobile phone as your modem, you must utilize a
mobile phone that does not support WAP push or MMS. This is because the mobile
phone automatically processes these messages, without forwarding them via the
modem interface. Similarly some mobile phones will not allow you to correctly
receive SMS text messages longer than 160 bytes (known as concatenated SMS or
long SMS). This is because these long messages are actually sent as separate SMS
messages, and the phone attempts to reassemble the message before forwarding via
the modem interface. (Weve observed this latter problem utilizing the Ericsson
R380, while it does not appear to be a problem with many other Ericsson models.)
53
When you install your GSM modem, or connect your GSM mobile phone to the
computer, be sure to install the appropriate Windows modem driver from the device
manufacturer.
communicate with the device via this driver. An additional benefit of utilizing this
driver is that you can use Windows diagnostics to ensure that the modem is
communicating properly with the computer.
The Now SMS/MMS gateway can simultaneously support multiple modems,
provided that your computer hardware has the available communications port
resources.
54
55
Temperature Range:
Operating temperature: from -200C to +550C
Storage temperature: from -250C to +700C
56
57
Parameters
Supply Voltage
Peak Current at 5 V supply
MIN
5V
Avg
9V
Max
12 V
1.8
(during
transmission
Average Current at 5 V supply
)
35 mA
in idle Mode
Average Current at 5 V supply
13 mA
Function
SMA
RF Antenna connector
USB
(optional)
2 pin Phoenix tm
SIM Connector
Audio link
58
ON
NAME
Designation
Type
X None
TX
Rx
DSR
GND
DTR
NC
Transmit Data
Receive Data
Data Set Ready
Ground
Data
Terminal
NC
Input
Output
Output
Ground
Input
CTS
Ready
Clear to send
Output
I
N
1
2
3
4
5
6
7
59
8
RTS
9
X None
Protecting Modem:
Request to send
NC
Input
NC
Do not expose to the modem to extreme conditions such as High temperatures, direct
sunlight, High Humidity, Rain, Chemicals, Water, Dust etc. For these details see the
specifications given.
Do not drop, Shake or hit the Modem. (Warranty may void)
The Modem should not be used in extreme vibrating conditions
Handle the Antenna and cable with care.
AT commands features:
Line settings:
A serial link handler is set with the following default values Autobaud, 8 bits data, 1
stop bit, no parity, flow control.
Command line
Commands always start with AT (which means attention) and finish with a <CR>
character.
Information responses and result codes
Responses start and end with <CR><LF>,.
If command syntax is incorrect, an ERROR string is returned.
If command syntax is correct but with some incorrect parameters, the +CME ERROR:
<Err> or +CMS ERROR: <SmsErr> strings are returned with different error codes.
If the command line has been performed successfully, an OK string is returned.
In some cases, such as AT+CPIN? or (unsolicited) incoming events, the product
does not return the OK string as a response.
Services provided by GSM
GSM was designed having interoperability with ISDN in mind, and the services
provided by GSM are a subset of the standard ISDN services. Speech is the most
basic, and most important, teleservice provided by GSM.
60
In addition, various data services are supported, with user bit rates up to 9600 bps.
Specially equipped GSM terminals can connect with PSTN, ISDN, Packet Switched
and Circuit Switched Public Data Networks, through several possible methods, using
synchronous or asynchronous transmission. Also supported are Group 3 facsimile
service, videotex, and teletex. Other GSM services include a cell broadcast service,
where messages such as traffic reports, are broadcast to users in particular cells.
A service unique to GSM, the Short Message Service, allows users to send and
receive point-to-point alphanumeric messages up to a few tens of bytes. It is similar to
paging services, but much more comprehensive, allowing bi-directional messages,
store-and-forward delivery, and acknowledgement of successful delivery.
Supplementary services enhance the set of basic teleservices. In the Phase I
specifications, supplementary services include variations of call forwarding and call
barring, such as Call Forward on Busy or Barring of Outgoing International Calls.
Many more supplementary services, including multiparty calls, advice of charge, call
waiting, and calling line identification presentation will be offered in the Phase 2
specifications.
Architecture of the GSM network
A GSM network is composed of several functional entities, whose functions and
interfaces are specified. Figure 1 shows the layout of a generic GSM network. The
GSM network can be divided into three broad parts. The Mobile Station is carried by
the subscriber. The Base Station Subsystem controls the radio link with the Mobile
Station. The Network Subsystem, the main part of which is the Mobile services
Switching Center (MSC), performs the switching of calls between the mobile users,
and between mobile and fixed network users. The MSC also handles the mobility
management operations. Not shown are the Operations
A GSM network is composed of several functional entities, whose functions and
interfaces are specified. Figure 1 shows the layout of a generic GSM network. The
GSM network can be divided into three broad parts. Subscriber carries the Mobile
Station. The Base Station Subsystem controls the radio link with the Mobile Station.
61
The Network Subsystem, the main part of which is the Mobile services Switching
Center (MSC), performs the switching of calls between the mobile users, and between
mobile and fixed network users. The MSC also handles the mobility management
operations. Not shown is the Operations intendance Center, which oversees the proper
operation and setup of the network. The Mobile Station and the Base Station
Subsystem communicate across the Um interface, also known as the air interface or
radio link. The Base Station Subsystem communicates with the Mobile services
Switching Center across the A interface.
62
63
The Home Location Register (HLR) and Visitor Location Register (VLR), together
with the MSC, provide the call-routing and roaming capabilities of GSM. The HLR
contains all the administrative information of each subscriber registered in the
corresponding GSM network, along with the current location of the mobile. The
location of the mobile is typically in the form of the signaling address of the VLR
associated with the mobile as a distributed database station. The actual routing
procedure will be described later. There is logically one HLR per GSM network,
although it may be implemented
The Visitor Location Register (VLR) contains selected administrative information
from the HLR, necessary for call control and provision of the subscribed services, for
each mobile currently located in the geographical area controlled by the VLR.
Although each functional entity can be implemented as an independent unit, all
manufacturers of switching equipment to date implement the VLR together with the
MSC, so that the geographical area controlled by the MSC corresponds to that
controlled by the VLR, thus simplifying the signalling required. Note that the MSC
contains no information about particular mobile stations --- this information is stored
in the location registers.
The other two registers are used for authentication and security purposes. The
Equipment Identity Register (EIR) is a database that contains a list of all valid mobile
equipment on the network, where each mobile station is identified by its International
Mobile Equipment Identity (IMEI). An IMEI is marked as invalid if it has been
reported stolen or is not type approved. The Authentication Center (AuC) is a
protected database that stores a copy of the secret key stored in each subscriber's SIM
card, which is used for authentication and encryption over the radio channel.
64
CHAPTER3
BLOCKDIAGRAM
The objective of this project is to determine the distance of the transmission lines fault
from base station in kilometers. The transmission line system is a common practice followed
in many urban areas. While a fault occurs for some reason, at that time the repairing process
related to that particular cable is difficult due to not knowing the exact location of the cable fault.
The proposed system is to find the exact location of the fault.
POWER
LCD(16x2
)
SUPPLY
VOLTAGE
SENSING
CIRCUIT
MICRO
CONTROLLER
GSM
8051
Fault
switch
es
Relay
Distance:
Distance:
3 Phases should be there and each phase 4 switches. (Each switch 2KM)
GSM to send the msg regarding distance and fault phase
65
CHAPTER4
HARDWARECOMPONENTS
POWERSUPPLYSECTION:
ThissectionismeantforsupplyingPowertoallthesectionsmentionedabove.Itbasically
consistsofaTransformertostepdownthe230Vacto9Vacfollowedbydiodes.Herediodesare
usedtorectifytheactodc.Afterrectificationtheobtainedrippleddcisfilteredusingacapacitor
Filter.Apositivevoltageregulatorisusedtoregulatetheobtaineddcvoltage.
Buthereinthisprojecttwopowersuppliesareusedoneismeanttosupplyoperatingvoltage
forMicrocontrollerandtheotheristosupplycontrolvoltageforRelay.
MICROCONTROLLERSECTION:
Thissectionformsthecontrolunitofthewholeproject.Thissectionbasicallyconsistsofa
MicrocontrollerwithitsassociatedcircuitrylikeCrystalwithcapacitors,Resetcircuitry,Pullup
resistors(ifneeded)andsoon.TheMicrocontrollerformstheheartoftheprojectbecauseit
controls the devices being interfaced and communicates with the devices according to the
programbeingwritten.
Microcontroller (AT89S52):
8-bit Microcontroller with 8K Bytes
In-System Programmable Flash
Features
Compatible with MCS-51 Products
8K Bytes of In-System Programmable (ISP) Flash Memory
Endurance: 1000 Write/Erase Cycles
4.0V to 5.5V Operating Range
Fully Static Operation: 0 Hz to 33 MHz
Three-level Program Memory Lock
66
MAX232SECTIONS:
ThemicrocontrollercancommunicatewiththeserialdevicesusingitssingleSerialPort.The
logiclevels atwhichthisserialportoperates isTTLlogics.Butsomeoftheserialdevices
operateatRS232Logiclevels.ForexamplePCandSmartCardReaderetc.Soinorderto
communicatetheMicrocontrollerwitheitherSmartCardReaderorPC,amismatchbetweenthe
Logiclevelsoccurs.Inordertoavoidthismismatch,inotherwordstomatchtheLogiclevels,a
Serialdriverisused.AndMAX232isaSerialLineDriverusedtoestablishcommunication
betweenmicrocontrollerandPC(orSmartCardReader).
RELAYSECTION:
ThissectionisnothingbutdrivingcircuitryneededtodrivetheLoads.Sothissection
basicallyincludesaRelaywithitsprotectioncircuitry.Thissectionisresponsibletodrivethe
NormalLoadsandalsotheEmergencyLoads.
67
CHAPTER5
WORKING
TheprojectusesthestandardconceptofOhmslawi.e.,whenalowDCvoltageisapplied
atthefeederendthroughaseriesresistor(Cablelines),thencurrentwouldvarydependingupon
thelocationoffaultinthecable.Incasethereisashortcircuit(LinetoGround),thevoltage
acrossseriesresistorschangesaccordingly,whichisthenfedtoanADCtodevelopprecise
digitaldatawhichtheprogrammedmicrocontrollerof8051familywoulddisplayinkilometers.
TheprojectisassembledwithasetofresistorsrepresentingcablelengthinKMsand
faultcreationismadebyasetofswitchesateveryknownKMtocrosschecktheaccuracyofthe
same.ThefaultoccurringataparticulardistanceandtherespectivephaseisdisplayedonaLCD
interfacedtothemicrocontroller.
GSMmoduleisusedtosendasmstothesubstationaboutphasefaultanddistance
calculated.
68
CHAPTER6
SOURCECODE
#include<REGX51.H>
#include<lcd.h>
#include<serial.h>
#include<gsm.h>
/**********************Pindeclarations**********************/
sbitSR1=P1^0;
sbitSR2=P1^1;
sbitSR3=P1^2;
sbitSR4=P1^3;
sbitSY1=P1^4;
sbitSY2=P1^5;
sbitSY3=P1^6;
sbitSY4=P1^7;
sbitSB1=P3^2;
sbitSB2=P3^3;
sbitSB3=P3^4;
sbitSB4=P3^5;
sbitSRR=P2^0;
sbitSYR=P2^1;
sbitSBR=P2^2;
69
bit
st_flag,st_flag1,st_flag2,st_flag3,st_flag4,st_flag5,st_flag6,st_flag7,st_flag8,st_flag9,st_flag10,st
_flag11;
unsignedcharidataD[60];
voidTxMsg(unsignedchar*msg,unsignedchar*mno);
//voiddelay(unsignedint);
/***********************MainProgram*************************/
voidmain()
{
lcd_init();SRR=SYR=SBR=0;
disp_loc(0x80,"WELCOMETO");
disp_str("THEPROJECT");
delay(100);
disp_loc(0x80,"R:NFY:NFB:NF");
SConfig();
while(1)
{
if(SR1==0&&SR2==0&&SR3==0&&SR4==0)
{
SRR=0;disp_loc(0x80,"R:NF");disp_loc(0xC0,"0KM");
elseif(SR1==1&&SR2==0&&SR3==0&&SR4==0)
{
SRR=1;disp_loc(0x80,"R:F");disp_loc(0xC0,"2KM");
if(ES=0;Delay(30);TxMsg("RPhase:Faultat
2KM","+919177848605");Delay(30);ES=1;}
}
elseif(SR1==0&&SR2==1&&SR3==0&&SR4==0)
{
70
SRR=1;disp_loc(0x80,"R:F");disp_loc(0xC0,"4KM");
if(st_flag1==0){ES=0;Delay(30);TxMsg("RPhase:Faultat
4KM","+919177848605");Delay(30);ES=1;}
}
elseif(SR1==0&&SR2==0&&SR3==1&&SR4==0)
{
SRR=1;disp_loc(0x80,"R:F");disp_loc(0xC0,"6KM");
if(st_flag2==0){ES=0;Delay(30);TxMsg("RPhase:Faultat
6KM","+919177848605");Delay(30);ES=1;}
}
elseif(SR1==0&&SR2==0&&SR3==0&&SR4==1)
{
SRR=1;disp_loc(0x80,"R:F");disp_loc(0xC0,"8KM");
if(st_flag3==0){ES=0;Delay(30);TxMsg("RPhase:Faultat
8KM","+919177848605");Delay(30);ES=1;}
}
if(SY1==0&&SY2==0&&SY3==0&&SY4==0)
{
SYR=0;disp_loc(0x86,"Y:NF");disp_loc(0xC6,"0KM");
}
elseif(SY1==1&&SY2==0&&SY3==0&&SY4==0)
{
SYR=1;disp_loc(0x86,"Y:F"); disp_loc(0xC6,"2KM");
if(st_flag4==0){ES=0;Delay(30);TxMsg("YPhase:Faultat
2KM","+919177848605");Delay(30);ES=1;}
}
elseif(SY1==0&&SY2==1&&SY3==0&&SY4==0)
71
{
SYR=1;disp_loc(0x86,"Y:F"); disp_loc(0xC6,"4KM");
if(st_flag5==0){ES=0;Delay(30);TxMsg("YPhase:Faultat
4KM","+919177848605");Delay(30);ES=1;}
}
elseif(SY1==0&&SY2==0&&SY3==1&&SY4==0)
{
SYR=1;disp_loc(0x86,"Y:F"); disp_loc(0xC6,"6KM");
if(st_flag6==0){ES=0;Delay(30);TxMsg("YPhase:Faultat
6KM","+919177848605");Delay(30);ES=1;}
}
elseif(SY1==0&&SY2==0&&SY3==0&&SY4==1)
{
SYR=1;disp_loc(0x86,"Y:F"); disp_loc(0xC6,"8KM");
if(st_flag7==0){ES=0;Delay(30);TxMsg("YPhase:Faultat
8KM","+919177848605");Delay(30);ES=1;}
}
if(SB1==0&&SB2==0&&SB3==0&&SB4==0)
{
SBR=0;disp_loc(0x8C,"B:NF");disp_loc(0xCC,"0KM");
}
elseif(SB1==1&&SB2==0&&SB3==0&&SB4==0)
{
SBR=1;disp_loc(0x8C,"B:F");disp_loc(0xCC,"2KM");
if(st_flag8==0){ES=0;Delay(30);TxMsg("BPhase:Faultat
2KM","+919177848605");Delay(30);ES=1;}
}
72
elseif(SB1==0&&SB2==1&&SB3==0&&SB4==0)
{
SBR=1;disp_loc(0x8C,"B:F");disp_loc(0xCC,"4KM");
if(st_flag9==0){ES=0;Delay(30);TxMsg("BPhase:Faultat
4KM","+919177848605");Delay(30);ES=1;}
}
elseif(SB1==0&&SB2==0&&SB3==1&&SB4==0)
{
SBR=1;disp_loc(0x8C,"B:F");disp_loc(0xCC,"6KM");
if(st_flag10==0){ES=0;Delay(30);TxMsg("BPhase:Faultat
6KM","+919177848605");Delay(30);ES=1;}
}
elseif(SB1==0&&SB2==0&&SB3==0&&SB4==1)
{
SBR=1;disp_loc(0x8C,"B:F");disp_loc(0xCC,"8KM");
if(st_flag11==0){ES=0;Delay(30);TxMsg("BPhase:Faultat
8KM","+919177848605");Delay(30);ES=1;}
}
}
}
73
CHAPTER7
SOFTWARE COMPONENTS
About Keil
1.
2.
3.
4.
74
5.
Save the Project by typing suitable project name with no extension in u r own
folder sited in either C:\ or D:\
6.
7.
8.
9.
75
10.
Then Click on OK
11.
12.
13.
14.
Now double click on the Target1, you would get another option Source group
1 as shown in next page.
76
15.
Click on the file option from menu bar and select new
16.
The next screen will be as shown in next page, and just maximize it by double
clicking on its blue boarder.
77
17.
18.
For a program written in Assembly, then save it with extension . asm and
for C based program save it with extension .C
78
19.
Now right click on Source group 1 and click on Add files to Group Source
20.
Now you will get another window, on which by default C files will appear.
21.
Now select as per your file extension given while saving the file
22.
23.
Now Press function key F7 to compile. Any error will appear if so happen.
79
24.
25.
26.
Then Click OK
27.
Now Click on the Peripherals from menu bar, and check your required port as
shown in fig below
80
28.
29.
30.
81
Embedded C:
What is an embedded system?
An embedded system is an application that contains at least one programmable
computer and which is used by individuals who are, in the main, unaware that the system
is computer-based.
Which programming language should you use?
Having decided to use an 8051 processor as the basis of your embedded system, the
next key decision that needs to be made is the choice of programming language. In order
to identify a suitable language for embedded systems, we might begin by making the
following observations:
Computers (such as microcontroller, microprocessor or DSP chips) only accept
instructions in machine code (object codes). Machine code is, by definition, in
the language of the computer, rather than that of the programmer. Interpretation of
the code by the programmer is difficult and error prone.
All software, whether in assembly, C, C++, Java or Ada must ultimately be
translated into machine code in order to be executed by the computer.
Embedded processors like the 8051 have limited processor power and very
limited memory available: the language used must be efficient.
The language chosen should be in common use.
Summary of C language Features:
It is mid-level, with high-level features (such as support for functions and modules),
and low-level features (such as good access to hardware via pointers).
It is very efficient.
82
// SFR declarations
// Infinite loop
83
CHAPTER8
FUTURESCOPE
Theprojectisdesignedtosendinanalertmessageassoonasthereisafault.Inthis
model,wepredicttheplaceoffaultusingthedistancefrompoletopole.Infuturewecanhavea
GPSattachedtoitthatwouldexactlysendthelocationintermsoflongitudeandlatitude.
Asafutureenhancement,ZIGBEEmodulesofProSeriescanbeusedtoimprovethe
rangeofthecommunication.
84
CHAPTER9
RESULTS
85
86
CHAPTER10
CONCLUSION
TheprojectDISTANCECALCULATIONFORTRANSMISSIONLINEFAULThas
beensuccessfullydesignedandtested.Integratingfeaturesofallthehardwarecomponentsused
havedevelopedit.Presenceofeverymodulehasbeenreasonedoutandplacedcarefullythus
contributingtothebestworkingoftheunit.Secondly,usinghighlyadvancedICsandwiththe
helpofgrowingtechnologytheprojecthasbeensuccessfullyimplemented.
ThemicrocontrollerdisplaysthemessageregardingthefaultlocationontheLCD.GSM
modulepresentonthereceiverunittransfersthismessagetothedesiredlocation.Thusfault
detection andprotection of the circuit is achieved. Nonetheless, there are still new ideas to
improveitandtoaddnewfunctionalitytoit.ParameterssuchasCurrentRatingandImpedence
canbecalculated.
GSMmoduleisusedtosendasmstothesubstationaboutphasefaultanddistance
calculated.
87
CHAPTER11
REFERENCES
REFERENCES
8051MicrocontrollerAndEmbeddedSystems.
Mohd.Mazidi.
The8051MicrocontrollerArchitecture,Programming&Applications
KennethJ.Ayala
FundamentalsOfMicroprocessorsandMicrocomputers
B.Ram
MicroprocessorArchitecture,Programming&Applications
RameshS.Gaonkar
ElectronicComponents
D.V.Prasad
NAMEOFTHESITES
1.
www.mitel.databook.com
2.
www.atmel.databook.com
3.
www.franklin.com
4.
www.keil.com
5.
www.8051projects.com
6.
www.microsoftsearch.com
7.
www.geocities.com
8.
www.alldatasheet.com
9.
www.bioenable.com
88