intel galileo essentials -...

278

Upload: vandang

Post on 13-Dec-2018

242 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 2: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 3: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

IntelGalileoEssentials

Page 4: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TableofContents

IntelGalileoEssentials

Credits

AbouttheAuthor

AbouttheReviewers

www.PacktPub.com

Supportfiles,eBooks,discountoffers,andmore

Whysubscribe?

FreeaccessforPacktaccountholders

Preface

Whatthisbookcovers

Whatyouneedforthisbook

Whothisbookisfor

Conventions

Readerfeedback

Customersupport

Downloadingthecolorimagesofthisbook

Errata

Piracy

Questions

1.GettingStartedwiththeGalileo

UnpackingandconnectingtheGalileo

DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachine

DownloadingthesoftwareandconnectingtheGalileotoaMac

DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachine

RunningtheIDEfortheGalileo

SettingtheIDEtoconnecttoyourboard

SelectingtheproperCOMportforWindows

SelectingtheproperCOMportfortheMac

SelectingtheproperCOMportforaLinuxMachine

Page 5: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Updatingthefirmware

OpeninganduploadingafiletotheGalileo

AccessingtheGalileo’sLinuxcapabilities

Summary

2.AccessingtheGPIOPins

TheGPIOcapabilityoftheGalileo

UsingtheGPIOpins

Connectingyourfirstexternalhardware

Pluggingyourwiresintothebreadboard

Settinguptheelectronics

TheIDEandLEDCode

Gettingsignalsfromtheoutsideworld

InterfacingdigitalinputsignalswithGalileo

InterfacinganaloginputsignalswithGalileo

Summary

3.AddingDisplayFunctionality

Thesimpleserialdisplay

EnablingtheserialdisplayintheIDE

TheTFTshield

AccessingthedisplaywiththeIDE

Summary

4.ControllingDCMotors

DCmotorbasics

ConnectingaDCmotordirectlytotheGalileo

GalileocodeforDCmotorspeedcontrol

ConnectingaDCmotorusinganH-bridgeandtheGalileo

GalileocodeforDCmotordirectioncontrol

ControllingDCmotorsusingashield

GalileocodefortheDCmotorshield

Summary

5.AddingSensors

Page 6: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Sensingdistance

TheInfraredsensor

ConnectinganIRsensortotheGalileo

AccessingtheIRsensorfromtheGalileoIDE

ConnectingadigitalcompasstotheGalileo

AccessingthecompassfromtheIDE

ConnectinganaccelerometerorgyrototheGalileo

AccessingtheaccelerometerfromtheIDE

Connectinganaltimeter/pressuresensortotheGalileo

Accessingthealtimeter/pressureSensorfromtheGalileoIDE

Summary

6.RemoteControl

ConnectinganXBeeinterfacetotheGalileo

ConfiguringtheXBeedevices

EnablinganXBeeInterfaceintheIDE

ConfiguringaWi-FiconnectionontheGalileo

UsingWi-FifromtheIDE

Summary

7.GoingFurtherwithGalileo

TheGalileoandLinux

CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

Buildingrobotsthatcanwalk

Howservomotorswork

Buildingthequadrupedplatform

Usingaservocontrollertocontroltheservos

CommunicatingwiththeservocontrollerviaaPC

ConnectingtheservocontrollertotheGalileo

CreatingaprograminLinuxsothatyoucancontrolyourquadruped

Summary

8.SpeechOutput

Hookingupthehardwaretomakeaninputsound

Page 7: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Usinganapplication

UsingEspeaktoallowourprojectstorespondinarobotvoice

Summary

Index

Page 8: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 9: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

IntelGalileoEssentials

Page 10: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 11: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

IntelGalileoEssentialsCopyright©2015PacktPublishing

Allrightsreserved.Nopartofthisbookmaybereproduced,storedinaretrievalsystem,ortransmittedinanyformorbyanymeans,withoutthepriorwrittenpermissionofthepublisher,exceptinthecaseofbriefquotationsembeddedincriticalarticlesorreviews.

Everyefforthasbeenmadeinthepreparationofthisbooktoensuretheaccuracyoftheinformationpresented.However,theinformationcontainedinthisbookissoldwithoutwarranty,eitherexpressorimplied.Neithertheauthor,norPacktPublishing,anditsdealersanddistributorswillbeheldliableforanydamagescausedorallegedtobecauseddirectlyorindirectlybythisbook.

PacktPublishinghasendeavoredtoprovidetrademarkinformationaboutallofthecompaniesandproductsmentionedinthisbookbytheappropriateuseofcapitals.However,PacktPublishingcannotguaranteetheaccuracyofthisinformation.

Firstpublished:February2015

Productionreference:1180215

PublishedbyPacktPublishingLtd.

LiveryPlace

35LiveryStreet

BirminghamB32PB,UK.

ISBN978-1-78439-890-3

www.packtpub.com

Page 12: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 13: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

CreditsAuthor

RichardGrimmett

Reviewers

AustinHughes

AlanPlotko

JasonWright

CommissioningEditor

AshwinNair

AcquisitionEditor

SamWood

ContentDevelopmentEditor

MohammedFahad

TechnicalEditor

NaveenkumarJain

CopyEditors

NehaKarnani

MerilynPereira

ProjectCoordinator

PuravMotiwalla

Proofreaders

StephenCopestake

PaulHindle

Indexer

RekhaNair

ProductionCoordinator

ShantanuN.Zagade

CoverWork

ShantanuN.Zagade

Page 14: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 15: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AbouttheAuthorRichardGrimmetthasalwaysbeenfascinatedbycomputersandelectronicsfromhisveryfirstprogrammingprojectthatusedFortranonpunchcards.Hehasabachelor’sandmaster’sdegreeinelectricalengineeringandaPhDinleadershipstudies.Healsohas26yearsofexperienceinelectronicsandcomputers.HepossessesoneoftheoriginalbrickphonesaswellasaGoogleglass.HenowteachescomputerscienceandelectricalengineeringatBrighamYoungUniversity-Idaho,wherehisofficeisfilledwithhismanyroboticsprojects.

Iwouldcertainlyliketothankmywife,Jeanne,andfamilyforprovidingmewithawonderful,supportiveenvironmentthatencouragesmetotakeonprojectslikethis.Iwouldalsoliketothankmystudents;theyshowmethatamazingthingscanbeaccomplishedbythosewhoareunawareofthebarriers.

Page 16: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 17: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AbouttheReviewersAustinHughesisasoftwareengineerwithaninterestinmicrocontrollers,embeddedsystems,androbotics.

AlanPlotkoisatechnologyenthusiastwithexperienceindevelopingacrossthefullstack.Hewasfirstexposedtoprogrammingattheageof9whenhediscoveredtheviewsourcecodeoptioninhisbrowser.Codingthenquicklyturnedintoahobby;thisledtohisstudyingcomputerscienceattheuniversitylevel.AlanlovesdevelopingapplicationsfortheWebandalwaysmakestimetoattendhackathons,whicharetypicallyweekend-longprogrammingcompetitionswhereparticipantsbuildprojectsfromscratchtobenefitthecommunity.Alan’sexperienceextendstoPythondevelopment,variousdatabasetechnologies,includingNoSQL,andframeworksforrapidapplicationdevelopment.Whenhe’snotwritingcode,Alanspendshistimewritingstories;heisanavidwriter,havingpreviouslyself-publishedafantasynovel.

JasonWrightisahardwareengineerinIntel’sNewDevicesGroup,whereheworksonprojectsintheareaoflow-powerembeddedandwearablecomputing.Previously,heworkedonGalileo-basedurbansensingdeviceswithinIntelLabsEurope.JasonreceivedhisBSandMEngdegreesinelectricalandcomputerengineeringfromCornellUniversityin2012and2013.

Jasonwouldliketothankhisfamilyandfriendsfortheircontinuedloveandsupport.

Page 18: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 19: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

www.PacktPub.com

Page 20: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Supportfiles,eBooks,discountoffers,andmoreForsupportfilesanddownloadsrelatedtoyourbook,pleasevisitwww.PacktPub.com.

DidyouknowthatPacktofferseBookversionsofeverybookpublished,withPDFandePubfilesavailable?YoucanupgradetotheeBookversionatwww.PacktPub.comandasaprintbookcustomer,youareentitledtoadiscountontheeBookcopy.Getintouchwithusat<[email protected]>formoredetails.

Atwww.PacktPub.com,youcanalsoreadacollectionoffreetechnicalarticles,signupforarangeoffreenewslettersandreceiveexclusivediscountsandoffersonPacktbooksandeBooks.

https://www2.packtpub.com/books/subscription/packtlib

DoyouneedinstantsolutionstoyourITquestions?PacktLibisPackt’sonlinedigitalbooklibrary.Here,youcansearch,access,andreadPackt’sentirelibraryofbooks.

Page 21: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Whysubscribe?FullysearchableacrosseverybookpublishedbyPacktCopyandpaste,print,andbookmarkcontentOndemandandaccessibleviaawebbrowser

Page 22: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

FreeaccessforPacktaccountholdersIfyouhaveanaccountwithPacktatwww.PacktPub.com,youcanusethistoaccessPacktLibtodayandview9entirelyfreebooks.Simplyuseyourlogincredentialsforimmediateaccess.

Page 23: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 24: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

PrefaceOverthelastfewyears,anumberofimportanttechnologicaltoolshavebeenintroducedthathaveenabledthemigrationofcomplexelectronicsprojectsfromtheUniversityorGovernmentLabtoalmostanyone’sprojectdesk.TheGalileo,aninexpensiveprocessorsystembyIntel,isanexampleofoneofthesetoolkits.Thissmall,inexpensive,butpowerfulboardcanbeusedinawiderangeofprojects.

Butjustasimportantasthehardwareisthecommunityofdeveloperswhonotonlyprovidehelpintheareaofsoftwaredevelopment,butalsoprovidehardwareadd-onsfortheprocessorboarditself.Still,itcanbeabitintimidatingtostartusingGalileotobuildyourveryownprojects.

Thisbookisdesignedtohelpanyone,eventhosewithnoprogrammingbackgroundorexperience,tobesuccessfulinbuildingbothsimplebutalsoquitecomplexprojects.Itwillleadyouthroughtheprocessstepbystepsothatyourprojectdesignscancometolife.Hopefully,thisbookwillinspirethosewiththeimaginationandcreativespirittobuildthosewildlyinventivedesignsthatwillrevolutionizetheworld!

Page 25: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

WhatthisbookcoversChapter1,GettingStartedwiththeGalileo,beginswithadiscussionofhowtoconnectpowerandendswithafullsystem,configuredandreadytobeginconnectingamazingdevicesandSWcapabilitiestofulfillalmostanyproject.

Chapter2,AccessingtheGPIOPins,showsyoutohowtoaccessthesepins,bothinputandoutput,soyoucandoallsortsofamazingthings.Oneofthecapabilitiesyou’llneedtocompleteyourprojectsisabasicknowledgeofhowtoaccesstheGPIOpinssothatyoucanaccessallsortsofadditionalhardwarecapabilities.

Chapter3,AddingDisplayFunctionality,showsyouhowtheGalileocanbeconnectedtoadisplaysothatyoucanbothseeoutputandalsogetinputfromatouchscreen.OneofthefirstthingsyoumightwanttodoistoconnectadisplayuptotheGalileo.

Chapter4,ControllingDCMotors,detailshowtocontrolaDCmotorsothattheunitcandrivewheelsortracks.

Chapter5,AddingSensors,showsyouhowtoaddIR,Sonar,andevenacompasstoyourproject.

Chapter6,RemoteControl,covershowtocommunicatewirelesslywithyourGalileoprojects,asyoumaywanttoaccessyourprojectswithoutconnectingwires.

Chapter7,GoingFurtherwithGalileo,introducesyoutotheLinuxcapabilitiesoftheGalileousingtheexampleofconstructingaquadrupedrobot.

Chapter8,SpeechOutput,covershowtomakeyourprojecttalkasanexampleofhowtousefree,opensourcesoftwaretoaddcomplexfunctionalitytoyourprojects.Oneoftheamazingfeaturesoftoday’scomputersystemsistheabilitytoprovideoutputwithoutascreenorkeyboard.

Page 26: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 27: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

WhatyouneedforthisbookThemostimportantpieceofsoftwarerequiredforthefirstsixchaptersofthebookistheGalileoIDE,whichisavailableathttps://communities.intel.com/docs/DOC-22226.Theonlyothersoftwarethatwillberequiredforthesechaptersisthesoftwaredriversassociatedwiththehardwarethatyoumightaddtoyourproject;thesewillbedetailedintheindividualchaptersthemselves.

ForChapter7,GoingFurtherwithGalileo,you’llneedtodownloadaversionofDebianLinuxavailableathttps://communities.intel.com/message/231688.ToburntheimagetoanSDcard,you’llneedWin32DiskImageavailableathttp://sourceforge.net/projects/win32diskimager/.You’llalsoneedaterminalemulatorprogram;PuTTYisonesuchprogram,availableathttp://www.chiark.greenend.org.uk/~sgtatham/putty/.Finally,you’llneedacontrolprogramforservos,availableatwww.pololu.com/docs/0J40/3.b.

ForChapter8,SpeechOutput,you’llneedafree,opensourcesoftwarepackagecalledEspeakthatisavailablebyusingthecommandsudoapt-getinstallespeak.

Page 28: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 29: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

WhothisbookisforThisbookisforanyonewithalittleprogrammingskill,abitofimagination,andthedesiretocreatetheirowndazzlingprojects.ThebookisdesignedtostartbyteachingbeginnersthebasicsofGalileoandhowtoprogramit.You’lltacklemoreandmorechallengingprojectsuntilyouhavetheknow-howtobuildyourownamazingprojects.

Page 30: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 31: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConventionsInthisbook,youwillfindanumberofstylesoftextthatdistinguishbetweendifferentkindsofinformation.Herearesomeexamplesofthesestyles,andanexplanationoftheirmeaning.

Codewordsintext,databasetablenames,foldernames,filenames,fileextensions,pathnames,dummyURLs,userinput,andTwitterhandlesareshownasfollows:“Thiswillun-archiveasetoffilesanddirectoriesunderthearduino-1.5.3-Intel.1.0.3directorystructure.”

Ablockofcodeissetasfollows:

qData=false;//Initializeonreset

gSerialStdPtr->begin(9600);//Receiver

gSerialTwoPtr->begin(9600);//Sender

waitForUser(5);//Giveusrtimetoopenserialterminal

gSerialStdPtr->println("XBee-Receiver-setup");

pinMode(led,OUTPUT);

Anycommand-lineinputoroutputiswrittenasfollows:

mvmaestro-linux-100507.tar.gz\?file_id\=0J315maestrolinux-100507.tar.gz

Newtermsandimportantwordsareshowninbold.Wordsthatyouseeonthescreen,inmenusordialogboxesforexample,appearinthetextlikethis:“SelecttheStart|ControlPanel|DeviceManagerinsideWindows.”

NoteWarningsorimportantnotesappearinaboxlikethis.

TipTipsandtricksappearlikethis.

Page 32: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 33: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ReaderfeedbackFeedbackfromourreadersisalwayswelcome.Letusknowwhatyouthinkaboutthisbook—whatyoulikedormayhavedisliked.Readerfeedbackisimportantforustodeveloptitlesthatyoureallygetthemostoutof.

Tosendusgeneralfeedback,simplysendane-mailto<[email protected]>,andmentionthebooktitleviathesubjectofyourmessage.

Ifthereisatopicthatyouhaveexpertiseinandyouareinterestedineitherwritingorcontributingtoabook,seeourauthorguideonwww.packtpub.com/authors.

Page 34: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 35: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

CustomersupportNowthatyouaretheproudownerofaPacktbook,wehaveanumberofthingstohelpyoutogetthemostfromyourpurchase.

Page 36: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

DownloadingthecolorimagesofthisbookWealsoprovideyouwithaPDFfilethathascolorimagesofthescreenshots/diagramsusedinthisbook.Thecolorimageswillhelpyoubetterunderstandthechangesintheoutput.Youcandownloadthisfilefrom:https://www.packtpub.com/sites/default/files/downloads/B03435.pdf.

Page 37: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ErrataAlthoughwehavetakeneverycaretoensuretheaccuracyofourcontent,mistakesdohappen.Ifyoufindamistakeinoneofourbooks—maybeamistakeinthetextorthecode—wewouldbegratefulifyouwouldreportthistous.Bydoingso,youcansaveotherreadersfromfrustrationandhelpusimprovesubsequentversionsofthisbook.Ifyoufindanyerrata,pleasereportthembyvisitinghttp://www.packtpub.com/submit-errata,selectingyourbook,clickingontheerratasubmissionformlink,andenteringthedetailsofyourerrata.Onceyourerrataareverified,yoursubmissionwillbeacceptedandtheerratawillbeuploadedonourwebsite,oraddedtoanylistofexistingerrata,undertheErratasectionofthattitle.Anyexistingerratacanbeviewedbyselectingyourtitlefromhttp://www.packtpub.com/support.

Page 38: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

PiracyPiracyofcopyrightmaterialontheInternetisanongoingproblemacrossallmedia.AtPackt,wetaketheprotectionofourcopyrightandlicensesveryseriously.Ifyoucomeacrossanyillegalcopiesofourworks,inanyform,ontheInternet,pleaseprovideuswiththelocationaddressorwebsitenameimmediatelysothatwecanpursuearemedy.

Pleasecontactusat<[email protected]>withalinktothesuspectedpiratedmaterial.

Weappreciateyourhelpinprotectingourauthors,andourabilitytobringyouvaluablecontent.

Page 39: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

QuestionsYoucancontactusat<[email protected]>ifyouarehavingaproblemwithanyaspectofthebook,andwewilldoourbesttoaddressit.

