REAL TIME ADAPTIVE NOISE CANCELLATION ON A FPGAsedwards/classes/2016/4840-spring/reports/… ·...
Transcript of REAL TIME ADAPTIVE NOISE CANCELLATION ON A FPGAsedwards/classes/2016/4840-spring/reports/… ·...
-
REALTIMEADAPTIVENOISECANCELLATIONONAFPGA
AshwinKarthikTamilselvan(at3103) RishikanthChandrasekaran(rc3022)GikkuStephenGeephilip(gg2624) RichaGlennNetto(rn2388)
-
1. OverviewOur project involves implementation of an adaptive noise canceller that takesenvironmentalnoiseasaninputandreducesitinreal-time.Externalsoundisubiquitous;an importantrequirementofcertainenvironmentssuchasvehiclesandaircrafts, is tominimizethenoiseexternaltothesysteminconsideration.Wehaveimplementedourprojectusinganadaptivefilterbasedonthefast-LMSalgorithmandinterfacedtheFPGAwithhardwareperipherals,amicrophoneandaspeaker,tocapturethenoiseandplaythereducednoiseresultrespectively.WehaveutilizedtheaudiocodecontheFPGAtoprocessthesoundsignals.
2. GeneralDescription
a. AdaptiveNoiseCancellation
Noisecancellationhasalwaysbeenoneofthemostfascinatingandconsumermarket-drivenareaofresearch.Inanidealsetup,anefficientcommunicationisoneinwhichthecompletemessageproducedfromthesourceisreproducibleinthedestination.Anidealsetupwouldbeexpectedtobefreeofanyextranoisethatcoulddisruptthecommunicationleadingtothelossofapartofthemessageorthecompletemessagetransmitted.Butanidealsetupisverydifficulttoachievepractically.Communicationhasbeenanintegralpartofthehumanlifeandhavebeenutilizedinvariousforms.Mediatransmissionisonesuchwidelyusedtypeofcommunication.
A special case of audio transmission has been discussed in this project. NoiseCancellation is a technique developedwith an aim of providing the best possibletransmissionofaudiosignalswithoutconsiderablelossofdateordisruptionoftheoriginal signal.Noisesarean inherentlypresentaspartof theenvironment.Noisecancellationintheorywouldaidinthereplication/reproductionoftheaudiosignalinthesamestate, itwastransmittedfromthesource.Varioustechniqueshavebeendevelopedovertimeandadaptivenoisecancellationisapopulartechniqueusedinthemarket.
AdaptiveNoiseCancellationprimarilydealswiththegenerationofanti-noisewhichintheory would cancel out the ambient noise. Adaptive noise cancellation can bebroadly divided into three different setups depending on the position ofmicrophone/s,witheachsetuphaving itsadvantageover theother - FeedforwardNoiseCancellation,FeedbackNoiseCancellationandHybridNoiseCancellation.
-
WehaveselectedFeedforwardNoiseCancellationtorealizetheworkingofAdaptiveNoiseCancellationonaSoCkitCycloneVboard.Inthissetup,amicrophoneisplacedoutsidetheearcupofaheadphonegivingtheadvantageofextraresponsetimeovertheFeedbackNoiseCancellationsetup.ThisimplementationofANCfaresbetteratreducinghighfrequencynoiseupto1-2kHz.Wehaveusedasinglemicrophoneandanaudiooutput(speakers/headphones)inoursetup.Wehavemodelledthesystemsuchthatthemicrophonefeedstheenvironment/ambientnoiseastheinputtothesystemanda reducednoise is obtainedat theoutput. The anti-noiseproduced issuperimposedontheinputnoisesignal.Thisleadstothepartialcancellationofthenoisesignalresultinginareducednoisesignal.
b. LeastMeanSquareAlgorithm:
WehaveusedtheLeastMeanSquareAlgorithminthisproject,mainlyowingtoitscomputationalsimplicityandeaseofimplementation.Thisalgorithmisbasedontheunderlying concept of Least Mean Squares and the Steepest Descent Algorithm,however,iteliminatestheneedforexactmeasurementsofthegradientvectoranddoesnotinvolvematrixinversion.TheLMSalgorithmisaclassofadaptivefilterusedto mimic a desired filter by adjusting the filter coefficients in such a way that itproducestheleastmeansquareoftheerrorsignal,ie,ifweconsidertheerrortobea cost function, the LMS algorithmbasically finds filter coefficient values that canminimizethecostfunction.Theerrorsignalinthiscaseisthedifferencebetweenthedesired and actual signal. Our project implements an adaptive filter using amoreefficientvariationoftheLMSalgorithmtoupdatetheweightsofthefilterinreal-timewhilesimultaneouslyensuringthatthecomputationalloadontheFPGAisreduced.
-
FigX:BlockDiagramofAdaptiveFilterusingLMSAlgorithm ThesignalsshownintheFigXaredescribedasfollows:
i. u(k)istheinputvector(purenoisesignal)ii. d(k)isthereferencesignal,ie,thecontaminatedinputsignaliii. y(k) is the output of the adaptive filter, which gives us anti-noise or
reducednoiseiv. e(k)istheestimatederrorobtainedbysubtractingtheanti-noisefromthe
contaminatedsignal.Thisisessentiallythefinalreduced-noiseoutputofthesystem.
ThefollowingequationsdefinetheworkingoftheLMSalgorithm:
i. FilterOutput:y(k)=uTWwhere,W=vectorofweightsappliedtothefiltercoefficients T=transposeoperation
ii. EstimatedError:e(k)=d(k)–y(k)iii. WeightUpdate:Wk+1=Wk+2*μ*e(k)*uk
Theestimatederrorand the inputnoisevectorareappliedas feedback to theadaptiveprocedure.μisthestepsizeandisinverselyproportionaltothesettlingtimeconstantoftheconvergencebehavior.Forsmallervaluesofstepsize,theadaptiveprocessslowsdownbutthemean-squareerrorisminimized,ie,ittakeslongertoconvergebuttheresultsarebetter.Similarly,forlargervaluesofstepsize,theadaptiveprocessconvergesquickly,buttheresultsarenotasgoodasthoseobtainedwithasmallerstepsize.
c. Fast-LMSAlgorithm
Inoursystem,theadaptivefilterisimplementedusingtheFast-LMSAlgorithm.Itfollowsthefollowingequationforupdatingtheweights:
Wk+1=Wk+e(k)*sign(u(k))>>n
The Fast-LMS algorithm replaces step size with a shift operation, where nrepresents the number of shifts. Also, Fast-LMS only uses the sign bit of thereferenceinput,u(k),insteadofusingitsvalue.
-
FigX:
d. AudioCodec:
TorecordandplayaudioontheFPGA,wehavetobuildan interface to theaudiocodec.Thisbidirectional interfacewillenableustocaptureaudiofromandstreamaudiotothehardwareperipherals,suchasmicrophonesandspeakers.Whensoundtravelsthroughtheairmedium,themicrophoneperceivesitaspressurewavesthatcreatealternatingareasofcompressionandrarefactionasittravelsfromthesourcetothemicrophone.Themicrophonethenconvertsthepressurewavesintoanelectricalsignal,usingavoltageleveltorepresentthepressureatapointinthewave.Thevoltagelevelsarecontinuousintime,sonowwehaveanalogsignals,whichtheFPGAcannotprocesssinceitacceptsdigitalquantitiesandrunsatafixedclockrate. Theaudio codecon the FPGA converts the analog voltage values todiscretequantitiesbycapturingvoltagelevelsatregularintervalsbasedonasamplingrate,and then performing analog-to-digital conversion (ADC) to discretize the capturedvoltagelevels.Inthereverseprocess,whenwewanttoplayanaudiosignalfromtheFPGAthroughthespeakers,thecodecperformsdigital-to-analog(DAC)conversion,which results in a slight lossof informationdue to reconstructionof a continuoussignalfromabunchofdiscretevalues.The audio codec on this FPGA (Analog Devices SSM2603) is configured withparameterssuchassamplingrateandsamplingwidthusingtheI2Cprotocol.
3. Setup
a. AdaptiveNoiseCanceller–PhysicalSetup
-
The setup of our project requires one microphone, one speaker and a noisesource.Weareusingawhitenoisesourceplayedoutofacellphoneasthenoisyinput.Themicrophoneisheldnearthenoisysourceandispluggedintothemic-inportontheFPGA.Theline-outportonFPGAisconnectedtoaspeakeranditgivesthereducednoiseasanoutput.
b. Fast-LMS
WehavedecidedtouseFast-LMSinsteadofLMSforourprojectbecauseFast-LMSonlyusesthesignbitoftheinputintheformulawhereweightsareupdatedandhence, it significantly reduces the number of multiplications required andsimplifiestheimplementationoftheLMSfilterinhardware.Italsoreplacesstepsizewithashiftoperation,furthersimplifyingthealgorithm.
WehavemodifiedtheblockdiagramofAdaptiveNoiseCancellationtoaccountfor the fact that our input to the system is noise (in the inherent presence ofsilence)recordedthroughamicrophone.TheAdaptiveFilteralsogetsthesamenoisyinput,anditgeneratesareducednoisewhichisrepresentedinthediagramas Filter Output. Then, we subtract the Filter Output from the Noisy Input togeneratetheerroroutput,whichisthereducednoisesignal.Thisisthensentbackto theadaptive filter so that it canbeused toupdate theweightsof the filtercoefficients.Finally,thereducederroroutputissentoutviaaspeaker.
FigX:
c. AudioCodec
TheSSM2603AudioCodectakes16-bitdatawords.Eachtransmissionwillinclude3 acknowledgements before the stop symbol must be sent. The maximumfrequencyofSCLKis526kHz.SCLKisdivideddownby128,givingafrequencyof
-
about 390 kHz. The codec only checks for acknowledgements after all 24-bits(includingaddress,dataandr/wbit)aretransmitted.Theacksignalissethighifalltheacknowledgementshavebeenreceived.UsingthedatasheetoftheSSM2603AudioCodec,wehaveassignedvaluestotheregisters that we require in our system. The audio codec organizes itsconfiguration variables into 19 9-bit registers. The first seven bits of thetransmitteddataareregisteraddress,thelast9bitsaretheregistercontents.
Register RegisterName
Value
R0 LeftChannelADCInputVolume
000010111
R1 RightChannelADC
InputVolume
000010111
R2 LeftChannelDACVolume
001111001
R3 RightChannelDAC
Volume
001111001
R4 AnalogAudioPath
011010100
R5 DigitalAudioPath
000000100
R7 DigitalAudioInterface
000000001
R8 SamplingRate
000100000
-
4. Implementation
WedevelopedthesystemmodelwithSimulinkandevaluatedthemeasureddatausingMATLAB.WethenusedModelSimtoverifytheresultsofthehardwaresimulationoftheadaptivefilterusingFast-LMSalgorithmandplotte dtheobtainedoutputusingMATLABtoverifythenoiseattenuation.ThefinalsynthesisoftheSystemVerilogcodehasbeendoneontheprovidedSockitCycloneVFPGA.
a. SimulinkandMATLABTheLMSalgorithmwasmodelledonSimulinkandMatlabtoverifyoperation.Wealsousedmatlabtoiterateoverthedesignofthealgorithmtomakeitmoreefficient.WemathematicallymodelledthealgorithmandreducedthecontrolblockdiagramstomakeitsuitableforimplementationontheFPGA.WethentestedthedesignedalgorithmwithactualaudioinputfromamicinterfacedviaUSBandplayedbacktheoutput.TheSimulinkblockdiagramdesignedisshownbelow:
-
b. ModelSimTheRTLorhardwaredesignwasdoneinSystemVerilogandfirstsimulatedonModelSim.Astatemachinewasdesignedtotakecareofdifferentsequenceofprocessingsinvolved.Thestatemachinehas6states.Thestatemachinetransitionsoccuronthepositiveedgeofthemainclockwhichrunsat50MHz,butthetriggeringofthestatemachineisonthepositiveedgeoftheDACclock(theIdlestatewaitsforthepositiveleveloftheDACclock).Thefirststate:WaitsfornoiseinputsampleSecondState:ComputefilterweightsThirdState:StorenoiseinputincircularbufferFourthState:IncrementbaseaddresspointerofcircularbufferFifthState:RestoreprevioushistoryofnoisesamplefromcircularbufferforeachtapSixthState:IdleState
-
Theerrorvaluesarecalculatedusingcontinuousassignmentstatementswhichcomputersthevaluesinstantlywhenanyofitsinputchanges.TheoutputvaluesfortheDACarewrittenatthenegativeedgeoftheDACclocksothatthedataisreadyforpushingtotheDACintheaudiocodecduringthenextimmediateclockcycle.WerecordeddatafromamicviaMATLABhaditconveredtointegersamplestofeedintotheModelSImsimulationinrealtime.AtestbenchwasalsodesignedinsystemVerilogwhichfeedsinputgeneratedasmentionedaboveintothedesignedSystemVerilogmoduleinreal-timeaccordingtotherequiredclock.Italsorecordstheoutputtoafileinreal-time.TheoutputdateisthentakenoutandplottedinMatlabtocheckthefunctioning.Theplotisshownasseenbelow:
-
5. ChallengesandLessonsLearnt:CHALLENGES:a.FiguringoutAudioCodec:Extensivereadingofthedatasheettofigureoutthe differentmodesandconfigurationregistersb.ImplementingI2CcommunicationfortheAudioCodecc.LMSoptimizationandreduction:SpentweekspouringoverresearchpapersandmathtofigureoutdifferentoperationsandhowwecouldreducethemtoenablefasterconvergenceaswellasreducemultiplicationstomakeiteasiertoimplementonFPGA.d.Findanalternativetofloatingpoint:Ideallytheweightsarefloatvalueswhichprovidebetterfilterperformance.SincetheSoCKitAlteraFPGAdoesnothaveafloatingpointunit,wehadtouseonlyintegerwaitsandhadtofindawaytoworkwiththat.e.IntegratingtheAudioCodecandtheLMSmoduletogetherforreal-timeperformanceLESSONSLEARNT:
a. Designingreal-timeembeddedsystemsrequiresagoodknowledgeofclocklevelexecutionofstatements.
b. Clockisgod.c. Timemanagement
6. FutureWork:ThesamesetupcanbeusedwithamoreoptimizedversionofthefastLMSalgorithmoramoreoptimizedalgorithmtoprovidebettercancellationeffect.Themodeltakesinambientnoiseasaninputandproducesareducedversionofthenoisesignalusingasinglemicrophoneandasingleaudiooutput.Inthecurrentsetup,silenceisinherentlymixedwiththeambientnoisesignaltoformtheinputofthesystem.Thissystemcanbeextendedtotakeanyaudiosignalmixedwithanambientnoiseandprovideanoisereduced/cancelledaudiosignalastheoutput.Anenhancementtoprovidesupportformp3formataudiofilescanbeaddedtoimprovetheflexibilityandextendtheoperationdomainofthesystem.
7. Contribution:a.SystemDesign:Richa,Gikkub.LMS:AlgorithmDesign:Richa,GikkuFPGA:Gikku,Rishic.AudioCodec:Rishi,Ashwin
-
d.Presentation:Rishi,Ashwind.Report:Richa
REFERENCES:[1]http://www.ti.com/lit/an/spra095/spra095.pdf[2]Foul,Wolfgang,JörnMatthies,andBerndSchwarz."AFPGA-basedadaptivenoisecancellingsystem."Proc.ofthe12thInt.ConferenceonDigitalAudioEffects(DAFx-09).2009.[3]Software/HardwareImplementationofanAdaptiveNoiseCancellationSystem”Dr.WagdyHMahmoud,Dr.NianZhang,UniversityoftheDistrictofColumbia[4]https://people.ece.cornell.edu/land/courses/ece5760/FinalProjects/f2011/jy554_jc2636/jy554_jc2636/_fpgaimplementation.htm[5]http://blog.jabra.com/anc-headsets-arent-all-the-same-three-types-of-anc/[6]http://www.analog.com/media/en/technical-documentation/data-sheets/SSM2603.pdf[7]SoCKitUserManual