Tkool Electronics

IDescriptionIndailylife,calendarclocksareusedinvariousplaces.Suchasshoppingmalls,supermarkets,offices,homes,schools,etc.Comparedwiththetraditionalmechanicalclock,thedigitalcalendarclockhasaseriesofadvantages.Suchashighprecision,intuitivedisplay,andlonglife.ThisblogintroducesacalendarclockdesignedwithaDS1302rtcchip.DS1302RTCwithArduinoTutorialCatalogIDescriptionIISystemHardwareDesign2.1OverallStructure2.2DS1302ClockModule2.3LCD1602LCDModuleIIISystemSoftwareDesign3.1DesignofDS1302ClockSubprogram3.2LCD1602LiquidCrystalDisplaySubprogramDesignIVConclusionFAQOrdering&QuantityIISystemHardwareDesign2.1OverallStructureTakeAT89C51single-chipmicrocomputerasthemaincontroller,anduseDS1302clockchiptodesigncalendarclock.ItsoverallstructureisshowninFigure1.Figure1.OverallStructureofSystemThedesignedcalendarclockmustnotonlydisplayhours,minutesandseconds,butalsodisplayyears,months,daysandweeks.ThecoreofthesystemistheAT89C51microcontroller.Throughthesingle-chipcomputercontrolDS1302displaycalendarandtime.AndtheoutputresultisdisplayedonLCD1602liquidcrystalscreen.2.2DS1302ClockModuleTheDS1302clockchiphasthecharacteristicsoflowpowerconsumptionandhighperformance.Itcancommunicatewiththemicrocontrollerthroughasimplesynchronousserialmode,andonlyrequiresthreeI/Olines.Namelyreset(RST),I/Odatalineandserialclock(SCLK)2.2.1DS1302PinsandStructureFigure2showstheexternalpinsandfunctionsofDS1302.Figure2.DS1302PinoutVCC2-mainpowersupplypin;X1,X2-32.768kHzcrystaloscillatorpin;GND-ground;VCC1-batterypin;SCLK-serialclock;I/O-datainput/output;RST-reset.TheinternalstructureofDS1302isshowninFigure3,whichismainlycomposedofthefollowingparts:real-timeclock,datamemoryRAM,oscillatorcircuitandfrequencydivider,inputshiftregister,commandandcontrollogicandsoon.2.2.2DS1302RegistersandcontrolcommandsTheDS1302clockchiphas7registersrelatedtothecalendarclock,asshowninTable1.ThecommunicationsignalbetweenDS1302andsingle-chipmicrocomputerisrealizedthroughsimplesynchronousserialcommunication.AccordingtotheworkingtimingrequirementsofDS1302,whetherthesingle-chipmicrocomputerperformsreadoperationcommunicationfromDS1302orthesingle-chipcomputerperformswriteoperationcommunicationtoDS1302,eachcommunicationisinitiatedbythesingle-chipcomputerfirst.Inotherwords,beforeexecutingthecorrespondingreadorwriteoperation,themicrocontrollermustwriteabyteofcommandwordtoDS1302.Theeight-bitdataofthebytecommandwordisshowninFigure4.Figure4.CommandwordstructureofDS13022.3LCD1602LCDModuleTheLCD1602screencandisplaytwolinesofcharacters,16charactersperline,foratotalof32characters.Thereisan80*8-bitdisplaydatamemoryDDRAMbufferinLCD1602.SeeTable2forthecorrespondencebetweencharacterdisplaybitsandDDRAMaddress.TheaddressonthefirstlineofDDRAMstartsat00Handendsat27H.Theaddressesonthesecondlinestartat40Handendat67H,with40addressesperline.AndLCD1602displays16charactersperline.Therefore,whenwritingaprogram,selectthefirst16addressesofDDRAM.Itisimportanttonotethatthesecondlineaddressstartsfrom40H.IfyouwanttodisplayacharacterinacertainrowandcertaincolumnoftheLCD1602screen,writetheASCIIcodecorrespondingtothischaracterintothecorrespondingDDRAMaddressofacertainrowandcertaincolumn.Atthistime,youwillfindthatthecharactercannotbedisplayednormallyontheLCDscreen.Thereasonisthat80Hmustbeaddedtotheaddress.Forexample,todisplaythesymbolVinthesecondrowandsecondcolumnofthevoltageunitvolts,firstadd80HtothecorrespondingDDRAMaddress41Hinthesecondrowandsecondcolumn,thatis,C1H.ThenwritetheASCIIcode0x56correspondingtotheVcharacterintheC1Haddress.Onlythencanitbedisplayednormally.Thedisplayofothercharacterscanbededucedbyanalogyandwillnotberepeatedhere.IIISystemSoftwareDesignThesoftwareprogrammainlycompletesthefunctionsofdatareading,conversionandliquidcrystaldisplayofthecalendarclock.3.1DesignofDS1302ClockSubprogramsbitRST=P1^0;//DS1302resetportisdefinedinP1.0pinsbitSCLK=P1^1;//TheDS1302clockoutputportisdefinedontheP1.1pinsbitDATA=P1^2;//TheDS1302dataoutputportisdefinedontheP1.2pin(1)Theprogramthatthesingle-chipmicrocomputerwritesabyteofdatatoDS1302voidwright1302(unsignedchardate){Unsigneedchari;SCLK=0;//BepreparedfortherisingedgetowritedataDelaynus(2);for(i=0;i8;i++)//Writeeight-bitdatacontinuously{DATA=date0x01;//Writethebit0dataofdateintoDS1302Delaynus(2);SCLK=1;//WritedataonrisingedgeDelaynus(2);SCLK=0;//date=1;//moveoneplacetotheright}}(2)Theprogramforthesingle-chipmicrocomputertoreadabyteofdatafromDS1302unsignedcharreadd1302(void){Unsignedchari,date;Delaynus(2);for(i=0;i8;i++)//Continuouslyreadeight-bitdata{Date=1;//shiftonebittotherightif(DATA==1)//Ifthedatareadoutis1date|=0x80;//Takeout1andwriteitinthehighestbitofdateSCLK=1;//SetSCLKtoahighlevel,readoutforthefallingedgeDelaynus(2);SCLK=0;//PulldownSCLKtoformthefallingedgeofthepulseDelaynus(2);}returndate;//Returnthereaddata}3.2LCD1602LiquidCrystalDisplaySubprogramDesignThedriverprogramofLCD1602LCDscreenisrelativelycomplicatedtocompile,sowemustfigureouttheusageandmeaningofeachoperationinstructionof1602.Mainlyincludethefollowing:DisplaymodesettingDisplayswitchcontrolInputmodecontrolReaddatafromDDRAMWritedatatoDDRAMClearscreen,cursorhomesettingDataaddresspointersettingLCDscurrentbusyworksign...Partofthecodedesignisasfollows:voidLcd_initial()//InitializeLCD{E=0;Lcd_writecmd(0x38);//16*2display,5*7dotmatrixMsdelay(1);Lcd_writecmd(0x08);//displayoffMsdelay(2);Lcd_writecmd(0x01);//displayclearscreenMsdelay(2);Lcd_writecmd(0x06);//Setthecursor,afterreadingandwritingacharacter,thecursorincreasesby1Msdelay(1);Lcd_writecmd(0x0c);//displayison,nocursorisdisplayedMsdelay(1);}Figure5.HardwarepowersupplydiagramofDS1302calendarclockIntheMedwinV3.0developmentenvironment,useC51languagetocompilethesystemprogram,compileanddebug.AndloadtheHEXhexadecimalfilegeneratedbycompilingintotheMCUchip.StartthesimulationandyoucanseethesimulationrunningeffectoftheDS1302calendarclockdesignsystembasedon1602LCDdisplay.Forexample,thecurrenttimeis11:42:25onMay28,2019,andthesimulationresultisshowninFigure6.Figure6.SimulationresultsofcalendarclockItcanbeseenfromFigure6thatthecurrentdateandtimecanbedisplayedontheLCDscreeninrealtimeandaccurately.IVConclusionCalendarclocksareeverywhereinourlives.ThistexttakesAT89C51single-chipmicrocomputerasthemaincontroller,andusesDS1302real-timeclockchiptodesignthecalendarclocksystem.Inaddition,thehardwarecircuitwasdesignedintheProteussimulationsoftware,andthecorrespondingC51programwaswrittenintheMedwinV3.0developmentenvironment.Thejointuseofthesetwosoftwares,ProteusandMedWinV3.0,greatlyimprovestheefficiencyofsingle-chipsystemdesign,reducescosts,andshortensthedevelopmentcycle.FAQWhatisDS1302?DS1302isatickle-chargetimekeepingchipwhichcontainsareal-timeclock/calendarand31bytesofstaticRAM.DS1302usesserialcommunicationtointeractwithmicrocontrollers.Also,itautomaticallyadjustthedateforthemonthwithfewerdays.WhatdoesanRTCdo?Areal-timeclock(RTC)isacomputerclock(mostoftenintheformofanintegratedcircuit)thatkeepstrackofthecurrenttime.Althoughthetermoftenreferstothedevicesinpersonalcomputers,serversandembeddedsystems,RTCsarepresentinalmostanyelectronicdevicewhichneedstokeepaccuratetime.HowdoyouuseRTC?WiringItUp.5VisusedtopowertotheRTCchipwhenyouwanttoqueryitforthetime.Ifthereisno5Vsignal,thechipgoestosleepusingthecoincellforbackup.ConnectGNDtocommonpower/dataground.ConnecttheSCLpintotheI2CclockSCLpinonyourArduino....ConnecttheSDApintotheI2CdataSDApinonyourArduino.

