您好,欢迎访问三七文档
ECE476FinalProject:LEDSensorPianoKeyboardCristinaGuzman(cgg27)andJoeVulih(jpv23)ContentsIntroductionHighleveldesignRationaleBackgroundMathLogicalStructureHardware/SoftwareTradeoffsStandardsPatentsProgramDesignHardwareDesignResultsofthedesignSpeedofExecutionAccuracySafetyInterferenceUsabilityConclusionsExpectationsApplicablestandardsIntellectualpropertyconsiderationsEthicalconsiderationsLegalconsiderationsAppendixA:CommentedCodeAppendixB:OverallSchematicsAppendixC:CostdetailsAppendixD:TasksAppendixE:ReferencesIntroductionOurprojectutilizesanarrayofLEDsthatworkaslightsensorstogenerateamusicaltone,simulatingapianokeyboard.ThebasicideaistouseLEDsasbothemittersandsensors.Forourprojectspecifically,weusedatotalof63LEDs,9foreachofthesevennaturalkeys.OnlythemiddleLEDservedasphotodetectorwhenthekeywaspressed,absorbinglightfromtheotherLEDsreflectedfromthefinger.WethenusedtheKarplus-Strongalgorithmforsoundgeneration,allprogrammedinC.Thetonewaspassedthroughanaudioamplifier,andcanbelistenedthroughheadphonesorspeakersconnectedtotheaudiojack.WechosethisprojectbecausewewantedtodosomethingwithLEDsassensors,andspecificallychosemusicbecauseofourinterestinthismatter.BacktotopHighleveldesignRationaleBackgroundMathLogicalStructureHardware/SoftwareTradeoffsStandardsPatentsRationaleTherationalebehindthisideaconsistsofusingadiodeina3stepprocess,asshowninthefollowingschematic.Eachstepisapproximately1millisecondlong.TheupperpinwillstartsatVccandstaythereforonemillisecond(stepone),andthendroptogroundfortwomilliseconds(steptwoandthree).Thelowerpinwillstartatgroundforstep1,thenrisetoVccforthelengthofsteptwoandfinallythediodewilldischargeexponentiallyduetothehole-electrongenerationduetotheincidentlightontheLED(8pinleakages).ForthesoundgenerationwewillusetheKarplus-Strongalgorithmdevelopedinthe80s,whichiscomputationallysimple.Itisamethodofphysicalmodelingastringthatsimulatesthesoundofsometypesofinstruments,includingthepiano.Itusesalowpassfilterandadelayblock,whichwewillimplementinsoftware.Aschematicofhowitworksisshownbelow.BackgroundMathTheoutputfrequencyforeachnotewascalculatedfromtheformula,WhereNisthelengthofthedelayline,andfsisthesamplefrequencyatwhichtheloopisupdated.Forthisprojectweusedasamplerateof8kHz.Whilethissampleratecausessomequantizationofpossiblefrequenciessincethedelaylinehasonlyintegerlengths,wewerestillabletogetrelativelyaccuratefrequencysynthesis.Theinputx(n)isexcitedusingasignalnoiseuntilthedelaylineisfilledtoexcitetheentiresystem.Thelowpassfilterissimplyamovingaverage,whichhastheequationbelowwheregisalossfactorthatmustbelessthan0.5forthesystemtobestable.Bymakinggsmallerthesignalwilldieoutfaster.LogicalstructureAboveisablockdiagramofthesystemwiring.TheMCUinterfaceswiththeLEDarraytogetthehumantouchinterfaces,andthenproducesasoundoutputthatispassedthroughtheaudioamplifiertothespeakers.Hardware/SoftwareTradeoffsWeimplementedalowpassfilterinsoftwarefortheKarplus-Strongalgorithm.Eventhoughlowpassfilterscanbemadewithhardware,forthispartitwasnecessarytodoitinsoftware.Also,whileweimplementedtheKarplus-Stronginsoftware,thealgorithmwouldworkmuchfasterinhardware,butwedidnothavetheexpertisenorthetimetodesignonthealgorithmonanFPGA.Wealsodecidedtouseintegersforourvariablesinourcodeinsteadoffloatsbecauseeventhoughthisgiveslessaccuracy,itisfasterandtimingwasmoreofanissue.StandardsOnestandardthatwefollowedinourdesignisISO16:1975thatspecifiesthatinmusictheAabovemiddleCis440Hz.PatentsSomeintellectualpropertyrightsweconsideredaretwopatents,bothconcerningtheKarplus-Strongalgorithm.Onepatentisthe“Wavetable-modificationinstrumentandmethodforgeneratingmusicalsound”(PatentNumber4,649,783)andtheotheris“Independentlycontrolledwavetable-modificationinstrumentandmethodforgeneratingmusicalsound”(4,622,877).Theyarebothexpired,sincetheywerefiledintheearly80s.BacktotopProgramdesignThesoftwarewasgroupedintotwofunctions.ThefirstwasthesensingoftheLEDsandthesecondwasthegenerationoftheaudiotones.TheLEDsensingwascontrolledbyastatemachinethatupdatedapproximatelyeverymillisecondandscannedtheentirekeypadonebuttonatatime.Sinceweonlyhad7buttons,wewereabletoscanthekeypadinaround16ms.ThisroutinewouldtheneitherreinitializetheKarplus-Strongroutineforaspecificbutton,oritwouldchangethedampingonthestringtoshutoffabutton.TheKarplus-Strongsoundsynthesiswasalwaysrunning.Thestringswerealwaysbeingupdated,andwhethertheywereplayingaudiblyornotwasdependedonthedampingonthestring.Thebuttonroutinewouldsetthedampingreallyhighifthebuttonwasnotpressed.Thisisequivalenttothestringsofthepianoalwaysbeingpresent,exceptbeingheavilydamped.ApartthatwastrickytowritethepartofsummingofeachoftheoutputsfromtheKarplus-Strong.Thiswasdifficultduetothefactthatwewereusingonlya10bitPWMontimer1.Todothiswefirstaddedupalltheoutputsaslongs,then,sincetheyarerepresentedusing16bits,werightshiftedthevalueby9bitssincetheadditionof716bitnumberscouldproduce19bitsofoutput.ThenanoffsetwasaddedtocenterthePWMatthemiddleofitsrange.BacktotopHardwaredesignThemajorhardwarecompon
本文标题:led反向应用
链接地址:https://www.777doc.com/doc-3218230 .html