Page 40: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 41: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Chapter1.GettingStartedwiththeGalileoYou’vechosenIntel’snewGalileoprocessorboardandyouarereadytostartsomeamazingprojects.However,youmightbenewtothiskindofprocessor,oryoumighthaveusedanothersimilarprocessorbutnottheGalileo.Thisbookisdesignedtoleadyoustep-by-stepthroughanumberofexamplesthatwillprovideyouwiththeknowledgeyouneedtoaccessthepoweroftheGalileo.You’llalsolearnhowtoaddadditionalhardwaretosensetheworldaroundyou,displayinformation,andevencontrolmotorsorservos.

Inthischapter,you’llstartbyunpackingandconnectingtheGalileotoyourhostmachine,thenyou’lllearnhowtousetheGalileofromyourremotecomputer.IfyouknowhowtouseMacorLinuxmachines,thischapterwillshowyouhowtousethem.You’lltakeapeekintotheinternalsoftheGalileoandlearnabouttheLinuxmachinehidingbehindthesimpleGalileoexterior.

Forthischapter,theobjectivesareasfollows:

UnpackingandconnectingtheGalileotoahostcomputerLoadingandconfiguringtheGalileoIDE,basedontheArduinoIDEDownloadingandrunningsomesimpleexampleprogramsTakingapeekattheLinuxmachineattheheartoftheGalileo

Page 42: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

UnpackingandconnectingtheGalileoTheGalileoispackagedwithapowercable.Hereisapictureoftheboard:

Thisishowtheboardwilllookwithouttheadapter:

Page 43: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

NoteThisparticularGalileoisaGen2board.ThisversionisaslightlyimprovedversionoftheoriginalGen1board,andhasafewconnectorchanges.Theexamplesinthisbookhavebeentestedonbothversions,andshouldworkunlessnoted.

Thepowerconnectionisverystraightforward.However,you’llalsoneedanothercabletostartworkingwiththeGalileo.ThisisaUSB-to-microUSBcable.Hereisapicture:

ThiscablewillgobetweentheGalileoandthehostmachinetodevelopanddebugthecode.Herearethespecificconnections:

Page 44: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TopreparefordevelopingtheGalileo,plugthepowerintoanoutletandtheboard.AgreenpowerLEDclosetotheUSBconnectorshouldlight.NowyouarereadytoconnectyourboardtoaremotecomputertobeginprogrammingThenextsectionswillcoverhowtoconnectyourGalileotoacomputerrunningWindows,OSX,orLinux.

Page 45: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 46: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachineThefirststepinsettingupyourremotecomputerfordevelopmentwiththeGalileoistodownloadtheIntegratedDevelopmentEnvironment(IDE)softwarefromhttps://communities.intel.com/docs/DOC-22226.ChoosethedownloadlinkforWindows.ThiswilldownloadtheIDEaswellasthedriversfortheGalileo.Whenthisfileisdownloaded,unzipthefileusinganarchivemanager(forexample7-zip)toalocationonyourC:.Thiswillun-archiveasetoffilesanddirectoriesunderthearduino-1.5.3-Intel.1.0.3directorystructure.

PlugtheUSBfromtheGalileointoyourcomputer.IfyouareusinganewerversionofMicrosoftWindows,whenyouplugtheGalileointothesystemitwilltrytoinstallthedriversautomatically.Thedevicewillfailtoinstall.You’llneedtoinstallthedriversmanually,usingthefollowingsteps:

1. SelecttheStart|ControlPanel|DeviceManagerinsideWindows.UndertheOtherdevicesmenu,selecttheGadgetSerialv2.4device.ThenselectUpdateDriverSoftware,asshowninthefollowingscreenshot:

2. NextclickonBrowsemycomputerfordriversoftware.

Page 47: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

3. ClickonBrowse…nexttothefilepathinputbox.4. IfyouinstalledyourArduinoIDEfolderintherootofyourharddrive,navigateto

C:\ardunio-1.5.3\hardware\arduino\x86\toolsandclickonOK.Ifyouhaveinstalleditinadifferentlocation,navigatetothisdirectory,selectit,andthenclickonOK.

Youwillgetasecuritywarning;clickonOKandthedriverswillinstall.Whenyourdriversareinstalled,youshouldseethefollowingdevicewhenyounavigatetoStartMenu|DevicesandPrinters:

Inthiscase,thedeviceisconnectedtoCOMport34.NotedowntheCOMporttheGalileoisconnectedtoasyou’llneedthatinaminute.

Page 48: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 49: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

DownloadingthesoftwareandconnectingtheGalileotoaMacIfyouareusinganOSXmachine,downloadtheOSXversionoftheIDEsoftwareathttps://communities.intel.com/docs/DOC-22226.UnzipthisfileintoyourApplicationsfolder.Thenconnectthe5VpowertotheGalileo.ConnecttheUSBcablefromtheGalileotoanavailableUSBsocketonyourcomputer.WaitforaminutewhiletheGalileobootsup.ToverifythattheGalileohasloadedproperly,opentheSystemInformationwindow.ThencheckundertheUSBtabforaGadgetSerialv2.4entryasdemonstratedinthefollowingscreenshot:

YoushouldalsocheckundertheNetworktabtofindthedevicenameofyourGalileo.ItshouldbesomethinglikeusbmodemXXXX.NotedownthisnameasyouwillneedittoselectthecorrectportlaterwhenyouconfiguretheconnectiontotheGalileo.Youarenowreadytorunthesoftware.

Page 50: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 51: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachineIfyouareusingaLinuxmachine,downloadtheLinuxversionoftheIDEsoftwarefromhttps://communities.intel.com/docs/DOC-22226.Unpackthisfileusingtar-zxvfarduino-1.5.3-linux32.tar.gz.YouwillalsoneedtodisablethemodemmanageronmostLinuxdistributionstoenableuploadingtotheboard.Howyoudothiswillvarybydistributionbut,ifyouareusingtheUbuntudistribution,typesudoapt-getremovemodemmanager.

ToconnecttheGalileoboardtotheLinuxmachine,simplyplugintheUSBconnectortooneoftheUSBportsontheLinuxmachine.Openaterminalandtypesudols/dev/ttyACM*andthiswilllistthedeviceconnectedtothemachine.Youshouldnotedownthisvalueasyouwilllaterneedtospecifytheport.

Page 52: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 53: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

RunningtheIDEfortheGalileoNowthatthedeviceisinstalled,youcanruntheIDE.Selectandruntheprogrambasedonthetypeofmachineyouareusing.TheIDEshouldstartandyoushouldseesomethingresemblingthefollowingscreenshot:

Thisistheenvironmentyouwillusetodevelopyourapplications.YoucanusethisIDEtocompilethecode,uploadittothedevice,andthenrunit.

Page 54: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SettingtheIDEtoconnecttoyourboardThefirstthingyou’llneedtodoissettheIDEtocreatecodefortheproperGalileoboard.Fortunately,theIDEletsyousetthatbychoosingtheboard.Todothis,navigatetoTools|Board|Intel®GalileoGen2,asshowninthefollowingscreenshot:

Thenextstep,selectingaporttoconnecttheboardtotheIDE,willdependonthetypeofoperatingsystemyouareusing.

Page 55: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SelectingtheproperCOMportforWindowsTospecifytheportforWindows,navigatetoTools|SerialPort|COM23,(theportyounotedearlier)asshowninthefollowingscreenshot:

TheIDEshouldnowindicatethatyouareusingtheGalileoonCOM23inthelower-rightcorneroftheIDE,asintheprecedingscreenshot.

Page 56: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SelectingtheproperCOMportfortheMacTospecifytheportforMac,navigatetoTools|SerialPort|andselecttheportyounotedearlierwhenyouinstalledthedrivers.TheIDEshouldnowindicatethatyouareusingtheGalileoontheproperportinthelower-rightcorneroftheIDE.

Page 57: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SelectingtheproperCOMportforaLinuxMachineTospecifytheportforaLinuxmachine,navigatetoTools|SerialPort|andselecttheportyounotedearlierwhenyoufirstconnectedtotheboard.TheIDEshouldnowindicatethatyouareusingtheGalileoontheproperportinthelower-rightcorneroftheIDE.

Page 58: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 59: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

UpdatingthefirmwareThefirstthingyou’llwanttodoisupdatethefirmwareontheGalileo.Todothis,selectHelp|GalileoFirmwareUpdate,asshowninthefollowingscreenshot:

Havingthelatestfirmwareisalwaysagoodidea;youmightwanttorepeatthisstepeveryweekorsojusttomakesureyouhavethelatest.

Page 60: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

OpeninganduploadingafiletotheGalileoNowthatyourboardisconnectedandyouarerunningthelatestfirmware,youcanopenanduploadasimpleexamplefile.Itiscalledtheblinkapplication.Ithasalreadybeenwrittenforyou,soyouwon’tneedtodoanycoding.

Togettheblinkapplication,performthefollowingsteps:

1. NavigatetoFile|Examples|01.Basics|Blink,asshowninthefollowingscreenshot:

2. YoushouldthenseetheBlinkcodeintheIDEwindow,asinthefollowingscreenshot:

Page 61: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

3. SelecttheUploadbutton,asinthefollowingscreenshot:

Page 62: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

4. Onceyouhaveuploadedthefile,itwilltellyouinthelower-leftcorneroftheIDEdisplaythatthefileisuploaded,asinthefollowingscreenshot:

Page 63: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Whentheprogramisuploaded,itwillautomaticallystartrunningandthegreenLEDthatispositionedclosetotheUSBconnectionontheGalileowillstartblinking.ThefollowingimagesshowstheLED:

Page 64: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

YouhavenowsuccessfullyuploadedyourfirstprogramtoyourGalileo!

Page 65: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 66: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AccessingtheGalileo’sLinuxcapabilitiesThereareseveraldifferencesbetweentheGalileoandthemorecommonArduinoboardthatmanyofyoumightbefamiliarwith.TheGalileohassignificantlymoreprocessingpower.However,italsostartsupintoaLinuxoperatingsystem,andthenexposesitsprogrammingenvironmentinanArduino-likeinterface.Whileyou’llalmostexclusivelyusetheArduinoIDEinterfaceinthisbook,youcanalsoaccesstheLinuxcapabilitiesoftheGalileo.You’lllearnmoreaboutthisinChapter7,GoingFurtherwithGalileo.

Page 67: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 68: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SummaryYou’vecompletedthenextstageofyourjourney.YouhaveyourGalileoup-and-talkingwithyourexternalcomputer,andknowhowtoconnecttotheIDEtocreatecode.YournextstepwillbelearninghowtoaccesstheGPIOpinssothatyoucaninteractwiththeoutsideworld.

Page 69: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 70: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Chapter2.AccessingtheGPIOPinsNowthatyouarefamiliarwiththeGalileoIDEandknowhowtocreate,edit,anduploadaprogram,thischapterwillnowfocusonhardware.You’lllearnaboutthecapabilitiesoftheGeneralPurposeInput/Output(GPIO)pinsandhowyoucanconnecttoandaccessthemviasoftware.Specifically,you’lllearnaboutthefollowing:

TheGPIOpins,whattheycanandcan’tdoHowtouseandaccessthemusingsomeverybasiccircuitsandverysimpleprogrammingexamplesthatdemonstratehowtomaketheGalileoaccesstheoutsideworld

Page 71: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TheGPIOcapabilityoftheGalileoTheGalileowasbuilttomodelhowtheArduinoaccessestheoutsideworld.MuchofthataccessshouldbethroughtheGPIOpins.TheGalileocomeswithastandardsetof14digitaland6analogIOpins,alongwithsomeadditionalpinstoprovidepowerandserialIO.Fortunately,thepinsareactuallywelllabeledontheboarditself.

Hereisaclose-up:

Hereisalistofpinsthatareavailable,andabriefdescriptionofwhateachpincando,startingattheupperrightandgoingclockwise.Amorein-depthdescriptionofthesepinswillcomelaterasyouactuallyusetheminsomeexampleprojects:

GalileoPin Description

AREF

Thispinprovidesareferencevoltagefortheanaloginputs.Thevaluesontheanalogpinswillbereportedinreferencetothisvoltage.You’llalsousethisinsomeapplicationstoprovideareferencevoltageforsensingdevices.Youcanalsoprovideanexternalreferencevaluetothispin,whichmeansthatthenumericalvaluesoftheinputswillbescaledaccordingtothevaluesuppliedonthispin.

GND ThispinprovidesagroundreferencefortheAREFpin.

Digital(PWM~)13/2

These11pinscanbeusedtoeitherreadorwritedigitalvalues.Ifinput,thevaluewillbereadaseithera0or1basedonthevoltagelevelattheinput.Ifoutput,thevaluewillbesettoeithera0or1basedonthelogicvoltagelevel(theactualvoltagewilldependonthevoltagelogiclevelofyourArduino.Someare5Vlogiclevel,othersare3.3Vlogiclevel).

DigitalTX->1

Thispin,andtheRXpinnexttoit,provideaserialinterfacethatcanbeusedtocommunicatewithotherdevices.

DigitalRX->0

Thispin,andtheTXpinnexttoit,provideaserialinterfacethatcanbeusedtocommunicatewithotherdevices.

Page 72: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AnalogINA5/A0

Thesepinsdodoubleduty.Normally,theyareusedasA/DinputstotheGalileotoreadcontinuousvoltagevaluesandturnthemintointegervalues.However,theycanalsobeusedasDigitalI/O,verysimilartotheDigitalI/Opins.

PowerVin

YoucanpowertheGalileofromthispin.Thiscanbeespeciallyusefulafteryouhaveuploadedyourprogram.YoucanthendisconnecttheUSBportand,whenyouapplyvoltagetothispin,yourGalileowillbootandruntheuploadedprogram.FortheGen1board,thisneedstobe5volts.FortheGen2board,youcanuseavoltagevaluefrom7to12Volts,soawidevarietyofDCpoweradapterorbatteryconfigurationscanbeused.

PowerGND ThispinwouldgivethegroundconnectionassociatedwiththePowerVinconnection.

PowerGND ThisisagroundnormallyassociatedwiththePower5VandPower3.3Voutputs.

Power5V Thisisavoltageoutputsetto5Volts.

Power3.3V Thisisavoltageoutputsetto3.3Volts.

RESET Thispinwillresettheprocessor,whichwillcausetheprogramtorunfromthebeginning.

IOREF Thisprovideseithera3.3V,or5Vreference,indicatingthelogicleveloftheboard.

Page 73: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 74: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

UsingtheGPIOpinsNowthatyouareawareofalltheGPIOcapabilities,youcanstartputtingthemtowork.Inordertodothis,itisbesttopurchaseasmallbreadboardandsomejumperwires;thiswillmakeconnectingtotheoutsideworldeasier.Hereisapictureofsuchabreadboard:

Theyareeasytofind,youcanpurchaseoneatalmostanyelectronicsstore,oronanyelectroniconlinesites.You’llneedsomejumperwirestoconnectfromtheGalileotothebreadboard.ThejumperwiresyouwantaretheMale-to-Malesolder-lessjumperwires.Hereisapictureofthissortofwire:

ThesejumpercablesplugeasilyintotheheaderpinsontheGalileoandthebreadboard.

Page 75: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Nowthatyouhavethecablesandthebreadboard,youcanstartaccessingandcontrollinghardware.

Page 76: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 77: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConnectingyourfirstexternalhardwareYourfirstprojectwillusetheDigitalIOpinstolightupanLED.Todothis,you’llneedtogathertwomorehardwarepieces.ThefirstisanLED(LightEmittingDiode).Thisisasmallpartwithtwoleadsthatlightsupwhenvoltageisapplied.Theycomeinawidevarietyofcolors.Ifyouwanttobuythemonline,searchfora3-mmLED.Youcanalsogetthematmostelectronicsshops.TheimageshowsanLED:

You’llalsoneedaresistortolimitthecurrenttotheLED;a220-ohmresisterwouldbetherightsize.Again,youcangetthemonlineoratmostelectronicsshops.Thefollowingimageshowsaresistor:

Page 78: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

IfyougetthreeLEDsandresistors,youcanexercisethreeoftheDigitalIOpins.

Page 79: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

PluggingyourwiresintothebreadboardNowthatyouhaveallthebitsandbobs,let’sbuildyourfirsthardwareproject.Beforeyoupluganythingin,let’slookatthebreadboardforamomentsothatyoucanunderstandhowyouaregoingtouseittomakeconnections.You’llbepluggingyourwiresintotheholesonthebreadboard.Theholesonthebreadboardareconnectedinauniquewaytomaketheconnectionsyoudesire.

Inthemiddleofthebreadboard,theholesareconnectedacrosstheboard.Soifyoupluginawire,andanotherwireintheholerightnexttoit,thesetwowireswillbeconnected,likethis:

Thetworowsoneachsideoftheboardaregenerallydesignedtoprovidepower,sotheyareconnectedupanddown,likethis:

Page 80: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 81: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SettinguptheelectronicsSolet’splacetheelectronicsonthebreadboard.PlacetheLEDsinsuchawaythatonewireisononesideofthemiddlesplitofthebreadboard.ThedirectionoftheLEDisimportant;makesurethatthelongerofthetwowiresisontheleftsideofthehole,likethis:

Page 82: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Nowplacetheresistorsontheholesononeside.Thedirectionoftheresistordoesnotmakeanydifference,butmakesurethesecondwireleadisplacedintherowofholesattheendoftheboard,likethis:

Page 83: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thesewillallbeconnectedtogether,andwillbeconnectedtotheGNDoftheGalileousingoneofthejumpercableslikethis:

Page 84: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Finally,usejumperwirestoconnecttheDigitalIOpins13,12,and11totheholesonthebreadboard,likethis:

Nowthatthehardwareisconfiguredcorrectly,you’llneedtoaddcodetoactivatetheLEDs.

Page 85: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 86: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TheIDEandLEDCodeTocreatethecodeforthisexample,starttheGalileoIDE.RecalltheBlinkexampleyouaccessedinChapter1,GettingStartedwiththeGalileo.TheIDEshouldlooklikethis:

Ifyourememberthiscode,intled=13littheorangeLEDontheboard.ItturnsoutthatLEDoutputpin13isalsotheconnectiontothe13pinontheGalileoconnector.Ifyouuploadandrunthisprogram,theLEDconnectedtopin13shouldflashatthesamerateastheLEDontheGalileo.Hereisapicture:

Page 87: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

You’llneedtoaddasimilarbitofcodetogettheLEDsconnectedtopin12and11.AddthefollowingtothesketchontheIDE:

Page 88: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Here,youarereplicatingthecodebutconnectingtheLEDconnectedtopin13tothevariableled,theLEDconnectedtopin12tothevariableled1,andtheLEDconnectedtopin13tothevariableled3.Youthenprogramthemalltobeoutputpinsandtheninthemainlooptogglebetweenhighandlow.NoticeIhavetwopinstogglingtogether(pins13and11)withtheother(pin12)togglingintheexactoppositesequence.Theoutertwo

Page 89: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

LEDsshouldlightforonesecond,thentheinnerLEDshouldlight.

IfoneormoreoftheLEDsdon’tlight,checktomakesuretheyarepushedfirmlydownintotheboard.YoucanalsochangethedirectionoftheLED;perhapsyouhavetheleadsinthewrongdirectionontheboard.

Page 90: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 91: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

GettingsignalsfromtheoutsideworldYouknowhowtosendsignalstotheoutsideworld.Youmightalsowanttoreceiveinputsignalsfromtheoutsideworld.Thesesignalscanbedividedintotwotypes:digitalsignalsandanalogsignals.

Page 92: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

InterfacingdigitalinputsignalswithGalileoTherearepinsontheGPIOconnectorsoftheGalileothancanbeusedtosensedigitalinput;thatis,aninputthatwillbeinterpretedaseithera0or1byaprogram.ThesearelabelledontheGalileo.Anexampleofhowtousetheseisasimplebuttonpresscircuit.Tocreatethiscircuit,you’llneedoneofthe220-ohmresistorsyouusedintheLEDcircuit.You’llalsoneedasimple,single-pole,single-throwswitch;youcangettheseatmostelectronicsstores.You’llalsoneedsomejumperwirestoconnecttheGalileotoyourcircuit.Hereisthecircuitdiagram:

Nowyou’llneedsomecode.YoucanuseoneoftheexampleprogramsincludedwiththeIDE.SelecttheExamples|02.Digital|Buttoncode,likethis:

Page 93: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Whenyouuploadthisexample,youwillfindthatpressingthebuttonlightstheLEDontheGalileoboard.Whenyoureleasethebutton,theLEDwillnotbelit.Youcannowgetdigitalinputintoyourproject.

Page 94: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

InterfacinganaloginputsignalswithGalileoTherearesomesignalsthataren’teitheron,oroff.Youwillactuallywanttomeasurethelevelofthesignal.Theseareanalogsignals,andtheGalileocanhandlethemaswell.You’llneedtouseoneoftheanaloginputs,however.Thesearealsolabelledontheboard.Asanexample,youcanbuildasimpleelectroniccircuitusingapotentiometertoillustratethiscapability.Apotentiometerisavariableresistor;youcanchangetheresistancebetweentwopointsbyadjustingthepotentiometer,normallybyturninganadjustmenteitherwithyourfingers,orascrewdriver.Tocreatethiscircuit,you’llneedapotentiometer,availableatalmostallelectronicsstores.Hereisthecircuittobuild:

Youhavetoconnectthe5-voltconnectiontoonesideofthepotentiometer,andtheGNDconnectiontotheothersideoftheconnector.Themiddleterminalofthepotentiometerwillchangevoltagevalueasyouadjustthepotentiometer.Tomeasurethisvoltage,you’lluseanotherexampleprogramthatcomeswiththeIDE.SelecttheExamples|03.Analog|AnalogInput,codelikethis:

Page 95: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AdjustingthepotentiometerwillcausetheLEDontheGalileotoflashfasterorblinkmoreslowly.TheGalileoisreadingthevoltagevalueandusingthatvaluetodeterminehowlongtheLEDshouldbeonandoff.YoucannowgetanaloginputintoyourGalileo.

Page 96: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 97: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SummaryThat’sit.You’vecompletedyourveryfirstexampleofinterfacingwiththeoutsideworld.YoucanplaywithdifferentpatternsofLEDsequencesbyusingloopsanddifferentwaitstates.Nowthatyouhavecreatedyourveryfirsthardwareproject,inthenextchapterwe’llcoverhowtoaddhardwarecapabilityusingahardwareshield,apieceofhardwarethatplugsdirectlyintotheIOconnectorsoftheGalileo.

Page 98: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 99: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Chapter3.AddingDisplayFunctionalityInChapter2,AccessingtheGPIOPins,youlearnedhowtoconnecttotheGalileoanditsGPIOpinsusingjumperwires,breadboards,andcomponents.Inthischapter,you’lllearnmoreaboutaddingfunctionalitybyaddinghardwaredesignedtoplugintotheGalileo.Insomeoftheseexamples,you’llusespecialhardwaredesignedtobepluggedintotheGalileo’sGPIOpins;thesearecalledshields.

Page 100: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ThesimpleserialdisplayInordertounderstandhowtouseashield,let’sstartwithoneofthemostbasicdisplaymodulesavailablefortheGalileo,theserialLCDdisplay.Thereareseveraldifferentversionsoutthere,butmostprovideasimple2x16characterdisplaythatcanbedrivenbytheserialTXpinontheArduino.TheyareavailableatmostlocationswheretheGalileoisoffered.Thefollowingimageshowsthedisplay:

You’llneedthreepinstodrivethisdisplay.TheyareaGNDandVCCpin,andtheTXpin.TheVCCandGNDwillcomefromthe5VandGNDpinsontheGalileo.You’llusedigitalI/Opin1ontheGalileoasaTX.ToconnecttheGalileotothedisplay,connectthemaletomalejumpersto5Volts,GND,anddigitalinput.Connectthethreeconnectorstotheproperconnectionsontheboard,likethis:

Page 101: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thisshouldcompletethehardwareconnectionstotheboard.Nowyou’llneedsomecodetowritecharacterstotheboard.

Page 102: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

EnablingtheserialdisplayintheIDENowbringuptheIDE.Beforeyoustartcoding,you’llneedtogetthelibraryassociatedwithyourdisplayandinstallitintheIDE.Forthisparticulardisplay,you’llusetheseriallibraryfoundathttps://github.com/downloads/nkcelectronics/SerialLCD/SerialLCD.zip.

The.zipfileshouldthenexistinyourDownloadsdirectory.Nowyou’llneedtoplacethesefilesinthelibrariesdirectoryofyourDEinstallation.Performthefollowingsteps:

1. ToincludethislibraryinyourIDE,firststartyourIDEandthenselectSketch|ImportLibrary…|AddLibrary…,likethis:

2. NowgotoyourDownloadsdirectoryandselecttheZIPfilethatholdsyourlibrary.Whencomplete,thislibraryshouldbeaddedtoyourlibrarychoices.YoucancheckthisbyagainselectingSketch|ImportLibrary…|AddLibrary…likethis:

Page 103: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

3. Oncethelibraryisinstalled,gobacktothemainIDEscreenandyoucanwritethefollowingcode:

Page 104: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ThiscodewaswrittenusingtheLCDdocumentationathttp://media.nkcelectronics.com/datasheet/LCM1602SK-NSW-BBW.pdf.Itisquitesimple.

Letsexplainthecodelinebyline:

charESC=0xFE;-Thischaracterneedstobesenttothedisplayeachtimeacommandissentvoidsetup()–ThesetupfunctioniscalledbytheGalileoeachtimetheprogramisrunSerial1.begin(9600);:-Setstheserialporttoabaudrateof9600Serial1.write(ESC);:-SendstheprecedingcharacterseteachtimeacommandissentSerial1.write(0x51);:-ThiscommandclearsthedisplaySerial1.write(ESC);:-SendsthepreviouscharacterseteachtimeacommandissentSerial1.write(0x46);:-Setsthecursortothefirstline,thefirstpositionSerial1.print("HelloWorld!");:-PrintsoutHelloWorld!

Page 105: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Serial1.write(ESC);:-SendstheprecedingcharacterseteachtimeacommandissentSerial1.write(0x45);:-SetsthecursortothesecondlineSerial1.write(0x40);:-SetsthecursortothefirstpositionSerial1.print("IntelGalileo");:-PrintsoutIntelGalileo!voidloop():–Thisloopiscalledoverandoverafterthesetup()functioniscomplete

4. NowuploadthesketchandyoushouldseeHelloWorld!IntelGalileoonthedisplay,likethis:

Nowyoucanaddallsortsoftext.Ifyouplaceamessageintheloop,besuretoaddindelay(2000).Thisisafunctionthatpausesforanumberofmilliseconds(inthiscase2000),thusallowingtheusertimetoreadthedisplaybeforeitischanged.

NowyoucandisplayinformationfromtheGalileo.Youmight,however,wantevenmoreflexibilitythanthisdisplaycanprovide,soyou’llnowlearnhowtoaddaTFTdisplay.

Page 106: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 107: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TheTFTshieldUsingaTFTdisplayshieldisanotherwayofaddingdisplaycapabilitytoyourGalileo.ThereisalimitedsetofTFTdisplaysthatwillworkwiththeGalileoandtheperformanceisn’tveryfast,butitdoeswork.First,you’llneedadisplay,forexampletheAdafruit2.8inchTFTV2availablefromadafruit.com.Thefollowingimageshowstheunit:

You’llplacethisshieldontotheGalileo,likethis:

Page 108: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Theunitwilllightupandshowthatitisconnected.Oncethehardwareisconnected,you’llnowneedtoaccessthedisplayviatheIDE.

Page 109: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AccessingthedisplaywiththeIDEToaccessthedisplay,you’llneedtofollowthesesteps:

1. GototheIDElibrariesdirectoryanddeletetheRobot_Controllibrary.Thishassomeduplicatefilesthatwillcauseproblemslaterifyoudon’tgetridofthem.

2. DownloadtheAdafruit_GFXlibraryandinstallitintheIDElibrary.Youcangetthislibraryathttps://learn.adafruit.com/adafruit-gfx-graphics-library.You’llneedtounzipit,changethenamefromAdafruit-GFX-Library-mastertoAdafruit_GFXandmoveitintotheIDElibrariesdirectory.

3. DownloadamodifiedversionoftheAdafruit_ILI9341libraryfromhttps://github.com/wallacezq/Adafruit_ILI9341.Unzipthislibrary.

4. GotothedirectoryAdafruit_ILI9341-master.Inthatdirectory,youwillfindtheArduinodirectoryandinsidethatdirectorythefileArduino.h.YoumustcopythatfileintotheIDEatthelocation\arduino-1.5.3-Intel.1.0.4\hardware\arduino\x86\cores\arduino.MakesureyoureplacetheexistingArduino.hfile.

5. IntheAdafruit_ILI9341-masterdirectory,thereisanotherdirectorynamedAdafruit_ILI9341-Library.RenameittoAdafruit_ILI9341andmoveitintotheIDElibrariesdirectory.

NowyouarereadytoopentheIDEandanexampleprogramthatwillaccessthedisplay.OpentheExamples|Adafruit_ILI9341|graphicstestexample,likethis:

Page 110: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

NowuploadthefileusingtheIDEandyoushouldseethefollowingresult:

Page 111: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Youcannowdisplaygraphicsonthedisplay!Theonlyexamplefromthisdirectorythatwillworkisthegraphicstestexample.Theothersrequireaccesstothetouchscreencapabilitythatisnotyetavailableviathelibrary.

Page 112: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 113: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SummaryThat’sit.You’velearnedhowtoadddisplaycapabilitytoyourGalileoprojectsusingshields.You’llusethesesameconceptsinlaterchapterstoaddothertypesoffunctionalities.Infactinthenextchapter,you’llusetheshieldconcepttocontrolDCmotors.

Page 114: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 115: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Chapter4.ControllingDCMotorsInChapter3,AddingDisplayFunctionality,youlearnedhowtoconnecttotheoutsideworldusingjumperwiresandspeciallydesignedhardwarecalledshields.Inthischapter,you’lllearnthefollowing:

HowtousetheGalileotocontrolsmallDCmotorsHowtotakethistothenextlevel,learninghowtoaddmorefunctionalityusingashieldtocontrolthespeedanddirectionofmorepowerfulDCmotors

Page 116: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

DCmotorbasicsBeforewegetstartedwithconnectingeverythingandmakingitallmove,let’sspendsometimeunderstandingsomeofthebasicsofDCmotorcontrol.Whetheryouchooseatwoorfourwheeledmobileplatform,oratrackedplatform,thebasicmovementcontrolisthesame.Theunitmovesbyengagingthemotors.Ifthedesireddirectionisstraight,themotorsarerunatthesamespeed.Ifyouwanttoturntheunit,themotorsarerunatdifferentspeeds.Theunitcanactuallyturninacircleifyourunonemotorforwardandonebackwards.

DCmotorsarefairlystraightforwarddevices.Thespeedanddirectionofthemotoriscontrolledbythemagnitudeandpolarityofthevoltageappliedtoitsterminals.Thehigherthevoltage,thefasterthemotorwillturn.Ifyoureversethepolarityofthevoltage,youcanreversethedirectionthemotoristurningin.

However,themagnitudeandpolarityofthevoltagearenottheonlyfactorthatisimportantwhenitcomestocontrollingyourmotors.Thepowerthatyourmotorcanapplytomovingyourplatformisalsodeterminedbythevoltageandthecurrentsuppliedatitsterminals.

Now,thereareactuallyGPIOpinsontheGalileothatyoucouldusetocreatethecontrolvoltageanddriveyourmotorsdirectly.ThechallengewiththismethodisthattheGalileocannotnormallysourceenoughcurrentandvoltageandthusyourmotorswouldnotbeabletogenerateenoughpowertomoveamobileplatform.

Thereareseveralsolutionstothisproblem.Thefirstistouseasimpletransistorcircuitandanexternalvoltagesource.You’llusethissolutioninthefirstexampleofthischapter.AnothersolutionistouseanH-bridge,achipthattheGalileocancontrolbutthatisconnectedtoapowersourceandcanprovideenoughcurrent.Thesecondexampleinthischapterwillshowyouhowtousethissortofchip.Thethirdsolutiontotheproblemistouseashieldthatcontainsallthecircuitryandcanconnecttoanexternalpowersourceinput.ThenyourGalileocanprovidebothvoltageandcurrentsothatyourplatformcanmovereliably.ThelastexampleinthischapterwilluseamotorcontrollershielddesignedfortheArduinotomakeDCmotorcontrolsimple.

Page 117: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 118: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConnectingaDCmotordirectlytotheGalileoThefirststepinconnectingaDCmotortotheGalileoistoactuallyobtainaDCmotor.Themotorsthatyouwillbedealingwithherearesimple,smallDCmotors.Forthisexample,youcanuseasmall6VDCmotoravailableatmostelectronicsorhobbystores,oronlineatwww.amazon.com.Hereisapictureofonesuchmotor:

InordertoconnectthismotortoyourGalileo,you’llneedsomeadditionalparts.You’llneedtwomale-to-malejumpercablesandtwoalligatorclipjumpercables.You’llalsoneedatransistor,TIP120tobespecific.You’llalsoneedadiode,the1N4004diode,a1,000-ohmresistor,anda1µFaradceramiccapacitor.Thelastfourpartsshouldbeavailableatalmostanyelectronicsstore,oronline.Tocontrolthismotor,you’llconnectonemotorconnectortodigitalpin11,andtheotherconnectortoGND.YoucoulduseoneofthevoltagesourcesontheGalileo,butsomeDCmotorscandrawlotsofcurrent,morethanyourGalileocansupply.AsaferwayistoconnecttheDCmotorsupplytoabatteryholderwith4AAbatteries.

ConnecttheGalileo,transistor,diode,resistor,andpowersupplylikethis:

Page 119: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

NowyoucanstarttheIDEsothatyoucanenteraprogramtosendacontrolsignaltotheDCmotor.

Page 120: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 121: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

GalileocodeforDCmotorspeedcontrolOpentheIDEandthenenterthefollowingcode:

ThiscodesendsbasiccommandstotheGalileotocontrolthespeedofthemotor.Herearethedetails:

intmotorPin=11;:-ThissetsdigitalI/Opin11tothecontrolpinyou’llbeusing.voidsetup():–ThesetupfunctionexecutesonceyousetupyourGalileo.pinMode(motorPin,OUTPUT);:-Thissetsthispintofunctionasanoutputpin.Serial.begin(9600);:-Thisstartstheserialportwithabaudrateof9600.Serial.println("SetSpeed0-255");:-Thisprintstheline“SetSpeed0–255”.voidloop():–ThisloopisperformedoverandoveragainontheGalileo.

Page 122: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

if(Serial.available()):–Ifthereisaserialinputdateontheserialport,thendothefollowingstatements.intspeed=Serial.parseInt();:-Thisbringsinthedataasaninteger.Serial.println("Speed");:-Thisprintstheline“Speed”.Serial.print(speed);:-Thisprintsthevalueinputfromtheserialport.Serial.println("");:-Thisfinishesthelineandgoestothenextline.if(speed>=0&&speed<=255):–Ifthespeedisintheproperrange,thenthissendsiton.analogWrite(motorPin,speed);:-Thiswritesthisvaluetothepin11.ThiswillsetthePWMsignaltothepropervaluetocontrolthespeedofthemotor.

