Arduino Microcontroller Processing for Everyone! Part II Synthesis Lectures on Digital Circuits and Systems Editor MitchellA.Thornton,SouthernMethodistUniversity TheSynthesisLecturesonDigitalCircuitsandSystemsseriesiscomprisedof50-to100-page bookstargetedforaudiencememberswithawide-rangingbackground.TheLecturesincludetopics thatareofinteresttostudents,professionals,andresearchersintheareaofdesignandanalysisof digitalcircuitsandsystems.EachLectureisself-containedandfocusesonthebackground informationrequiredtounderstandthesubjectmatterandpracticalcasestudiesthatillustrate applications.TheformatofaLectureisstructuredsuchthateachwillbedevotedtoaspecifictopic indigitalcircuitsandsystemsratherthanalargeroverviewofseveraltopicssuchasthatfoundina comprehensivehandbook.TheLecturescoverbothwell-establishedareasaswellasnewly developedoremergingmaterialindigitalcircuitsandsystemsdesignandanalysis. ArduinoMicrocontroller:ProcessingforEveryone!PartII StevenF.Barrett 2010 ArduinoMicrocontroller:ProcessingforEveryone!PartI StevenF.Barrett 2010 DigitalSystemVerification:ACombinedFormalMethodsandSimulationFramework LunLiandMitchellA.Thornton 2010 ProgressinApplicationsofBooleanFunctions TsutomuSasaoandJonT.Butler 2009 EmbeddedSystemsDesignwiththeAtmelAVRMicrocontroller:PartII StevenF.Barrett 2009 EmbeddedSystemsDesignwiththeAtmelAVRMicrocontroller:PartI StevenF.Barrett 2009 iv EmbeddedSystemsInterfacingforEngineersusingtheFreescaleHCS08Microcontroller II:DigitalandAnalogHardwareInterfacing DouglasH.Summerville 2009 DesigningAsynchronousCircuitsusingNULLConventionLogic(NCL) ScottC.SmithandJiaDi 2009 EmbeddedSystemsInterfacingforEngineersusingtheFreescaleHCS08Microcontroller I:AssemblyLanguageProgramming DouglasH.Summerville 2009 DevelopingEmbeddedSoftwareusingDaVinci&OMAPTechnology B.I.(Raj)Pawate 2009 MismatchandNoiseinModernICProcesses AndrewMarshall 2009 AsynchronousSequentialMachineDesignandAnalysis:AComprehensiveDevelopment oftheDesignandAnalysisofClock-IndependentStateMachinesandSystems RichardF.Tinder 2009 AnIntroductiontoLogicCircuitTesting ParagK.Lala 2008 PragmaticPower WilliamJ.Eccles 2008 MultipleValuedLogic:ConceptsandRepresentations D.MichaelMillerandMitchellA.Thornton 2007 FiniteStateMachineDatapathDesign,Optimization,andImplementation JustinDavisandRobertReese 2007 AtmelAVRMicrocontrollerPrimer:ProgrammingandInterfacing StevenF.BarrettandDanielJ.Pack 2007 v PragmaticLogic WilliamJ.Eccles 2007 PSpiceforFiltersandTransmissionLines PaulTobin 2007 PSpiceforDigitalSignalProcessing PaulTobin 2007 PSpiceforAnalogCommunicationsEngineering PaulTobin 2007 PSpiceforDigitalCommunicationsEngineering PaulTobin 2007 PSpiceforCircuitTheoryandElectronicDevices PaulTobin 2007 PragmaticCircuits:DCandTimeDomain WilliamJ.Eccles 2006 PragmaticCircuits:FrequencyDomain WilliamJ.Eccles 2006 PragmaticCircuits:SignalsandFilters WilliamJ.Eccles 2006 High-SpeedDigitalSystemDesign JustinDavis 2006 IntroductiontoLogicSynthesisusingVerilogHDL RobertB.ReeseandMitchellA.Thornton 2006 MicrocontrollersFundamentalsforEngineersandScientists StevenF.BarrettandDanielJ.Pack 2006 Copyright© 2010byMorgan&Claypool Allrightsreserved.Nopartofthispublicationmaybereproduced,storedinaretrievalsystem,ortransmittedin anyformorbyanymeans—electronic,mechanical,photocopy,recording,oranyotherexceptforbriefquotationsin printedreviews,withoutthepriorpermissionofthepublisher. ArduinoMicrocontroller:ProcessingforEveryone!PartII StevenF.Barrett www.morganclaypool.com ISBN:9781608454372 paperback ISBN:9781608454884 ebook DOI10.2200/S00283ED1V01Y201005DCS029 APublicationintheMorgan&ClaypoolPublishersseries SYNTHESISLECTURESONDIGITALCIRCUITSANDSYSTEMS Lecture#29 SeriesEditor:MitchellA.Thornton,SouthernMethodistUniversity SeriesISSN SynthesisLecturesonDigitalCircuitsandSystems Print1932-3166 Electronic1932-3174 Arduino Microcontroller Processing for Everyone! Part II Steven F.Barrett UniversityofWyoming,Laramie,WY SYNTHESISLECTURESONDIGITALCIRCUITSANDSYSTEMS#29 M &C Morgan &cLaypool publishers ABSTRACT This book is about the Arduino microcontroller and the Arduino concept.The visionary Arduino teamofMassimoBanzi,DavidCuartielles,TomIgoe,GianlucaMartino,andDavidMellislaunched anewinnovationinmicrocontrollerhardwarein2005,theconceptofopensourcehardware.Their approachwastoopenlysharedetailsofmicrocontroller-basedhardwaredesignplatformstostimulate thesharingofideasandpromoteinnovation.Thisconcepthasbeenpopularinthesoftwareworld formanyyears.Thisbookisintendedforawidevarietyofaudiencesincludingstudentsofthefine arts,middleandseniorhighschoolstudents,engineeringdesignstudents,andpracticingscientists and engineers.To meet this wide audience,the book has been divided into sections to satisfy the needofeachreader.Thebookcontainsmanysoftwareandhardwareexamplestoassistthereaderin developing a wide variety of systems.For the examples,the Arduino Duemilanove and the Atmel ATmega328isemployedasthetargetprocessor. KEYWORDS Arduinomicrocontroller,ArduinoDuemilanove,Atmelmicrocontroller,AtmelAVR, ATmega328,microcontrollerinterfacing,embeddedsystemsdesign ix Contents Preface......................................................................xv 5 AnalogtoDigitalConversion(ADC).........................................97 5.1 Overview.................................................................97 5.2 Sampling,QuantizationandEncoding ......................................98 5.2.1 ResolutionandDataRate 100 5.3 Analog-to-DigitalConversion(ADC)Process..............................101 5.3.1 TransducerInterfaceDesign(TID)Circuit 102 5.3.2 OperationalAmplifiers 103 5.4 ADCConversionTechnologies............................................106 5.4.1 Successive-Approximation 107 5.5 TheAtmelATmega328ADCSystem......................................107 5.5.1 BlockDiagram 109 5.5.2 Registers 109 5.6 ProgrammingtheADCusingtheArduinoDevelopmentEnvironment........112 5.7 ProgrammingtheADCinC..............................................112 5.8 Example:ADCRainGageIndicator.......................................114 5.8.1 ADCRainGageIndicatorusingtheArduinoDevelopment Environment 114 5.8.2 ADCRainGageIndicatorinC 119 5.8.3 ADCRainGageusingtheArduinoDevelopment Environment—Revisited 125 5.9 One-bitADC-ThresholdDetector .......................................127 5.10 Digital-to-AnalogConversion(DAC)......................................129 5.10.1DACwiththeArduinoDevelopmentEnvironment 130 5.10.2DACwithexternalconverters 130 5.10.3OctalChannel,8-bitDACviatheSPI 130 x 5.11 Application:Artpieceilluminationsystem–Revisited.......................131 5.12 Summary................................................................134 5.13 References...............................................................135 5.14 ChapterProblems........................................................136 6 InterruptSubsystem ....................................................... 137 6.1 Overview................................................................137 6.2 ATmega328InterruptSystem .............................................138 6.3 InterruptProgramming...................................................140 6.4 ProgrammingInterruptsinCandtheArduinoDevelopmentEnvironment....140 6.4.1 ExternalInterruptProgramming 141 6.4.2 InternalInterruptProgramming 144 6.5 ForegroundandBackgroundProcessing....................................149 6.6 InterruptExamples.......................................................149 6.6.1 RealTimeClockinC 149 6.6.2 RealTimeClockusingtheArduinoDevelopmentEnvironment 153 6.6.3 InterruptDrivenUSARTinC 155 6.7 Summary................................................................166 6.8 References...............................................................166 6.9 ChapterProblems........................................................167 7 TimingSubsystem .........................................................169 7.1 Overview................................................................169 7.2 Timingrelatedterminology ...............................................170 7.2.1 Frequency 170 7.2.2 Period 170 7.2.3 DutyCycle 170 7.3 TimingSystemOverview.................................................170 7.4 Applications.............................................................174 7.4.1 InputCapture—MeasuringExternalTimingEvent 174 7.4.2 CountingEvents 175
Description: