Anda di halaman 1dari 5

Global/English

HOME

BLOGS

FORUMS

PROJECTS

DOWNLOADS

FAQ

Searchthissite

NOTICE:Thiswebsitewillbeshutdowninthenearfuture.Productcontenthasmovedtonxp.com.ForumcontentandFAQshave
beenmovedtocommunity.nxp.com.Weencourageyoutocreateauseraccountonnxp.comtousethenewcommunityforumsand
accessNXPmicrocontrollercontent.Wegreatlyappreciateyourcontribu onsandlookforwardtoseeingyouatournewweb
loca on.

ECGApplicationExampleusingLPC4370andLabToolHardware
Home
SubmittedbyNXP_SupportonThu,2013112115:18

ADCHSandDACprogrammingwithLPCLink2+LabTool
DirceuRodrigues,Jr.Oct.2013

Bio
DirceuRodrigues,Jr.isacomputerengineerwithamaster'sdegreeinelectricalengineering.Asanindependentconsultant,hetestsnewproductswithparticularinterestintheareasofwireless
sensornetworks,ARMprocessors,DSP,motorcontrol,andmedicalapplications.

Introduction
WhenIgotinvolvedwiththiscampaign,myinitialideawastousetheNXPLPC4370microcontrolleravailableontheLPCLink2toimplementamulticoreFIRfilter.Combinedwiththeanalog
processingcapabilitiespresentonLabTooladdonboard,wouldbeidealtoputinplaceastructurewhichIdiscussedonESCBrazil2013(MulticoreMicrocontrollersinInstrumentationandControl).But
afteratimestudyingtheschematicsoftheseboards,Irealizedthatunderstandingthesignalconditioningcircuits,gainsettings,inputcalibrationandthecorrectuseofADCHS(12bitHighSpeedADC)
peripheralandexternalDAC,deserveawholearticle.Forme,themostimportantfeatureoftheboardLPCLink2(inadditiontobeingaprogrammer/debuggerforthetarget)isabletoprogramageneric
applicationonLPC4370memory,sincethereareseveralanalog/digitalpinsavailableonexpansionconnectors.
Firstly,IdownloadedthelatestversionoftheARMKeilVision(V4.72.10.0).Attime,IhadnotexperiencedthenewLPCOpenlibrary,soIchangedtheLPC43xx.hprovidedbythecompilerto
addarawsupportforADCHSperipheralrenamingittoLPC43xx_new.h.Thechangeconsistsprimarilyindefineregisteraddresses,enablingreferencessuchasLPC_ADCHS>xxx.Beforeattach
LPCLink2ontopofLabToolboard,Iconnectedthe10pinSWDcableonJ2ofLPCLink2,accordingFigure1.Willlooklikethecableissqueezedbetweentheboards,butthatisquitenormal.Also,
theusermusttoensuretheotherconnectorsarenotslightlymisaligned.

LabToolAnalogInputs
NextItriedtounveilthestructurearoundthehighspeedanalogtodigitalconverter.ThereasonforthepresenceoftheBNCconnectorsonLabToolistoimplementacompletetwochanneloscilloscope,
whosefeaturesarefarfrommodest,sincetheLPC4370includesa12bitADC,andcanoperateupto80MHz.Notethatthetwo10bitADCmodulesareabsentonLPC4370TFBGA100packageused
inLabTool.AverysimplifiedschematicofinputconditioningcircuitforeachchannelisshownonFigure2.Thecompletedesign,providedbyEmbeddedArtists[1],includesseveralothercomponents,
includingcapacitorsforshapingthefrequencyresponse.

Allse ngsarecontrolledviatheSPIinterface,includingtheDC/ACcoupling.Theinput(0.5V)isprovidedbyaproperMCUpinrelatedtoADCHS,asIwillexplainlater.Twoanalog
mul plexersallowsetthegainwhenchangingtheopera onalamplierfeedbackresistor.Fromthenominalvaluesofcomponentsongure,wecanwritesomeequa onsfortheDC
model:

Search

TheLPC4370ADCisaashtypewithdieren alinputFigure3.

Thevalueconvertedtodigitaldomain,aspresentedonpage1287ofLPC43xxUserManual(2013dra version),is:

ThroughtheDCINNEGandDCINPOSbitsonADCHSPOWER_CONTROLregister,theusercanadda0.5VDCosettothedieren alinputs.InthecaseofLabtoolboard,isconvenient
makeDCINNEG=1andDCINPOS=0,consideringthepresenceofampopwiththenoninver nginputvoltage

accordingFigure2.Withthesese ngs:

and

Also,notethat

Subs tu ngtheseresultsonEq.4:

,and:

Dening:

ThevalueofGAdependsonposi onoftwomul plexers(feedbackresistorselec on1out8)andSPDTswitch(dividedinputvoltageselec onVUorVD).So,IcancreatetheTable1,


whichallowmetocalculatetheanaloginputvalueorVCH1,foreachselec on.

Feedbackresistance

NoninvertingAmp.Op.gain

GA

VCH1

2k87//158R

0.4

2k87//536R

0.8

2k87//1k65

1.6

2k87

20

0R

0.016

1k33//270R

2.5

0.04

1k33//1k07

5(4.95)

0.08

1k33

10(9.86)

0.16

In order toobtain a value of acceptableprecisionit's required to compensate the ADC readings (NADC) for component tolerances and other devia ons associated with the input
condi oningcircuit.Thisisdoneinso ware.Ananefunc on(gainandoset)makesthecorrec onbasedonthecurrentreadingandpreviouscalibra ondataLis ng1.

Rememberthatameasuringinstrumentisnotonlyasgoodasitscomponents,butalsoasthecalibra onmethodused.