NowuploadthecodetoyourGalileo.Yourmotorshouldstartrunning.Onceyouhaveuploadedthecode,you’llwanttoopenuptheSerialMonitorsoyoucancommandyourmotortorunatdifferentspeeds.Toopenthis,you’llselectTools|SerialMonitor.Whenyouopenthis,youshouldseethefollowingwindowpopup,displayingthetextfromyourprogram:

Enteravalue,say255,andthenclickonSend.Yourmotorshouldspeedup.Enteranothernumber,say0,clickonSend,andyourmotorshouldstop.NumbersbetweenthesetwovaluesshouldadjustthespeedofyourDCmotor.Unfortunately,themotorcanonlygoinonedirection.Thenextexamplewillprovideasolutionifyou’dlikebidirectionalcontrolofyourDCmotor.

Page 123: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 124: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConnectingaDCmotorusinganH-bridgeandtheGalileoThenextstepistoaddabitmorefunctionalitywithanewtypeofchip,anH-bridge.AnH-bridgeisafairlysimpledevice;itbasicallyconsistsofasetofswitchesandfunctionalitiestoallowthedirectionofthecurrenttobereversedsothatthemotorcaneitherberunintheforward,orinthereverse,direction.

Let’sstartthisexamplebybuildingtheH-bridgecircuitandcontrollingjustonemotor.Todothis,you’llneedtogetanH-bridge.OneofthemostcommononesistheL293dualH-bridgechip.ThischipwillallowyoutocontrolthedirectionoftheDCmotors.Thesechipsareavailableatmostelectronicsstoresoronline.You’llalsoneedacapacitor;youcanusethe1µFaradfromthepreviousexample,ifyoulike.OnceyouhaveyourH-bridge,buildthefollowingcircuitwiththeGalileo,themotor,andbreadboard:

Specifically,you’llwanttoconnectthesepinsontheGalileotothepinsontheH-bridge.Hereistheconnectionlist:

GalileoPin H-BridgePin

9 1

4 2

Page 125: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

3 7

Onceyouhavetheconnections,youcantestthesystem.Todothat,you’llneedtoaddsomecode.

Page 126: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 127: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

GalileocodeforDCmotordirectioncontrolOpentheIDEandtypeinthefollowingcode:

Page 128: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thiscodesetsuppins3,4,and9toenablethechipandcontrolthedirectionofthemotor.Asmentionedbefore,youcanusetheTools|SerialPorttosenddatatotheprogram.Sendinga0setspin3toHIGHandpin4toLOW,causingthemotortospininonedirection.Sendinga1setspin3toLOWandpin4toHIGH,causingthemotortospinintheotherdirection.

NowyouknowhowtobuildcircuitstocontrolboththespeedandthedirectionofDCmotors.However,insteadofprocuringallthepartsandbuildingthecircuitsyourself,youcanactuallybuyaDCmotorcontrolshield.

Page 129: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 130: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ControllingDCmotorsusingashieldForthisfinalexample,let’sgraduatefromasimpleDCmotortoawheeledplatform.Thereareseveralsimple,two-wheeledroboticsplatforms.Inthisexample,you’lluseonethatisavailableonseveralonlineelectronicsstores.ItiscalledtheMagicianChassis,sourcedbySparkFun.Thefollowingimageshowsthis:

Tomakethiswheeledroboticplatformwork,you’regoingtocontrolthetwoDCmotorsconnecteddirectlytothetwowheels.You’llwanttocontrolboththedirectionandthespeedofthetwowheelstocontrolthedirectionoftherobot.

You’lldothiswithanArduinoshielddesignedforthispurpose.TheGalileoisdesignedtoaccommodatemanyoftheseshields.Thefollowingimageshowstheshield:

Page 131: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Specifically,you’llbeinterestedintheconnectionsonthefrontcorneroftheshield,whichiswhereyouwillconnectthetwoDCmotors.Hereisaclose-upofthatpartoftheboard:

Itisthesethreeconnectionsthatyouwilluseinthisexample.First,however,placetheboardontopoftheGalileo,muchasyoudidwiththedisplayshieldfromthelastchapter’sexample.Thenmountthetwoboardstothetopofyourtwo-wheeledroboticplatform,likethis:

Page 132: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Inthiscase,Iusedalargecabletietomounttheboardstotheplatform,usingthefoamthatcamewiththemotorshieldbetweentheGalileoandplasticplatform.Thisparticularplatformcomeswitha4AAbatteryholder,soyou’llneedtoconnectthispowersource,orwhateverpowersourceyouaregoingtouse,tothemotorshield.Thepositiveandnegativeterminalsareinsertedintothemotorshieldbylooseningthescrews,insertingthewires,andthentighteningthescrews,likethis:

Page 133: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thefinalstepistoconnectthemotorwirestothemotorcontrollershield.Therearetwosetsofconnections,oneforeachmotorlikethis:

Page 134: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Insertsomebatteries,andthenconnecttheGalileotothecomputerviatheUSBcable,andyouarenowreadytostartprogramminginordertocontrolthemotors.

Page 135: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 136: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

GalileocodefortheDCmotorshieldNowthattheHWisinplace,bringuptheIDE,makesurethattheproperportanddeviceareselected,andenterthefollowingcode:

Page 137: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 138: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thecodeisstraightforward.Itconsistsofthefollowingthreeblocks:

1. ThedeclarationofthesixvariablesthatconnecttotheproperGalileopins:

intpwmA=3;

intpwmB=11;

intbrakeA=9;

intbrakeB=8;

intdirectionA=12;

intdirectionB=13;

2. Thesetup()function,whichsetsthedirectionA,directionB,brakeA,andbrakeBdigitaloutputpins:

pinMode(directionA,OUTPUT);

pinMode(brakeA,OUTPUT);

pinMode(directionB,OUTPUT);

pinMode(brakeB,OUTPUT);

3. Theloop()function.Thisisanexampleofhowtomakethewheeledrobotgoforward,thenturntotheright.Ateachofthesesteps,youusethebraketostoptherobot:

//MoveForward

digitalWrite(directionA,HIGH);

digitalWrite(brakeA,LOW);

analogWrite(pwmA,255);

digitalWrite(directionB,HIGH);

digitalWrite(brakeB,LOW);

analogWrite(pwmB,255);

delay(2000);

digitalWrite(brakeA,HIGH);

digitalWrite(brakeB,HIGH);

delay(1000);

//TurnRight

digitalWrite(directionA,LOW);//Establishesbackwarddirectionof

ChannelA

digitalWrite(brakeA,LOW);//DisengagetheBrakeforChannelA

analogWrite(pwmA,128);//SpinsthemotoronChannelAathalfspeed

digitalWrite(directionB,HIGH);//Establishesforwarddirectionof

ChannelB

digitalWrite(brakeB,LOW);//DisengagetheBrakeforChannelB

analogWrite(pwmB,128);//SpinsthemotoronChannelBatfullspeed

delay(2000);

digitalWrite(brakeA,HIGH);

digitalWrite(brakeB,HIGH);

delay(1000);

Onceyouhaveuploadedthecode,theprogramshouldruninaloop.Ifyouwanttorunyourrobotwithoutconnectingtothecomputer,you’llneedtoaddabatterytopowertheGalileo.TheGalileowillneedatleast2Amps,butyoumightwanttoconsiderproviding3Ampsormorebasedonyourproject.Tosupplythisfromabattery,youcanuseoneofseveraldifferentchoices.Mypersonalfavoriteistouseanemergencycellphonechargingbattery,likethis:

Page 139: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Ifyouaregoingtousethis,you’llneedaUSB-to-2.1mmDCplugcable,availableatmostonlinestores.Onceyouhaveuploadedthecode,youcandisconnectthecomputer,thenpresstheresetbutton.Yourrobotcanmoveallbyitself!

Page 140: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 141: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SummaryBynow,youshouldbefeelingabitmorecomfortablewithconfiguringHWandwritingcodefortheGalileo.Thisexampleisfun,andprovidesyouwithamovingplatform.Inthenextchapter,you’llchangethisplatformfromonebasedonDCmotorstoonebasedonservos,andyou’llbuildarobotthatcanwalk.

Page 142: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 143: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Chapter5.AddingSensorsInChapter4,ControllingDCMotors,youlearnedhowtousetheGalileotocontrolDCmotors.Inthischapter,you’lllearnhowtoaddsensorstoyourprojects.Sensorsareimportantbecauseyoucanusethemtofind,oravoid,objects.Youcanusethemtosenseyourdirectionandspeed,andalsotemperature.Youcanalsousethemtosenseacousticandelectromagneticwaves,pressure,andmanyotherphysicalphenomena.OneofthechallengesofusingtheGalileoisthatitusestheLinuxoperatingsystematitscore,sotherearechallengesifasensorneedstodoreal—timeprocessingofsignalswithtighttiming.Linuxisnotareal-timeoperatingsystem,andmightbedoingotherthingswhenyouneedtomakesomethingspecifichappen.Thiswilllimitsomeofthesensorsyoucanuseonyourproject.ForacompletelistofsensorsandotherhardwarethatarecurrentlysupportedbytheGalileo,seehttps://communities.intel.com/docs/DOC-23423.ThegoalofthischapteristowalkyouthroughafewoftheexamplesfromthislisttoshowyouhowtoconnectsensorstotheGalileo.

Page 144: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SensingdistanceTherearetwobasicsensorsthatwillreturninformationonthedistancetoanobject:sonarandinfrared.Inthecaseofsonar,thesensorusesultrasonicsoundtocalculatethedistancetoanobject.Thesensorconsistsofatransmitterandreceiver,thetransmittercreatesasoundwavethattravelsoutfromthesensor,asillustratedhere:

Thedeviceistriggeredbyanelectronicsignaltosendoutasoundwave.Ifanobjectisinthepathofthesewaves,thenthewavesreflectofftheobject,sendingwavesthatreturntothesensor,asshownhere:

Page 145: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thebasicsensorthenmeasuresthereceivedsoundwaveandsendsoutanelectronicsignal.Theusercanthencalculatethetimedifferencebetweenwhenthesoundwavewassentoutandwhenitreturnstomeasurethedistancetotheobject.Unfortunately,thereturntimemustbemeasuredwithprecisionforthistypeofsensortowork.ThisischallengingforaprocessorsuchastheGalileo,thatrunsLinuxasthebaseoperatingsystem.Therearewaystomakethiswork,butitisnotsimple.Pleaseseetheshieldcompatibilityguideathttps://communities.intel.com/docs/DOC-23423fordetails.

Page 146: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 147: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TheInfraredsensorNow,alittletutorialonIRsensors.Thesensoryouareusinghasbothatransmitterandasensor.Thetransmittertransmitsanarrowbeamoflight,andthesensorreceivesthisbeamoflight.Thedifferenceintransitendsupasananglemeasurementatthesensor,asshownhere:

Thedifferentanglesgiveyouanindicationofthedistancetotheobject.Unfortunately,therelationshipbetweentheoutputofthesensorandthedistanceisnotlinear,soyou’llneedtodosomecalibrationtopredicttheactualdistanceanditsrelationshiptotheoutputofthesensor.

Thevoltagetodistancechartforthedevicelookslikethis:

Page 148: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thiskindofchartwillcomefromthesensor’sdatesheet.Therearereallytwopartstothecurve;thefirstisthedistanceuptoabout15centimeters,thenthedistancefrom15centimetersoutto150centimeters.Youcansimplifythecodeifyouignoredistancescloserthan15centimeters,andmodelthedistancefrom15centimetersandoutasadecayingexponentialwiththeformConstant*InputValue-exponentialvalue.Thiswillbethecalculationthatyouwilluselaterintheprogram.

Page 149: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 150: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConnectinganIRsensortotheGalileoThefirststepinconnectinganIRsensortoyourGalileoistoobtainasensor.OnepopularchoiceistheSharpseriesofIRsensors.Thefollowingimageshowsoneofthemodels,theSharp2Y0A02,aunitthatprovidessensingtoadistanceof150cm:

Toconnectthisunit,you’llconnectthethreepinsthatareavailableonthebottomofthesensor.Hereistheconnectionlist:

GalileoPin SensorPin

5V Vcc

GND Gnd

A3 Vo

Unfortunately,therearenolabelsontheunit,butherearethepinsyou’llconnect:

Page 151: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Oneofthechallengesofmakingthisconnectionisthatthefemale-to-maleconnectionjumpersaretoobigtoconnectdirectlytothesensor.You’llwanttoorderathree-wirecablewithconnectorswiththesensor.Manyversionscomewiththiscable.YoucanmaketheconnectionsbetweenthiscableandtheGalileousingthemale-to-malejumperwires.Hereisthediagram:

Page 152: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Oncethepinsareconnected,youarereadytoaccessthesensorviatheIDE.

Page 153: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AccessingtheIRsensorfromtheGalileoIDENowbringuptheIDE.Thefollowingthatprovidesaccesstothesensorandreturnsviatheseriallinkthedistancetotheobject:

Thisisquitesimple.Thethreeglobalvariablesatthetopsettheinputpinto3,andprovideastoragelocationfortheinputvalueanddistance.Thesetup()functionsimplysetstheserialportbaudrateto9600andprintsoutsinglelinetotheserialport.TheSerialMonitorcommunicateswiththeGalileoviaaserialport,andthebaudratespecifiesthecommunicationratebetweentheGalileoandthehostcomputer.

Intheloop()function,youfirstgetthevaluefromtheA3inputpin.Thenextstepistoconvertittoadistancebasedonthevoltage.

IfyouopentheSerialMonitorwindowandplaceanobjectinfrontofthesensor,you’llseethereadingsforthedistancetotheobject,likethis:

Page 154: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Bytheway,whenyouplacetheobjectcloserthan15cm,youshouldbegintoseedistancesthatseemmuchlargerthanindicated.Thisisduetothevoltage-to-distancecurveatthesemuchshorterdistances.Ifyoutrulyneedveryshortdistances,you’llwantadifferentsensor.

Page 155: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 156: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConnectingadigitalcompasstotheGalileoOneoftheimportantpiecesofinformationthatmightbeusefulforyourprojectisitsdirectionoftravel.ThiscouldbegivenbyaGPSunit,butaGPSunitcanbeexpensive,anditoftendoesn’tworkwellinsidebuildings.Youcanalsojust“keeptrack”ofthedirectionassociatedwithyourhardware,butyou’llneedtocarefullyupdatethiswheneveryourprojectmightmove.Usingacompassfreesyoufromalwayshavingtokeeptrack,andwillalsoallowyoutoavoidinaccuraciesthatcanaccumulatefrominaccuraciesinyourcontrolsystem.So,let’slearnhowtohookupadigitalcompasstotheGalileo.

Thereareseveralchipsthatprovidedigitalcompasscapability;oneofthemostcommonistheHMC5883L3-AxisDigitalCompasschip.Thischipispackagedontoamodulebyseveralcompanies,butalmostallofthemresultinasimilarinterface.HereisanimageofonebyacompanycalledSainSmart,thatisavailableatanumberofonlineretailers,suchaswww.amazon.com:

Theconnectionstothischiparestraightforward,thedevicecommunicateswiththeGalileousingtheI2Cbus,astandardserialcommunicationsbus.Onthebackofthemodule,theconnectionsarelabelled,likethis:

Page 157: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Herearetheconnectionsthatyou’llneedtomakebetweentheGalileoandthedevice:

GalileoPin SensorPin

5V 5V

GND GND

A5 SCL

A4 SDA

Youwon’tconnecttothe3.3voltpin,asyouareusingthe5volttoconnecttothedevice.TheDRDYpinisanoptionalconnectionthatisusedwhenyouwanttocommunicateathigherdatarates.NowyouarereadytotalkwiththedeviceusingtheIDE.

Page 158: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AccessingthecompassfromtheIDEThefirststepinaccessingthecompasscapabilityfortheIDEistoinstallalibrary.Findingalibrarytosupportthemoduleisabitdifficult,buttheonethatworkswellforthisdeviceisavailableatwww.emartee.com/product/42254/HMC5883L%203%20Axis%20Digital%20Compass%20Module

Followthesestepstoinstallthelibraryandruntheexample:

1. SelecttheArduinoLibraryforHMC5883Llinkonthispageanditwilltakeyoutoasetoflibraryselections.

2. YouneedtoselecttheHMC5883L/HMC5883LLibraryforArduino.rarlinktowardsthebottomofthispage,andthiswilldownloada.rarfilethatholdsthelibrary.

3. UnzipthisfileintothelibrariesdirectoryofyourGalileoIDEinstallation.4. Now,bringuptheIDE.IftheIDEwasalreadyopen,you’llwanttocloseitandopen

itagainsoitcanrecognizethenewlibrary.SelectFile|ExamplesandyoushouldbeabletoselecttheHMC5883Llibraryexample,likethis:

Onceyouhaveselectedthisexample,uploadittoyourGalileoandopentheSerialMonitor.Youmighthavetoresizethedisplaytogetagoodlookattheresults,butyoushouldseesomethinglikethis:

Page 159: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Nowyoucanadddirectiontoyourproject!Asyoumovethedevicearound,youshouldseetheHeadingvaluechange.Thisisveryusefulforhelpingyougivedirectiontoyourprojects.Thefirstthreenumbersaretherawmagneticsensorreadings,andthemiddlethreeareanglereadingsfromthemagnetsensors.Thelasttwoaretheheadingsinradiansanddegrees.Themagneticsensorissensingthemagneticfieldoftheearth.Asyoumovethedevicearound,youshouldseethesereadingschange.Thisdatacanbethenusedtosensewhatdirectionyourprojectisfacing.Thedevicehaslotsofcapability,includingtheabilitytocalibratethedevicesothataparticularpositionisinthe0position.Formoreinformationaboutthesecapabilities,feelfreetolookatbothexampleprogramsprovidedbythelibrary.However,youmightwanttoaddevenmoreinformationtoyourproject,suchasthespeedandtilt.Fortunately,therearesensorsforthisaswell.