TPS79301

ActingasaSTEMeducationaltoythatfosterstheircuriosity.

STM32F405OGY6TR-90-UFBGA, WLCSP-STMicroelectronics

simpleandeasytousewhichmakesthemperfectforsimpleDIYelectronicprojects.

TICC2540

Mybestsuggestionforyouiswheneveryoudecidetopurchaseanygadgetgetcompleteideaaboutitandthenmakeaplan.

BLU1RHD

Thissensitiveandadjustablemicrophonecanabsorbanymusicalbeatsandrespondtothelightsaccordingly.

CD4543BE

Itturnsresultinagreatlossofthesignalandquality.

UA5822

 Frequencyadjustmentscanbedoneinthestepsof1.

STM32F078VBH6-100-UFBGA-STMicroelectronics

equivalentandotherdetailsabouthowtouseitandinwhichapplicationsthistransistorcanbeused.

ISO17987

Coveredwithsoftfurwhichisverylife-like.

CH3−O−CH3

 FeaturesWorkVoltage:110VPower:60WTemperatureRange:200°C–450°CWeight:100gramsSolderingStand:SteelMet

STM32F105VBT6-100-LQFP-STMicroelectronics

Thesevoltageregulatorsarequitefamousandwidelyused.

Powered By Tkool Electronics

Copyright Your WebSite.sitemap