led反向应用

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

ECE476FinalProject:LEDSensorPianoKeyboardCristinaGuzman(cgg27)andJoeVulih(jpv23)ContentsIntroductionHighleveldesignRationaleBackgroundMathLogicalStructureHardware/SoftwareTradeoffsStandardsPatentsProgramDesignHardwareDesignResultsofthedesignSpeedofExecutionAccuracySafetyInterferenceUsabilityConclusionsExpectationsApplicablestandardsIntellectualpropertyconsiderationsEthicalconsiderationsLegalconsiderationsAppendixA:CommentedCodeAppendixB:OverallSchematicsAppendixC:CostdetailsAppendixD:TasksAppendixE:ReferencesIntroductionOurprojectutilizesanarrayofLEDsthatworkaslightsensorstogenerateamusicaltone,simulatingapianokeyboard.ThebasicideaistouseLEDsasbothemittersandsensors.Forourprojectspecifically,weusedatotalof63LEDs,9foreachofthesevennaturalkeys.OnlythemiddleLEDservedasphotodetectorwhenthekeywaspressed,absorbinglightfromtheotherLEDsreflectedfromthefinger.WethenusedtheKarplus-Strongalgorithmforsoundgeneration,allprogrammedinC.Thetonewaspassedthroughanaudioamplifier,andcanbelistenedthroughheadphonesorspeakersconnectedtotheaudiojack.WechosethisprojectbecausewewantedtodosomethingwithLEDsassensors,andspecificallychosemusicbecauseofourinterestinthismatter.BacktotopHighleveldesignRationaleBackgroundMathLogicalStructureHardware/SoftwareTradeoffsStandardsPatentsRationaleTherationalebehindthisideaconsistsofusingadiodeina3stepprocess,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

1 / 36
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功