资源描述:
《单片机设计简易正弦波发生器(single chip microcomputer design simple sine wave generator)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、单片机设计简易正弦波发生器(Singlechipmicrocomputerdesignsimplesinewavegenerator)Youknowtherestof>'sfulltextdataregister,andyoucandirectlyinterfacewiththemicrocomputerwithouttheextracircuit.Anothertypeofchipinternalnodataregister,theoutputsignalchangesoverthestateofdatainputline,soyoucan'tdirectly
2、withamicrocomputerinterface,mustthroughtheparallelinterfacewithmicrocomputerinterface.DAC0832isAdual-lineCMOSdevicewith20leads.IthasAtwo-stagedataregisterinside,whichcompletesthe8-bitcurrentD/Aconversion,sonoadditionalcircuitisrequired.0832isthecurrentoutputtype,shownontheoscilloscop
3、ewaveform,usuallyneedtovoltagesignal,currentsignaltovoltagesignalconversioncanberealizedbyoperationalamplifierLM358,withtwopiecesofLM358bipolaroutputisavailable.Singlechipsendsnumericcodingto0832,producingdifferentoutput.Samplingtheoremisusedtoanalysethevariouswaveformsamplingfirst,a
4、ndthenputthecodesamplesvalues,tothedigitalquantityineachwaveformlist,executeAprogramthroughthelook-uptablemethod,inturnafterD/Aconversionoutputwaveformcanbecalculatedout.IfNpointsconstituteaperiodofwaveform,then0832outputsNsamplepoints,andthesamplepointsformamotiontrajectory,namelyap
5、eriod.RepeattheNpointtobecomethesecondcycle.Thespeedoftheoutputcycleiscontrolledbythesinglechipmicrocomputer,whichcontrolsthefrequencyoftheoutputwaveform.Thiscontrolstheoutputwaveformanditsamplitudeandfrequency.Iv.SoftwaredesignBoththemainprogramandthesubroutinearestoredintheAT89S51s
6、inglechip.Isthefunctionofthemainprogram:bootaftercheckbutton,keyboardscanninganddisplaythejob,andthenaccordingtotheusersaccordingtothekeytothecorrespondingsubroutineforprocessing,themainprogramblockdiagramisshowninfigure1.Thefunctionsofasubroutineinclude:amplitudeinputprocessing,freq
7、uencyinputprocessing,sinewaveoutput,sawtoothwaveoutput,squarewaveoutput,display,etc.Here'stheprogramInclude#defineucharunsignedchar#defineuintunsignedintSbitLCP=P2^2;SbitSCP=P2^1;SbitSI=P2^0;SbitS1=P2^3;SbitS2=P2^4;SbitS3=P2^5;SbitS4=P2^6;SbitS5=P2^7;SbitDA0832=P3^3;SbitDA08
8、32_ON=P3^2;U