dynamic acceleration

27
THE OHIO STATE UNVIERSITY Wireless Accelerometer ECE 682 Clay Cochran, Tim Duly, Brandon Ervin, & Mike Jender 3/13/2009

Upload: barbu-ioan

Post on 24-Nov-2015

20 views

Category:

Documents


0 download

DESCRIPTION

Dynamic Acceleration

TRANSCRIPT

  • THEOHIOSTATEUNVIERSITY

    WirelessAccelerometerECE682

    ClayCochran,TimDuly,BrandonErvin,&MikeJender

    3/13/2009

  • 1

    ExecutiveSummary

    PurposeThisdocumentproposesthedesignanddevelopmentofawirelesscircuitnetworktorecordandanalyzetheaccelerationofsomesystem.

    ProblemStatementAnalarmingstatisticthatisincreasingtodayisthenumberofstudentsnotenteringengineeringafterhighschool.Highschoolstudentswithinterestinengineeringleavehighschoolandentercollegewithlittleornoengineeringexperience.Asmallprogrammablemicrocontrollercouldbeusedtocreateafairlysimpleapplicationsuchasmeasuringaccelerationtobeintegratedintoahighschoollabsetting.

    BackgroundResearchByusingtheTIeZ430rf2500WirelessDevelopmentTool,itispossibletocreateamoreuserfriendly,easytouseaccelerometer;thisdevicecouldbeusedinavarietyofwaysthathighschoolstudentswouldfindinteresting.

    Oncetheaccelerometerdeviceisdesignedandbuilt,usingtheunitdiscussedjustpreviously,novelandinterestingwaystouseitintheclassroommustbedevised.Onesuchapplicationcouldbeuseonamodelrollercoaster.Inthiscase,theaccelerometercouldbeusedtoanalyzespeedsorgforcesatvarioustimesthroughouttherollercoaster.

    DesignApproachWewillinvestigatewirelesstransmittersandbuyonetoevaluate.Afterwearefamiliarwiththeproduct,wewillintegratetheaccelerometertosenddata.Oncewehaveagoodmeansofsendingandreceivingaccelerationdata,thedooriswideopenforapplications.Thespiraldesignprocesswillbeused;manypartsofthedesignwillberevisited.

    DesignWeplantousetheeZ430RF2500Ttosenddatafromtheaccelerometer.Ourinitialdesignincludedadigitalaccelerometerbutitwasdecidedtorevisitthedesignandwesettledonananalogaccelerometer.Itwasmucheasiertodebugandfixproblems.WeusedMATLABtorecordaccelerationintheX,Y,andZdirectionsandplotteditonascreen.WeplantoapplythissystemtoamodelrollercoasterwithCoasterDynamixandintegrateitintoahighschoollabprojectmodeledaftertheInfinityProject.

    ConclusionThedesignanddevelopmentofafairlysimpleandaffordablewirelessanalogaccelerometernetworkhasimportantapplications,oneofwhichtomeasureaccelerationofamodelrollercoasterforahighschoollabsetting.

  • 2

    TIPartsDiscussion

    RFTransmitterandReceiver TheCC2500RFtransceiverprovidedcommunicationfromtheaccelerometerontherollercoastertothereceivernode.Itwaslowpowerwhichensuredalongerbatterylifeforthesystem.Thisisalsoimportanttoconsidersincethereareamultitudeoftransmissionsoccurring.Thecommunicationlinkprovidedsufficientdistancefromourtransmitterandreceiverperfectforusinginsidearoom.

    MSP430Microcontroller TheMSP430F2274wasused.Thismicrocontrollerprovidedthenecessaryanalogtodigitalconversionaswellastheprocessingpowertoreadthedata.Onthetransmittingend,themicrocontrollerprovidedtheanalogtodigitalconversion,necessarydatamanipulation,andsetuptobesentwirelesslythroughtheCC2500.Onthereceivingend,thechipactedasameanstopassdatathroughtotheUSBportonthecomputer,whichwasreadbyourMATLABprogram.

    Thisparticularmicrocontrollerwaschosenforavarietyofreasons.Itwaslowpowerwhichmeantoursystemcouldworklongerbeforechangingthebattery.ItssizewasidealforattachingtotheaccelerometerboardandforfutureimplementationinaPCBboard.

    VoltageRegulator TheTPS71530wasusedtoallowdifferentvoltagestobeconnectedtothesystem.Thispartacceptedvoltagesupto24Voltsandprovidedaconstantoutputof3V;thereforenoadjustmentswereneededtomaintainthevoltagelevel.Thisensuredconsistentoperation.Thisparthadanerroror4%,whichstillprovidesacceptablevoltagesfortheaccelerometer.TheTPS71530wasdesignedtoworkwithMSP430microcontrollersandisverysuitableforourpurposes.

  • 3

    TableofContents

    ExecutiveSummary.......................................................................................................................................1

    Purpose.....................................................................................................................................................1

    ProblemStatement...................................................................................................................................1

    BackgroundResearch................................................................................................................................1

    DesignApproach.......................................................................................................................................1

    Design........................................................................................................................................................1

    Conclusion.................................................................................................................................................1

    TIPartsDiscussion.........................................................................................................................................2

    RFTransmitterandReceiver.....................................................................................................................2

    MSP430Microcontroller...........................................................................................................................2

    VoltageRegulator.....................................................................................................................................2

    TableofContents..........................................................................................................................................3

    Introduction..................................................................................................................................................4

    Purpose.....................................................................................................................................................4

    ProblemStatement...................................................................................................................................5

    Scope.........................................................................................................................................................5

    BackgroundResearch....................................................................................................................................6

    RequirementsAnalysis..................................................................................................................................7

    DesignApproach...........................................................................................................................................7

    InitialDesignPlan..........................................................................................................................................7

    FinalDesign...................................................................................................................................................8

    ExplanationofCode................................................................................................................................10

    Calibration...............................................................................................................................................11

    SampleImageCapture................................................................................................................................11

    ReportofWork...........................................................................................................................................12

    Resources....................................................................................................................................................12

    Personnel................................................................................................................................................12

    Facilities,Equipment,andCosts.........................................................................................................13

    Schedule......................................................................................................................................................14

    DesignReview.............................................................................................................................................15

  • 4

    FuturePlannedDevelopments...................................................................................................................16

    Conclusion...................................................................................................................................................16

    Appendix:Code...........................................................................................................................................17

    CCodeUsedinIAREmbeddedWorkbench............................................................................................17

    AccessPoint........................................................................................................................................17

    EndDevice...........................................................................................................................................22

    MATLABCodetoDisplayPlots................................................................................................................26

    TableofFiguresFigure1:BlockDiagramofWirelessAccelerometerNetwork.....................................................................8Figure2:SchematicofAnalogAccelerometerEndpoint............................................................................10Figure3:SampleAccelerationinX,Y,&Z...................................................................................................11Figure4:SparkFun3DAccelerometer.......................................................................................................14Figure5:TIMSP430WirelessDevelopmentTool.......................................................................................14Figure6:TableofDesignWorktoBeCompleted......................................................................................15

    Introduction

    Purpose Thisdocumentproposesthedesignanddevelopmentofawirelesscircuitnetworktorecordandanalyzetheaccelerationofsomesystem.Thisistobedonebyimplementingtheuseofawirelesscapablemicrocontrollerandasmallaccelerometer.Thiscircuitwouldbevaluablebecauseitcouldbeusedforawidevarietyofprojectsandapplications.Thewirelessaccelerometernetworkcouldbeusedifdevelopmentisfairlystraightforwardtointroduceandpromoteinterestinhighschoolstudentstoengineeringbyimplementingthedevelopmentofthecircuitinaclassroom.Thisisimportantbecausemanyhighschoolstudentsarenotinterestedinengineeringprogramswhentheygraduatebecausetheyarenotexposedtothemandthinkthatitistoocomplicatedtocompletethelargenumberofcomplexscienceandmathcourses.Theaccelerometercircuitcouldalsobeusedinmanyothermorecommonengineeringapplications.Arollercoastermodeloneoftheseexamplesofaprojectthatthewirelessaccelerometercouldbeimplementedinto.Thiscouldbeusedtomeasuretheaccelerationinthreedirectionstoseehowintensetheactualrollercoasterexperiencewouldbeforsomeoneridingtheactualrollercoaster.Ifthewirelessaccelerometernetworkisfoundtobeeffectiveandfairlycompact,itwouldalsobepossibletoimplementinmanyotherextremelyimportantandmarketableapplications.

  • 5

    ProblemStatementAnalarmingstatisticthatisincreasingtodayisthenumberofstudentsnotenteringengineering

    afterhighschool.Astheworldcontinuestobecomemoretechnologicallycenteredandcomplex,itisimportanttomakecertainthatthereareanabundanceofpotentialengineersleavingourcountryshighschools. Highschoolstudentswithinterestinengineeringleavehighschoolandentercollegewithlittleornoengineeringexperience.Asaresult,therearealargepercentageofstudentsthatdropoutofengineeringoncetheygetintothemajorbecausetheyfeeloverwhelmedorunprepared.Furthermore,manystudentslacktheinitialinterestinengineeringbecausetheyarenotexposedtoit.Theyarediscouragedbythewaymathandsciencearetaughtandtrytoavoidafieldofstudyorcareerthatwillbeusingthesefortherestoftheirlives.Inordertocombatthis,studentsneedtobeexposedtocomplexbutachievableengineeringprojectsinhighschools.Theseprojectswillalsodemonstrateareallifeapplicationusingmathandscienceasopposedtoonlyworkingtrivialproblems.

    Teachersfeelfrustratedwithteachingbecausemanylabkitsareexpensiveandoverlycomplexforthehighschoollevel.Thereforeitisimportanttomakesuretheteachersarewellpreparedandeducatedregardingengineeringlabkitssothattheycaneffectivelyteachtheirstudents.Itisjustasimportanttomakethekitslowcostsopublicschoolscanaffordthemtobeimplementedintheirlabsandprovidetheirstudentswiththesameopportunitiesasprivateschools.

    SomekitsareavailablesuchastheInfinityprojectthatutilizesadigitalsignalprocessortocreatevariousprojects.Programmingadigitalsignalprocessorisfairlycomplicated,especiallyatthehighschoollevel.Thereforeanotherapproachthatiseasiertoworkwithandthatrequireslessbackgroundknowledgeshouldbeusedinthekitstomaketheprogrammoreeffective.Asmallprogrammablemicrocontrollercouldbeusedtocreateafairlysimpleapplicationsuchasmeasuringacceleration.PerhapsthiscouldbeappliedtoamodelrollercoasterapplicationsuchasaCoasterDynamixrollercoaster.Engineeringeducationwouldalsobecomplimentedbyphysicsandothersciencedisciplines.

    Theaccelerometercircuitcouldalsobeimplementedintomanymoreimportantapplicationsifitisfairlyaccurate.Therearemanyapplicationssuchastestingofautomobilesandsafetyandhealthofhumanbeingsjusttonameafewthatcouldbeimprovedbytheuseandimplementationofanaccuratewirelessaccelerometernetwork.

    Scope Thisreportdiscussesthedesignandimplementationofthewirelessaccelerometercircuit.Itdiscussesthedifferentpiecesofequipmentandthehardwareselectedfortheimplementationofthecircuitandhowtheywillbeconnectedandimplementedtogetthedesiredresults.Itwillonlydiscusstheapplicationsofthecircuitveryminimally.Thereismuchmoreofafocusontheactualconceptualdesignthanontheactualapplicationsoftheaccelerometernetwork.Althoughonlyasmallnumberofapplicationsarementioned,thereareunlimitedapplicationsforthiswirelessaccelerometercircuit. TheaccelerometerwasdesignedandbuiltthroughoutthecourseofthedesignseriesofECE582andECE682/683.AfairlysimpleGraphicalUserInterface(GUI)wasdevelopedinMATLABtomonitortheaccelerationreadingsintheX,Y,andZdirections.Thisprovidedawayofcollectingtheaccelerationdatasoitcouldbeusedforanalysisofthesystemlater.Thecircuitanddatacollection

  • 6

    systemwascompletedandisdiscussedinadditiontothepossibleadvancementsandimprovementstothesystem.

    BackgroundResearchItisessentialtocontinueemphasizingexposuretothesciencesandengineeringduringhigh

    school.Amajorobstaclestandinginthewayofthisgoalisthecomplexityofmanyexistingtechnologykits.ByusingtheTIeZ430rf2500WirelessDevelopmentTool,itispossibletocreateamoreuserfriendly,easytouseaccelerometer;thisdevicecouldbeusedinavarietyofwaysthathighschoolstudentswouldfindinteresting.

    TheTIeZ430rf2500WirelessDevelopmentToolisactuallyadevicewiththreemainparts.AttheheartofthedeviceistheMSP430F2274Microcontroller.Thisisaverylowpowermicrocontrollerthatincludesseveralusefulperipheralcomponents.Theseincludea10bitA/Dconverter,twogeneralpurposeoperationalamplifiers,two16bittimers,and32I/Opins.Thus,thismicrocontrollerisveryusefulforapplicationsthatrequireananalogsignaltobedigitizedandsubsequentlyprocessed.Thisisanimportantability,becauseitwouldenabletheprocessingofanalogaccelerometerdata.

    AlsoincludedintheWirelessDevelopmentToolistheCS2500Transceiver.Thisisalowcostelectroniccomponentthatbothtransmitsandreceiveswirelessdata;itisdesignedespeciallyforuseinverylowpowerapplications.Itisequippedwithamodemcapableofadjustabledataratesofupto500kBaud,aswellasvariousmodulationschemes.Thereare64bitFIFOsforbothtransmitandreceive.Thiscomponentwouldallowtheaccelerometertobewireless,openingupavarietyofexcitingpossibleuses.

    Lastly,andperhapsmostimportantly,theeZ430RFDebuggingInterfaceisincludedwiththedevice.ThispieceallowstheusertouseaUSBconnectiontoprogramanddebugtheattachedmicroprocessor.Thiscomponentcanbeseparatedfromtherestoftheunit.Thisisoneofthemostimportantadvantagesofthisdevice,asitallowsaccesstoaneasytouseinterfacewiththemicroprocessorandallowsstepthroughdebugging.

    Alsoincludedinthedeviceisatargetboard,whichisagroupof18developmentpinsthatallowseasyaccesstotheMSP430F2274microcontroller.Thisprovidesasimplewayfortheusertoconnectvarioustypesofhardwaretothemicrocontroller,andallowsforawiderangeofusesfortheunit.

    Oncetheaccelerometerdeviceisdesignedandbuilt,usingtheunitdiscussedjustpreviously,novelandinterestingwaystouseitintheclassroommustbedevised.Onesuchapplicationcouldbeuseonamodelrollercoaster.Inthiscase,theaccelerometercouldbeusedtoanalyzespeedsorgforcesatvarioustimesthroughouttherollercoaster.

    CoasterDynamix,asmallcompanybasedinVirginia,makeshighqualityrollercoastermodelsthatwouldworkverywellinconjunctionwiththeaccelerometerunit.Thesewellmadescalemodelswouldexposestudentstointerestingengineeringandphysicsconceptswhichtheycouldidentifywith.

  • 7

    RequirementsAnalysis Thissystemwillbeginasageneralaccelerometerdatatransmitter,andapplyittospecificapplications.Weplantoimplementthisdeviceintoaclassroomsettingforahighschoolorevenjuniorhighlaboratory,whichwouldbemoreeffectivethanacomplextoolkitthattheInfinityprojectnowhas.Furthermore,thissystemhassellingpotentialtocompaniessuchasRollerCoasterDynamixinwhichtheywantshowinrealtimetheaccelerationoftheirmodelrollercoasters. Thesystemmustbeabletotransmitaccelerationdatawirelesslytoareceiverwithinahundredmeters.Thisdatawillbestoredinamicrocontrollerandwillbeeasilyavailableforcalculations(i.e.,velocity,distance).Thewirelesstransmitsystemisrequiredtobephysicallysmall:nomorethan10cmx10cminareasothatitcanbeimplementeddiscretelyintosystemssuchasamodelrollercoaster.

    DesignApproach Ourteamisusingabottomupapproachtodesigningthissystem.Wewillstartwithanaccelerometerevaluationboardtotestandcharacterize.Nextwewillinvestigatewirelesstransmittersandbuyonetoevaluate.Afterwearefamiliarwiththeproduct,wewillintegratetheaccelerometertosenddata.Thenwewillworkonthereceivedeviceandworkonhowtotalktothetransmitter.Oncewehaveagoodmeansofsendingandreceivingaccelerationdata,thedooriswideopenforapplications,andweshallapproacheachapplicationindividuallyandbranchofffromthere. Acommonthemeinourdesignapproachistakingsmallsteps.Thisway,wecanseparatetheproblemanddebugitindividually.Thisismucheasiertodoratherthanbuildingthesystemasawholeandattemptingtofixitwhensomethinggoeswrong.Alsoweintendfortheprogramstoberelativelysimplefordebuggingpurposesandforcreatingmorecomplexsystemsinthefuture. Aspiraldesignapproachwillbeusedforthedevelopmentofthesystem.Astimeprogresses,manypartsofthedesignprocesswillberevisited.Asthedesignprocessisadvanced,theactualsolutiondefinedwillchangeaswillmanyotheraspectsofthedesign.Thisiseasilyshowninaspiraldesignrepresentation.Also,thedebuggingprocesswillprovetobeextremelyimportantduetoactuallyseeingwhatthemicrocontrolleriscapableofandtheprogrammingskillsofallteammembers.

    InitialDesignPlan TheinitialplanwastocreateadesignforawirelessaccelerometerimplementingTIpartsintothedesign.WeplannedtousetwoeZ430RF2500Ttargetboardsforthedesign,usingoneforthemainnodeandonefortheendpointofthesystemcollectingdatafromtheaccelerometer.Thesedevicesallowdatatobesentwirelesslybythetransceiversconvenientlylocatedoneachtargetboard.Theaccelerometerdatawasplannedtobeoutputeitherdigitaloranalogdata.Thisdecisionprovedtobethemostimportantdecisionbecauseitwasdiscoveredthatthedesignwasmucheasierimplementedusingtheanalogaccelerometer.ThedigitalaccelerometerprovedtobemuchmoredifficultduetotheSPIcommunicationscheme.TheeZ430RF2500ThasanA/Dconverterthatwastobeusedtoconverttheanalogsignalfromtheaccelerometertodigitalforsignalprocessing.Thisleadtomucheasiertroubleshootingofthecircuitduringtestingandwasmucheasiertodevelopsoftwarefor.

  • 8

    Oncethesignalwasreceived,itwasplannedtobesenttoanothermicrocontrollerwherethedatawouldbecollectedforprocessing,andthensenttoacomputerforinterpretation.AfairlysimpleGUIwastobedevelopedthatwouldmakeitpossibletoanalyzethedatacollectedfromtheaccelerometerforanalysispurposes.ItwastobedevelopedtoshowtheX,Y,Zmovementonthecomputerscreenandsaveallofthedatacollected.Nextitwasplannedtoapplyaspecificapplicationtothewirelessaccelerometer.Forexample,withtherollercoaster,CoasterDynamixwouldliketoseetheamountofgsexertedonthemodelrollercoasterinrealtimeasitmovesalongthetrack.Also,itcouldbeimplementedintoasecondgenerationInfinityProjectforHighSchoolstudentstolearnmathandscience.Oncethesystemwascompleted,numerousopportunitiesforapplicationsarise,withlittleornotweaking.Figure1showstheblockdiagramfortheprojectshowingboththepossibilitiesofusingeitherananalogofdigitalaccelerometer.

    Figure1:BlockDiagramofWirelessAccelerometerNetwork

    FinalDesign ThefinalhardwaredesignwasfairlystraightforwardandisshowninFigure3.Ananalog3dimensionalaccelerometerwaspickedforthefinaldesignbecauseitwasmucheasiertotestandworkwiththanthedigitalaccelerometerusingSPIcommunications.ThepinslabeledX,Y,andZaretheactualanalogoutputsoftheaccelerometer.ThesepinswerethenconnectedtoanaloginputsforPortAofthemicrocontrollertargetboard.ThiskeptallofthedataconfinedtothefirstthreechannelsofPortA.Inordertoactuallyreadthedata,theSLPpinoftheaccelerometerhadtobesettohigh.Thiswasdonebyoutputtingahighvaluefrompin8continuouslyfromthetargetboard.Thiswasusingmore

  • 9

    powerbykeepingtheaccelerometeractiveallofthetime,butitwaseasiestandmosteffectiveforthisapplication.

    TheschematicoftheconnectionsfortheendpointisshowninFigure2below.Thisshowsthenecessaryconnectionstocollecttheaccelerationdatafromtheaccelerometerandthenprepareitforwirelesstransfertothemainnode.TheVccwireisusedtopowertheaccelerometerbysupplyingitwithapproximately3VDCfromthepowersupplyofthetargetboard.TheGS1andGS2pinsselecttheaccelerationrangefortheaccelerometer.Inthisapplication,bothpinsweresettohighinordertosetitfora+/6grangeofaccelerationdata.Thereareotherrangesthatcanbesetbychangingtheconfigurationofthesetwopins.Inordertogetthesetwopinstohighvoltage,theyaretappedoffoftheVccpoleonthebreadboard.Thegroundisobviouslythenfedfromthegroundonthetargetboardwhichissuppliedbythepowersupplyofthetargetboard.Thiswouldserveastheminusofthebattery.TheX,Y,andZpinsontheaccelerometeraretheoutputpinsfortheaccelerationinthatspecifieddirection.ThesearefedintotheanalogPORTAonthemicrocontrollertargetboardasshownbelow.TheSLPpinontheaccelerometercouldbeusedtosavepowerbyonlysendingdatawhenthevoltageatthatpinishigh.Inordertosimplifythis,itwassettohighallofthetime,whichwouldresultinashorterbatterylife,butsinceitusessuchsmallpower,itwasdecidedthateaseofdevelopmenttookprecedence.Inordertosetthishighitcouldbeapproachedtwoways.OnewaywastodirectlyconnectittotheVccpole,whiletheotherwaywastooutputahighsignalfrompin8onthetargetboardallofthetimetothatpin.

    Afteraworkingprototypewasbuilt,itwasdecidedthatinordertomakethesystemmoreversatile,avoltageregulatorcouldbeusedwhichwouldacceptvariousvoltagelevelsandoutputtheconstant3Vthatthesystemrequired.TheTPS71530issuitableforthistask,acceptingvoltagesupto24Vandproviding3Voutputwithadequatecurrentforthesystem.

  • 10

    Figure2:SchematicofAnalogAccelerometerEndpoint

    ExplanationofCode

    Themicrocontrollercodewasdividedintotwoparts,accesspointandenddevice.TheaccesspointcodeisrunonthemicrocontrollerthatisattachedtoaPCandservestogatherthedatabeingtransmittedfromtheenddevice.ThisdataisthenconditionedandsenttothePCthroughaUSBconnection.Theaccesspointcodestartsbycontinuouslyloopinguntilitdetectsasignalfromanenddevice.Onceasignalisacquiredandaconnectionismade,theaccesspointentersthedataprocessingloop.InthislooptheaccesspointcontinuouslygathersdatafromtheenddeviceandconditionsthecharacteroutputtobesenttothePCovertheUSBconnection.Theenddevicecodestartsbyinitializingthemicrocontrollerandtheprotocolsneededforwirelessdatatransmission.Theenddevicethenentersthedatagatheringloopwhereitreadstheanalogaccelerometervoltagesusingthreeseparateanaloginputs.Thevoltagesareconvertedusingthe10bitADCtodigitalnumbersrangingfrom01023.Thesevaluesarethentransmittedtotheaccesspointandnewvaluesarethenacquired.TheMatlabcodeisusedtopresenttheaccelerationdatainauserreadableform.TheMatlabcodestartsbyopeningaCOMportthatislinkedtothemicrocontrollerattachedtothePC.ThecodethencontinuouslypollstheCOMportfordataandenterseachdatareadingintotherespectiveX,YandZdatamatrices.Theadvantageofhavingseparatematricesforeachaxisisthatthedataisstored

  • 11

    separatelyandcanthereforebemanipulatedlaterifnecessary.Afterasetnumberofdatapointsaregathered,thedatagatherloopexitsandtheaccelerationdataforeachaxisareplottedtogether.AllcodesareincludedintheAppendixattheendofthereport.

    Calibration

    Inordertotrytocalibratetheaccelerationvaluestothecorrectvalues,theaccelerometerwasplacedintheXYplanesothattheonlyforceactingontheaccelerometerwasgravityanditwasintheZdirection.Therefore,thevalueswerethennormalizedbysubtractinginMATLABbyaconstanttoaccountfortheoffsetoftheactualoutputoftheaccelerometer.ThiscalibrationwasdonebytakingtheZaxisdataandthensubtractingbyavaluetomakeitequalto1g.ThissameprocedurewasdonetomakethevaluesoftheXandYaxesequalto0gsincetheywerebothnotactedonbygravityatallandtheaccelerometerwasnotinmotion.

    SampleImageCaptureFigure3showsasampleoutputofrunningtheMATLABscriptthatcapturestheX,Y,andZaccelerationanddisplaysinasubplot.Thisprovidestheenduserwithaccurate,easilyvisibleaccelerationoftheirsystem.Themaximumaccelerationineitherdirectionis6gs.

    Figure3:SampleAccelerationinX,Y,&Z

  • 12

    ReportofWork582

    Themaingoalof582wastodefinetheproblemandrequirementsofthewirelesssystem/accelerometer.Theoveralldesignprocesswasdefinedandplanspartswereorderedduringthebreaksowecouldbeginprototypinginthebeginningof682.Asignificantamountoftimewasdevotedtodevelopingtherequirementsthattheaccelerometerandsoftwarewillhavetomeet.ThewirelesstransceiverportionofthedesignisanofftheshelfpartfromTIandthereforeitcanbeorderedattheendof582toprovidemorebuildtimein682.Attheendof582theplansanddesignshouldbesufficientenoughtobeginbuildingassoonasthepartsarrive.

    682

    Prototypingwasstartedasquicklyaspossible.WeusedtheMSP430RF2500andspentasignificanttimelearninghowitoperatedandhowitsentandreceiveddata.WeinitiallyorderedadigitalaccelerometerfromSparkFunbutafterreiterationofthedesignprocessdecidedtouseananalogaccelerometer.Wealsoorderedasmallcoincellbatterytopowerthesystem.

    Thedesigncontinuedtoberefinedbasedupontestedconductedwiththeworkingprototype.ArobustsoftwareapplicationusingMATLABwasusedtogatherthedataandplot.Agraphofthesensorsaccelerationinrealtimewassuccessfullycompletedandgaveademonstration.

    Beyond682

    TheprototypewasfairlylargeonabreadboardandifwewantedtorunthemoduleonarollercoasterwithCoasterDynamixthedesignwillbeimplementedonaPCBboard.AlsothereportplanstoberigorouslyreviewedinordertosubmittoTIcontest.

    Resources

    Personnel TheprojectandtaskspreviouslymentionedwillbeperformedbyfourseniorengineeringstudentsatTheOhioStateUniversity.Theyeachhaveawidevarietyofskillsthatwhenintertwinedcanbeusedtosuccessfullydevelopthewirelessaccelerometercircuit.Thefollowingisalistofallteammembersandwhattheyarebringingtotheteamtoresultinasuccessfulcircuitdevelopment.

    ClaytonCochran:HehasgainedexperienceinthedevelopmentanddesignprocessbyworkingasaninternwithEmersonNetworkPower:LiebertCorporationintheresearchanddevelopmentdepartment.Hehasalsocompletedawidevarietyofcourseworkincluding,microcontrollerprogrammingandcommunicationsthatwilllikelybehelpfulinthedevelopmentofthewirelessaccelerometercircuit.

  • 13

    BrandonErvin:HeisaSeniorinElectricalEngineering,graduatingSpring2009,whoisfocusingonPowerSystemswithminorfocusesinComputersandControl.HeparticipatedintheFEHprogram,placing4thintherobotdesigncompetition,Spring2006.

    TimDuly:HeisfocusinghisElectricalEngineeringstudiesinCommunications/DSPandElectromagnetics.HehashadexperienceprogrammingMSP430microcontrollersinaninternshipin2008.

    MikeJender:HeisafifthyearelectricalengineeringstudentatTheOhioStateUniversity.Hiscourseworkconcentrationsinclude:DigitalSignalProcessing,Communications,ControlSystems,andElectromagnetics.

    Facilities,Equipment,andCosts Thedevelopmentoftheaccelerometercircuitwillrequireaverysmallamountofequipmentandessentiallynospecialfacilities.Theonlyfacilitiesthatwillbenecessarywillbeaplacetomeetasagroupandaplacetobuildandtestthecircuit.Thisplaceneedstoonlyconsistofatablelargeenoughtocompletethebuildingandtestingandthenacomputercontainingthesoftwareneededtodeveloptheprogramforthemicrocontroller.Thefollowingisalistofhardwareneededtodevelopthewirelessaccelerometernetwork.

    Microcontroller:TexasInstrumentsMSP430RF2500DevelopmentTool($49.00)o MSP430developmenttoolwithtargetboards(USBdevelopment)o CC2500transceiverforwirelesscommunicationso IntegratedDevelopmentEnvironmentSoftwareforcompilingthecode

    SmallDigitalAccelerometer:SparkFun3DAccelerometerLIS302DL($19.95)o Selectable+/2gto+/8grangeo 8bitresolutiono Extremelysmall

    SmallAnalogAccelerometer:SparkFun3DAccelerometerMMA7260Q($19.95)o Selectable+/1.5gto+/6grangeo Extremelysmall

    VoltageRegulator(DigiKey)($1)o Allowsformultipleinputvoltagesupto24V

    SparkFuncoincell3Vbatteriesandbatteryholder($10.00) Wiringandheadersfordevelopingthesystemwiththetargetboards($20.00)

    TOTALCOST:$139.90

    BothaccelerometersfromSparkFunthatwereusedareverysmall,asseeninFigure4.Theanalogaccelerometer,asmentionedearlier,hasaselectablerangeofaccelerationreadingsfrom+/1.5gto+/6g.Thisrangeofaccelerationshouldbelargeenoughformostofitsexpectedapplications.

  • 14

    Althoughthedigitalaccelerometerencounteredperformanceproblemsduringthecourseoftheproject,itisourhopethatwewilleventuallybeabletoimplementadigitalversionofourproject.The8bitresolutionshouldalsoprovidethenecessaryaccuracyforthesystem,butifamoreaccurateaccelerometersystemisneededthereareaccelerometersouttherethatdohavehigherresolution.Becausethisspecificaccelerometergivesitsoutputindigitalform,itwillnotbenecessarytoperformananalogtodigitalconversiontosendthedata.

    Figure4:SparkFun3DAccelerometer

    ThemaincomponentofthedesignistheMSP430WirelessDevelopmenttoolshowninFigure5.ThiskitcomeswitheverythingshowninthefigureandhasaneasytouseUSBconnectiontousewithacomputer.Thiswillcomeinveryhelpfulwhiledevelopingthecodeforthemicrocontrollerandtestingthedesign.Thisdevicealreadyhasthetransceiverandthemicrocontrolleralreadyintegratedintoonedevice.Thisshouldprovemucheasierthantryingtoimplementthemonourownwhichcouldprovetobefairlydifficult.

    Figure5:TIMSP430WirelessDevelopmentTool

    Asseenabove,thecostoftheprojectwillbereasonablyaffordable.Also,someofthepartswillmostlikelybepaidforbyCoasterDynamixwiththeagreementthatiftheaccelerometerworks,itcanbeusedontheirmodelrollercoaster.

    Schedule Accordingtotheoriginalschedule,themajorityoftheprojectwasgoingtobebuiltanddevelopedthroughthedurationof682.Theplanningfortheprojectwasmostlydoneduringthedurationof582.Therefore,thegoalwastogetthepreliminaryplanandmentalideathatweredevelopedduringthefirstquarteroftheseries,andthenactuallyimplementthedesignandideasinthelasthalfoftheseries.

  • 15

    ThefollowingFigure6showstheoriginalroughtemporaryplanforthedesignprocessofthewirelessaccelerometernetwork.Itiseasilyseenthatastheprojectprogressed,thegoalwastorevisittaskstomakecertainthattheprojectwasprogressingwhereitneededto.Thistableagainessentiallyshowsthespiraldesignplan.

    Week

    1 2 3 4 5 6 7 8 9 10

    Task

    DefineSolutionApplications

    DrawSchematics,Purchase

    PartExploration

    ComponentCommunication

    Test

    Debugging Figure6:TableofDesignWorktoBeCompleted

    Theactualdesignprocessfollowedthisscheduleexactly.Duringthefirst6weeks,themainfocuswasonthedigitalaccelerometer.However,oncethesixthweekconcludedanditwasdecidedthatitwastoodifficulttoworkwithSPIinthisshortamountoftime,thesolutionwasredefinedtoincludetheanalogaccelerometer.Afterthiswasdecided,therestoftheplanfellintoplaceandresultedinafunctionalwirelessanalogaccelerometer.

    DesignReview Afteraverybriefdesignreviewitwasdecidedthatifthewirelessaccelerometersystemisdevelopedcorrectlyandfunctioningasexpectedagyroscopeelementcouldbeaddedtothesystem.Thiswouldmakecertainthattheaccelerationreadingsareallconsistentbykeepingtheorientationoftheaccelerometerataconstant.Thereforez,x,andydirectionaccelerationwouldbeinthattruedirectiontheentiredurationofthetest.Ifthereisnogyroscopeandtheaccelerometeristestingarollercoastermodelasmentionedearlier,thedirectionsofaccelerationwillchangewiththeorientationoftheaccelerometer.Suchaswhentheaccelerometerisgoinguphillthezdirectionwillbedifferentthanthezdirectionwhentheaccelerometerisonflattrack.Thiswouldmakethewirelessaccelerometersystemmuchmoreaccurateandmorevaluable.

    Thestatusreviewmeetingsprovedtobeextremelyvaluableinkeepingthegroupontrack.Itwasimportanttogetweeklyfeedbackonourprojectandtogetsuggestions.Forexample,itwasrecommendedthatweuseananalogaccelerometerafterourinitialdigitaldesignwasnotworking.Thedigitaldesignwasdifficulttodebugandwedecidedthatananalogdevicewouldbeeasiertotrackproblems,andthereforeeasiertofix.

  • 16

    FuturePlannedDevelopments Sincetheonequarterofworkfordevelopmentoftheprojectwasafairlyshorttime,thereweremanyotherdevelopmentsthatcouldhavebeenapproachedfortheproject.Thesedevelopmentsarelistedasfollows:

    Implementagyroscopeintothecircuittogettrueaccelerationreadingstoaccountfortherotationoftheaccelerometerduringtesting.

    Developaprogramtomanipulatethedataforcalculationofvelocityandpositioninthreedimensions,possiblymodelingthemotioninthreedimensionalspace.

    Minimizethesizeoftheentirecircuitbycombiningthetargetboardandtheaccelerometeroftheendpointtoasinglefabricatedprintedcircuitboard.

    MakeamoredetailedanduserfriendlyGUIthatcanbeusedtosettherangeofaccelerometerandthatcanstartandstopthedatacollectionwithapushofthebutton.

    Conclusion Thedesignanddevelopmentofafairlysimpleandaffordablewirelessaccelerometernetworkcouldprovetohaveextremelyimportantandendlessapplications.AwirelessaccelerometercanbedesignedusingTIcomponents,suchasamicrocontrollerandtransceiver,andanaccelerometer.Itisimportanttokeeptheelementsofthesystemphysicallysmalltomakecertainthatitcanbeappliedtomostsituationswhereaccelerationshouldbemeasured.Oneapplicationusedtodevelopthesizeandperformanceofthesystemwasamodelrollercoaster.Inthisapplicationtheaccelerometermustbesmall,lightweight,andabletomeasureupto6g.Also,ifthemicrocontrollerprogrammingisproventobefairlysimple,itcouldbeusedinahighschoolsettingtogetstudentsinterestedinthefieldsofengineeringandphysics.Thewirelessaccelerometernetworkcouldretrievedataontheaccelerationofacertainobjectandthenprovidethisdatatoacomputertoruncalculationsonthedataanddeterminemuchmoreimportantinformationaboutthesystemundertest.Thewirelessaccelerometernetworkcouldbeaveryvaluablecircuitthatcouldbeusedformanyimportantapplications.

  • 17

    Appendix:Code

    CCodeUsedinIAREmbeddedWorkbench

    AccessPoint//Access Point File

    #include "bsp.h" #include "mrfi.h" #include "bsp_leds.h" #include "bsp_buttons.h" #include "nwk_types.h" #include "nwk_api.h" #include "nwk_frame.h" #include "nwk.h" #include "msp430x22x4.h" #include "vlo_rand.h" #define MESSAGE_LENGTH 6 void TXString( char* string, int length ); void MCU_Init(void); void transmitData(char msg[MESSAGE_LENGTH] ); void transmitDataString(char msg[MESSAGE_LENGTH]); void createRandomAddress(); //data for terminal output const char splash[] = {"\r\n--------------------------------------------------\r\n ****\r\n **** eZ430-RF2500\r\n ******o**** Temperature Sensor Network\r\n********_///_**** Copyright 2007\r\n ******/_//_/***** Texas Instruments Incorporated\r\n ** ***(__/***** All rights reserved.\r\n ********* Version 1.02\r\n *****\r\n ***\r\n--------------------------------------------------\r\n"}; __no_init volatile char Flash_Addr[4] @ 0x10F0; // Flash address set randomly // reserve space for the maximum possible peer Link IDs static linkID_t sLID[NUM_CONNECTIONS]; static uint8_t sNumCurrentPeers; // callback handler static uint8_t sCB(linkID_t); // work loop semaphores static uint8_t sPeerFrameSem; static uint8_t sJoinSem; //static uint8_t sSelfMeasureSem; int run; void main (void) { addr_t lAddr; bspIState_t intState; WDTCTL = WDTPW + WDTHOLD; // Stop WDT // delay loop to ensure proper startup before SimpliciTI increases DCO

  • 18

    // This is typically tailored to the power supply used, and in this case // is overkill for safety due to wide distribution. volatile int i; for(i = 0; i < 0xFFFF; i++){} if( CALBC1_8MHZ == 0xFF ) // Do not run if cal values are erased { volatile int i; P1DIR |= 0x03; BSP_TURN_ON_LED1(); BSP_TURN_OFF_LED2(); while(1) { for(i = 0; i < 0x5FFF; i++){} BSP_TOGGLE_LED2(); BSP_TOGGLE_LED1(); } } BSP_Init(); if( Flash_Addr[0] == 0xFF && Flash_Addr[1] == 0xFF && Flash_Addr[2] == 0xFF && Flash_Addr[3] == 0xFF ) { createRandomAddress(); // set Random device address at initial startup } lAddr.addr[0]=Flash_Addr[0]; lAddr.addr[1]=Flash_Addr[1]; lAddr.addr[2]=Flash_Addr[2]; lAddr.addr[3]=Flash_Addr[3]; SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr); MCU_Init(); //Transmit splash screen and network init notification TXString( (char*)splash, sizeof splash); TXString( "\r\nInitializing Network....", 26 ); SMPL_Init(sCB); // network initialized TXString( "Done\r\n", 6); //Some of our original code begins here BSP_TOGGLE_LED2(); // main work loop while (1) { // Wait for the Join semaphore to be set by the receipt of a Join frame from a // device that supports and End Device. if (sJoinSem && (sNumCurrentPeers < NUM_CONNECTIONS)) { // listen for a new connection SMPL_LinkListen(&sLID[sNumCurrentPeers]); sNumCurrentPeers++; BSP_ENTER_CRITICAL_SECTION(intState); if (sJoinSem) {

  • 19

    sJoinSem--; } BSP_EXIT_CRITICAL_SECTION(intState); } // Have we received a frame on one of the ED connections? // No critical section -- it doesn't really matter much if we miss a poll if (sPeerFrameSem) { uint8_t msg[MAX_APP_PAYLOAD], len, i; // process all frames waiting for (i=0; i>8) & 0xFF; Flash_Addr[1]=rand & 0xFF; Flash_Addr[2]=(rand2>>8) & 0xFF; Flash_Addr[3]=rand2 & 0xFF; FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit } /*------------------------------------------------------------------------------ * ------------------------------------------------------------------------------*/ void transmitData(char msg[MESSAGE_LENGTH] ) {

  • 20

    transmitDataString( msg ); } /*------------------------------------------------------------------------------ * ------------------------------------------------------------------------------*/ void transmitDataString(char msg[MESSAGE_LENGTH] ) { char x_string[] = {"XXXX"}; char y_string[] = {"XXXX"}; char z_string[] = {"XXXX"}; int tempx = msg[0] + (msg[1]

  • 21

    /*------------------------------------------------------------------------------ * ------------------------------------------------------------------------------*/ void MCU_Init() { BCSCTL1 = CALBC1_8MHZ; // Set DCO DCOCTL = CALDCO_8MHZ; BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO TACCTL0 = CCIE; // TACCR0 interrupt enabled TACCR0 = 2000; // ~1/6 second TACTL = TASSEL_1 + MC_1; // ACLK, upmode P3SEL |= 0x30; // P3.4,5 = USCI_A0 TXD/RXD UCA0CTL1 = UCSSEL_2; // SMCLK UCA0BR0 = 0x41; // 9600 from 8Mhz UCA0BR1 = 0x3; UCA0MCTL = UCBRS_2; UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine** IE2 |= UCA0RXIE; // Enable USCI_A0 RX interrupt __enable_interrupt(); } /*------------------------------------------------------------------------------ * Runs in ISR context. Reading the frame should be done in the * application thread not in the ISR thread. ------------------------------------------------------------------------------*/ static uint8_t sCB(linkID_t lid) { if (lid) { sPeerFrameSem++; } else { sJoinSem++; } // leave frame to be read by application. return 0; } /*------------------------------------------------------------------------------ * ADC10 interrupt service routine ------------------------------------------------------------------------------*/ #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR) } /*------------------------------------------------------------------------------ * Timer A0 interrupt service routine ------------------------------------------------------------------------------*/ #pragma vector=TIMERA0_VECTOR __interrupt void Timer_A (void) { run = 1;}

  • 22

    EndDevice//End Device File #include "bsp.h" #include "mrfi.h" #include "nwk_types.h" #include "nwk_api.h" #include "bsp_leds.h" #include "bsp_buttons.h" #include "vlo_rand.h" void linkTo(void); void MCU_Init(void); __no_init volatile char Flash_Addr[4] @ 0x10F0; // Flash address set randomly void createRandomAddress(); void main (void) { addr_t lAddr; WDTCTL = WDTPW + WDTHOLD; // Stop WDT { // delay loop to ensure proper startup before SimpliciTI increases DCO // This is typically tailored to the power supply used, and in this case // is overkill for safety due to wide distribution. volatile int i; for(i = 0; i < 0xFFFF; i++){} } if( CALBC1_8MHZ == 0xFF ) // Do not run if cal values are erased { volatile int i; P1DIR |= 0x03; BSP_TURN_ON_LED1(); BSP_TURN_OFF_LED2(); while(1) { for(i = 0; i < 0x5FFF; i++){} BSP_TOGGLE_LED2(); BSP_TOGGLE_LED1(); } } // SimpliciTI will change port pin settings as well P1DIR = 0xFF; P1OUT = 0x00; P2DIR = 0x20; //P2OUT = 0x00; P3DIR = 0xC0; P3OUT = 0x00; P4DIR = 0xFF; P4OUT = 0x00; //P2SEL = 0x07; P4OUT |= 0x08; //Sets Pin 8 (P4.3) high, turns on the accelerometer, set low to put to sleep BSP_Init(); if( Flash_Addr[0] == 0xFF && Flash_Addr[1] == 0xFF && Flash_Addr[2] == 0xFF && Flash_Addr[3] == 0xFF )

  • 23

    { createRandomAddress(); // set Random device address at initial startup } lAddr.addr[0]=Flash_Addr[0]; lAddr.addr[1]=Flash_Addr[1]; lAddr.addr[2]=Flash_Addr[2]; lAddr.addr[3]=Flash_Addr[3]; SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr); BCSCTL1 = CALBC1_8MHZ; // Set DCO after random function DCOCTL = CALDCO_8MHZ; BCSCTL3 |= LFXT1S_2; // LFXT1 = VLO // keep trying to join until successful. toggle LEDS to indicate that // joining has not occurred. LED3 is red but labeled LED 4 on the EXP // board silkscreen. LED1 is green. while (SMPL_NO_JOIN == SMPL_Init((uint8_t (*)(linkID_t))0)) { BSP_TOGGLE_LED1(); BSP_TOGGLE_LED2();; __bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled } // unconditional link to AP which is listening due to successful join. linkTo(); } void createRandomAddress() { unsigned int rand, rand2; do { rand = TI_getRandomIntegerFromVLO(); // first byte can not be 0x00 of 0xFF } while( (rand & 0xFF00)==0xFF00 || (rand & 0xFF00)==0x0000 ); rand2 = TI_getRandomIntegerFromVLO(); BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz DCOCTL = CALDCO_1MHZ; FCTL2 = FWKEY + FSSEL0 + FN1; // MCLK/3 for Flash Timing Generator FCTL3 = FWKEY + LOCKA; // Clear LOCK & LOCKA bits FCTL1 = FWKEY + WRT; // Set WRT bit for write operation Flash_Addr[0]=(rand>>8) & 0xFF; Flash_Addr[1]=rand & 0xFF; Flash_Addr[2]=(rand2>>8) & 0xFF; Flash_Addr[3]=rand2 & 0xFF; FCTL1 = FWKEY; // Clear WRT bit FCTL3 = FWKEY + LOCKA + LOCK; // Set LOCK & LOCKA bit } void linkTo() { linkID_t linkID1; uint8_t msg[6]; // keep trying to link... while (SMPL_SUCCESS != SMPL_Link(&linkID1)) { __bis_SR_register(LPM3_bits + GIE); // LPM3 with interrupts enabled BSP_TOGGLE_LED1(); BSP_TOGGLE_LED2();

  • 24

    } // Turn off all LEDs if (BSP_LED1_IS_ON()) { BSP_TOGGLE_LED1(); } if (BSP_LED2_IS_ON()) { BSP_TOGGLE_LED2(); } while (1) { char msg[6]; int data_x,data_y,data_z; volatile long temp; int results[3]; SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, "" ); //__bis_SR_register(LPM3_bits+GIE); // LPM3 with interrupts enabled SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, "" ); //read x: x is A0 which is P2.0 BSP_TOGGLE_LED2(); ADC10CTL1 = INCH_0 + ADC10DIV_2; //set ADC to A0 with clock divide of 2, we might not need the clock divide ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; //using Vcc and gnd for reference, 16 clks/sample, turn ADC on and enable interrupts //for( int a = 100; a > 0; a-- ); // delay to allow reference to settle, might not be necessary ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled, this means that it enters low power until ADC conversion is done results[0] = ADC10MEM; //copy ADC results to x data ADC10CTL0 &= ~ENC; //reset encode bit //read y: y is A1 which is P2.1 ADC10CTL1 = INCH_1 + ADC10DIV_2; //set ADC to A1 with clock divide of 2, we might not need the clock divide ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; //using Vcc and gnd for reference, 16 clks/sample, turn ADC on and enable interrupts //for( int a = 100; a > 0; a-- ); // delay to allow reference to settle, might not be necessary ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled, this means that it enters low power until ADC conversion is done results[1] = ADC10MEM; //copy ADC results to y data ADC10CTL0 &= ~ENC; //reset encode bit //read z: z is A2 which is P2.2 ADC10CTL1 = INCH_2 + ADC10DIV_2; //set ADC to A2 with clock divide of 2, we might not need the clock divide ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE; //using Vcc and gnd for reference, 16 clks/sample, turn ADC on and enable interrupts //for( int a = 100; a > 0; a-- ); // delay to allow reference to settle, might not be necessary ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start __bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled, this means that it enters low power until ADC conversion is done results[2] = ADC10MEM; //copy ADC results to z data ADC10CTL0 &= ~ENC; //reset encode bit

  • 25

    ADC10CTL0 &= ~(REFON + ADC10ON); // turn off A/D to save power /* The anaolog data is converted using the following formula: Digital = 1023*(Vanalog - Vref-) / (Vref+ - Vref-) The 1023 comes from the 10 bit ADC (2^10) For our case as it's setup, Vref- = Gnd and Vref+ = Vcc An input voltage of Vcc/2 corresponds to zero acceleration so zero accerlation is 512 in digital (1023/2 rounded up, not sure if supposed to round up) */ data_x = results[0]; data_y = results[1]; data_z = results[2]; msg[0] = data_x&0xFF; msg[1] = (data_x>>8)&0x03; msg[2] = data_y&0xFF; msg[3] = (data_y>>8)&0xFF; msg[4] = data_z&0xFF; msg[5] = (data_z>>8)&0xFF; BSP_TOGGLE_LED1(); if (SMPL_SUCCESS == SMPL_Send(linkID1, msg, sizeof(msg))) { BSP_TOGGLE_LED2(); } else { BSP_TOGGLE_LED2(); BSP_TOGGLE_LED1(); } } } /*------------------------------------------------------------------------------ * ADC10 interrupt service routine ------------------------------------------------------------------------------*/ #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { __bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR) }

  • 26

    MATLABCodetoDisplayPlots

    %serial data capture and plot clear all s = serial('COM1'); set(s,'BaudRate',9600,'DataBits',8,'Parity','none');%,'InputBufferSize',28); fopen(s); s.ByteOrder = 'bigEndian'; l = 200; i = 2; t = []; x = []; y = []; z = []; t(1) = 0; data = fgets(s); data = fgets(s); tic data2 = str2num(data); x(1) = data2(1); y(1) = data2(2); z(1) = data2(3); while (i < (l + 2)) data = fgets(s); data = fgets(s); t(i) = t(i-1) + toc; tic data2 = str2num(data); x(i) = data2(1); y(i) = data2(2); z(i) = data2(3); i = i + 1; disp(data) end n = toc; fclose(s);delete(s);clear s x = (x - 474)./85.3; y = (y - 481)./85.3; z = (z - 478)./85.3; subplot(3,1,1) plot(t,x) axis([0 t(l) -6 6]) subplot(3,1,2) plot(t,y) axis([0 t(l) -6 6]) subplot(3,1,3) plot(t,z) axis([0 t(l) -6 6])