LabToolAnalogOutputs
TheDigitaltoAnalogsec onismorestraigh orward.Sincethe10bitDACmoduleisabsentonLPC4370TFBGA100package,theLabToolboardreliesonexternalDAC102S085from
Na onaltooutputtwoanalogvoltages.Asbefore,thesimplerschema conFigure4showstheessen alcomponentsfortheDCmodel.

OnLabToolboard,theLPC4370SSP1peripheralhasthreeusages:
SettingsfortheADCHSconditioningcircuit.
WritingonDAC
CommunicationwithanEEPROM

Thesharingiscarriedoutthroughappropriateslaveselec onsignals(SSELandGPIOs)fromMCU.TheDAChastwochannelswithinternaldataregisterincludingcontrolsfor
update/refresh ming.

Therelevantequationsare:

SubstitutingEq.7inEq.8:

Applica on:FilteringanECG
InordertotesttheADCHSandrelatedequationsobtainedfromtheLabToolmanufacturerschematics,IdecidedtoprogramtheARMCortexM4onLPC4370toimplementastopbandFIR(Finite
ImpulseResponse)filterwith127taps.TheideaistofilteranECGsignalcorruptedby60Hzhum.Toavoidbuildingacircuitaroundaninstrumentationamplifier(somethingI'vedoneafewtimes)and
wastesomeskinelectrodesIthoughtusingthecomputersoundcardtogeneratethedesiredsignal.So,thefollowingtaskswereperformed:
FindanECGsignaldatabaseinaudioformat[2].
Selectthefileecg.wav(60sduration,16bit,1kSa/s).
ExtractthefiledataonMatlab,inserta60Hznoiseandrewriteitinwavformat.
PlaythefileoncomputerlineoutusingasoftwareforaudioeditinglikeGoldWave.
Thiswillallowsomeexperimentation,asrepeatintervals,invertpolarity,attenuateandmanyotherusefultransformationsFigure6.
DesignanotchFIRfilterinMatlabandsimulatetheresult.
Makeaheaderfilewiththegenerated127coefficients.

Forthisapplica on,IusedDCcouplingoninput(capacitorshortcircuitedonFigure2).Also,theADCHSwasconguredtopresenttheresultintwoscomplementformat(otherop on
isosetbinary).Figure7showsadiagramfortheFIRltercoecientsandoutputlabeledascandNFILT,respec vely.

Tochecktheresult,thelteredsignalissenttotheanalogoutputinreal me.ForthisitsnecessarytoperformaconversionbetweentheADCHSandDAC102S085rangesusing
appropriateequa ons.HereIhaveatleasttwoop ons:
1.Takingadvantageofmaximumavailableresolu on(notused):
Inthiscase,theconversionisperformedthroughtheEqua on10andFigure8.

Subs tu ngEq.10onEq.9:

Inordertoensurecompa bilitywiththeamplitudeofsoundcardoutputitisappropriatetoselectthegain10fortheADCnoninver ngamplier(lastrowofTable1).Therefore,the


equa onfortheanalogtodigitalconversionis:

Thisleadstoamaximuminputvoltagearound+/2.5V,when2048<=NFILT<+2048.CombiningEq.11andEq.12,therela onshipbetweeninputandoutputisgivenby:

2.Equalamplitudes(input/output):
IntheECGlteringapplica oonitisdesirablethattheoriginalandlteredsignalshadthesameamplitude,ora1:1rela onship.Therefore,I'vecarriedadierentconversioninorder
tomeetVEXT_AOUT1=VCH1.S llmaintainingthegain10betweenVCH1andNFILTandequa ngEq.12andEq.9:

Thusresul ngintheequa onresponsiblefortheconversion:

ArmedwihtthismodelingIdidasimula ononMatlab.TheplotsonFigure9allowedmetocheckthelterperformancebycomparingtheinput,thenoisysignalandtheoutput.
Noteanapproximatedelayof64msbetweentheinputandoutput(represen ngtaps/2samples).

Withthissetofequa onsandtheFIRitselfcodedonLPC4370,thenalresultisshownfollowing.

Thesamplingandoutputratesbothareequalto1k/s.Noteanapproximatedelayof64msbetweeninputandoutput(represen ngtaps/2samples).Thispowerfulmicrocontroller
anditshighspeedADCareabletohandlesampleratesmuchhigherthantheoneIusedhere,includingmul channelaudio.AsImen onedearlier,thepurposeofthissimple
applica onisjusttointroducetheanalogresourcesavailableonLabToolboard.
Conclusion
TheADCHShasmanyothercongura onop ons.Itworksthroughastatemachinewithadedicated merandasetofeightdescriptors,forwhichitispossibletoestablishhowandwhenaconversion
occurs,genera nginterrupts,llinga16posi onFIFOortransferringdatathroughDMA

Theclockforthisapplica onwasadjustedto180MHz,avaluemorethansucient.Inanextinstallment,IintendtowakeuptheothertwoCortexM0coresontheLPC4370,implemen ngatrulymul core


lterthroughIPC(InterprocessCommunica on),runningatalowerclock;somethinglike60MHzandcomparetheresultswiththesinglecoresolu onforexample,analyzingthepowerconsump on.Stay
tuned[3].
References

[1]h p://www.embeddedar sts.com


[2]h p://courses.engr.illinois.edu/bioe415/labs/ecgwav.html

[3]h p://www.youtube.com/DirceuRodriguesJr

Average:
Yourrating:NoneAverage:4.5(2votes)

Privacy|TermsofUse

Copyright2016LPCWare.com

Anda mungkin juga menyukai