Circuitplanet - Password Based Electrical Appliances Control System Using 89c51 Micrcontroller

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 92

0

More NextBlog

CreateBlog SignIn

Advertisewithus

Sep21,2009

PASSWORDBASEDELECTRICALAPPLIANCES
CONTROLSYSTEMUSING89C51
MICRCONTROLLER

ABSTRACT
Securityisprimeconcerninourdaytodaylife.Everyonewantstobeasmuch
assecureastobepossible.Anaccesscontrolsystemsformsavitallinkina
securitychain.Themicrocontrollerbaseddigitallockpresentedhereisan
accesscontrolsystemthatallowsonlyauthorizedpersonstoaccessarestricted
area.Thissystemisbestsuitableforcorporateoffices,ATMsandhomesecurity.
Thesystemcomprisesasmallelectronicunitwithanumerickeypad,whichis
fixedoutsidetheentrydoortocontrolasolenoidoperatedlockwiththehelpofa
steppermotor.WhenanauthorizedpersonenterspredetermineduserIDand

PopularPosts

Solarpowerrelatedschematics
1381solarengineBeamsolarengineAA
BatterySolarChargerCurrentmeterusedto
measurethecurrentfromasolarpanel.It
hasvery...
PASSWORDBASED
ELECTRICALAPPLIANCES
CONTROLSYSTEMUSING
89C51MICRCONTROLLER
ABSTRACTSecurityisprime
concerninourdaytodaylife.Everyone
wantstobeasmuch...
Designwithmicrocontrollers:FinalyearECE
projects
ATmega644JTAGDebuggerUltrasonic
HapticVision(MP4,MP4,MP4)Haptic
appointmentmanager(MP4lotsofwind
andconstructionn...

passwordviathekeypad,thesteppermotorisoperatedforalimitedtimeto
unlatchthesolenoidoperatedlocksothedoorcanbeopen.Attheendofpreset
delay,thesteppermotorisoperatedinreversedirectionandthedoorgets
lockedagain.
Whenthecodehasbeenincorrectlyenteredthreetimesinarow,thecodelock
willswitchtoblockmode.Thisfunctionthwartsanyattemptbyhackersto
quicklytryalargenumberofcodesinasequence.Iftheuserforgetshis
password,thecodelockcanbeaccessedbyaunique10digitadministrator
password.Thesecretcodecanbechangedanytimeafterenteringthecurrent
code(Mastercode).

Microcontrollerprojectsandapplication
resources
MicrocontrollerApplicationsCarparking
systemusingMicrocontroller8051,74157,
555ElectronicdoorcodelockwithPI...
Electronicprojectsrelatedtocomputers
Analogtodigitalanddigitaltoanalog
converterforUSBAudiovideoswitchan8
inputxoutputaudio/videoswitchmoduleto
be...
8086pinconfiguration

Abuzzerisprovidedforaudioacknowledgmentofthekeyimpression.
Wheneverakeyispressedonthenumerickeypad,thesystemacknowledges
theimpressionbyashortbeepsound.ThisbuzzerisdrivenbyanNPN
transistor.
Thisprojectusesregulated5V,500mApowersupply.7805threeterminal
voltageregulatorisusedforvoltageregulation.Bridgetypefullwaverectifieris
usedtorectifytheacoutputofsecondaryof230/12Vstepdowntransformer.
INTRODUCTION
Anembeddedsystemisacombinationofsoftwareandhardwaretoperforma
dedicatedtask.
SomeofthemaindevicesusedinembeddedproductsareMicroprocessorsand
Microcontrollers.
Microprocessorsarecommonlyreferredtoasgeneralpurposeprocessorsas
theysimplyaccepttheinputs,processitandgivetheoutput.
Incontrast,amicrocontrollernotonlyacceptsthedataasinputsbutalso
manipulatesit,interfacesthedatawithvariousdevices,controlsthedataand
thusfinallygivestheresult.

ads

Download
Free Download
www.un...

Links

ClicknScroll

TheProjectEmbeddedPasswordbasedElectricalAppliancescontrolsystem
using89C51Microcontrollerisanexcellentprojectthatprovidessecurityinevery
way.Thisprojectisveryusefulinplaceswheresecurityismust.

Download
Free Download

BLOCKDIAGRAM

www.unzipper.com

Therewasanerrorinthisgadget

TransistorDriver
Circuit

Resetcircuit

Crystal

Buzzer
8051
Microcontroller
BLOCKDESCRIPTION
POWERSUPPLY:
Theinputtothecircuitisappliedfromtheregulatedpowersupply.Thea.c.input
i.e.,230Vfromthemainssupplyisstepdownbythetransformerto12Vandis
fedtoarectifier.Theoutputobtainedfromtherectifierisapulsatingd.cvoltage.
Soinordertogetapured.cvoltage,theoutputvoltagefromtherectifierisfedto

afiltertoremoveanya.ccomponentspresentevenafterrectification.Now,this
voltageisgiventoavoltageregulatortoobtainapureconstantdcvoltage.
230V
AC
50Hz

Fig:Powersupply
Transformer:
Usually,DCvoltagesarerequiredtooperatevariouselectronicequipmentand
thesevoltagesare5V,9Vor12V.Butthesevoltagescannotbeobtaineddirectly.
Thusthea.cinputavailableatthemainssupplyi.e.,230Vistobebroughtdown

totherequiredvoltagelevel.Thisisdonebyatransformer.Thus,astepdown
transformerisemployedtodecreasethevoltagetoarequiredlevel.
Rectifier:
Theoutputfromthetransformerisfedtotherectifier.ItconvertsA.C.into
pulsatingD.C.Therectifiermaybeahalfwaveorafullwaverectifier.Inthis
project,abridgerectifierisusedbecauseofitsmeritslikegoodstabilityandfull
waverectification.
Filter:
Capacitivefilterisusedinthisproject.Itremovestheripplesfromtheoutputof
rectifierandsmoothenstheD.C.Outputreceivedfromthisfilterisconstantuntil
themainsvoltageandloadismaintainedconstant.However,ifeitherofthetwo
isvaried,D.C.voltagereceivedatthispointchanges.Thereforearegulatoris
appliedattheoutputstage.
Voltageregulator:
Asthenameitselfimplies,itregulatestheinputappliedtoit.Avoltageregulatoris
anelectricalregulatordesignedtoautomaticallymaintainaconstantvoltage
level.Inthisproject,powersupplyof5Vand12Varerequired.Inordertoobtain
thesevoltagelevels,7805and7812voltageregulatorsaretobeused.Thefirst
number78representspositivesupplyandthenumbers05,12representthe
requiredoutputvoltagelevels.
MICROCONTROLLERS:
Microprocessorsandmicrocontrollersarewidelyusedinembeddedsystems
products.Microcontrollerisaprogrammabledevice.AmicrocontrollerhasaCPU
inadditiontoafixedamountofRAM,ROM,I/Oportsandatimerembeddedall
onasinglechip.ThefixedamountofonchipROM,RAMandnumberofI/O
portsinmicrocontrollersmakesthemidealformanyapplicationsinwhichcost
andspacearecritical.

TheIntel8051isaHarvardarchitecture,singlechipmicrocontroller(C)which
wasdevelopedbyIntelin1980foruseinembeddedsystems.Itwaspopularin
the1980sandearly1990s,buttodayithaslargelybeensupersededbyavast
rangeofenhanceddeviceswith8051compatibleprocessorcoresthatare
manufacturedbymorethan20independentmanufacturersincludingAtmel,
InfineonTechnologiesandMaximIntegratedProducts.
8051isan8bitprocessor,meaningthattheCPUcanworkononly8bitsofdata
atatime.Datalargerthan8bitshastobebrokeninto8bitpiecestobe
processedbytheCPU.8051isavailableindifferentmemorytypessuchasUV
EPROM,FlashandNVRAM.
ThepresentprojectisimplementedonKeilUvision.Inordertoprogramthe
device,Proloadtoolhasbeenusedtoburntheprogramontothemicrocontroller.
Thefeatures,pindescriptionofthemicrocontrollerandthesoftwaretoolsused
arediscussedinthefollowingsections.
FEATURESOFAT89C51:
4KBytesofReprogrammableFlashMemory.
RAMis128bytes.
2.7Vto6VOperatingRange.
FullyStaticOperation:0Hzto24MHz.
TwolevelProgramMemoryLock.
128x8bitInternalRAM.
32ProgrammableI/OLines.
Two16bitTimer/Counters.
SixInterruptSources.

ProgrammableSerialUARTChannel.
LowpowerIdleandPowerdownModes.
Description:
TheAT89C51isalowvoltage,highperformanceCMOS8bitmicrocomputer
with4KbytesofFlashprogrammablememory.Thedeviceismanufacturedusing
Atmelshighdensitynonvolatilememorytechnologyandiscompatiblewiththe
industrystandardMCS51instructionset.Bycombiningaversatile8bitCPU
withFlashonamonolithicchip,theAtmelAT89C51isapowerfulmicrocomputer,
whichprovidesahighlyflexibleandcosteffectivesolutiontomanyembedded
controlapplications.
Inaddition,theAT89C51isdesignedwithstaticlogicforoperationdowntozero
frequencyandsupportstwosoftwareselectablepowersavingmodes.TheIdle
ModestopstheCPUwhileallowingtheRAM,timer/counters,serialportand
interruptsystemtocontinuefunctioning.ThepowerdownmodesavestheRAM
contentsbutfreezestheoscillatordisablingallotherchipfunctionsuntilthenext
hardwarereset.

Fig:Pindiagram

Fig:Blockdiagram
PINDESCRIPTION:
Vcc
Pin40providessupplyvoltagetothechip.Thevoltagesourceis+5V.
GND
Pin20istheground.
XTAL1andXTAL2
XTAL1andXTAL2aretheinputandoutput,respectively,ofaninvertingamplifier
thatcanbeconfiguredforuseasanonchiposcillator,asshowninFigure11.
Eitheraquartzcrystalorceramicresonatormaybeused.Todrivethedevice
fromanexternalclocksource,XTAL2shouldbeleftunconnectedwhileXTAL1is
driven,asshowninthebelowfigure.Therearenorequirementsontheduty
cycleoftheexternalclocksignal,sincetheinputtotheinternalclockingcircuitry
isthroughadividebytwoflipflop,butminimumandmaximumvoltagehighand
lowtimespecificationsmustbeobserved.

Fig:OscillatorConnections
C1,C2=30pF10pFforCrystals
=40pF10pFforCeramicResonators

Fig:ExternalClockDriveConfiguration
RESET

Pin9istheresetpin.Itisaninputandisactivehigh.Uponapplyingahighpulse
tothispin,themicrocontrollerwillresetandterminatealltheactivities.Thisis
oftenreferredtoasapoweronreset.
EA(Externalaccess)
Pin31isEA.Itisanactivelowsignal.Itisaninputpinandmustbeconnectedto
eitherVccorGNDbutitcannotbeleftunconnected.
The8051familymembersallcomewithonchipROMtostoreprograms.Insuch
cases,theEApinisconnectedtoVcc.IfthecodeisstoredonanexternalROM,
theEApinmustbeconnectedtoGNDtoindicatethatthecodeisstored
externally.
PSEN(Programstoreenable)
Thisisanoutputpin.
ALE(Addresslatchenable)
Thisisanoutputpinandisactivehigh.
Ports0,1,2and3
ThefourportsP0,P1,P2andP3eachuse8pins,makingthem8bitports.All
theportsuponRESETareconfiguredasinput,sinceP0P3havevalueFFHon
them.
Port0(P0)
Port0isalsodesignatedasAD0AD7,allowingittobeusedforbothaddress
anddata.ALEindicatesifP0hasaddressordata.WhenALE=0,itprovidesdata
D0D7,butwhenALE=1,ithasaddressA0A7.Therefore,ALEisusedfor
demultiplexingaddressanddatawiththehelpofaninternallatch.
Whenthereisnoexternalmemoryconnection,thepinsofP0mustbe
connectedtoa10Kohmpullupresistor.ThisisduetothefactthatP0isan
opendrain.WithexternalpullupresistorsconnectedtoP0,itcanbeusedasa

simpleI/O,justlikeP1andP2.ButtheportsP1,P2andP3donotneedanypull
upresistorssincetheyalreadyhavepullupresistorsinternally.Uponreset,ports
P1,P2andP3areconfiguredasinputports.
Port1andPort2
Withnoexternalmemoryconnection,bothP1andP2areusedassimpleI/O.
Withexternalmemoryconnections,port2mustbeusedalongwithP0toprovide
the16bitaddressfortheexternalmemory.Port2isdesignatedasA8A15
indicatingitsdualfunction.WhileP0providesthelower8bitsviaA0A7,itisthe
jobofP2toprovidebitsA8A15oftheaddress.
Port3
Port3occupiesatotalof8pins,pins10through17.Itcanbeusedasinputor
output.P3doesnotneedanypullupresistors,thesameasport1andport2.
Port3hasanadditionalfunctionofprovidingsomeextremelyimportantsignals
suchasinterrupts.

Table:Port3AlternateFunctions
Machinecycleforthe8051
TheCPUtakesacertainnumberofclockcyclestoexecuteaninstruction.Inthe
8051family,theseclockcyclesarereferredtoasmachinecycles.Thelengthof
themachinecycledependsonthefrequencyofthecrystaloscillator.Thecrystal
oscillator,alongwithonchipcircuitry,providestheclocksourceforthe8051
CPU.
Thefrequencycanvaryfrom4MHzto30MHz,dependinguponthechiprating
andmanufacturer.Buttheexactfrequencyof11.0592MHzcrystaloscillatoris

usedtomakethe8051basedsystemcompatiblewiththeserialportoftheIBM
PC.
Intheoriginalversionof8051,onemachinecyclelasts12oscillatorperiods.
Therefore,tocalculatethemachinecycleforthe8051,thecalculationismade
as1/12ofthecrystalfrequencyanditsinverseistaken.
Theassemblylanguageprogramiswrittenandthisprogramhastobedumped
intothemicrocontrollerforthehardwarekittofunctionaccordingtothesoftware.
TheprogramdumpedinthemicrocontrollerisstoredintheFlashmemoryinthe
microcontroller.Beforethat,thisFlashmemoryhastobeprogrammedandis
discussedinthenextsection.
PROGRAMMINGTHEFLASH:
TheAT89C51isnormallyshippedwiththeonchipFlashmemoryarrayinthe
erasedstate(thatis,contents=FFH)andreadytobeprogrammed.The
programminginterfaceacceptseitherahighvoltage(12volt)oralowvoltage
(VCC)programenablesignal.Thelowvoltageprogrammingmodeprovidesa
convenientwaytoprogramtheAT89C51insidetheuserssystem,whilethe
highvoltageprogrammingmodeiscompatiblewithconventionalthirdparty
FlashorEPROMprogrammers.TheAT89C51isshippedwitheitherthehigh
voltageorlowvoltageprogrammingmodeenabled.Therespectivetopside
markinganddevicesignaturecodesarelistedinthefollowingtable.

TheAT89C51codememoryarrayisprogrammedbytebyteineither
programmingmode.
ToprogramanynonblankbyteintheonchipFlashMemory,theentirememory
mustbeerasedusingtheChipEraseMode.

ProgrammingAlgorithm:
BeforeprogrammingtheAT89C51,theaddress,dataandcontrolsignalsshould
besetupaccordingtotheFlashprogrammingmodetable.Toprogramthe
AT89C51,thefollowingstepsshouldbeconsidered:
1.Inputthedesiredmemorylocationontheaddresslines.
2.Inputtheappropriatedatabyteonthedatalines.
3.Activatethecorrectcombinationofcontrolsignals.
4.RaiseEA/VPPto12Vforthehighvoltageprogrammingmode.
5.PulseALE/PROGoncetoprogramabyteintheFlasharrayorthelockbits.
Thebytewritecycleisselftimedandtypicallytakesnomorethan1.5ms.
Repeatsteps1through5,changingtheaddressanddatafortheentirearrayor
untiltheendoftheobjectfileisreached.
DataPolling:
TheAT89C51featuresDataPollingtoindicatetheendofawritecycle.Duringa
writecycle,anattemptedreadofthelastbytewrittenwillresultinthecomplement
ofthewrittendatumonPO.7.Oncethewritecyclehasbeencompleted,true
dataarevalidonalloutputs,andthenextcyclemaybegin.DataPollingmay
beginanytimeafterawritecyclehasbeeninitiated.
Ready/Busy:
TheprogressofbyteprogrammingcanalsobemonitoredbytheRDY/BSY
outputsignal.P3.4ispulledlowafterALEgoeshighduringprogrammingto
indicateBUSY.P3.4ispulledhighagainwhenprogrammingisdonetoindicate
READY.
ChipErase:

TheentireFlasharrayiserasedelectricallybyusingthepropercombinationof
controlsignalsandbyholdingALE/PROGlowfor10ms.Thecodearrayis
writtenwithall1s.Thechiperaseoperationmustbeexecutedbeforethecode
memorycanbereprogrammed.
ReadingtheSignatureBytes:
Thesignaturebytesarereadbythesameprocedureasanormalverificationof
locations030H,031H,and032H,exceptthatP3.6andP3.7mustbepulledtoa
logiclow.Thevaluesreturnedareasfollows.
(030H)=1EHindicatesmanufacturedbyAtmel
(031H)=51Hindicates89C51
(032H)=FFHindicates12Vprogramming
(032H)=05Hindicates5Vprogramming
ProgrammingInterface:
EverycodebyteintheFlasharraycanbewrittenandtheentirearraycanbe
erasedbyusingtheappropriatecombinationofcontrolsignals.Thewrite
operationcycleisselftimedandonceinitiated,willautomaticallytimeitselfto
completion.AllmajorprogrammingvendorsofferworldwidesupportfortheAtmel
microcontrollerseries.

Fig:FlashProgrammingModes

Fig:ProgrammingtheFlash

Fig:VerifyingtheFlash
EEPROM:
Inthedesignofallmicroprocessorsbasedsystems,semiconductormemories
areusedasprimarystorageforcodeanddata.Semiconductormemoriesare
connecteddirectlytotheCPUandtheyarethememorythattheCPUfirstasks

forinformation(codeanddata).Forthisreason,semiconductormemoriesare
sometimesreferredtoasprimarymemory.
ImportantTerminologycommontoallSemiconductorMemories:
Memorycapacity:
Thenumberofbitsthatasemiconductormemorychipcanstoreiscalledchip
capacity.ItcanbeinunitsofKilobits,Megabitsandsoon.Thismustbe
distinguishedfromthestoragecapacityofcomputersystem.Whilethememory
capacityofamemoryICchipisalwaysgiveninbits,thememorycapacityofa
computersystemisgiveninbytes.
Memoryorganization:
MemorychipsareorganizedintoanumberoflocationswithintheIC.Each
locationcanhold1bit,4bits,8bitsoreven16bits,dependingonhowitis
designedinternally.Thenumberofbitsthateachlocationwithinthememorychip
canholdisalwaysequaltothenumberofdatapinsonthechip.i.e.,thetotal
numberofbitsthatamemorychipcanstoreisequaltothenumberoflocations
timesthenumberofdatabitsperlocation.
Speed:
Oneofthemostimportantcharacteristicsofamemorychipisthespeedatwhich
itsdatacanbeaccessed.Thespeedofthememorychipiscommonlyreferred
toasitsaccesstime.Theaccesstimeofmemorychipvariesfromafew
nanosecondstohundredsofnanoseconds,dependingontheICtechnology
usedinthedesignandfabricationprocess.
ThedifferenttypesofmemoriesareRAM,ROM,EPROMandEEPROM.
RAMandROMareinbuiltinthemicroprocessor.
Thisprojectrequiresthedatasuchastheuseridentificationnumberand
passwordtobestoredpermanently.Thusthisdatahastobestoredinsucha
locationwhereitcannotbeerasedwhenpowerfailsandalsothedatashouldbe

allowedtomakechangesinitwithoutthesysteminterfacei.e.,thereshouldbea
provisioninsuchawaythatthedatashouldbeaccessed(ormodified)whileitis
insystemboardbutnotexternalerasureandprogramming.Theflashmemory
inbuiltinthemicrocontrollercanerasetheentirecontentsinlessthanasecond
andtheerasuremethodiselectrical.ButthemajordrawbackofFlashmemoryis
thatwhenflashmemoryscontentsareerased,theentiredevicewillbeerased
butnotadesiredsectionorbyte.
Forthispurpose,wepreferEEPROMinourproject.
EEPROM(ElectricallyErasableProgrammableReadonlymemory)
EEPROMhasseveraladvantagesoverothermemorydevices,suchasthefact
thatitsmethodoferasureiselectricalandthereforeinstant.Inaddition,in
EEPROMonecanselectwhichbytetobeerased,incontrasttoflash,inwhich
theentirecontentsofROMareerased.ThemainadvantageofEEPROMisthat
onecanprogramanderaseitscontentswhileitisinsystemboard.Itdoesnot
requirephysicalremovalofthememorychipfromitssocket.Ingeneral,thecost
perbitforEEPROMismuchhigherwhencomparedtootherdevices.
TheEEPROMusedinthisprojectis24C04type.
Featuresof24C04EEPROM:
1millionerase/writecycleswith40yearsdataretention.
Singlesupplyvoltage:
3vto5.5vforst24x04versions.
2.5vto5.5vforst25x04versions.
Hardwarewritecontrolversions:
st24w04andst25w04.
Programmablewriteprotection.
Twowireserialinterface,fullyi2cbuscompatible.

Byteandmultibytewrite(upto4bytes).
Pagewrite(upto8bytes).
Byte,randomandsequentialreadmodes
Selftimedprogrammingcycle
Automaticaddressincrementing
EnhancedESD/Latchupperformances

DIPPinConnectionsSOPinConnection

Fig:SignalNames

Fig:LogicDiagram
DESCRIPTION
The24C04isa4Kbitelectricallyerasableprogrammablememory(EEPROM),
organizedas2blocksof256x8bits.TheyaremanufacturedinST
MicroelectronicsHiEnduranceAdvancedCMOStechnologywhichguarantees
anenduranceofonemillionerase/writecycleswithadataretentionof40years.
BothPlasticDualinLineandPlasticSmallOutlinepackagesareavailable.The
memoriesarecompatiblewiththeI2Cstandard,twowireserialinterfacewhich
usesabidirectionaldatabusandserialclock.Thememoriescarryabuiltin4
bit,uniquedeviceidentificationcode(1010)correspondingtotheI2Cbus
definition.Thisisusedtogetherwith2chipenableinputs(E2,E1)sothatupto4
x4KdevicesmaybeattachedtotheI2Cbusandselectedindividually.The
memoriesbehaveasaslavedeviceintheI2Cprotocolwithallmemory
operationssynchronizedbytheserialclock.Readandwriteoperationsare
initiatedbyaSTARTconditiongeneratedbythebusmaster.TheSTART
conditionisfollowedbyastreamof7bits(identificationcode1010),plusone
read/writebitandterminatedbyanacknowledgebit.

Table:DeviceSelectMode

Table:OperatingModes
Whenwritingdatatothememoryitrespondstothe8bitsreceivedbyasserting
anacknowledgebitduringthe9thbittime.Whendataisreadbythebusmaster,
itacknowledgesthereceiptofthedatabytesinthesameway.Datatransfersare
terminatedwithaSTOPcondition.
PowerOnReset:VCClockoutwriteprotect.
Inordertopreventdatacorruptionandinadvertentwriteoperationsduringpower
up,aPowerOnReset(POR)circuitisimplemented.UntiltheVCCvoltagehas
reachedthePORthresholdvalue,theinternalresetisactive,alloperationsare
disabledandthedevicewillnotrespondtoanycommand.Inthesameway,
whenVCCdropsdownfromtheoperatingvoltagetobelowthePORthreshold
value,alloperationsaredisabledandthedevicewillnotrespondtoany
command.AstableVCCmustbeappliedbeforeapplyinganylogicsignal.
SIGNALDESCRIPTIONS
SerialClock(SCL).
TheSCLinputpinisusedtosynchronizealldatainandoutofthememory.A
resistorcanbeconnectedfromtheSCLlinetoVCCtoactasapullup.
SerialData(SDA).
TheSDApinisbidirectionalandisusedtotransferdatainoroutofthememory.
ItisanopendrainoutputthatmaybewireORedwithotheropendrainoropen

collectorsignalsonthebus.AresistormustbeconnectedfromtheSDAbusline
toVCCtoactaspullup.
ChipEnable(E1E2).
Thesechipenableinputsareusedtosetthe2leastsignificantbits(b2,b3)of
the7bitdeviceselectcode.Theseinputsmaybedrivendynamicallyortiedto
VCCorVSStoestablishthedeviceselectcode.
ProtectEnable(PRE).
ThePREinputpin,inadditiontothestatusoftheBlockAddressPointerbit(b2,
location1FFhasinbelowfigure),setsthePREwriteprotectionactive.

Fig:MemoryProtection
Mode(MODE).
TheMODEinputisavailableonpin7andmaybedrivendynamically.Itmustbe
atVILorVIHfortheByteWritemode,VIHforMultibyteWritemodeorVILfor
PageWritemode.Whenunconnected,theMODEinputisinternallyreadasVIH
(MultibyteWritemode).
WriteControl(WC).

AnhardwareWriteControlfeature(WC)isofferedonlyforST24W04and
ST25W04versionsonpin7.Thisfeatureisusefultoprotectthecontentsofthe
memoryfromanyerroneouserase/writecycle.TheWriteControlsignalisused
toenable(WC=VIH)ordisable(WC=VIL)theinternalwriteprotection.When
unconnected,theWCinputisinternallyreadasVILandthememoryareaisnot
writeprotected.
DEVICEOPERATION
I2CBusBackground
TheST24/25x04supportstheI2Cprotocol.Thisprotocoldefinesanydevicethat
sendsdataontothebusasatransmitterandanydevicethatreadsthedataasa
receiver.Thedevicethatcontrolsthedatatransferisknownasthemasterand
theotherastheslave.Themasterwillalwaysinitiateadatatransferandwill
providetheserialclockforsynchronization.
TheST24/25x04isalwaysslavedevicesinallcommunications.

Fig:I2CProtocol
StartCondition.

STARTisidentifiedbyahightolowtransitionoftheSDAlinewhiletheclockSCL
isstableinthehighstate.ASTARTconditionmustprecedeanycommandfor
datatransfer.Exceptduringaprogrammingcycle,theST24/25x04continuously
monitortheSDAandSCLsignalsforaSTARTconditionandwillnotrespond
unlessoneisgiven.
StopCondition.
STOPisidentifiedbyalowtohightransitionoftheSDAlinewhiletheclockSCL
isstableinthehighstate.ASTOPconditionterminatescommunicationbetween
theST24/25x04andthebusmaster.ASTOPconditionattheendofaRead
command,afterandonlyafteraNoAcknowledge,forcesthestandbystate.A
STOPconditionattheendofaWritecommandtriggerstheinternalEEPROM
writecycle.
AcknowledgeBit(ACK).
Anacknowledgesignalisusedtoindicateasuccessfuldatatransfer.Thebus
transmitter,eithermasterorslave,willreleasetheSDAbusaftersending8bitsof
data.Duringthe9thclockpulseperiodthereceiverpullstheSDAbuslowto
acknowledgethereceiptofthe8bitsofdata.
DataInput.
DuringdatainputtheST24/25x04sampletheSDAbussignalontherisingedge
oftheclockSCL.NotethatforcorrectdeviceoperationtheSDAsignalmustbe
stableduringtheclocklowtohightransitionandthedatamustchangeONLY
whentheSCLlineislow.
MemoryAddressing.
TostartcommunicationbetweenthebusmasterandtheslaveST24/25x04,the
mastermustinitiateaSTARTcondition.Followingthis,themastersendsontothe
SDAbusline8bits(MSBfirst)correspondingtothedeviceselectcode(7bits)
andaREADorWRITEbit.The4mostsignificantbitsofthedeviceselectcode
arethedevicetypeidentifier,correspondingtotheI2Cbusdefinition.Forthese
memoriesthe4bitsarefixedas1010b.Thefollowing2bitsidentifythespecific

memoryonthebus.TheyarematchedtothechipenablesignalsE2,E1.Thus
upto4x4Kmemoriescanbeconnectedonthesamebusgivingamemory
capacitytotalof16Kilobits.AfteraSTARTconditionanymemoryonthebuswill
identifythedevicecodeandcomparethefollowing2bitstoitschipenableinputs
E2,E1.The7thbitsentistheblocknumber(oneblock=256bytes).The8thbit
sentisthereadorwritebit(RW),thisbitissetto1forreadand0forwrite
operations.Ifamatchisfound,thecorrespondingmemorywillacknowledgethe
identificationontheSDAbusduringthe9thbittime.

Fig:ACWaveforms
WriteOperations
TheMultibyteWritemode(onlyavailableontheST24/25C04versions)is
selectedwhentheMODEpinisatVIHandthePageWritemodewhenMODE
pinisatVIL.TheMODEpinmaybedrivendynamicallywithCMOSinputlevels.
FollowingaSTARTconditionthemastersendsadeviceselectcodewiththeRW
bitresetto0.Thememoryacknowledgesthisandwaitsforabyteaddress.The
byteaddressof8bitsprovidesaccesstooneblockof256bytesofthememory.
Afterreceiptofthebyteaddressthedeviceagainrespondswithan
acknowledge.FortheST24/25W04versions,anywritecommandwithWC=1
willnotmodifythememorycontent.

ByteWrite.
IntheByteWritemodethemastersendsonedatabyte,whichisacknowledged
bythememory.ThemasterthenterminatesthetransferbygeneratingaSTOP
condition.TheWritemodeisindependentofthestateoftheMODEpinwhich
couldbeleftfloatingifonlythismodewastobeused.Howeveritisnota
recommendedoperatingmode,asthispinhastobeconnectedtoeitherVIHor
VIL,tominimizethestandbycurrent.
MultibyteWrite.
FortheMultibyteWritemode,theMODEpinmustbeatVIH.TheMultibyteWrite
modecanbestartedfromanyaddressinthememory.Themastersendsfrom
oneupto4bytesofdata,whichareeachacknowledgedbythememory.The
transferisterminatedbythemastergeneratingaSTOPcondition.Theduration
ofthewritecycleisTw=10msmaximumexceptwhenbytesareaccessedon2
rows(thatishavedifferentvaluesforthe6mostsignificantaddressbitsA7A2),
theprogrammingtimeisthendoubledtoamaximumof20ms.Writingmorethan
4bytesintheMultibyteWritemodemaymodifydatabytesinanadjacentrow
(onerowis8byteslong).However,theMultibyteWritecanproperlywriteupto8
consecutivebytesassoonasthefirstaddressofthese8bytesisthefirst
addressoftherow,the7followingbytesbeingwritteninthe7followingbytesof
thissamerow.
PageWrite.
ForthePageWritemode,theMODEpinmustbeatVIL.ThePageWritemode
allowsupto8bytestobewritteninasinglewritecycle,providedthattheyareall
locatedinthesamerowinthememory:thatisthe5mostsignificantmemory
addressbits(A7A3)arethesameinsideoneblock.Themastersendsfromone
upto8bytesofdata,whichareeachacknowledgedbythememory.Aftereach
byteistransferred,theinternalbyteaddresscounter(3leastsignificantbitsonly)
isincremented.ThetransferisterminatedbythemastergeneratingaSTOP
condition.Caremustbetakentoavoidaddresscounterrolloverwhichcould
resultindatabeingoverwritten.Notethat,foranywritemode,thegenerationby
themasteroftheSTOPconditionstartstheinternalmemoryprogramcycle.All

inputsaredisableduntilthecompletionofthiscycleandthememorywillnot
respondtoanyrequest.
MinimizingSystemDelaysbyPollingonACK.
Duringtheinternalwritecycle,thememorydisconnectsitselffromthebusin
ordertocopythedatafromtheinternallatchestothememorycells.The
maximumvalueofthewritetime(Tw)isgivenfromtheACCharacteristics,since
thetypicaltimeisshorter,thetimeseenbythesystemmaybereducedbyan
ACKpollingsequenceissuedbythemaster.

Fig:WriteCyclePollingusingACK
Dataintheupperblockof256bytesofthememorymaybewriteprotected.The
memoryiswriteprotectedbetweenaboundaryaddressandthetopofmemory
(address1FFh)whenthePREinputpinistakenhighandwhentheProtectFlag
(bitb2inlocation1FFh)issetto0.Theboundaryaddressisuserdefinedby
writingitintheBlockAddressPointer.TheBlockAddressPointerisan8bit
EEPROMregisterlocatedattheaddress1FFh.Itiscomposedby5MSBs
AddressPointer,whichdefinesthebottomboundaryaddressand3LSBswhich
mustbeprogrammedat0.ThisAddressPointercanthereforeaddressa
boundaryinstepsof8bytes.

ThesequencetousetheWriteProtectedfeatureis:
writethedatatobeprotectedintothetopofthememory,upto,butnot
including,location1FFh
settheprotectionbywritingthecorrectbottomboundaryaddressinthe
AddressPointer(5MSBsoflocation1FFh)withbitb2(Protectflag)setto0.
Notethatforacorrectfunctionalityofthememory,allthe3LSBsoftheBlock
AddressPointermustalsobeprogrammedat0.Theareawillnowbeprotected
whenthePREinputpinistakenHigh.WhilethePREinputpinisreadat0by
thememory,thelocation1FFhcanbeusedasanormalEEPROMbyte.

Fig:WriteModesSequence
ReadOperations
ReadoperationsareindependentofthestateoftheMODEpin.Ondelivery,the
memorycontentissetatall"1s"(orFFh).
CurrentAddressRead.
Thememoryhasaninternalbyteaddresscounter.Eachtimeabyteisread,this
counterisincremented.FortheCurrentAddressReadmode,followingaSTART
condition,themastersendsamemoryaddresswiththeRWbitsetto1.The
memoryacknowledgesthisandoutputsthebyteaddressedbytheinternalbyte
addresscounter.Thiscounteristhenincremented.ThemasterdoesNOT
acknowledgethebyteoutput,butterminatesthetransferwithaSTOPcondition.

RandomAddressRead.
Adummywriteisperformedtoloadtheaddressintotheaddresscounter.Thisis
followedbyanotherSTARTconditionfromthemasterandthebyteaddressis
repeatedwiththeRWbitsetto1.Thememoryacknowledgesthisandoutputs
thebyteaddressed.ThemasterhastoNOTacknowledgethebyteoutput,but
terminatesthetransferwithaSTOPcondition.
SequentialRead.
ThismodecanbeinitiatedwitheitheraCurrentAddressReadoraRandom
AddressRead.However,inthiscasethemasterDOESacknowledgethedata
byteoutputandthememorycontinuestooutputthenextbyteinsequence.To
terminatethestreamofbytes,themastermustNOTacknowledgethelastbyte
output,butMUSTgenerateaSTOPcondition.Theoutputdataisfrom
consecutivebyteaddresses,withtheinternalbyteaddresscounterautomatically
incrementedaftereachbyteoutput.Afteracountofthelastmemoryaddress,
theaddresscounterwillrolloverandthememorywillcontinuetooutputdata.
AcknowledgeinReadMode.
InallreadmodestheST24/25x04waitforanacknowledgeduringthe9thbit
time.IfthemasterdoesnotpulltheSDAlinelowduringthistime,theST24/25x04
terminatethedatatransferandswitchestoastandbystate.

Fig:ReadModesSequence

KEYPAD:
KeypadsandLCDsarethemostwidelyusedinput/outputdevicesofthe8051
andabasicunderstandingofthemisessential.Thekeypadsaremainlythree
types:
1.4*3keypad
2.4*4keypad
3.4*8keypad.
Thekeypadusedinthisprojectis4*3keypad.

CalculatorkeypadTelephonekeypad

INTERFACINGTHEKEYPADTO8051
Atthelowestlevel,keyboardsareorganizedinamatrixofrowsandcolumns.
TheCPUaccessesbothrowsandcolumnsthroughports.Therefore,withtwo8
bitports,an8*8matrixofkeyscanbeconnectedtoamicroprocessor.Whena
keyispressed,arowandacolumnmakeacontact,otherwisethereisno
connectionbetweenrowsandcolumns.Asinglemicrocontroller(consistingofa
microprocessor,RAM,EPROMandseveralportsallonasinglechip)takescare
ofhardwareandsoftwareinterfacingofthekeypad.Insuchsystems,itisthe
functionofprogramsstoredinEPROMofthemicrocontrollertoscanthekeys
continuously,identifywhichonehasbeenactivatedandpresentittothe
motherboard.

Fig:4*3MatrixKeypadConnectionstoPorts
Scanningandidentifyingthekey:
Therowsareconnectedtoanoutputportandthecolumnsareconnectedtoan
inputport.Ifnokeyhasbeenpressed,readingtheinputportwillyield1sforall
columnssincetheyareallconnectedtohigh(Vcc).Ifalltherowsaregrounded
andakeyispressed,oneofthecolumnswillhave0sincethekeypressed
providesthepathtoground.Itisthefunctionofthemicrocontrollertoscanthe
keypadcontinuouslytodetectandidentifythekeypressed.

Groundingrowsandreadingthecolumns:
Todetectapressedkey,themicrocontrollergroundsallrowsbyproviding0
(zero)totheoutputlatch,thenitreadsthecolumns.Ifthedatareadfromthe
columnsisD2D0=111,nokeyhasbeenpressedandtheprocesscontinues
untilakeypressisdetected.However,ifoneofthecolumnbitshasazero,this
meansthatakeypresshasoccurredi.e.,forexample,ifD2D0=110,thismeans
thatakeyintheD0columnhasbeenpressed.Afterakeypressisdetected,the
microcontrollerwillgothroughaprocessofidentifyingthekey.Startingwiththe
toprow,themicrocontrollergroundsitbyprovidingalowtorowD0onlyandthen
itreadsthecolumns.Ifthedatareadisall1s,nokeyinthatrowisactivatedand
theprocessismovedtothenextrow.Itgroundsthenextrow,readsthecolumns
andchecksforanyzero.Thisprocesscontinuesuntiltherowisidentified.After
identificationoftherowinwhichthekeyhasbeenpressed,thenexttaskisto
findoutwhichcolumnthepressedkeybelongsto.Nowthiswillbeeasysince
themicrocontrollerknowsatanytimewhichrowandcolumnarebeing
accessed.
TRANSISTORDRIVERCIRCUIT:
Digitalsystemsandmicrocontrollerpinslacksufficientcurrenttodrivethecircuits
likebuzzercircuitsandrelaycircuits.Whilethesecircuitsneedaround10milli
ampstobeenergized,themicrocontrollerspincanprovideamaximumof1
2milliampscurrent.Forthisreason,adriversuchasapowertransistorisplaced
inbetweenthemicrocontrollerandthebuzzer.

Theoperationofthiscircuitisasfollows:

Theinputtothebaseofthetransistorisappliedfromthemicrocontrollerportpin
P1.0.Thetransistorwillbeswitchedonwhenthebasetoemittervoltageis
greaterthan0.7V(cutinvoltage).ThuswhenthevoltageappliedtothepinP1.0
ishighi.e.,P1.0=1(>0.7V),thetransistorwillbeswitchedonandthusthebuzzer
willbeactivatedandproducesaloudnoise.
WhenthevoltageatthepinP1.0islowi.e.,P1.0=0(<0.7V)thetransistorwillbe
inoffstateandthebuzzerwillbeoff.Thusthetransistoractslikeacurrentdriver
tooperatethebuzzeraccordingly.
BUZZERINTERFACINGWITHTHEMICROCONTROLLER:
AT89C51
P1.0

ULN2003CURRENTDRIVER:

Fig:DIP16Package

TheULN2003currentdriverisahighvoltage,highcurrentDarlingtonarrays
eachcontainingsevenopencollectorDarlingtonpairswithcommonemitters.
Eachchannelisratedat500mAandcanwithstandpeakcurrentsof600mA.
Suppressiondiodesareincludedforinductiveloaddrivingandtheinputsare
pinnedoppositetheoutputstosimplifyboardlayout.
Theseversatiledevicesareusefulfordrivingawiderangeofloadsincluding
solenoids,relaysDCmotors,LEDdisplaysfilamentlamps,thermalprintheads
andhighpowerbuffers.Thischipissuppliedin16pinplasticDIPpackageswith
acopperleadframetoreducethermalresistance.

Fig:PinConnection
ThisULN2003drivercandrivesevenrelaysatatime.Thepins8and9provide
groundandVccrespectively.
TheworkingofULNdriverisasfollows:
Itcanacceptseveninputsatatimeandproducessevencorrespondingoutputs.
Iftheinputtoanyoneoftheseveninputpinsishigh,thenthevalueatits
correspondingoutputpinwillbelow,forexampleiftheinputatpin6ishigh,then
thevalueatthecorrespondingoutputi.e.,outputatpin11willbelow.Similarlyif
theinputataparticularpinislow,thenthecorrespondingoutputwillbehigh.

STEPPERMOTOR:

Fig:Steppermotor
Asteppermotorisawidelyuseddevicethattranslateselectricalpulsesinto
mechanicalmovement.Thesteppermotorisusedforpositioncontrolin
applicationssuchasdiskdrives,dotmatrixprintersandrobotics.
Steppermotorscommonlyhaveapermanentmagnetrotorsurroundedbya
stator.Themostcommonsteppermotorshavefourstatorwindingsthatare
pairedwithacentertappedcommon.Thistypeofsteppermotoriscommonly
referredtoasafourphaseorunipolarsteppermotor.Thecentertapallowsa
changeofcurrentdirectionineachofthetwocoilswhenawindingisgrounded,
therebyresultinginapolaritychangeofthestator.
Thedirectionoftherotationisdictatedbythestatorpoles.Thestatorpolesare
determinedbythecurrentsentthroughthewirecoils.Asthedirectionofthe
currentischanged,thepolarityisalsochangedcausingthereversemotionof
therotor.
Itshouldbenotedthatwhileaconventionalmotorshaftrunsfreely,thestepper
motorshaftmovesinafixedrepeatableincrement,whichallowsonetomoveit
toapreciseposition.Thus,thesteppermotormovesonestepwhenthedirection
ofcurrentflowinthefieldcoil(s)changes,reversingthemagneticfieldofthe

statorpoles.Thedifferencebetweenunipolarandbipolarmotorsliesinthemay
thatthisreversalisachieved.

Fig:Steppermotoroperation
Advantages:
1.Therotationangleofthemotorisproportionaltotheinputpulse.
2.Themotorhasfulltorqueatstandstill(ifthewindingsareenergized)
3.Precisepositioningandrepeatabilityofmovementsincegoodsteppermotors
haveanaccuracyof35%ofastepandthiserrorisnoncumulativefromone
steptothenext.
4.Excellentresponsetostarting/stopping/reversing.
5.Veryreliablesincetherearenocontactbrushesinthemotor.Thereforethelife
ofthemotorissimplydependantonthelifeofthebearing.
6.Themotorsresponsetodigitalinputpulsesprovidesopenloopcontrol,
makingthemotorsimplerandlesscostlytocontrol.
7.Itispossibletoachieveverylowspeedsynchronousrotationwithaloadthat
isdirectlycoupledtotheshaft.

8.Awiderangeofrotationalspeedscanberealizedasthespeedisproportional
tothefrequencyoftheinputpulses.
Disadvantages:
1.Resonancescanoccurifnotproperlycontrolled.
2.Noteasytooperateatextremelyhighspeeds.
OpenLoopOperation:
Oneofthemostsignificantadvantagesofasteppermotorisitsabilitytobe
accuratelycontrolledinanopenloopsystem.Openloopcontrolmeansno
feedbackinformationaboutpositionisneeded.Thistypeofcontroleliminatesthe
needforexpensivesensingandfeedbackdevicessuchasopticalencoders.
StepperMotorTypes:
Therearethreebasicsteppermotortypes.Theyare:
Variablereluctance
Permanentmagnet
Hybrid
Variablereluctance(VR)
Thistypeofsteppermotorhasbeenaroundforalongtime.Itisprobablythe
easiesttounderstandfromastructuralpointofview.Thistypeofmotorconsists
ofasoftironmultitoothedrotorandawoundstator.Whenthestatorwindings
areenergizedwithDCcurrent,thepolesbecomemagnetized.Rotationoccurs
whentherotorteethareattractedtotheenergizedstatorpoles.

Fig1:Crosssectionofavariablereluctance(VR)motor.
PermanentMagnet(PM)
Thepermanentmagnetstepmotorisalowcostandlowresolutiontypemotor
withtypicalstepanglesof7.5to15.(4824steps/revolution)PMmotorsas
thenameimplieshavepermanentmagnetsaddedtothemotorstructure.Inthis
typeofmotor,therotordoesnothaveteeth.Insteadtherotorismagnetizedwith
alternatingnorthandsouthpolessituatedinastraightlineparalleltotherotor
shaft.Thesemagnetizedrotorpolesprovideanincreasedmagneticfluxintensity
andbecauseofthisthePMmotorexhibitsimprovedtorquecharacteristicswhen
comparedwiththeVRtype.

PMsteppermotorprincipleCrosssectionofahybridsteppermotor
Hybrid(HB)
ThehybridsteppermotorismoreexpensivethanthePMsteppermotorbut
providesbetterperformancewithrespecttostepresolution,torqueandspeed.
TypicalstepanglesfortheHBsteppermotorrangefrom3.6to0.9(100400
stepsperrevolution).
ThehybridsteppermotorcombinesthebestfeaturesofboththePMandVR
typesteppermotors.TherotorismultitoothedliketheVRmotorandcontainsan
axiallymagnetizedconcentricmagnetarounditsshaft.Theteethontherotor
provideanevenbetterpathwhichhelpsguidethemagneticfluxtopreferred
locationsintheairgap.Thisfurtherincreasesthedetent,holdinganddynamic
torquecharacteristicsofthemotorwhencomparedwithboththeVRandPM
types.Thismotortypehassomeadvantagessuchasverylowinertiaanda
optimizedmagneticflowpathwithnocouplingbetweenthetwostatorwindings.
Thesequalitiesareessentialinsomeapplications.
WhentoUseaStepperMotor:
Asteppermotorcanbeagoodchoicewhenevercontrolledmovementis
required.Theycanbeusedtoadvantageinapplicationswhereyouneedto

controlrotationangle,speed,positionandsynchronism.Becauseoftheinherent
advantageslistedpreviously,steppermotorshavefoundtheirplaceinmany
differentapplications.
TheRotatingMagneticField:
Whenaphasewindingofasteppermotorisenergizedwithcurrentamagnetic
fluxisdevelopedinthestator.Thedirectionofthisfluxisdeterminedbythe
RightHandRulewhichstates:
Ifthecoilisgraspedintherighthandwiththefingerspointinginthedirectionof
thecurrentinthewinding(thethumbisextendedata90angletothefingers),
thenthethumbwillpointinthedirectionofthemagneticfield.
ThebelowfigureshowsthemagneticfluxpathdevelopedwhenphaseBis
energizedwithwindingcurrentinthedirectionshown.Therotorthenalignsitself
sothatthefluxoppositionisminimized.Inthiscasethemotorwouldrotate
clockwisesothatitssouthpolealignswiththenorthpoleofthestatorBat
position2anditsnorthpolealignswiththesouthpoleofstatorBatposition6.To
getthemotortorotatewecannowseethatwemustprovideasequenceof
energizingthestatorwindingsinsuchafashionthatprovidesarotatingmagnetic
fluxfieldwhichtherotorfollowsduetomagneticattraction.

Fig:Magneticfluxpaththroughatwopolesteppermotorwithalagbetweenthe
rotorandstator.
TorqueGeneration:
Thetorqueproducedbyasteppermotordependsonseveralfactors.
Thesteprate
Thedrivecurrentinthewindings
Thedrivedesignortype
Inasteppermotor,atorquewillbedevelopedwhenthemagneticfluxesofthe
rotorandstatoraredisplacedfromeachother.Thestatorismadeupofahigh
permeabilitymagneticmaterial.Thepresenceofthishighpermeabilitymaterial
causesthemagneticfluxtobeconfinedforthemostparttothepathsdefinedby
thestatorstructure.Thisservestoconcentratethefluxatthestatorpoles.The
torqueoutputproducedbythemotorisproportionaltotheintensityofthe
magneticfluxgeneratedwhenthewindingisenergized.
Thebasicrelationshipwhichdefinestheintensityofthemagneticfluxisdefined
by:
H=(N*i)/l
where
N=Thenumberofwindingturns
i=current
H=Magneticfieldintensity
l=Magneticfluxpathlength
Thisrelationshipshowsthatthemagneticfluxintensityandconsequentlythe
torqueisproportionaltothenumberofwindingturnsandthecurrentand

inverselyproportionaltothelengthofthemagneticfluxpath.Thusfromthisbasic
relationshipitisconcludedthatthesameframesizesteppermotorcouldhave
verydifferenttorqueoutputcapabilitiessimplybychangingthewinding
parameters.
StepAngleAccuracy:

Themainreasonthatthesteppermotorgainedsuchpopularityasapositioning
deviceisforitsaccuracyandrepeatability.Typicallysteppermotorswillhavea
stepangleaccuracyof35%ofonestep.Thiserrorisalsononcumulativefrom
steptostep.Theaccuracyofthesteppermotorismainlyafunctionofthe
mechanicalprecisionofitspartsandassembly.
Fig:Positionalaccuracyofasteppermotor
TorqueversusSpeedCharacteristics:
Thetorqueversusspeedcharacteristicsarethekeytoselectingtherightmotor
anddrivemethodforaspecificapplication.Thesecharacteristicsaredependent
upon(changewith)themotor,excitationmodeandtypeofdriverordrivemethod.

Fig:Torqueversusspeedcharacteristics
SingleStepResponseandResonances:
Steppermotorscanoftenexhibitaphenomenareferredtoasresonanceat
certainsteprates.Thiscanbeseenasasuddenlossordropintorqueatcertain
speedswhichcanresultinmissedstepsorlossofsynchronism.Itoccurswhen
theinputsteppulseratecoincideswiththenaturaloscillationfrequencyofthe
rotor.Oftenthereisaresonanceareaaroundthe100200ppsregionandalso
oneinthehighsteppulserateregion.Theresonancephenomenaofastepper
motorcomesfromitsbasicconstructionandthereforeitisnotpossibleto
eliminateitcompletely.Itisalsodependentupontheloadconditions.Itcanbe
reducedbydrivingthemotorinhalformicrosteppingmodes.

Fig:Singlestepresponseversustime
FewDefinitionsrelatedtosteppermotor:
1.Stepangle
Stepangleisassociatedwiththeinternalconstructionofthemotor,inparticular
thenumberofteethonthestatorandtherotor.
Thestepangleistheminimumdegreeofrotationassociatedwithasinglestep.
Stepangle

StepsperRevolution

0.72

500

1.8

200

2.0

180

2.5

144

5.0

72

7.5

48

15

24

Fig:Steppermotorstepangles
2.Stepspersecondandrpmrelation

Therelationbetweenrpm(revolutionsperminute),stepsperrevolutionand
stepspersecondisasfollows:
Stepspersecond=(rpm*stepsperrevolution)/60
3.Motorspeed:
Themotorspeed,measuredinstepspersecond(steps/sec)isafunctionofthe
switchingrate.
4.Holdingtorque:
Theamountoftorque,fromanexternalsource,requiredtobreakawaytheshaft
fromitsholdingpositionwiththemotorshaftstandstillorzerorpmcondition.
STEPPERMOTORINTERFACINGWITHTHEMICROCONTROLLER:
AT89C51
P1.0

LIQUIDCRYSTALDISPLAY:
LCDstandsforLiquidCrystalDisplay.LCDisfindingwidespreadusereplacing
LEDs(sevensegmentLEDsorothermultisegmentLEDs)becauseofthe
followingreasons:
1.ThedecliningpricesofLCDs.

2.Theabilitytodisplaynumbers,charactersandgraphics.Thisisincontrastto
LEDs,whicharelimitedtonumbersandafewcharacters.
3.IncorporationofarefreshingcontrollerintotheLCD,therebyrelievingtheCPU
ofthetaskofrefreshingtheLCD.Incontrast,theLEDmustberefreshedbythe
CPUtokeepdisplayingthedata.
4.Easeofprogrammingforcharactersandgraphics.
Thesecomponentsarespecializedforbeingusedwiththemicrocontrollers,
whichmeansthattheycannotbeactivatedbystandardICcircuits.Theyare
usedforwritingdifferentmessagesonaminiatureLCD.

Amodeldescribedhereisforitslowpriceandgreatpossibilitiesmostfrequently
usedinpractice.ItisbasedontheHD44780microcontroller(Hitachi)andcan
displaymessagesintwolineswith16characterseach.Itdisplaysallthe
alphabets,Greekletters,punctuationmarks,mathematicalsymbolsetc.In
addition,itispossibletodisplaysymbolsthatusermakesuponitsown.
Automaticshiftingmessageondisplay(shiftleftandright),appearanceofthe
pointer,backlightetc.areconsideredasusefulcharacteristics.
PinsFunctions
Therearepinsalongonesideofthesmallprintedboardusedforconnectionto
themicrocontroller.Therearetotalof14pinsmarkedwithnumbers(16incase
thebackgroundlightisbuiltin).Theirfunctionisdescribedinthetablebelow:

Function

Pin
Name
Number

LogicState

Description

Ground

Vss

0V

Powersupply 2

Vdd

+5V

Vee

0Vdd

RS

0
1

D0D7are
interpretedas
commands
D0D7are
interpretedasdata

R/W

0
1

Writedata(from
controllertoLCD)
Readdata(fromLCDto
controller)

0
1
From1
to0

AccesstoLCDdisabled
Normaloperating
Data/commandsare
transferredtoLCD

Data/
commands

D0

0/1

D1

0/1

Bit1

D2

0/1

Bit2

Co
3
ntrast

Controlof
operating

Bit0LSB

10

D3

0/1

Bit3

11

D4

0/1

Bit4

12

D5

0/1

Bit5

13

D6

0/1

Bit6

14

D7

0/1

Bit7MSB

LCDscreen:
LCDscreenconsistsoftwolineswith16characterseach.Eachcharacter
consistsof5x7dotmatrix.Contrastondisplaydependsonthepowersupply
voltageandwhethermessagesaredisplayedinoneortwolines.Forthat
reason,variablevoltage0VddisappliedonpinmarkedasVee.Trimmer
potentiometerisusuallyusedforthatpurpose.Someversionsofdisplayshave
builtinbacklight(blueorgreendiodes).Whenusedduringoperating,aresistor
forcurrentlimitationshouldbeused(likewithanyLEdiode).

LCDBasicCommands
AlldatatransferredtoLCDthroughoutputsD0D7willbeinterpretedas
commandsorasdata,whichdependsonlogicstateonpinRS:

RS=1BitsD0D7areaddressesofcharactersthatshouldbedisplayed.Built
inprocessoraddressesbuiltinmapofcharactersanddisplayscorresponding
symbols.DisplayingpositionisdeterminedbyDDRAMaddress.Thisaddressis
eitherpreviouslydefinedortheaddressofpreviouslytransferredcharacteris
automaticallyincremented.
RS=0BitsD0D7arecommandswhichdeterminedisplaymode.Listof
commandswhichLCDrecognizesaregiveninthetablebelow:
Execution
Time

Command

RSRW D7D6

D5

D4

D3 D2 D1D0

Cleardisplay

0 0

0 0

0 1 1.64mS

Cursorhome

0 0

0 0

1 x 1.64mS

Entrymodeset 0 0

0 0

I/D S 40uS

Displayon/off
control

0 0

0 0

D U B 40uS

Cursor/Display
0 0
Shift

0 0

D/CR/L x x 40uS

Functionset

0 0

0 0

DL

SetCGRAM
address

0 0

0 1

CGRAM
address

40uS

SetDDRAM
address

0 0

DDRAM
address

40uS

x x 40uS

ReadBUSY
flag(BF)

0 1

BF

DDRAM
address

WritetoCGRAM
1 0
orDDRAM

D7D6

D5

D4

D3 D2 D1D040uS

Readfrom
CGRAMor
DDRAM

D7D6

D5

D4

D3 D2 D1D040uS

1 1

I/D1=Increment(by1)R/L1=Shiftright
0=Decrement(by1)0=Shiftleft
S1=DisplayshiftonDL1=8bitinterface
0=Displayshiftoff0=4bitinterface
D1=DisplayonN1=Displayintwolines
0=Displayoff0=Displayinoneline
U1=CursoronF1=Characterformat5x10dots
0=Cursoroff0=Characterformat5x7dots
B1=CursorblinkonD/C1=Displayshift
0=Cursorblinkoff0=Cursorshift
LCDInitialization:
Oncethepowersupplyisturnedon,LCDisautomaticallycleared.Thisprocess
lastsforapproximately15mS.Afterthat,displayisreadytooperate.Themodeof
operatingissetbydefault.Thismeansthat:

1.Displayiscleared
2.Mode
DL=1Communicationthrough8bitinterface
N=0Messagesaredisplayedinoneline
F=0Characterfont5x8dots
3.Display/Cursoron/off
D=0Displayoff
U=0Cursoroff
B=0Cursorblinkoff
4.Characterentry
ID=1Addressesondisplayareautomaticallyincrementedby1.
S=0Displayshiftoff
Automaticresetismainlyperformedwithoutanyproblems.Mainlybutnot
always!Ifforanyreasonpowersupplyvoltagedoesnotreachfullvalueinthe
courseof10mS,displaywillstartperformcompletelyunpredictably.Ifvoltage
supplyunitcannotmeetthisconditionorifitisneededtoprovidecompletely
safeoperating,theprocessofinitializationbywhichanewresetenablingdisplay
tooperatenormallymustbeapplied.
Algorithmaccordingtotheinitializationisbeingperformeddependsonwhether
connectiontothemicrocontrolleristhrough4or8bitinterface.Allleftovertobe
doneafterthatistogivebasiccommandsandofcoursetodisplaymessages.

Fig:Procedureon8bitinitialization.
LCDINTERFACINGWITHTHEMICROCONTROLLER:
Gnd

4(RS)1
5(R/W)2
6(EN)3
LCD
D0
D1
D2
D3
D4
D515

D616
D7
P2.0
P2.1
P2.2
89C51P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7

SOFTWARESUSED:
KEILCOMPILER:

Keilcompilerisasoftwareusedwherethemachinelanguagecodeiswrittenand
compiled.Aftercompilation,themachinesourcecodeisconvertedintohexcode
whichistobedumpedintothemicrocontrollerforfurtherprocessing.Keil
compileralsosupportsClanguagecode.
PROLOAD:
Proloadisasoftwarewhichacceptsonlyhexfiles.Oncethemachinecodeis
convertedintohexcode,thathexcodehastobedumpedintothe
microcontrollerandthisisdonebytheProload.Proloadisaprogrammerwhich
itselfcontainsamicrocontrollerinitotherthantheonewhichistobe
programmed.Thismicrocontrollerhasaprograminitwritteninsuchawaythatit
acceptsthehexfilefromthekeilcompileranddumpsthishexfileintothe
microcontrollerwhichistobeprogrammed.Astheproloadprogrammerkit
requirespowersupplytobeoperated,thispowersupplyisgivenfromthepower
supplycircuitdesignedabove.Itshouldbenotedthatthisprogrammerkit
containsapowersupplysectionintheboarditselfbutinordertoswitchonthat
powersupply,asourceisrequired.Thusthisisaccomplishedfromthepower
supplyboardwithanoutputof12volts.
WORKINGPROCEDURE:
TheProjectEmbeddedPasswordbasedElectricalAppliancescontrolsystem
using89C51MicrocontrollerisanexclusiveprojectthatprovidessecurityatATM
centers,officesandhomes.
Securityisofprimaryconcernandinthisbusy,competitiveworld,humancannot
findwaystoprovidesecuritytohisconfidentialbelongingsmanually.Instead,he
findsanalternativewhichcanprovideafullfledgedsecurityaswellas
automized.Thisprojecthasbeendevelopedonthismotto.
Inthisprojecteveryuser,apartofanorganization,isgivenanuniqueuserID
andpassword.Thepasswordsofalltheusersofthatparticularorganizationwill
bestoredinEEPROMpresentinthesystemboardbecausethedatain
EEPROMcanbechangedanynumberoftimeswithoutthephysicalremovalof
thememorychipfromitssocket.

Thissystemwillbefixedatthemaindooroftherestrictedarea.Wheneverthe
usertriestoenterintotheorganization,thissystemaskstheusertoenterhis
userid.ThismessageEnterUSERIDwillbedisplayedontheLCD.Thenthe
userhastoenterhisidentificationnumberwhichcanrangefrom3to8numbers.
Themicrocontrolleracceptsthisdataandcomparesthisuseridwhichisalready
storesintheEEPROM.Iftheuseridisnotmatchedwithanyofthestoreduser
ids,themicrocontrollerwillnotproceedforfurtherdetailsbutdisplaysamessage
InvalidUSERID.Ifthisuseridismatchedwithanyoneofthealreadystored
userids,thenthesystemaskstheusertoenterhispassword.Afterheentershis
password,themicrocontrolleronceagaincomparestheenteredpasswordwith
thealreadypasswordsintheEEPROM.Ifthispasswordmatcheswithanyoneof
thepasswordsstored,themicrocontrolleropensthedoorbyrotatingthestepper
motorthroughULNDriverforthepersontoenterintotherestrictedareaandthe
messageDoorisopeningwillbedisplayedontheLCDdisplay.
Butiftheenteredpassworddoesnotmatchwiththealreadystoredpasswords,
themessagePasswordfailed.EnterIDwillbedisplayedontheLCDandthe
steppermotordoesnotrotate.
Ifthepasswordisenteredwronglyfor3timescontinuously,thenthetotalsystem
willbeblocked.Thesystemcancometonormalconditiononlyafterpressingthe
RESETswitch.Initiallythesystemisgivenwithdefaultpasswordsasshown
below.
UserID

Password

101

100

102

200

103

300

104

400

Thedefaultpasswordscanbechangedatanytime.Forthat111shouldbe
enteredwhenthesystemasksforpassword.Afterenteringthiscode111:it
displayschangingpasswordandasksTypeCURRENTPSWD.Afterentering
currentpassword,Itasksfornewpassword.Thepasswordshouldnotmatch
withchangepasswordcodei.e.111.
Iftheuserforgothispasswordthenheshouldconsultadministrator.Thenthe
administratorentersa10digitcodewhichisadminPSWD.Thentheforgotten
passwordisdisplayedonLCD.Defaultpasswordforadministratoris
1234567890.#keyshouldbeenteredaftercompletionofenteringIDor
password.ThiskeyactslikeaENTERkey.

Fig:Schematicdiagram
SOURCECODE:
WTCMDEQU10100000BEEPROM24C04WRITECOMMAND
RDCMDEQU10100001BEEPROM24C04READCOMMAND
SCLEQUP3.6SERIALCLOCKPIN

SDAEQUP3.7SERIALDATAPIN
FAILCOUNTDATA22H
KEYCOUNTDATA25HTOSTORETHENO.KEYSENTERDFOREACHTIME
TEMPDATA26HTEMPVARIABLE
PWDFINDDATA27HTOFINDWHICHPASSWORDSHOULDBECOMPARED
PCOUNT1DATA28HTOSTORETHENO.OFDIGITSOFPASSWORD1
PCOUNT2DATA29HTOSTORETHENO.OFDIGITSOFPASSWORD2
PCOUNT3DATA2AHTOSTORETHENO.OFDIGITSOFPASSWORD3
PCOUNT4DATA2BHTOSTORETHENO.OFDIGITSOFPASSWORD4
ORG00H
MOVP3,#00000111BMAKEP3.0P3.2ASINPUTPINSFORCOLUMNS
MOVR1,#50HSCANNEDKEYISSTOREDINTHISLOCATION
MOVR0,#0
CLRP2.7BUZZOROFF
MOVFAILCOUNT,#0
LCDINTIALIZATION
MOVDPTR,#COMM
XX:CLRA
MOVCA,@A+DPTR
JZSTART1

ACALLCOMMAND
ACALLDELAY
INCDPTR
SJMPXX
START1:
MOVDPTR,#MSGADISPLAY"WINKIT"
ACALLDISPLAY1
ACALLDELAY
MOVA,#0C0H
ACALLCOMMAND
ACALLDELAY
MOVDPTR,#MSGBDISPLAY"LEARNINGISFUN"
ACALLDISPLAY1
ACALLDELAY
MOVDPTR,#MSGDISPLAY"SECURITYSYSTEM"
ACALLDISPLAY
ACALLDELAY
MOVR3,#00TOCHECKANYTHINGWRITTENINEEPROMORNOT
ACALLREAD_FROMIFANYTHINGWRIITENTHENNONEEDTOWRITEIT
AGAINGOFORATART
CJNEA,#0FFH,TO_START2

MOVR3,#00STOREID'SINEEPROMADDRESS00HT00BH
MOVDPTR,#ID1ID1
B1:CLRA
MOVCA,@A+DPTR
JZF1
ACALLWRITE_TO
INCDPTR
SJMPB1
TO_START2:LJMPSTART2
F1:MOVR3,#03H
MOVDPTR,#ID2ID2
B2:CLRA
MOVCA,@A+DPTR
JZF2
ACALLWRITE_TO
INCDPTR
SJMPB2
F2:MOVR3,#06H
MOVDPTR,#ID3ID3
B3:CLRA

MOVCA,@A+DPTR
JZFL
ACALLWRITE_TO
INCDPTR
SJMPB3
FL:MOVR3,#09H
MOVDPTR,#ID4ID4
BB:CLRA
MOVCA,@A+DPTR
JZF3
ACALLWRITE_TO
INCDPTR
SJMPBB
/*STOREDEFAULTPASSWORDSINEEPROMLOCATIONS10HTO50H*/
F3:MOVR3,#10H
MOVDPTR,#PWD1PASSWORD1
B4:CLRA
MOVCA,@A+DPTR
JZF4
ACALLWRITE_TO

INCDPTR
SJMPB4
F4:MOVR3,#20HPASSWORD2
MOVDPTR,#PWD2
B5:CLRA
MOVCA,@A+DPTR
JZF5
ACALLWRITE_TO
INCDPTR
SJMPB5
F5:MOVR3,#30HPASSWORD3
MOVDPTR,#PWD3
B6:CLRA
MOVCA,@A+DPTR
JZF6
ACALLWRITE_TO
INCDPTR
SJMPB6
PASSWORD4
F6:MOVR3,#40H

MOVDPTR,#PWD4
B7:CLRA
MOVCA,@A+DPTR
JZF7
ACALLWRITE_TO
INCDPTR
SJMPB7
F7:MOVR3,#50H
MOVDPTR,#ADMINPWDADMINPASSWORD
B8:CLRA
MOVCA,@A+DPTR
JZSTRT
ACALLWRITE_TO
INCDPTR
SJMPB8
/*STORETHENO.OFDIGITSOFPASSWORDSAS3INTIALLY*/
STRT:MOVR3,#19H
MOVA,#3
ACALLWRITE_TO
MOVR3,#29H

MOVA,#3
ACALLWRITE_TO
MOVR3,#39H
MOVA,#3
ACALLWRITE_TO
MOVR3,#49H
MOVA,#3
ACALLWRITE_TO
START2:
CLRP2.7
MOVDPTR,#MSG1ASKINGFORID
ACALLDISPLAY
ACALLDELAY
ACALLKEYSCANENTERTHEID
ACALLDELAY
ACALLCOMPARISONIDCOMPARISION
ACALLDELAY
SJMPSTART2
WRITE_TO:
MOVR4,ADATAISSTOREDINR4

ACALLWRITEWRITETHEDATAINTOEEPROM
INCR3
ACALLDELAY
RET
READ_FROM:
ACALLREADREADTHEDATAFROM24C04FROMTHEMEMORY
ACALLDELAY
INCR3
RET
WRITE:
MOVA,#WTCMDDEVADDRSINWRITEMODE
ACALLOUTS
MOVA,R3DATAADDRS
ACALLOUT
MOVA,R4DATA
ACALLOUT
ACALLSTOPSTOP
RET
READ:
MOVA,#WTCMD

ACALLOUTS
MOVA,R3
ACALLOUT
MOVA,#RDCMD
ACALLOUTS
ACALLIN
ACALLSTOP
RET
OUTS:
MOVB,#8
SETBSDABUSFREEANDSTARTCONDITION
SETBSCL
NOP
CLRSDA
NOP
CLRSCL
OSLOOP:
RLCA
MOVSDA,C
SETBSCL

NOP
CLRSCL
DJNZB,OSLOOP
SETBSDA
NOP
SETBSCL
NOP
CLRSCL
RET
OUT:
MOVB,#8
OLOOP:
RLCA
MOVSDA,C
SETBSCL
NOP
CLRSCL
DJNZB,OLOOP
SETBSDA
NOP

SETBSCL
NOP
CLRSCL
RET
IN:
MOVB,#8
SETBSDA
INLOOP:
CLRSCL
NOP
SETBSCL
MOVC,SDA
RLCA
DJNZB,INLOOP
CLRSCL
RET
STOP:I2CSTOPCONDITION
CLRSDA
NOP
SETBSCL

NOP
SETBSDA
LCALLDLAYms
RET
/*@@@@@@@KEYSCANSUBROUTINE@@@@@@@@@@@@@@@*/
KEYSCAN:MOVR1,#50HSCANNEDKEYISSTOREDINTHISLOCATION
MOVA,#0C3HENTERDKEYSAREDISPLAYEDFROM4THLOCATIONOF
2NDLINE
LCALLCOMMAND
LCALLDELAY
MOVKEYCOUNT,#0
NEXTKEY:MOVP0,#0F0HGROUNDALLROWSINTIALLY
MOVA,P3READALLCOLMNSENSUREALLKEYSOPEN
ANLA,#00000111B
CJNEA,#00000111B,NEXTKEY
K2:ACALLDELAY
MOVA,P3READALLCOLMNSENSUREALLKEYSOPEN
ANLA,#00000111B
CJNEA,#00000111B,OVER
SJMPK2
OVER:ACALLDELAY

MOVA,P3READALLCOLMNS
ANLA,#00000111B
CJNEA,#00000111B,OVER1
SJMPK2
OVER1:MOVP0,#00001110BGROUNDROW0
MOVA,P3READALLCOLMNS
ANLA,#00000111B
CJNEA,#00000111B,ROW_0
MOVP0,#00001101BGROUNDROW1
MOVA,P3READALLCOLMNS
ANLA,#00000111B
CJNEA,#00000111B,ROW_1
MOVP0,#00001011BGROUNDROW2
MOVA,P3READALLCOLMNS
ANLA,#00000111B
CJNEA,#00000111B,ROW_2
MOVP0,#00000111BGROUNDROW3
MOVA,P3READALLCOLMNS
ANLA,#00000111B
CJNEA,#00000111B,ROW_3

LJMPK2
ROW_0:MOVDPTR,#KCODE0
SJMPFIND
ROW_1:MOVDPTR,#KCODE1
SJMPFIND
ROW_2:MOVDPTR,#KCODE2
SJMPFIND
ROW_3:MOVDPTR,#KCODE3
FIND:RRCA
JNCMATCH
INCDPTR
SJMPFIND
MATCH:
SETBP2.7
ACALLDELAYIFKEYISDETECTEDTHENGIVEABEEPSOUND
ACALLDELAY
CLRP2.7
CLRA
MOVCA,@A+DPTR
MOV@R1,A

CJNEA,#23H,NKSTOPTHEKEYSCANNINGWHEN'#'ISPRESSED
RET
NK:ACALLDATAWRTDISPLAYTHEPRESSEDKEY
ACALLDELAY
INCKEYCOUNT
INCR1
SJMPNEXTKEY
COMPARISON:
MOVA,KEYCOUNT
CJNEA,#3,FFAIL
MOVR3,#00HEEPROMLOCATION
CHECKID1:LCALLREAD_FROMCOMPAREWITHID1
CJNEA,50H,CHECKID2
LCALLREAD_FROM
CJNEA,51H,CHECKID2
LCALLREAD_FROM
CJNEA,52H,CHECKID2
SJMPPWDCHECK1IFIDMATCHEDGOFORITSPASSWORD
COMPAREWITHID2
CHECKID2:MOVR3,#03H

LCALLREAD_FROM
CJNEA,50H,CHECKID3
LCALLREAD_FROM
CJNEA,51H,CHECKID3
LCALLREAD_FROM
CJNEA,52H,CHECKID3
SJMPPWDCHECK2
COMPAREWITHID3
CHECKID3:MOVR3,#06H
LCALLREAD_FROM
CJNEA,50H,CHECKID4
LCALLREAD_FROM
CJNEA,51H,CHECKID4
LCALLREAD_FROM
CJNEA,52H,CHECKID4
SJMPPWDCHECK3
COMPAREWITHID4
CHECKID4:MOVR3,#09H
LCALLREAD_FROM
CJNEA,50H,FFAIL

LCALLREAD_FROM
CJNEA,51H,FFAIL
LCALLREAD_FROM
CJNEA,52H,FFAIL
LJMPPWDCHECK4
FFAIL:LJMPFAIL
PWDCHECK1:MOVPWDFIND,#10000001BTOSET8th,1stBITTHISLOGICIS
USEDTOKNOWWHICHID'SPASSWORDSHOULDBECOMPARED
MOVDPTR,#MSG2ASKFORPASSWORD
ACALLDISPLAY
ACALLKEYSCANENTERPASSWORD
ACALLDELAY
MOVA,KEYCOUNT
CJNEA,#10,PD1IFNO.OFKEYSENTERDARE10THENGOCOMPAREWITH
ADMINPASSWORD
LJMPADMIN_PSWD
PD1:MOVR3,#19H
LCALLREAD_FROM
MOVPCOUNT1,ALOADTHENO.OFDIGITSOFPASSWORD1INPCOUNT1
MOVR3,#10H
MOVR2,#10H

ACALLPWDCHANGECHECKWHETHERUSERWANTSTOCHANGE
PASSWORDORNOT
MOVR3,#19HIFPASSWORDISCHANGEDTHENSTORETHENO.OFDIGITS
OFNEWPASSWORD
MOVA,TEMP
LCALLWRITE_TO
LJMPSTART2
PWDCHECK2:MOVPWDFIND,#01000010BTOSET7thAND2ndBIT
MOVDPTR,#MSG2
ACALLDISPLAY
ACALLKEYSCAN
ACALLDELAY
MOVA,KEYCOUNT
CJNEA,#10,PD11
LJMPADMIN_PSWD
PD11:
MOVR3,#29H
LCALLREAD_FROM
MOVPCOUNT2,A
MOVR3,#20H
MOVR2,#20H

ACALLPWDCHANGE
MOVR3,#29H
MOVA,TEMP
LCALLWRITE_TO
LJMPSTART2
PWDCHECK3:MOVPWDFIND,#00100100BTOSET6th,3rdBIT
MOVDPTR,#MSG2
ACALLDISPLAY
ACALLKEYSCAN
ACALLDELAY
MOVA,KEYCOUNT
CJNEA,#10,PD111
LJMPADMIN_PSWD
PD111:MOVR3,#39H
LCALLREAD_FROM
MOVPCOUNT3,A
MOVR3,#30H
MOVR2,#30H
ACALLPWDCHANGE
MOVR3,#39H

MOVA,TEMP
LCALLWRITE_TO
LJMPSTART2
PWDCHECK4:MOVPWDFIND,#00011000BTOSET5th,4thBIT
MOVDPTR,#MSG2
ACALLDISPLAY
ACALLKEYSCAN
ACALLDELAY
MOVA,KEYCOUNT
CJNEA,#10,PD1111
LJMPADMIN_PSWD
PD1111:MOVR3,#49H
LCALLREAD_FROM
MOVPCOUNT4,A
MOVR3,#40H
MOVR2,#40H
ACALLPWDCHANGE
MOVR3,#49H
MOVA,TEMP
LCALLWRITE_TO

LJMPSTART2
PWDCHANGE:
MOVA,KEYCOUNT
CJNEA,#3,INTIALCHECKIFNO.OFKEYSENTERDARE3THENCHECKFOR
NEWPASSWORDREQUEST
MOVA,#'1'
CJNEA,50H,INTIALCHECK
CJNEA,51H,INTIALCHECK
CJNEA,52H,INTIALCHECK
IFITISNEWPASSWORDREQUESTTHENALLOWFORGIVE
NEWPASSWORD
NEWPSWD:MOVDPTR,#MSG5
ACALLDISPLAY
ACALLDELAY
MOVDPTR,#MSG6
ACALLDISPLAYCHECKCURRENTPSWD
ACALLDELAY
LCALLKEYSCAN
ACALLDELAY
ACALLCHECKPWDIFOLDPASSWORDISENTERDCORRECTLYTHENGO
FORNEWPASSWORD
MOVA,R2

MOVR3,A
TRY:MOVDPTR,#MSG7
ACALLDISPLAY
ACALLDELAY
LCALLKEYSCANTYPENEWPSWD
ACALLDELAY
MOVA,#3
CJNEA,KEYCOUNT,ACCEPT
MOVA,#'1'
CJNEA,50H,ACCEPT
CJNEA,51H,ACCEPT
CJNEA,52H,ACCEPT
MOVDPTR,#MSG12
ACALLDISPLAY
ACALLDELAY
SJMPTRY
ACCEPT:MOVTEMP,KEYCOUNT
MOVA,KEYCOUNT
CJNEA,#10,LK
MOVDPTR,#MSG9

ACALLDISPLAY
SJMPTRY
LK:MOVR1,#50HWRITETHENEWPASSWORDINEEPROM
LL:MOVA,@R1
LCALLWRITE_TO
INCR1
DJNZKEYCOUNT,LL
RET
INTIALCHECK:ACALLCHECKPWD
ACALLDELAY
LJMPSUCCESS
CHECKPWD:JBPWDFIND.7,PSWD1
JBPWDFIND.6,PSWD2
JBPWDFIND.5,PSWD3
JBPWDFIND.4,PSWD4
LJMPSTART2
PSWD1:MOVA,PCOUNT1
SJMPJJJ
PSWD2:MOVA,PCOUNT2
SJMPJJJ

PSWD3:MOVA,PCOUNT3
SJMPJJJ
PSWD4:MOVA,PCOUNT4
JJJ:CJNEA,KEYCOUNT,FAIL
MOVR1,#50H
JJ:LCALLREAD_FROM
MOVTEMP,@R1
CJNEA,TEMP,FAIL
INCR1
DJNZKEYCOUNT,JJ
RET
ADMIN_PSWD:MOVR1,#50HRAMLOCATION
MOVR3,#50HEEPROMLOCATION
RPT:LCALLREAD_FROM
MOVTEMP,@R1
CJNEA,TEMP,FAIL
INCR1
DJNZKEYCOUNT,RPT
IFADMINPASSWORDISMATCHEDTHENDISPLAYTHERESPECTIVE
USER'SPASSWOR
MOVDPTR,#MSG8

ACALLDISPLAY
JBPWDFIND.0,DISP_PWD1
JBPWDFIND.1,DISP_PWD2
JBPWDFIND.2,DISP_PWD3
JBPWDFIND.3,DISP_PWD4
DISP_PWD1:MOVR3,#10HDISPLAYPASSWORD1
MOVTEMP,PCOUNT1
SJMPDO_AGAIN
DISPLAYPASSWORD2
DISP_PWD2:MOVR3,#20H
MOVTEMP,PCOUNT2
SJMPDO_AGAIN
DISPLAYPASSWORD3
DISP_PWD3:MOVR3,#30H
MOVTEMP,PCOUNT3
SJMPDO_AGAIN
DISPLAYPASSWORD4
DISP_PWD4:MOVR3,#40H
MOVTEMP,PCOUNT4
DO_AGAIN:

MOVA,#0C4H
ACALLCOMMAND
ACALLDELAY
DO_AGAIN1:LCALLREAD_FROM
ACALLDATAWRT
ACALLDELAY
DJNZTEMP,DO_AGAIN1
ACALLDLAYms
ACALLDLAYms
ACALLDLAYms
ACALLDLAYms
LJMPSTART2
SUCCESS:MOVFAILCOUNT,#0
MOVDPTR,#MSG3IFTHEID&PSWDAREMATCHEDTHENSTEEPPER
MOTORROTATES
ACALLDISPLAY
ACALLSTEPPER
LJMPSTART2
IFNOTMATCHEDTHENGIVETHREEBEEPSOUNDS
FAIL:
MOVDPTR,#MSG4

ACALLDISPLAY
INCFAILCOUNT
MOVA,#3
CJNEA,FAILCOUNT,TRY1
MOVFAILCOUNT,#0
MOVDPTR,#MSG13
ACALLDISPLAY
SETBP2.7
SJMP$
TRY1:SETBP2.7
ACALLDLAYms
ACALLDLAYms
CLRP2.7
ACALLDELAY
ACALLDELAY
SETBP2.7
ACALLDLAYms
ACALLDLAYms
CLRP2.7
ACALLDELAY

ACALLDELAY
SETBP2.7
ACALLDLAYms
ACALLDLAYms
LJMPSTART2
STEPPER:MOVDPTR,#MSG10
ACALLDISPLAY
ACALLDELAY
MOVTEMP,#15
ROTATE_R:ROTATECLOCKWISE
MOVP2,#06H
ACALLDELAY
MOVP2,#03H
ACALLDELAY
MOVP2,#09H
ACALLDELAY
MOVP2,#0CH
ACALLDELAY
DJNZTEMP,ROTATE_R
MOVP2,#0

ACALLL_DELAY
ACALLL_DELAY
ACALLL_DELAY
MOVDPTR,#MSG11
ACALLDISPLAY
ACALLDELAY
MOVTEMP,#15
ROTATE_L:ROTATEANTICLOCKWISE
MOVP2,#06H
ACALLDELAY
MOVP2,#0CH
ACALLDELAY
MOVP2,#09H
ACALLDELAY
MOVP2,#03H
ACALLDELAY
DJNZTEMP,ROTATE_L
RET
/*LCDDISPLAYSUBROUTINE*/
DISPLAY:MOVA,#01H

ACALLCOMMAND
ACALLDELAY
DISPLAY1:CLRA
MOVCA,@A+DPTR
JZXYZ
ACALLDATAWRT
ACALLDELAY
INCDPTR
SJMPDISPLAY1
XYZ:MOVA,#0C4H
ACALLCOMMAND
ACALLDELAY
RET
COMMAND:SENDCOMMANDSTOLCD
MOVP1,A
CLRP3.3
CLRP3.4
SETBP3.5
ACALLDELAY
CLRP3.5

RET
DATAWRT:SENDDATATOLCD
MOVP1,A
SETBP3.3
CLRP3.4
SETBP3.5
ACALLDELAY
CLRP3.5
RET
DELAY:
MOVR6,#200
HERE1:MOVR7,#100
HERE:DJNZR7,HERE
DJNZR6,HERE1
RET
DLAYms:
MOVR6,#100
MOVB,#00
MS1:DJNZB,$
DJNZB,$

DJNZR6,MS1
RET
L_DELAY:
MOVR7,#0AH
LLL:LCALLDLAYms
DJNZR7,LLL
RET
COMM:DB38H,0EH,01H,06H,84H,00H
ID1:DB"101",0
ID2:DB"102",0
ID3:DB"103",0
ID4:DB"104",0
PWD1:DB"100",0
PWD2:DB"200",0
PWD3:DB"300",0
PWD4:DB"400",0
ADMINPWD:DB"1234567890",0
MSGA:DB"WINKIT",0
MSGB:DB"LEARNINGISFUN",0
MSG:DB"SECURITYSYSTEM",0

MSG1:DB"ENTERID",0
MSG2:DB"ENTERPASSWORD",0
MSG3:DB"SUCCESS",0
MSG4:DB"FAIL",0
MSG5:DB"CHANGEPASSWORD",0
MSG6:DB"TYPECURRENTPWD",0
MSG7:DB"ENTERNEWPSWD",0
MSG8:DB"YOURPSWDIS",0
MSG9:DB"MAXLENTHOVER",0
MSG10:DB"DOORISOPENING",0
MSG11:DB"DOORISCLOSING",0
MSG12:DB"INVALIDPSWD",0
MSG13:DB"SYSTEMBLOCKED",0
KCODE0:DB'1','2','3'
KCODE1:DB'4','5','6'
KCODE2:DB'7','8','9'
KCODE3:DB'*','0','#'
END
PostedbyArunKumarat9:45AM

Recommend this on Google

Reactions:

funny (0)

interesting (0)

Nocomments:
PostaComment
Enteryourcomment...

Commentas:

Publish

Selectprofile...

Preview

Linkstothispost
CreateaLink

cool (0)

NewerPost

Home

OlderPost

Subscribeto:PostComments(Atom)

Labels

BlogArchive

8051(1)

2011(1)

8052(1)

2010(6)

8082(1)
assembler(2)
avr(1)
BASIC(1)
circuitsimulators(5)
communication(1)

2009(37)
November(1)
October(5)
September(11)
Solarpowerrelatedschematics

compiler(1)

Electronicprojectsrelatedtocomputers

cpu(1)

PASSWORDBASEDELECTRICAL
APPLIANCESCONTROLSYSTE...

deisgnwithmicrocontrollers(1)
delaygenerator(1)
EEPROM(1)

Microcontrollerprojectsandapplication
resources...

electronicsoftwares(4)

Infraredcircuitsrelatedresources

finalyeareceprojects(1)

AVRmicrocontrollerresources

hbridge(1)
hostcomputer(1)

PASSWORDBASEDELECTRICAL
APPLIANCESCONTROLSYSTE...

i/oports(1)

PIC16f84basedLEDchaser

interpreter(2)

FreePICmicrocontrollerbooks

microcontroller(3)
microcontrollers(2)
motor(1)

Freeebooksonmicrocontrollers
Freeelectronicsebooks

PROM(1)

August(1)

RAM(2)

July(2)

ROM(2)
serialport(1)
transistors(1)

February(5)
January(12)
2008(2)

Simpletemplate.PoweredbyBlogger.

You might also like