Page 160: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 161: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConnectinganaccelerometerorgyrototheGalileoTheabilitytomeasurespeedandtiltisimportantinmanyroboticsapplications.Thiscantellyouhowfastyourrobotistraveling,andinwhatdirection.Fortunately,therearechipsthatcandothisforyou.OneofthoseistheMPU-6050,whichprovidesacompletesetofinformationonmovement,includingaccelerationandtilt.Formoreinformationonthistypeofdevice,seehttps://www.sparkfun.com/pages/accel_gyro_guide.ThereareseveraldifferentmanufacturerswhoplacethischiponasmallboardaccessibletotheGalileo.OneoftheseistheSparkFunversion,theSparkfunSEN-11028,availableatwww.sparkfun.com.Itispicturedhere:

Page 162: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Theinterfacetotheboardisquitesimple,withonlyoneissue.ThisparticularchipwillrequireyoutosolderheaderpinstotheboardtoconnectthejumperwirestotheGalileo.Youcanpurchasetheseatwww.sparkfun.comaswell,justsearchfortheArduinostackableheader,the10-pinversion.Or,ifyoudon’tliketosolder,youcantryasolderlessversion,athttps://www.sparkfun.com/products/10527.Oncetheheaderisconnectedtotheboard,thedevicewilllooklikethis:

Page 163: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Nowyoucanusemale-to-malejumpercabletoconnecttheGalileoandtheboard.Hereisthetablefortheconnections:

GalileoPin SensorPin

3.3V VDD

GND GND

A5 SCL

A4 SDA

3.3V VIO

You’llnoticethatyouneedtomaketwoconnectionstothe3.3Vsupply,soyoumightwanttocreateamale-to-malejumpercablewithtwoconnectionsononeend.Thiscanbedonebyusingtwomale-to-malecables,bycuttingoffoneendandstrippingbacktheinsulation,solderingthethreecablestogether,andthenwrappingthesolderconnectioninelectricaltape.

Page 164: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

AccessingtheaccelerometerfromtheIDENowthatthetwodevicesareconnected,you’llneedtobringuptheIDEandaddalibrarysothatyoucanaccessthefunctionalityfromtheSW.Togetthelibraries,dothefollowingsteps:

NoteFromtheSparkfunpageonthedeviceatwww.sparkfun.com/products/11028you’llfindagithubrepositorythatsupportsnotonlythisdevice,butanumberofdevicesthatusetheI2Cinterface.

1. Gotohttps://github.com/jrowberg/i2cdevlibandlookontherightsideofthepageforthedownloadlink.Thiswilldownloadtheentirelibrary.

2. Nowyoushouldunzipthefiletoahandylocation,Iunzippedmineinthedownloaddirectory.WhatyouwantisjustthefilesassociatedwiththeArduino,sogotothedirectorythatsupportsthosefiles,likethis:

Page 165: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

3. Eventhoughyouwon’tneedalltheselibrariesrightnow,youcanjustcopyallthesetothelibrariesdirectoryofyourGalileoforfutureuse.Bytheway,you’llnoticethatthereisaduplicateoftheHMC5883Llibraryyouinstalledearlier,soyoucandecidetomergethesedirectories.

4. Onceyouhavethesedirectoriesinstalled,bringuptheGalileoIDE.IftheIDEisalreadyrunning,you’llwanttorestartitsoitcanrecognizethelibrary.NowbringuptheexampleprogramthatreadstherawvaluesoftheaccelerometerandgyrobyselectingExamples|MPU6050|Examples|MPU6050_raw,likethis:

Page 166: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thiswillopenawindowthatprovidesthecodetoreadtherawdatafromyoursensor.WhenyouuploadthecodeandopentheSerialMonitor,youshouldseesomethinglikethis:

Page 167: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thefirstthreenumbersarethex,y,andzrawaccelerometerreadings,andthelastthreearex,y,andzanglereadingsfromthegyroscope.Ifyoumountthedeviceflatinyourproject,x,y,andzwouldbeassociatedwiththeyaw,pitch,androllofthedevice.Hereisadiagramofhowtheyaw,pitch,androllindicatethepositionofadevice:

Page 168: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Asyoumovethedevicearound,youshouldseethesereadingschange.Thisdatacanthenbeusedtosensewhenyourdeviceismoving,andinwhatdirection.Thedevicehaslotsofcapability,includingtheabilitytosettheoffsetsofthedevicesothataparticularpositionisinthe0position.Formoreinformationaboutthesecapabilities,feelfreetolookatbothexampleprogramsprovidedbythelibrary.

Page 169: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 170: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Connectinganaltimeter/pressuresensortotheGalileoThefinalsensoryou’lllearnaboutinthischapteristhealtimeter/pressuresensor.Thealtimeterisusefulwhenyouwanttoknowthealtitudeofyourproject.Thisisparticularlyusefulwhenyouwanttobuildarobotthatcanfly.Formoreonpressuresensorsandhowtheywork,seehttp://www.sensorsmag.com/sensors/pressure/fundamentals-pressure-sensor-technology-846.First,you’llneedtoselectadevice.OnedevicethatcanprovidethisinformationistheSainSmartBMP085Module,DigitalBarometricPressureSensor,availableatmanyonlineretailers,includingwww.amazon.com.Thisdeviceusespiezo-resistivetechnologytomeasurealtitude.Thefollowingimageshowsthis:

Itlooksverysimilartothedigitalcompass;justlikethetwopreviousdevices,itconnectsviatheI2Cinterface.Youcanevenusethesamelibrariesyoujustdownloadedfortheaccelerometer/gyroforI2Csupport.

TheconnectionsbetweentheGalileoandthedevicewillbethesameasthedigitalcompass,likethis:

GalileoPin SensorPin

5V 5V

GND GND

A5 SCL

A4 SDA

Page 171: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Theconnections,justlikethoseofthedigitalcompass,areclearlymarkedonthebackofthedevice,andyoucanusethefemale-to-malejumperstomaketheconnections.

Page 172: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Accessingthealtimeter/pressureSensorfromtheGalileoIDEAswiththeprevioustwoexamples,thefirststepinaccessingthedeviceistodownloadtheappropriatelibrary.Youcanusethelibrarydescribedinthesectionontheaccelerometer/gyro,oryoucandownloadalibraryjustforthisdevice.Ifyouwanttodownloadthelibraryforthisdevice,gotowww.sainsmart.com/sainsmart-bmp085-digital-pressure-sensor-module-board.htmlpageandselecttheDownloadLinkselectiontowardsthebottomoftheDescription.Thiswilldownloada.rarfilethatwillincludeanexamplesketch.IpersonallyprefertousetheI2Clibraryversion,itismoreup-to-date,soIwillfollowthatexamplehere.

OpentheexamplebyselectingFile|Examples|BMP085|Examples|BMP085_basic,likethis:

NowyoucanuploadthesketchontheGalileoand,whenyouopentheSerialMonitor,youshouldseesomethingthatlookslikethis:

Page 173: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Youcanseenotonlythealtitude,butthetemperatureandpressureaswell.TheTisthetemperatureinCelsius,thePisthepressureinPascals,andtheAisthealtitudeinmeters.

Page 174: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 175: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SummaryTherearemanymoresensorswecouldhavecoveredinthischapter,buthopefullyyouhaveafeelforhowyoumightbeabletoaddthemafterfollowingtheinstructionsforthesesensors.Yourprojectnowhaslotsofpossiblecapabilities,butyouarestilltetheredtothecomputer.Inthenextchapter,you’lllearnhowtocommunicatewithyourprojectwirelesslysoitwon’tneedacabletoacceptcommands.

Page 176: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 177: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Chapter6.RemoteControlNowyoumightwantyourprojecttobemobile.You’llatleastwanttodisconnectitfromthetethercablethatyouhavebeenusingtocommunicatewithittosendcontrolcommands.Inthischapter,you’lllearnhowtocommunicatewirelesslywithyourproject.Dependingonyourchoiceofdevice,you’llbeabletocommunicateacrosstheroomoracrossadistanceofuptoamile.

Inthischapter,you’lllearnthefollowing:

HowtocommunicatewiththeGalileousinganXBeetransmitter/receiver,apoint-to-pointcommunicationsystemthatallowsyoutocommunicatebetweentwoGalileosorbetweenaGalileoandahostcomputerHowtoconfiguretheGalileousingaWi-FiminiPCIExpresscardsoyoucancommunicateviaWirelessLAN

Page 178: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConnectinganXBeeinterfacetotheGalileoOneofthemostpopularandwell-documentedwaysofconnectingtotheGalileoviaanRFconnectionistouseanXBeedevice.ThisdeviceusesatechnologycalledZigBeeanditismadeforlonger-rangewirelesscommunications.Thesetypesofdevicescanworkuptoarangeofonemile.TheZigBeestandardisbuiltupontheIEEE802.15.4standard,astandardthatwascreatedtoallowasetofdevicestocommunicatewitheachothertoenablelowdataratecoordinationofmultipledevices.

TheotherstandardthatyoumighthearaboutasyoutrytopurchaseorusedevicessuchastheseisXBee.Thisisaspecificcompany’simplementation,Digi,ofseveraldifferentwirelessstandardswithstandardhardwaremodulesthatcanconnectinmanydifferentwaystodifferentembeddedsystems.TheymakesomethatsupportZigBee.HereisanimageofthistypeofdevicethatsupportsZigBeeattachedtoasmall,XBee-specificshieldthatprovidesaUSBport:

TheadvantageofusingthisdeviceisthatitisconfiguredtomakeitveryeasytocreateandmanageasimplelinkbetweentwoXBeeseries#1devices.Tomakethiswork,you’llneedfouritems:

1. MakesureyouhavetwoXBeedevicesthatsupportZigBeeseries#1.2. You’llalsoneedtopurchaseasmall,XBee-specificshieldthatprovidesaUSBport

connectiontooneofthetwodevices.Thiswillprovidecommunicationfromahostcomputer.

3. You’llalsoneedtobuyashieldthatplugsintoyourArduinosoyoucaninterfacetotheXBeedevices.ThisshieldistheWirelessSDcardshield,andhasheaderpinsreadyfortheXBeedevice.HereisanimageoftheshieldpluggedintoaGalileo,

Page 179: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

withtheXBeedevicepluggedin:

Nowlet’sgetstartedwithconfiguringyourtwodevicestotalk.

Page 180: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConfiguringtheXBeedevicesYou’llneedtoconfigurebothdevicesbypluggingthemintoyourhostcomputer.Plugoneofthedevicesintothesmall,XBee-specificUSBshieldandthenconnecttheshieldtoyourpersonalcomputer.Yourcomputershouldfindthelatestdriversforthedevice.Ifyourcomputerdoesnotfindthedeviceorisunabletocorrectlyinstallthedrivers,seehttp://ftp1.digi.com/support/images/Win7DriverInstall.pdfforhelp.Youshouldseeyourdeviceafteryou’veselectedDevicesandPrintersfromtheStartmenu,likethis:

ThedeviceisnowavailabletocommunicateviatheIEEE802.15.4wirelessinterface.YoucouldsetupafullZigBee-compliantnetwork,butyou’rejustgoingtocommunicatefromonedevicetoanotherdirectly,soyou’lljustusethedeviceasaserialportconnection.Double-clickonthedevice,selecttheHardwaretab,andyoushouldseethis:

Page 181: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

NotethatthedeviceisconnectedtotheCOM20serialport.You’llusethistocommunicatewiththedeviceandconfigurethedevice.Youcanuseanyterminalemulatorprogram;IliketousePuTTY.Ifyoudon’thavePuTTY,youcandownloaditfromwww.chiark.greenend.org.uk/~sgtatham/putty/download.html.Thiswillprovideanexecutablethatyoucanruntotalkwithandconfigurethedevices.

NoteDigihasrecentlyintroducedanewgraphicaltoolforconfiguringXBeedevices.ItprovidesaccesstoalltheconfigurationsettingsontheXBee.Ifyouwouldliketousethistool,seehttp://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/xctu

Performthefollowingstepstoconfigurethedevice:

1. OpenupPuTTY,selectSerial,andthe(inthiscase)COM20port.HereishowtofillinthePuTTYwindowtodothis:

Page 182: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

2. Configuretheterminalwindowasshowninthescreenshot:

Page 183: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

3. Now,intheTerminalwindow,makesureyoualsoselectLocalechoForceon,andchecktheImplicitCRineveryLFandImplicitLFineveryCR(availableunderTerminalintheCategory:selection.):

Page 184: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

4. ConnecttothedevicebyselectingOpen.5. Enterthefollowingcommandsbytypingthemintotheterminalwindow:

Page 185: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TheOKresponsecomesbackfromthedeviceasyouentereachcommand.Thefirstdeviceisnowconfigured.Removeitfromthesmall,XBee-specificshieldandplugitintotheArduinoXBeeshield.

Nowplugtheseconddeviceintothesmall,XBeeshieldandthenplugitintothePC.NotethatitmightchooseadifferentCOMport,gototheDevicesandPrintersoption,double-clickonthedevice,andselecttheHardwaretabtofindtheCOMport.Followthesamestepstoconfiguretheseconddevice,excepttherearetwochanges.Hereistheterminalwindowforthesecommands:

Thetwodevicesarenowreadytocommunicate.

ConfiguringthedeviceusingaMacisverysimilar.Followthesestepstostartaterminalconnectionwiththedevice:

1. PlugtheXBeemoduleintotheXBeeshieldandhookittoyourMacviaUSB.2. OpenupaCoolTermwindowandthenhittheOptionsonthetoolbar.3. SelectthecorrectportforyourXBeedevice.Itwilllooksomethinglikeusbserial-

XXXXXXXX.4. Ifyourdevicedoesn’tappear,plugitbackinandclickonRe-ScanSerialPorts.5. HittheOkbuttonandtherestofthedefaultswillworkjustfine.6. HittheConnectbuttononthetoolbarandyoushouldbetalkingtoyourXBee.

Nowyoucanconfigureyourdeviceasshownpreviously.IfyouareusingLinuxtoconfigureyourdevice,youwillsimilarlyopenaterminalwindow,connectittotheproperUSBserialport,andthenconfigurethedevice.

Page 186: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 187: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

EnablinganXBeeInterfaceintheIDELet’sfirstsetuptheIDEfortheXBeethatwillbeconnectedtotheGalileo.OnceyouhaveconnectedtheshieldtotheGalileo,simplyconnecttheGalileowiththeUSBcabletoyourhostcomputers.BringuptheIDEandthentypeinthefollowingcodeintothesketchwindow:

Page 188: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Hereisanexplanationofthissetofcode:

Page 189: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ThissetofcodeinitializestheserialportontheGalileo,soyoucanreceiveviatheserialinterface:

TTYUARTClass*gSerialStdPtr=&Serial;//Galileo,/dev/ttyGSO,Txpin

TTYUARTClass*gSerialTwoPtr=&Serial1;//Galileo,/dev/ttySO,Rxpin

boolgGalileo=true;

boolqData;

intled=13;

Thissetofcodestartsthesendandreceiveprocess,you’llonlyusethereceiveprocessforthisapplication:

qData=false;//Initializeonreset

gSerialStdPtr->begin(9600);//Receiver

gSerialTwoPtr->begin(9600);//Sender

waitForUser(5);//Giveusrtimetoopenserialterminal

gSerialStdPtr->println("XBee-Receiver-setup");

pinMode(led,OUTPUT);

ThiscodewaitsforavalidinputfromtheserialportontheXbeeandthenprintsittotheSerialMonitorscreen.ItalsotakesthedataandturnsontheonboardLED,connectedtoPin13,iftheinputisa1;itturnsitoffifthedataisa0:

if(qData==false)

gSerialStdPtr->println("XBee-Receiver-waiting");

//GetdatafromSenderandprinttoReceiverserialport

while(gSerialTwoPtr->available())

{

charc=gSerialTwoPtr->read();//ReadXBeedata

if(c=='1')

digitalWrite(led,HIGH);

if(c=='0')

digitalWrite(led,LOW);

gSerialStdPtr->write(c);//Writelocal

qData=true;

}

if(qData==false)delay(1000*1);//Slowdownuntildataisrec

}

Thiscodewaitsforasettimefortheusertobringuptheserialport:

voidwaitForUser(unsignedintaSec)

{

//Giveusertimetobringuptheserialport

for(inti=aSec;i>0;i--)

{

delay(1000*1);

gSerialStdPtr->print(i);

}

gSerialStdPtr->println("");

}

Oncethecodeisuploaded,you’llneedtophysicallychangeaswitchsettingontheWirelessShield,sothedevicewillnowacceptcommandsfromyourXBeecontroller.Itisontheoppositeendoftheshieldfromthedevice,andlookslikethis:

Page 190: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ThisswitchconnectstheXBeetoeithertheUSBserialportorthemicrocontroller(inthiscase,theGalileo)serialport.ChangeittotheMICROsettingonceyoursketchhasfinishedcompilationanduploadedtotheGalileo.

NowconnecttheotherXBeedeviceviathesmall,Xbee-specificUSBshieldtothe

Page 191: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

computer.OpenPuTTYoranotherterminalemulatorwindow.Makesureyousettheterminalemulatordatarateto9600baud.InPuTTY,yourconfigurationwilllooklikethis:

Nowopentheterminalwindow.YoushouldnowbeabletoentercommandsintothePuttywindowandmonitorthemusingtheSerialMonitorontheGalileo.HereisapictureofthePuttyapplication:

HereiswhatyoushouldseeifyouopentheSerialMonitoronyourGalileo:

Page 192: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Mostimportantly,eachtimeyouentera1youshouldseetheLEDontheGalileoturnonand,whenyoutypea0,youshouldseeitturnoff.Now,ifyoursystemisnotworking,thereareacoupleofwaystotryanddeterminewhatisgoingwrong.Firstandforemost,makesuretheGalileoisturnedonandisexecutingthecorrectcode.Second,checktoseethatcharactersarebeingtypedinthePuttywindow.Third,checkthebaudrateofthePuTTYwindow.Ifitistoohigh,youwillseecharacterscomethroughthesystem,butyoutheywillnotbeinterpretedcorrectlyontheGalileo.Fourth,makesureyouactuallyconfiguredboththedevicesinsteadofjustone.Fifth,makesuretheserialswitchontheXbeeshieldisintherightposition.Finally,makesurethedevicesareinrange.

Page 193: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 194: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConfiguringaWi-FiconnectionontheGalileoYoucanalsocommunicatewiththeGalileoviaWirelessLAN.Todothis,you’llneedsomeadditionalhardware.Thefirstpieceofhardwareyou’llneedisaminiPCIwirelessdevice.ThebasicGalileoPokyoperatingsystemsupportstwodevices:theIntel®Centrino®Wireless-N135andIntel®Centrino®Advanced-N6205adapters.Ifyoudon’twanttocompileyourowndrivers,youshouldpurchaseoneofthesetwodevices.

NoteIfyouwishtopurchaseadifferentminiPCIwirelessdevice,seehttp://www.malinov.com/Home/sergey-s-blog/intelgalileo-addingwififorhowtocompiledriversforyourdevice.

You’llalsoneedsomecablesandantennas.You’llneedtwo6dBiRPSMAantennasandtwo8-inchUFLcables.Therearekitsavailable,forexampleathttp://www.amazon.com/gp/product/B00DP64JRG.AlsousefulisaHalftoFullHeightMiniPCIExpress(PCI-E)CardBracketAdapter,thismakesthewirelesscardeasiertoinstall.Onceyou’vegatheredallthehardware,installthecardintotheGalileo.Itisstraightforwardbut,ifyougetconfused,followtheinstructionsathttp://ionospherics.com/intel-galileo-setting-up-wifi/toinstallallthehardwareintotheGalileo.Hereiswhatitshouldlooklike:

Page 195: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Onceyouhavethewirelesshardwaresetup,you’llalsoneedacabletoestablishaterminalconnectiontotheLinuxoperatingsystemonyourdevice.FortheIntelGalileoGen2board,thecableyouwillneedisaUSBconnectorononeendandaFDTI6pinconnectorontheother.Theseareavailableatmostonlineelectronicsstores:

Page 196: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

IfyouareusingtheGalileoGen1board,thisis3.5mmtoUSBcable.PlugthiscableintotheterminalportontheGalileo,andtheUSBconnectoronyourhostcomputer.

Nowthatyouhaveallthehardware,herearethestepstogetyourGalileoupandconnectedtoWi-Fi:

1. First,you’llneedanewversionoftheLinuxoperatingsystemforyourGalileo.Togetthisgotohttp://www.intel.com/content/www/us/en/do-it-yourself/downloads-and-documentation.html#galileosoftwareandselectDownloadSD-CardLinuxImageforIntelGalileo(48MB,.bz2).Thiswilldownloada.tarfile(anarchivedfile)withthesupportforyourwirelessconnection.

2. You’llneedtoun-archivethisfileusinganarchiveutilitysuchas7-Zip.3. NowcopyallthefilesundertheSDCarddirectoryontoamicroSDcard.4. You’llneedaterminalwindowtointeractwithyourGalileo.Ifyouareusing

Windows,you’llneedaterminalemulatorwindowtocommunicatewiththeGalileo.Onepopular,freeversioniscalledPutty.FormoreinformationonPuttyandhowtodownload,seehttp://www.chiark.greenend.org.uk/~sgtatham/putty/.However,anyterminalemulatorprogramwilldo.BothLinuxandtheAppleOScomewithterminalemulatorprograms.

5. OpenaterminalwindowandselecttheserialportthatisconnectedtotheUSBtotheFTDIconnectorusingabaudrateof115200.EverytimetheGalileoboots,itwilllookforanimageontheSDcardandbootthatimageifitispresent.Ifitisnotpresent,itwillbootthePokyversionthatisintheinternalmemory.Theterminal

Page 197: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

windowwillallowyoutoselectbetweenthetwo.You’llnowwanttoboottheunitusingthemicroSDcardandthenewversionoftheGalileooperatingsystembyinstallingthecardandapplyingpower.Youshouldseethisbootupscreen:

Ifnotalreadyhighlighted,selectthesecondchoiceheretobootfromthecard.

6. Nowlogintothesystemusingrootastheuser.7. Typeifconfig–a.ThisshouldshowallLANinterfaces,andshouldlooklikethis:

Page 198: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Youcanseethewlan0interfacethatisnowavailabletoconnecttoyourWi-Finetwork.However,thereisnoaddressassigned;asyoucansee,thereisnoinetaddr:lineinthewlan0section.YoucanusetheIDEtoconnecttoyournetwork,thiswillbeshowninthenextsection.

NoteIfyouwanttoautoconnecttoagivennetworkeachtimeyouboottheGalileo,you’llneedtoaddyourwirelessnetworkIDandpasswordtothewpa_supplicant.conffile.Todothis,typewpa_passphraseWIFI-SSIDWIFI-PASSPHRASE>/etc/wpa_supplicant.conf.

8. YouwillneedtoeditonemorefiletoensureaccesstotheWi-FiconnectioneachtimeyoubootyourGalileo.Thefileis/etc/networks/config.Editthisfileusingvi(viistheeditorthatcomesonthisLinuxrelease.)Addautowlan0asthelastline.

9. Rebootyoursystem,asbefore.Log-inusingrootastheuser.

Nowthatthehardwareisconnected,youcanaccessthewirelesscapabilitiesinsidetheIDE.

Page 199: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 200: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

UsingWi-FifromtheIDENowthatthehardwareisup-and-running,youcanruntheexamplesintheIDE.IfyoubringuptheIDEandselectExamples|Wi-Fi,youcanseethattherearemanychoices:

ThemostbasicofthesechoicesistheScanNetworkssketch.IfyouselectthissketchandthenopentheSerialMonitorWindow,youshouldseesomethinglikethis:

Page 201: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Theothersketchesprovidefurthercapabilities.TherearesketchesthatshowhowtoconnectusingWPAorWEPsecurityprotocols.OneofthemostusefulistheSimpleWebServerWi-FithatshowshowtoturnanLEDonandoffovertheWi-Finetworkviaanexternalwebpage.SimplyconnectaresistorandLEDinseriesbetweenGNDanddigitalIOpinnine,editthesketchtoincludetheSSIDandpasswordofyournetwork,andthenopenawebbrowser.WhenyouopentheSerialMonitor,itwillshowyouconnectedtothenetwork:

Nowgoonthehostcomputerandentertheaddressshownintheaddressline.The

Page 202: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

followingshouldappearonyourbrowser:

YoucannowturntheLEDonandoff.

Page 203: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 204: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SummaryAsyounowknow,thereareseveralusefulwaysofconnectingwirelesslywithyourArduino.Inthischapter,you’velearnedhowtoconnectyourprojectwirelesslyusingXBee,areliablelong-rangeinterface.You’vealsolearnedhowtoconnectviaWi-Fi.Nowyourprojectcangountethered,needingonlyanoccasionalbatterychargetokeepitup-and-running.Inthenextchapter,you’lllearnhowtoaccesstheLinuxsystemonGalileoandaccessevenmoreinterestingcapabilities.

Page 205: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 206: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Chapter7.GoingFurtherwithGalileoWithyourGalileo,you’velearnedhowtobuildprojectsthatcanroll,nowlet’sbuildonethatcanwalk.Inthisfinalchapter,you’llmovefromusingthesimpleGalileoIDEtousingtheLinuxcapabilitiesoftheGalileotodriveanexternalUSBservocontrollersothatyoucancontrolthe12servosthatwillmakeyourquadrupedmove.

Inthischapter,youwilllearnhowtousetheGalileo’sLinuxcapabilitiestocontrolabasicquadrupedplatform.Todothisyouwilllearnthefollowing:

Galileo’sLinuxcapabilitiesHowservosworkHowtousetheGalileo’sLinuxcapabilitiestocontrolaservocontrollerthatcancontrollotsofservosCreatingcomplexmovementsoutofsimpleservocommands

Page 207: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TheGalileoandLinuxWhileyouhavebeenaccessingtheGalileoexclusivelythroughtheIDE,theGalileoactuallyhasbeenrunningaversionoftheLinuxoperatingsystemallalong.LinuxisanoperatingsystemsimilartoWindows,ortheAppleMacoperatingsystem.Infact,theMacoperatingsystemisbuiltuponaversionofUnix,whichisverysimilartoLinux.NowLinux,unlikeWindows,Android,orIOS,isnottightlycontrolledbyasinglecompany.Itisagroupeffort,mostlyopensource,andwhileitisavailableforfree,itgrowsanddevelopsbasedoncommunitydevelopmentandsupport.

Thus,anumberofdistributionshaveemerged,eachbuiltonasimilarkernel,orcoresetofcapabilities.ThesecorecapabilitiesareallbasedontheLinuxspecification.However,theyarepackagedslightlydifferently,anddeveloped,supported,andpackagedbydifferentorganizations.Angstromisoneoftheseversions.Debianisanother.Thereareothersaswell.TheoneincludedintheinternalmemoryassociatedwiththeGalileoiscalledPoky,andisbuiltusingasetoftoolscalledYocto.YoctoisatoolkitthatallowsuserstobuildtheirownLinuxdistribution.

Forthisproject,you’regoingtocreateanewSDcardimageofLinuxwithaDebiandistribution,installitonamicroSDcard,andboottheGalileofromthecard.ThisisaverypopularversionofLinuxthatsupportsawiderangeofdifferentcapabilities.

Nowyou’llneedtoconnecttheGalileototheLANtoaddcapability.Therearetwowaystodothis.Thefirstisusingawiredconnection;youcansimplyconnecttheGalileodirectlybyconnectingaLANcabletotheconnectorontheGalileo.YoucanalsoconnecttheGalileousingaWi-Ficonnection.ThisrequiresyoutoaddadditionalHardwareandconfigureyourWi-Ficonnection.Seehttps://software.intel.com/en-us/blogs/2014/03/13/configuring-wifi-for-the-intel-galileo-boardorhttp://www.hackshed.co.uk/how-to-use-wifi-with-the-intel-galileoformoreinformationonhowtoassemble,configure,andconnectyourGalileotoaWi-Finetwork.

Page 208: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 209: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

CreatingandbootingtheDebianLinuxSDcardimageontheGalileoHerearethestepstofollowtoinstallandruntheDebianimageonyourGalileo:

1. Thefirstthingyou’llneedisaDebianLinuximagethatsupportsLANandDHCP.Thesiteathttps://communities.intel.com/message/231688hasaversion,thereareothers.Ifyougotothissite,youcandownloadthisfile.

2. IfyouareusingWindowsonyourcomputer,thisfilewillnowexistinyourDownloadsdirectory.Unzipthisfileandyoushouldendupwithagalileo.imgfile.

3. NowyouneedaprogramthatwillwritethisfiletoamicroSDcard.IfyouareusingWindows,downloadtheprogramWin32DiskImagerfromhttp://sourceforge.net/projects/win32diskimager/.InstallthisprogramonyourPC.IfyouareusingLinux,youcanusetheddcommandtowritetothecard.

4. IfyouareusingaPC,runWin32DiskImager.InsertyourmicroSDcardintoyourPC.YoumightneedamicroSDtoUSBadapterforthis.Now,specifythefileandthecardinWin32DiskImager,likethis:

Becarefulinselectingthedevice,youcancorruptadriveifyouchoosethewrongone.IfyouareusingLinux,usethecommandsudoddif=galileo.imgof=sdXwherethesdXisthelocationofthecardyouwanttowriteto.

5. NowtakethecardandinsertitintotheGalileo’smicroSDslot.6. Tomonitoryoursystem,youwillwanttoconnectaterminalcablebetweenthe

Galileoandyourhostcomputer.IfyouareusingtheGalileoGen2board,thecableyouwillwantwillhaveaUSBconnectorononeendandaFDTI6pinconnectorontheother.Theseareavailableatmostonlineelectronicsstores:

Page 210: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

IfyouareusingtheGalileoGen1board,thisisa3.5mmtoUSBcable.

7. You’llnowwanttoboottheunitusingthemicroSDcardandDebianbyapplyingpower,butfirstalsoconnecttheLANcableandserialcable.FortheGalileoGen2,theserialcableconnectsrightnexttotheLANconnector;thereisa6pinFTDIconnectorforthecable.

8. You’llneedaterminalemulatorwindowtocommunicatewiththeGalileo.Onepopular,freeversioniscalledPutty.FormoreinformationonPuttyandhowtodownload,seehttp://www.chiark.greenend.org.uk/~sgtatham/putty/.However,anyterminalemulatorprogramwilldo.

9. OpenaterminalwindowandselecttheserialportofyourUSBtoFTDIconnector(orUSB-to-3.5mmconnector,ifyouhaveaGEN1board)andabaudrateof115200.EverytimetheGalileoboots,itwilllookforanimageontheSDcardandbootthatimageifitispresent.Ifitisnotpresent,itwillbootthePokyversionthatisintheinternalmemory.Theterminalemulatorwillallowyoutoselectwhichoperatingsystemyouwanttorun.

10. Powerontheunit.Youshouldseethisbootupscreen:

Page 211: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

11. Selectthelastselectiononthislist.TheunitwillnowbootfromtheDebianLinuxdistributiononthecard.Typetheusernameandpassword,forthisdistributionitisuseranduser.Theunitwillnowprovideaterminalconnectionfromyourhostcomputerwhereyoucantypecommands.

12. YouwillneedtoeditafiletogetaccesstotheLANconnection.Thefileis/etc/networks/config.Editthisfileusingeithervi,ornano(bothareeditorsthatcomewiththisLinuxrelease.)Makesurethefilelookslikethis:

13. Rebootyoursystem.14. Runthecommandsudoifconfig.andyoushouldbeabletoseetheIPaddressof

yourGalileo.15. Thisimageisquitesmall.Whenyouwritetheimagetoyourcard,thesystemwill

nowseeyourSDcardasquitesmallaswell,evenifyouhaveamuchlargercardwithmorememoryavailable.Youcanfollowtheinstructionsathttp://sourceforge.net/p/galileodebian/wiki/How%20to%20expand%20the%20root%20filesystem%20to%20use%20the%20entire%20SD%20card/toexpandyourcardtoitsfullsize.

Page 212: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

NowyoursystemisupandrunningandconnectedtotheInternet.Thisparticulardistributionalsohaspythonavailable,whichyouwilluselater.Youwillwanttorunthecommandsudoapt-getupdatetoupdatethelinksforanyinstallsyouwanttodointhefuture.Youwillalsowanttorunthecommandsudoapt-getupgradetoupdateyoursystemtothelatest.

Page 213: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 214: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

BuildingrobotsthatcanwalkNowthatyourGalileocanrunLinux,you’llneedtobuildaquadrupedthathasfourlegs.You’llbeusing12servossoeachleghasthreepointsthatcanmove,orthreedegreesoffreedom(DOF).YoucouldusetheIDEanditsGeneralPurposeInput/Output(GPIO)pinstocontrolalimitednumberofservos.However,youneedtocontrol12servosforthisproject,sothiswon’twork.Inthisproject,you’lluseanexternalservocontrollerthatcansupplythecontrolsignalsandvoltagesforall12servos.ThisexamplewillalsoshowyouhowtousetheLinuxcapabilitiesoftheGalileoforevenmorecomplexroboticsprojects.

Sinceservosarethemaincomponentofthisproject,itisperhapsusefultogothroughatutorialonservosandhowtocontrolthem.

Page 215: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 216: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

HowservomotorsworkServomotorsaresomewhatsimilartoDCmotors;however,thereisanimportantdifference.WhileDCmotorsaregenerallydesignedtomoveinacontinuousway—rotating360degreesatagivenspeed—servosaregenerallydesignedtomovetoalimitedsetofangles.Inotherwords,intheDCmotorworld,yougenerallywantyourmotorstospinwithacontinuousrotationspeedthatyoucontrol.Intheservoworld,youwantyourmotortomovetoaspecificpositionthatyoucontrol.

ThisisdonebysendingaPulse-Width-Modulated(PWM)signalonthecontrolconnectoroftheservo.Thelengthofthispulsewillcontroltheangleoftheservo,likethis:

Thesepulsesaresentoutwitharepetitionrateof60Hz.Youcanpositiontheservotoanyanglebysettingthecorrectcontrolpulse.

Page 217: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 218: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

BuildingthequadrupedplatformYou’llfirstneedsomepartssoyoucanbuildyourquadrupedrobot.Thereareseveralkitsoutthere,includingtheonesfoundatwww.trossenrobotics.com/p/PhantomX-AX-12-Quadruped.aspx.However,suchkitscanbeexpensiveso,forthisexample,you’llcreateyourownkitusingasetofLynxmotionparts.Theseareavailablefromseveralonlineretailers,suchaswww.robotshop.com.Tobuildthisquadruped,you’llneedtwosetseachofthetwolegparts,andthenoneseteachofthebody.Herearethepartswiththeirrobotshoppartnumber:

Quantity Description

1 LynxmotionSymmetricQuadrapodBodyKit-MiniQBK-02

2 Lynxmotion3”AluminumFemurPair

2 LynxmotionRobotLeg“A”Pair(NoServo)RL-01

4 LynxmotionAluminumMulti-PurposeServoBracketTwoPackASB-04

2BallBearingwithFlange-3mmID(pair)

ProductCode:RB-Lyn-317

ThelastpartisnotaLynxmotionpart,butisabearingyou’llneedtoconnectthelegtothebody.

You’llalsoneed12standardsizeservos.Thereareseveralpossiblechoices,butIpersonallyliketheHitecservos.Theyareaveryinexpensiveservoyoucangetatmosthobbyshopsandonlineelectronicsretailers.Nowlet’stalkbrieflyaboutthemodelofservo.Servoscomeindifferentmodelnumbers,primarilybasedontheamountoftorquetheycangenerate.

Torqueistheforcethattheservocanexerttomovethepartconnectedtoit.Inthiscase,yourservoswillneedtoliftandmovetheweightassociatedwithyourquadruped,soyou’llneedaservowithenoughtorquetodothis.Inthiscase,IsuggestyouuseeightmodelHS-485HBservos,you’llusethesefortheservosattachedtotheendofthelegandforthebody.Thenyou’llusefourmodelHS-645MGservosforthemiddleoftheleg;thisistheservothatwillrequirethehighestamountoftorque.YoucanalsojustusetwelveHS-645MGservos,buttheyaremoreexpensivethantheHS-485,sousingthetwodifferentservoswillbelessexpensive.

Herearethestepsforassemblingthequadruped:

1. Putthelowerpartoftherightlegtogether;itshouldlooklikethis:

Page 219: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

2. Nowconnectthisassemblytoaninterconnectingpiece,likethis:

Page 220: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

3. Completethelegbyconnectingtwooftheservobracketstogetheratrightangles,mountingtheHS-645MGontooneofthebracketsandthenconnectingthisservototheinterconnectedpiece,likethis:

Page 221: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

4. Putanotherrightlegtogether.5. Nowputtwoleftlegstogetherfollowingthesamestepsasmentionedpreviously,but

inleftlegconfiguration.Theylooklikethis:

Page 222: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

6. Thenextstepistobuildthebodykit.Therearesomeinstructionsatwww.lynxmotion.com/images/html/sq3u-assembly.htm,butitshouldlooklikethis:

Page 223: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

7. Thenconnecteachlegtothebodykit.First,connecttheemptyservobrackettothebodyusingthebearing,likethis:

8. Nowconnecttheotherservototheemptyservobracketandthebody,likethis:

Page 224: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Yourquadrupedshouldnowlooklikethis:

Nowthatyouhavethebasichardwareassembled,youcanturnyourattentiontotheelectronics.

Page 225: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 226: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

UsingaservocontrollertocontroltheservosTomakeyourquadrupedwalk,youfirstneedtoconnecttheservomotorcontrollertotheservos.TheservocontrolleryouaregoingtouseforthisprojectisasimpleservomotorcontrollerutilizingUSBfromPololu(Pololuitem#:1354availableatwww.pololu.com)thatcancontrol18servomotors.Hereisanimageoftheunit:

Makesureyouordertheassembledversion.ThispieceofhardwarewillturnUSBcommandsfromtheGalileointosignalsthatcontrolyourservomotors.Pololumakesanumberofdifferentversionsofthiscontroller,eachabletocontrolacertainnumberofservos.Inthiscase,youmightwanttochoosethe18servoversionsoyoucancontrolall12servoswithonecontrollerandalsoaddanadditionalservotocontrolthedirectionofacameraorsensor.Youcouldalsochoosethe12-servoversion.Oneadvantageofthe18-servocontrolleristheeaseofconnectingpowertotheunitviascrewtypeconnectors.

Therearetwoconnectionsyou’llneedtomaketotheservocontrollertogetstarted;thefirsttotheservomotors,andthesecondtoabattery.

First,connecttheservostothecontroller.Inordertobeconsistent,let’sconnectyour12servostotheconnectionsmarkedzerothrough11onthecontrollerusingthisconfiguration:

ServoConnector Servo

0 RightFrontLowerLeg

1 RightFrontMiddleLeg

Page 227: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

2 RightFrontUpperLeg

3 RightRearLowerLeg

4 RightRearMiddleLeg

5 RightRearUpperLeg

6 LeftFrontLowerLeg

7 LeftFrontMiddleLeg

8 LeftFrontUpperLeg

9 LeftRearLowerLeg

10 LeftRearMiddleLeg

11 LeftRearUpperLeg

Hereisapictureofthebackofthecontroller;thiswilltelluswheretoconnectourservos:

Page 228: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Nowyouneedtoconnecttheservomotorcontrollertoyourbattery.Forthisproject,youcanusea2SRCLiPobattery,itwillsupplythe7.4voltsandthecurrentneededbyyourservos,whichcanbeintheorderof2Amps.Hereisapicture:

Page 229: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thisbatterywillcomewithtwoconnectors,onewithlarger-gaugewiresfornormalusageandasmallerconnectorforconnectingtothebatteryrecharger.YoucanusetheXT60ConnectorPairs,soldersomewirestothematingconnectorofthebattery,andtheninsertthebareendofthewiresintotheservocontroller.

Yoursystemisnowfunctional.Nowyou’llconnectthemotorcontrollertoyourpersonalcomputertochecktoseeifyoucancommunicatewithit.Todothis,connectaminiUSBcablebetweentheservocontrollerandyourpersonalcomputer.

Page 230: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 231: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

CommunicatingwiththeservocontrollerviaaPCNowthatthehardwareisconnected,youcanusesomesoftwareprovidedbyPolulutocontroltheservos.Let’sdothisbyusingyourpersonalcomputer.First,downloadthePolulusoftwarefromwww.pololu.com/docs/0J40/3.aandinstallitbasedontheinstructionsonthewebsite.Onceitisinstalled,runthesoftwareandyoushouldseethisscreen:

YouwillfirstneedtochangetheconfigurationonSerialSettings,soselecttheSerialSettingstabsandyoushouldseethis:

Page 232: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

MakesurethattheUSBChainedoptionisselected,thiswillallowyoutoconnectandcontrolthemotorcontrolleroverUSB.NowgobacktothemainscreenbyselectingtheStatustabandnowyoucanactuallyturnonthetwelveservos.Thescreenshouldlooklikethis:

Page 233: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Nowyoucanusethesliderstoactuallycontroltheservos.Makesurethattheservo0movestherightfrontlowerservo,1therightfrontmiddleservo,2therightfrontupperservo,andsoon.Youcanalsousethistocentertheservos.Setalltheservossothatthesliderisinthemiddle.Now,unscrewtheservohornoneachservountiltheservosarecenteredatthislocation.Atthezerolocationofallservos,yourquadrupedshouldlooklikethis:

Page 234: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 235: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 236: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ConnectingtheservocontrollertotheGalileoYou’vecheckedtheservomotorcontrollerandtheservos;you’llnowconnectthemotorcontrolleruptotheGalileoandmakesureyoucancontroltheservosfromit.

Let’snowtalktothemotorcontroller.Herearethesteps:

1. ConnectGalileotothemotorcontrollerbyconnectingaminiUSB-to-miniUSBcable.ConnectthecabletotheUSBhostconnectionontheGalileo,likethis:

2. DownloadtheLinuxcodefromPololuatwww.pololu.com/docs/0J40/3.b.PerhapsthebestwayistologontoyourGalileo,thentypewgethttp://www.pololu.com/file/download/maestro-linux-100507.tar.gz?file_id=0J315.

3. Then,movethefileusingthiscommand:

mvmaestro-linux-100507.tar.gz\?file_id\=0J315maestro-linux-

100507.tar.gz

4. Unpackthefilebytypingtar–xzfvmaestro_linux_011507.tar.gz.Thiswillcreateadirectorycalledmaestro_linux.Gotothatdirectorybytypingcdmaestro_linuxandthentypels,youshouldseesomethinglikethis:

Page 237: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ThedocumentREADME.txtwillgiveyouexplicitinstructionsonhowtoinstallthesoftware.Unfortunately,youcan’trunMaestroControlCenteronyourGalileo,yourversionofwindowsdoesn’tsupportthegraphics,butyoucancontrolyourservosusingtheUscCmdcommandlineapplication.Firsttype./UscCmd--listandyoushouldseethefollowing:

Theunitseesyourservocontroller.Ifyoujusttypemono./UscCmd,youcanseeallthe

Page 238: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

commandsyoucansendtoyourcontroller:

Noticeyoucansendaservoaspecifictargetangle,althoughthetargetisnotinanglevaluessoitmakesitabitdifficulttoknowwhereyouaresendingyourservo.Withaservoandbatteryconnectedtotheservocontroller,trytyping./UscCmd--servo0,10.Theservowillmovetoitsfullangleposition.Type./UscCmd–servo0,0anditwillstoptheservofromtryingtomove.Inthenextsection,you’llwritesomepythoncodethatwilltranslateyouranglestothecommandsthattheservocontrollerwillwanttoseetomoveittospecificanglelocations.IfyouarestrugglingwiththeUSBconnection,seehttp://www.linux-usb.org/FAQ.htmlformoreinformation.

NoteIfyoudidn’truntheWindowsversionofMaestroControllerandsettheSerialSettingstoUSBChained,yourmotorcontrollermightnotrespond.ReruntheMaestroControllercodeandsettheSerialSettingstoUSBChained.

Page 239: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 240: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

CreatingaprograminLinuxsothatyoucancontrolyourquadrupedYounowknowthatyoucantalktoyourservomotorcontroller,andmoveyourservos.Inthissection,you’llcreateapythonprogramthatwillletyoutalktoyourservostomovethemtospecificangles.You’llusepythonasitisverysimpleandeasytorun.

Let’sstartwithasimpleprogramthatwillmakeyourleggedmobilerobot’sservosgoto90degrees(thisshouldbesomewhereclosetothemiddleofthe0to180degreesyoucanset.)IfyouareunfamiliarwiththeeditingcodeinLinux,thebestsourceisatutorialontheeditoryouareusing.Fornanotryhttp://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/.Hereisthecode:

Hereisanexplanationofthecode:

1. #!/usr/bin/python:-Thisfirstlineallowsyoutomakethispythonfileexecutefromthecommandline.

2. importserial:–Thislineimportstheseriallibrary.YouneedtheseriallibrarytotalktoyourunitviaUSB.

3. defsetAngle(ser,channel,angle):-Thisfunctionconvertsyourdesiredsettingofservoandangleintotheserialcommandthattheservomotorcontrollerneeds.Tounderstandthespecificsofthecodeusedtocontroltheservos,seehttps://www.pololu.com/docs/0J40.

Page 241: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

4. ser=serial.Serial("/dev/ttyACM0",9600):–Thisopenstheserialportconnectiontoyourservocontroller.

5. Nowyoucanseteachservotothemiddle(home)position:

foriinrange(0,15):

setAngle(ser,i,90)

Thedefaultwouldbetoseteachservoto90degrees.Ifyourlegsaren’tintheirmiddleposition,youcanadjustthembyadjustingthepositionoftheservohornsoneachservo.

Toaccesstheserialport,you’llneedtomakesureyouhavethepythonseriallibrary.Ifyoudon’t,thentypeapt-getinstallpython-serial.Afteryouhaveinstalledtheseriallibrary,youcanrunyourprogrambytypingpythonquad.py.

Onceyouhavethebasichomepositionset,youcannowaskyourrobottodosomethings.Let’sstartbyhavingyourquadrupedwave.Hereisthepythoncode:

Page 242: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Inthiscase,youareusingyoursetAnglecommandtosetyourservostomanipulateyourrobot’sfrontrightarm.Themiddleservoraisesthearm,andthelowersurveythengoesbackandforthbetweenanangleof100and130.

Oneofthemostbasicactionsyou’llwantyourrobottotakeistowalkforward.Hereisanexampleofhowtomanipulatethelegstomakethishappen:

Thisprogramliftsandthenmovesforwardeachleg,oneatatime,thenmovesallthelegstothehomeposition,whichmovestherobotforward.Notthemostelegant,butitdoeswork.Therearemoresophisticatedalgorithmsforwalkingwithyourquadruped,seehttp://letsmakerobots.com/node/35354andhttps://www.youtube.com/watch?v=jWP3RnYa_tw.Onceyouhavetheprogramworking,you’llwanttopackageallyourhardwareontothemobilerobot.

Youcanmakeyourrobotdomanyamazingthings.Walkforward,walkbackward,dance,turnaround;anynumberofmovementsarepossible.Thebestwaytolearnistotrynewanddifferentpositionswiththeservos.

Page 243: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 244: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SummaryYounowhavearobotthancanwalk!ThisshouldnowgiveyoutheopportunitytousetheLinuxsystemtoaddmorecomplexcapabilities.Debianisquitepowerful,andopensanentiresetofopen-sourcecapabilities.Inthenextchapter,you’llexploreusingtheGalileotoproducespeech.

Page 245: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 246: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Chapter8.SpeechOutputNowthatyou’velearnedhowtogettotheLinuxoperatingsystemonyourGalileo,youhaveawholenewsetofcapabilitiesthatyoucanaddtoyourprojects.Oneexampleisspeech;itisagoodbasicprojectandoffersanexampleofaddingcapabilityinbothhardwareandsoftware.You’llbeaddingaspeakertoyourGalileo.You’llalsoaddfunctionalitysotherobotcanrespondviathespeaker.

Specifically,inthischapteryou’lllearnhowto:

HookupthehardwaretoinputsoundUseEspeaktoallowyourprojectstorespondinarobotvoice

ThisprojectrequiresaUSBmicrophoneorspeakeradapter.Theboarditselfdoesnothaveaudiooutoraudioin.OntheGalileoGen1board,the3.5mmconnectoristoconnecttothehostcomputer.Soyou’llneedthefollowingtwopiecesofhardware:

AUSBdevicethatsupportsmicrophoneinandspeakerout.Theseareinexpensiveandcanbepurchasedatanyonlineelectronicsoutlet.Refertothefollowingimage:

ApoweredspeakerthatcanplugintotheUSBdevice.Again,theseareavailableonlineoratanyaudiostore.Refertothefollowingimage:

Page 247: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Makesurethespeakerispoweredbecauseyourboardwillgenerallynotbeabletodriveapassivespeakerwithenoughpowerforyourapplications.Thespeakercanuseeitherinternalbatterypower,oranexternallypoweredUSBhub.

Page 248: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

HookingupthehardwaretomakeaninputsoundForthistask,youaregoingtohookupyourhardwaresothatyoucanrecordandplaysound.Todothis,assembleyourGalileoandthecomponents.PlugintheLANcable,orconnectviathewirelessadapter.PluginthemicrophoneorspeakerUSBdevice.Also,pluginyourspeakersandthemicrophone.Pluginthepower,aswellastheUARTconnector.Theentiresystemshouldlooklikethefollowingimage:

Pluginthepower.Oncetheterminalwindowcomesup,loginwithyourusernameandpassword.Nowtypeincat/proc/asound/cards.TheGalileowilltellyouwhatsoundcarditseesattached.Youshouldseearesponsethatresemblesthefollowingscreenshot:

Page 249: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Thereisonlyoneaudiodevice,yourUSBaudioplugin.First,let’splaysomemusictotestthattheUSBsounddeviceisworking.You’llneedtoconfigureyoursystemtolookforyourUSBaudiopluginanduseitasthedefaultsounddevicetoplayandrecordsound.Todothis,you’llneedtoaddacoupleoflibrariestoyoursystem.ThefirstisAdvancedLinuxSoundArchitecture(ALSA).ItisgoingtoenableyoursoundsystemontheGalileo.Performthefollowingsteps:

1. Firstly,installtwolibrariesassociatedwithALSAbytypingsudoapt-getinstallalsa-basealsa-utils.Asareminder,youneedtohaveanetworkconnectiontodownloadnewpackages,andapt-getwillsearchthedefaultpackagerepositorybyname.

2. Then,alsoinstallsomefilesthathelpprovidethesoundlibrarybytypingsudoapt-getinstalllibasound2-dev.

Ifyoursystemalreadycontainstheselibraries,Linuxwillsimplytellyouthattheyarealreadyinstalledorthattheyareup-to-date.Afterinstallingbothlibraries,rebootyourGalileo.Ittakestime,andisnotalwaysrequired,butthesystemoftenneedsarebootafternewlibrariesorhardwareareinstalled.

Page 250: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

UsinganapplicationNowyou’lluseanapplicationnamedalsamixertocontrolthevolumeofboththeinputandtheoutputofourUSBsoundcard.Performthefollowingsteps:

1. Typealsamixerontheprompt.Youshouldseeascreenthatlookslikethefollowingscreenshot:

2. Youcanusethearrowkeystosetthevolumeforboththespeakersandthemicrophone.UsetheMkeytounmutethemicrophone.Intheprecedingscreenshot,MMismuteand∞isunmute.

3. Let’smakesureyoursystemknowsaboutyourUSBsounddevice.Attheprompt,typesudoaplay–l.Youshouldnowseeascreenresemblingthefollowingscreenshot:

Page 251: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Nowthatyouhavesomesoundhardware,let’sfirstrecordsomesound.Todothis,you’regoingtousethearecordprogram.Attheprompt,typearecord-d5-r48000test.wav.Thiswillrecordfivesecondsofsoundata48,000Hzsamplerateandsaveittoafilecalledtest.wav.

Onceyouhavetypedthecommand,eitherspeakintothemicrophoneormakesomeotherrecognizablesound.Youshouldseethefollowingoutputintheterminal:

Page 252: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Onceyoucreatethefile,playitwithaplay.Typesudoaplaytest.wavandyoushouldheartherecording.Ifyoucan’thearyourrecording,checkalsamixertomakesureyourspeakersandmicrophonearebothunmuted.

NowyoucanplaymusicorothersoundfilesusingyourGalileo.Youcanchangethevolumeofyourspeakerandrecordyourvoiceorothersoundsonthesystem.You’rereadyforthenextstep.

Page 253: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 254: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

UsingEspeaktoallowourprojectstorespondinarobotvoiceSoundisanimportanttoolinourrobotictoolkit,butyouwillwanttodomorethanjustrecordandplayyourvoice.Let’sallowyourrobottospeak.You’regoingtostartbyenablingEspeak,anopen-sourceapplicationthatprovidesuswithacomputervoice.DownloadtheEspeaklibrarybytypingsudoapt-getinstallespeak.Thedownloadmighttakeawhile,butthepromptwillreappearwhenitiscomplete.Nowlet’sseeifyourGalileohasavoice.Typethesudoespeak"hello"command.Thespeakershouldemitacomputer-voicedhello.Ifitdoesnot,checkthespeakersandvolumelevel.

Nowthatyouhaveacomputervoice,youmightwanttocustomizeit.Espeakoffersafairlycompletesetofcustomizationfeatures,includingalargenumberoflanguages,voices,andotheroptions.Toaccessthese,youcantypeintheoptionsatthecommand-lineprompt.Forexample,typeinespeak-v+f3"hello"andyoushouldhearafemalevoice.YoucanaddaScottishaccentbytypingespeak–ven-sc+f3"hello".ThecommandlineargumentsthatareavailableforEspeakaredocumentedathttp://espeak.sourceforge.net/commands.html.Onceyouhaveselectedthekindofvoiceyou’dlikeforyourprojects,youcansetitasthedefault,soyoudon’talwayshavetoincludeitinthecommandline.

Tosetthedefault,gotothedefaultfiledefinitionforespeak,whichisinthe//usr/lib/arm-linux-gnueabihf/espeak-data/voicesdirectory.Thedefaultfileistheonethatespeakusestochooseavoice.Togetyourdesiredvoice,sayonewithafemaletone,youaregoingtocopyafileintothedefaultfile.Thefile,thatis,thefemaletone,isinthe!vdirectory.Type\!vwheneveryouwanttospecifythisdirectory.Weneedtotypethe\characterbecausethe!characterisaspecialcharacterinLinux;ifwewanttouseitasaregularcharacter,weneedtoputa\characterbeforeit.Beforestartingtheprocess,copythecurrentdefaultfileintoafilenameddefault.old,soitcanberetrievedlater,ifneeded.Thenextstepistocopythef3voiceasyourdefaultfile.Typethesudocp./\!v/f3defaultcommand.Thishasallthesettingsforyourfemalevoice.Nowyoucansimplytypeespeakandthedesiredtext.Youwillnowgetyourfemalecomputervoice.

Nowyourprojectcanspeak.Simplytypeespeakfollowedbythetextyouwanttospeakinquotesandoutcomesyourspeech.Ifyouwanttoreadanentiretextfile,youcandothataswellusingthe–foptionandthentypingthenameofthefile.Trythisbyusingyoureditortocreateatextfilecalledspeak.txt;thentypetheespeak-fspeak.txtcommand.

Therearelotsofchoiceswithrespecttothevoicesyoumightusewithespeak.Feelfreetoplayaroundandchooseyourfavorite.Theneditthedefaultfiletosetittothatvoice.However,don’texpectthatyou’llgetthekindofvoicesthatyouhearfromcomputersinthemovies.Thoseareactorsandnotcomputers;oneday,though,wewillhopefullygettothepointwherecomputerswillsoundalotmorelikerealpeople.

Page 255: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the
Page 256: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

SummaryNowyourprojectcanspeak.Youcanusethislaterwhenyouwanttointerfacewithyourprojectwithoutusingthedisplay.Youshouldalsofeelmorecomfortableinstallingnewhardwareandsoftwareinyoursystem.Inthenextchapter,you’lladdcapabilitythatwillallowyourrobotstoseeandusevisiontotrackobjects,ormotion,orwhateverelseyourrobotneedstotrack.

Page 257: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

IndexA

accelerometerconnecting,toGalileo/ConnectinganaccelerometerorgyrototheGalileoURL/ConnectinganaccelerometerorgyrototheGalileoaccessing,fromGalileoIDE/ConnectinganaccelerometerorgyrototheGalileo,AccessingtheaccelerometerfromtheIDE

Adafruit2.8inchTFTV2URL/TheTFTshield

Adafruit_GFXlibraryURL,fordownloading/AccessingthedisplaywiththeIDE

Adafruit_ILI9341libraryURL,fordownloading/AccessingthedisplaywiththeIDE

AdvancedLinuxSoundArchitecture(ALS)/Hookingupthehardwaretomakeaninputsoundaltimeter/pressuresensor

connecting,toGalileo/Connectinganaltimeter/pressuresensortotheGalileoaccessing,fromGalileoIDE/Accessingthealtimeter/pressureSensorfromtheGalileoIDE

AnalogINA5/A0pin/TheGPIOcapabilityoftheGalileoanaloginputsignals

interfacing,withGalileo/InterfacinganaloginputsignalswithGalileoAREFpin/TheGPIOcapabilityoftheGalileo

Page 258: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Bblinkapplication

about/OpeninganduploadingafiletotheGalileoobtaining/OpeninganduploadingafiletotheGalileo

BMP085Module,DigitalBarometricPressureSensorURL/Connectinganaltimeter/pressuresensortotheGalileo

breadboardwires,plugging/Pluggingyourwiresintothebreadboard

Page 259: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

CCOMport

selecting,forWindows/SelectingtheproperCOMportforWindowsselecting,forMac/SelectingtheproperCOMportfortheMacselecting,forLinuxmachine/SelectingtheproperCOMportforaLinuxMachine

Page 260: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

DDCmotor

basics/DCmotorbasicsconnecting,toGalileo/ConnectingaDCmotordirectlytotheGalileoconnecting,H-bridgeused/ConnectingaDCmotorusinganH-bridgeandtheGalileoconnecting,Galileoused/ConnectingaDCmotorusinganH-bridgeandtheGalileocontrolling,shieldused/ControllingDCmotorsusingashield

DebianLinuxSDcardimagecreating,onGalileo/CreatingandbootingtheDebianLinuxSDcardimageontheGalileobooting,onGalileo/CreatingandbootingtheDebianLinuxSDcardimageontheGalileoURL/CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

degreesoffreedom(DOF)/BuildingrobotsthatcanwalkDigi/ConfiguringtheXBeedevicesDigital((PWM~)13/2pin/TheGPIOcapabilityoftheGalileodigitalcompass

connecting,toGalileo/ConnectingadigitalcompasstotheGalileoaccessing,fromGalileoIDE/AccessingthecompassfromtheIDEURL/AccessingthecompassfromtheIDE

digitalinputsignalsinterfacing,withGalileo/InterfacingdigitalinputsignalswithGalileo

DigitalRX->0pin/TheGPIOcapabilityoftheGalileoDigitalTX->1pin/TheGPIOcapabilityoftheGalileodistance

sensing/Sensingdistance

Page 261: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Eelectronics

settingup/SettinguptheelectronicsEspeak

used,forrespondinginrobotvoice/UsingEspeaktoallowourprojectstorespondinarobotvoiceURL/UsingEspeaktoallowourprojectstorespondinarobotvoice

externalhardwareconnecting/Connectingyourfirstexternalhardwarewires,pluggingintobreadboard/Pluggingyourwiresintothebreadboardelectronics,settingup/Settinguptheelectronics

Page 262: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Ffile

uploading,toGalileo/OpeninganduploadingafiletotheGalileoopening/OpeninganduploadingafiletotheGalileo

firmwareupdating/Updatingthefirmware

Page 263: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

GGalileo

unpacking/UnpackingandconnectingtheGalileoconnecting/UnpackingandconnectingtheGalileoconnecting,toWindowsmachine/DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachineconnecting,toMac/DownloadingthesoftwareandconnectingtheGalileotoaMacconnecting,toLinuxmachine/DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachineIDE,runningfor/RunningtheIDEfortheGalileofile,uploadingto/OpeninganduploadingafiletotheGalileoLinuxcapabilities,accessing/AccessingtheGalileo’sLinuxcapabilitiesGPIOcapability/TheGPIOcapabilityoftheGalileodigitalinputsignals,interfacing/InterfacingdigitalinputsignalswithGalileoanaloginputsignals,interfacing/InterfacinganaloginputsignalswithGalileoDCmotor,connectingto/ConnectingaDCmotordirectlytotheGalileoDCmotor,connectingwith/ConnectingaDCmotorusinganH-bridgeandtheGalileoIRsensors,connectingto/ConnectinganIRsensortotheGalileodigitalcompass,connectingto/ConnectingadigitalcompasstotheGalileoaccelerometer,connectingto/ConnectinganaccelerometerorgyrototheGalileogyro,connectingto/ConnectinganaccelerometerorgyrototheGalileoaltimeter/pressuresensor,connectingto/Connectinganaltimeter/pressuresensortotheGalileo,Accessingthealtimeter/pressureSensorfromtheGalileoIDEaltimeter/pressuresensor,accessingfrom/Accessingthealtimeter/pressureSensorfromtheGalileoIDEXBeedevices,connectingto/ConnectinganXBeeinterfacetotheGalileoWi-Ficonnection,configuring/ConfiguringaWi-FiconnectionontheGalileoandLinux/TheGalileoandLinuxDebianLinuxSDcardimage,booting/CreatingandbootingtheDebianLinuxSDcardimageontheGalileoDebianLinuxSDcardimage,creating/CreatingandbootingtheDebianLinuxSDcardimageontheGalileoservocontroller,connectingto/ConnectingtheservocontrollertotheGalileo

Galileocode,DCmotordirectioncontrol/GalileocodeforDCmotordirectioncontrolGalileocode,DCmotorshield/GalileocodefortheDCmotorshieldGalileocode,DCmotorspeedcontrol/GalileocodeforDCmotorspeedcontrolGalileoIDE

code,creating/TheIDEandLEDCode

Page 264: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

IRsensor,accessingfrom/AccessingtheIRsensorfromtheGalileoIDEdigitalcompass,accessingfrom/AccessingthecompassfromtheIDEaccelerometer,accessingfrom/AccessingtheaccelerometerfromtheIDEaltimeter/pressuresensor,accessingfrom/Accessingthealtimeter/pressureSensorfromtheGalileoIDEXBeeinterface,enabling/EnablinganXBeeInterfaceintheIDEWi-Fi,using/UsingWi-FifromtheIDE

GalileopinsAREF/TheGPIOcapabilityoftheGalileoGND/TheGPIOcapabilityoftheGalileoDigital((PWM~)13/2/TheGPIOcapabilityoftheGalileoDigitalTX->1/TheGPIOcapabilityoftheGalileoDigitalRX->0/TheGPIOcapabilityoftheGalileoAnalogINA5/A0/TheGPIOcapabilityoftheGalileoPowerVin/TheGPIOcapabilityoftheGalileoPowerGND/TheGPIOcapabilityoftheGalileoPower5V/TheGPIOcapabilityoftheGalileoPower3.3V/TheGPIOcapabilityoftheGalileoRESET/TheGPIOcapabilityoftheGalileoIOREF/TheGPIOcapabilityoftheGalileo

GalileoPokyoperatingsystemIntel®Centrino®Wireless-N135/ConfiguringaWi-FiconnectionontheGalileoIntel®Centrino®Advanced-N6205/ConfiguringaWi-FiconnectionontheGalileo

GNDpin/TheGPIOcapabilityoftheGalileoGPIOpins

capability/TheGPIOcapabilityoftheGalileousing/UsingtheGPIOpins

gyroURL/ConnectinganaccelerometerorgyrototheGalileoconnecting,toGalileo/ConnectinganaccelerometerorgyrototheGalileo

Page 265: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

HH-bridge

DCmotor,connectingwith/ConnectingaDCmotorusinganH-bridgeandtheGalileo

hardwarehookingup,forcreatinginputsound/Hookingupthehardwaretomakeaninputsound

Page 266: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Ii2cdevlib

URL/AccessingtheaccelerometerfromtheIDEIDE

downloading/DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachineOSXversion,downloading/DownloadingthesoftwareandconnectingtheGalileotoaMacLinuxversion,downloading/DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachinerunning,forGalileo/RunningtheIDEfortheGalileosetting,forconnectingtoboard/SettingtheIDEtoconnecttoyourboardserialdisplay,enabling/EnablingtheserialdisplayintheIDEused,foraccessingdisplay/AccessingthedisplaywiththeIDE

inputsoundcreating,byhookinguphardware/Hookingupthehardwaretomakeaninputsoundapplication,using/Usinganapplication

IOREFpin/TheGPIOcapabilityoftheGalileoIRsensor

about/TheInfraredsensorconnecting,toGalileo/ConnectinganIRsensortotheGalileoaccessing,fromGalileoIDE/AccessingtheIRsensorfromtheGalileoIDE

Page 267: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

LLCD

URL/EnablingtheserialdisplayintheIDELED

connecting/TheIDEandLEDCodeLinux

andGalileo/TheGalileoandLinuxprogram,creatingforquadrupedcontrol/CreatingaprograminLinuxsothatyoucancontrolyourquadruped

Linuxcapabilities,Galileoaccessing/AccessingtheGalileo’sLinuxcapabilities

LinuxmachineGalileo,connectingto/DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachineCOMport,selectingfor/SelectingtheproperCOMportforaLinuxMachine

LinuxoperatingsystemURL/ConfiguringaWi-FiconnectionontheGalileo

loop()function/AccessingtheIRsensorfromtheGalileoIDE

Page 268: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

MMac

Galileo,connectingto/DownloadingthesoftwareandconnectingtheGalileotoaMacCOMport,selectingfor/SelectingtheproperCOMportfortheMac

MPU-6050/ConnectinganaccelerometerorgyrototheGalileo

Page 269: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Nnano

URL/CreatingaprograminLinuxsothatyoucancontrolyourquadruped

Page 270: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

PPC

used,forcommunicatingwithservocontroller/CommunicatingwiththeservocontrollerviaaPC

PCIExpress(PCI-E)/ConfiguringaWi-FiconnectionontheGalileoPCIwirelessdevice

URL/ConfiguringaWi-FiconnectionontheGalileoPololu

URL/Usingaservocontrollertocontroltheservos,CommunicatingwiththeservocontrollerviaaPC,ConnectingtheservocontrollertotheGalileo

Power3.3Vpin/TheGPIOcapabilityoftheGalileoPower5Vpin/TheGPIOcapabilityoftheGalileoPowerGNDpin/TheGPIOcapabilityoftheGalileoPowerVinpin/TheGPIOcapabilityoftheGalileopressuresensors

URL/Connectinganaltimeter/pressuresensortotheGalileoPulse-Width-Modulated(PWM)/HowservomotorsworkPutty

URL/ConfiguringaWi-FiconnectionontheGalileoURL,fordownload/CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

Page 271: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Qquadruped

building/Buildingrobotsthatcanwalkcontrolling,withLinuxprogram/CreatingaprograminLinuxsothatyoucancontrolyourquadruped

quadrupedplatformbuilding/BuildingthequadrupedplatformURL/BuildingthequadrupedplatformHS-485HBservos,using/BuildingthequadrupedplatformHS-645MGservos,using/Buildingthequadrupedplatform

Page 272: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

RRESETpin/TheGPIOcapabilityoftheGalileo

Page 273: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Ssensors

used,forsensingdistance/Sensingdistanceserialdisplay

enabling,inIDE/EnablingtheserialdisplayintheIDEseriallibrary

URL/EnablingtheserialdisplayintheIDEservocontroller

using,forcontrollingservos/Usingaservocontrollertocontroltheservoscommunicating,withPC/CommunicatingwiththeservocontrollerviaaPCconnecting,toGalileo/ConnectingtheservocontrollertotheGalileo

servomotorsworking/Howservomotorswork

servoscontrolling,withservocontroller/Usingaservocontrollertocontroltheservos

setAnglecommand/CreatingaprograminLinuxsothatyoucancontrolyourquadrupedsetup()function/AccessingtheIRsensorfromtheGalileoIDEshield

using/Thesimpleserialdisplayused,forcontrollingDCmotor/ControllingDCmotorsusingashield

shieldcompatibilityguideURL/Sensingdistance

signalsobtaining,fromoutsideworld/Gettingsignalsfromtheoutsideworlddigitalinputsignals,interfacingwithGalileo/InterfacingdigitalinputsignalswithGalileoanaloginputsignals,interfacingwithGalileo/InterfacinganaloginputsignalswithGalileo

simpleserialdisplay/Thesimpleserialdisplaysolderlessversion

URL/ConnectinganaccelerometerorgyrototheGalileoSparkfun

URL/AccessingtheaccelerometerfromtheIDESparkfunSEN-11028

URL/ConnectinganaccelerometerorgyrototheGalileosudoapt-getupdatecommand/CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

Page 274: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

TTFTshield

about/TheTFTshielddisplay,accessingwithIDE/AccessingthedisplaywiththeIDE

Page 275: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

UUSBDriver

URL,forinstallation/ConfiguringtheXBeedevices

Page 276: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

Wwget

URL/ConnectingtheservocontrollertotheGalileoWi-Fi

configuring,onGalileo/ConfiguringaWi-FiconnectionontheGalileousing,fromGalileoIDE/UsingWi-FifromtheIDE

Win32DiskImagerURL/CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

WindowsCOMport,selectingfor/SelectingtheproperCOMportforWindows,SelectingtheproperCOMportfortheMac

WindowsmachineGalileo,connectingto/DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachine

Page 277: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

XXBeedevices

about/ConnectinganXBeeinterfacetotheGalileoconfiguring/ConfiguringtheXBeedevices

XBeeinterfaceconnecting,toGalileo/ConnectinganXBeeinterfacetotheGalileoenabling,inGalileoIDE/EnablinganXBeeInterfaceintheIDE

Page 278: Intel Galileo Essentials - DropPDF1.droppdf.com/files/Ag7Bj/intel-galileo-essentials-by-richard... · Table of Contents Intel Galileo Essentials Credits About the Author About the

ZZigBee/ConnectinganXBeeinterfacetotheGalileo