Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
IN DEGREE PROJECT TECHNOLOGY,FIRST CYCLE, 15 CREDITS
, STOCKHOLM SWEDEN 2016
Light Tracking RobotNavigation using light and colour sensors
MIKAELA KARLÉRUS
BEATA TÖRNEMAN
KTH ROYAL INSTITUTE OF TECHNOLOGYSCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT
I
Bachelor Thesis MMKB 2016:41 MDAB102
Light Tracking Robot
Mikaela Karlérus Beata Törneman
Approved
2016-06-07 Examiner
Martin Edin Grimheden Supervisor
Baha Alhaj Hasan
ABSTRACTThe increasing demand of making the roads safer has trigged a lot of companies todevelopcompleteself-drivingcars.Aself-drivingcarrequiresagreatnumberofdifferentsensorsasgyros,radars,GPS,tachymetersetc.andadvancedsoftware.Thisthesiswillfocus on the possibilities of using only light sensing devices for a tracking robot andexaminetheadvantagesanddisadvantagesofthis.Thepurposeistoinvestigatewhichtypeof lightsensorismoresuitableforatrackingrobotandwhatthelimitationsofatrackingrobotusingthistechnologyare.Ademonstratorusingtwolightsensorsforcontrollingspeedanddirectionandacoloursensortoavoidobstacleswillbebuilt.Apartfromchoosingthemostsuitablesensorforalight-trackingrobotthesensingdistanceandrangeofthechosenonewillbetested.To investigate the different light-tracking possibilities and the accuracy of thedemonstrator, thevehiclewillbeput inanopen indoorspacewitharrangedcolouredluminousobstacles.The robotwillbe tested inbothacompletelydark roomanda litroom.Theintentionwiththeoutcomeistoseethedifferencesoftherobotsbehaviourwhendisturbancesfromsurroundinglightareaddedasanadditionalaspect.Theresultsfromthetestarepresentedandtheuseofdifferentsensorsarediscussed.Thefinalconclusiononusinglightsensingforatrackingrobotisthatit isaneasyandinexpensivemethod,butitshouldbeusedasacomplementtoothersensingdevicesnotasastand-alonemethod.
II
III
Kandidatarbete MMKB 2016:41 MDAB102
Light tracking robot
Mikaela Karlérus Beata Törneman
Godkänt
2016-06-07 Examinator
Martin Edin Grimheden
Handledare
Baha Alhaj Hasan
SAMMANFATTNINGDen ökande efterfrågan på säkra bilvägar har lett till en utveckling av komplettasjälvkörandebilar.Ensjälvkörandebilkräverettstortantalolikasensorersomgyros,GPS,tachymeterosv.samtavanceradprogramvara.Dennaavhandlingkommerfokuserapåmöjligheternaattkonstrueraenspårningsrobotmedbaraljuskännandeenhetersamtundersökafördelarochnackdelarmeddetta.Syftetärattavgöravilkentypavljussensorsomlämparsigbästförenspårningsrobotochvilkabegränsningarenspårningsrobotsomanvänderdennateknologikommerattha.Enprototypsomanvändertvåljussensorerförkontrollerandeavhastighetochriktningsamtenfärgsensorförattundvikahinderkommerattkonstrueras.Bortsettfrånattväljaden mest lämpade sensorn för en spårningsrobot, kommer avståndskänning ochräckningsvidd att testat för den valda sensorn. Roboten kommer att testas i både ettfullständigtmörktrumochiettupplystrum.Förattundersökadeolikaljusavkänningsalternativenochnoggrannhetenhosroboten,kommer fordonet att placeras inomhus på ett öppet område med färgade ljuskällorarrangerade som hinder. Avsikten är att se skillnaderna i robotens beteende närstörningarsåsomreflektionerocholikaljuskälloriomgivningentillkommer.Resultatet från testerna kommer att presenteras och användningen av olika sensorerkommerattdiskuteras.Slutsatsen är att det är en enkel och billig metod att använda ljusavkänning för enspårningsrobot men att det framförallt bör användas som ett komplement till andraavkänningsanordningarochintesomenfriståendemetod.
IV
V
PREFACE
First we would like to thank Baha Alhaj Hasan for the supervising and feedbackthroughouttheproject.We would also like to thank Staffan Qvarntröm for helping with the electrical andmechanicaldesignandtothestudentassistantswhohelpedusduringtheway.Finally, a huge thanks to Martin Åkerblad and Todd Barker for very useful andappreciatedfeedbackonthereportandproject.
MikaelaKarlérusBeataTörneman
Stockholm,May2016
VI
VII
NOMENCLATURE
Thischapterdescribesabbreviationsusedinthisproject.
Abbreviations
LDR LightDependentResistorPWM PulseWidthModulationRGB Red,Green,BlueLED LightEmittingDiodeCAD ComputerAidedDesignIR Infra-RedSDA SerialDataLineSCL SerialClockLineVIN InputVoltageGND GroundIPS IndoorPositionSystemGPS GlobalPositionSystemAIS AutomaticIdentificationSystem
VIII
IX
CONTENTSABSTRACT.........................................................................................................................................................ISAMMANFATTNING.....................................................................................................................................IIIPREFACE...........................................................................................................................................................VNOMENCLATURE.........................................................................................................................................VIICONTENTS.......................................................................................................................................................IX1 INTRODUCTION....................................................................................................................................11.1 BACKGROUND......................................................................................................................................................11.2 PURPOSE..............................................................................................................................................................11.3 SCOPE...................................................................................................................................................................21.4 METHOD...............................................................................................................................................................21.4.1 Testone..............................................................................................................................................................21.4.2 Testtwo.............................................................................................................................................................21.4.3 Testthree..........................................................................................................................................................3
2 THEORY...................................................................................................................................................52.1 LIGHTINTENSITYSENSING...............................................................................................................................52.1.1 Lightdependentresistor............................................................................................................................52.1.2 Photodiode.......................................................................................................................................................6
2.2 COLOURSENSING................................................................................................................................................62.3 MOTORCONTROL...............................................................................................................................................7
3 DEMONSTRATOR................................................................................................................................113.1 PROBLEMFORMULATION................................................................................................................................113.2 SOFTWARE.........................................................................................................................................................113.3 ELECTRONICS....................................................................................................................................................123.3.1 Microcontroller............................................................................................................................................133.3.2 Motordriver..................................................................................................................................................143.3.3 Lightsensor....................................................................................................................................................143.3.4 Coloursensor.................................................................................................................................................15
3.4 HARDWARE.......................................................................................................................................................163.4.1 Chassis..............................................................................................................................................................16
3.5 RESULTS.............................................................................................................................................................163.5.1 Lightsensors..................................................................................................................................................163.5.2 Coloursensor.................................................................................................................................................18
4 DISCUSSIONANDCONCLUSIONS...................................................................................................214.1 DISCUSSION.......................................................................................................................................................214.1.1 Lightsensor....................................................................................................................................................214.1.2 Colourssensor...............................................................................................................................................21
4.2 CONCLUSIONS....................................................................................................................................................225 RECOMMENDATIONSANDFUTUREWORK...............................................................................235.1 RECOMMENDATIONS.......................................................................................................................................235.2 FUTUREWORK..................................................................................................................................................23
REFERENCES..................................................................................................................................................25APPENDIXA:TESTTHREE...........................................................................................................................IAPPENDIXB:THEFINISHEDROBOT.....................................................................................................III
X
1
1 INTRODUCTIONThis chapter describes in detail the thesis to be investigated, assumptions made and limitations in the modelling and construction of the demonstrator.
1.1 Background Self-driving cars are no longer just a surrealistic theory. Inmedia you can follow thedevelopmentofself-drivingcarsthatsoonwillbeputontheroadinSwedenfortestingpurposesbyVolvo(VolvoCars,2016).Companies likeBMW,MercedesandTeslahavedevelopedself-drivingfeaturesthataresoontobereleasedonthemarketwithambitionto make fully autonomous vehicles (Business Insider, 2015). Google has since 2009workedwiththeirself-drivingcarprojectandarerightnowtestingprototypevehiclesontheroad(Google,2016).Aself-drivingcarcanbedefinedasavehiclewithfeaturesthatcanmakeitaccelerate,brakeorsteerwithnohumaninput.Itrequiresagreatnumberofdifferentsensorsasgyros,radars,GPS,tachymetersetc.andadvancedsoftwaretomakeitself-driven.Oneofthemainpurposesofaself-drivingcaristomaketheroadsaferandfacilitatedaily life forcommutingpeople.Everyyearapproximately1.2millionpeoplediesintrafficaccidents,which94%arecausedbyhumanerrors,afigurewhichcouldbedecreasedgreatlywithuseofself-drivingtechnology(Google,2016).Forthisthesisafullyautonomouscarwouldbetoocomplicatedtobuild,eveninasmallerscale.Ontheotherhand,asmalleramountofsensorscouldbeusedforothertypesofautonomousvehicles,withamissionthatissimplertopredict.Inworkingenvironmentsnotoptimal forhumans, like inmines, it couldbepossible todevelopamuchsimplerautonomousvehiclewhichcouldforexamplefollowlightinadarktunnel.Inanairport,asimpler self-driving vehicle could be used to towairplanewhen taxing on the airportfollowinglightandcoloursonthegroundtosteeritswayonthefield.
1.2 Purpose This bachelor thesiswill investigate the possibility to control a robotwith light only.However,acompleteinvestigationonthesubjectwilltakelongertimeandcostmorethanthe framework and limits given so the investigationwill be limited to answering thefollowingmainquestion.Whichaspectsoflightarerelevanttoatrackingrobotcontrolledbylight?Thisquestionhasbeendividedfurtherintotwomorespecificquestions:• Which type of light sensor is more suitable for a tracking robot and what are the
limitationsofatrackingrobotusingthistechnology?• Isitpossibletomaketherobotobstacleavoidingbyusingcolouredlightandifso,is
thereanyspecificcolourthat’seasiertodetect?
Differentaspectsoflightcouldbeintensity,brightness,colour,wavelengthandasuitablesensorwould then be a sensor that reacts a lot to changes in one or several of these
2
aspects. Answers to above questions could hopefully be used as guide for furtherdevelopmentoflightcontrolledvehiclesorrobotstoachievedifferentbasicmanoeuvres.
1.3 Scope TheOpen-SourceArduino-platformhascontributedinmakingtheuseofsensorseasierandmoreapproachable.Thecodeusedforreadingthefilteredsensorvalues,red,green,blueandcalculatingluxandcolourtemperatureiscollectedfromanopensourcelibrary.Therefore,thetheorybehindiscoveredonlybriefly.Focushasinsteadbeenputontestingandverifyingtheoutputfromthesensortodeterminethesensingrangeandthesamplingfrequencythatmakesausefulcompromisebetweenaccuracyandbreakdistance.AlsothecommunicationbusI2CbetweenthecoloursensorandtheArduinoisfromanopensourcelibraryandisnotexplainedfurther.Thisreportcoversthetheoryandconceptsbehindalightseekingandobstacleavoidingrobot.Thecalculationswillbemadebasedonindoorusagesandtherobotwillberunandtestedinanindoorenvironment.Thethesiswillonlycoverdrivingintwoenvironments,acompletelydarkroom(0lux)andalightedroom(10lux).Theobstacleavoidancewillbe based on a colour sensor and therefore obstacles that are supposed to be avoidedneedstobecolourcoded.Moreover,thereportfollowsthescopeofaBachelorthesisatKTHandcorrespondsto10weeksofwork.
1.4 Method Tobeginwithastudyof theequipmentand the theorybehind their functionalitywasmade,tobeabletoevaluatetherightusageofthedifferentcomponents.Theinformationretrieval involvedmainlysciencearticlesanddatasheets.Forthe followingresearch,acompleteprototypewasbuiltbasedonArduinosoftwareandarobotkit.Sensorsandelectricmotorcontrolwasthenaddedtotherobotvehicletogetherwithanextrapowersourceinshapeofabatterypackage.Threedifferenttestswereconductedtoevaluatethesensorsandwillbedescribedbelow.
1.4.1 TestoneAcomparisonbetweentwolightsensorswasperformedbyplacingbothsensorsnexttoeachotheronabreadboardandmeasuringtheirresponsetodifferentlightenvironments.Intheinitialstatebothsensorswerecovered,thesensorswerethenmovedfromadarkerto a brighter part of the hallway. Themost suitable sensor of those two i.e. themostsensitivesensorwaschosenforthedemonstratorandusedforthefollowingtests.
1.4.2 TesttwoToinvestigatethetrackingabilitiesofthechosenlightsensorthesensingdistanceandsensingrangewereevaluated.Thetestwasdoneintwoenvironments,acompletelydarkroom (0 lux) and a lit room (10 lux). The sensing distancewere determined by firstmeasuringhowfarawaythechosenlightsensorcouldsensethelightsourceinthetwodifferent environments.After that the sensors response fromdifferentdistanceswereconductedaccordingtofollowingsteps:
1. Measuringtheambientvalueintheroom.2. Placingalightsource3minfrontofthelightsensor.
3
3. Calculatingthesensorvalue.4. Stepping0.5mforwardstothesensor.5. Calculatingthesensorvalue.6. Repeatingstep4-5untilthedistance0.5m.7. Addingthevaluesinatable.
Thesensingrangetestwereconductedaccordingtothefollowingsteps:
1. Measuringtheambientvalueintheroom.2. Placingthelightsource1minfrontofthelightsensor.3. Calculatingthesensorvalue.4. Stepping0,1mtotheside.5. Calculatingthesensorvalue.6. Repeatingstep4-5untilthesensorvalueisbacktotheambientvalue.7. Determinatethesensorsrange.
1.4.3 TestthreeA test to determine the colour sensors sensitivity to different colours were done byplacingthedemonstratoratsetdistanceseverytenthcentimetrebetween1-1.5metresfroma colour lightedobstacle. The illuminatedobstacles are of owndesignwithRGBLED:splacedonabreadboard.Thetestwasdoneinacompletelydarkroomandinalitroomandobstaclesinthethreedifferentcolours,red,greenandblueweretested.Thetestwasconductedaccordingtothefollowingsteps:
1. Placingthelightedobjectinfrontofthedemonstratoron1.5mdistance.2. Calculatingthesensorvalue.3. Movingtheobject0.1mforward.4. Calculatingthesensorvalue.5. Repeatingstep3-5untilthedistance0.1m.6. Repeatingstep1-5forthethreecolours.7. Plottingthevaluesinexcel.
TheresultfromthetestwillbepresentedinSection3.5.
4
5
2 THEORYThis chapter presents the theoretical framework that the performed research is based on. The different parts will be described separately below.
2.1 Light intensity sensing Lightsensorisadevicethatdetectstheambientlight levelandsendsanoutputsignalwhichvarieswiththelightintensity.Lightsensorsabsorblightenergyandreactwithaphysicalalterationinaspectrumfrominfra-redtoultravioletlightandcreateelectricityin form of electrons (Eriksson, 2003). Light sensors are commonly known as photosensorsandcanbedividedintotwogroups,theonesthatconvertthelightenergydirectlyintocurrent,forexamplesolarcellsandtheonesthatchangestheirelectricalpropertiesdepending on the intensity of the incident light and converts themeasured light to anumerical value, for example light dependent resistor, photodiode etc. The numericalvaluethencontrolsthesuppliedcurrenttothemotors.
2.1.1 LightdependentresistorAlightdependentresistor,alsocalledLDR,changesitsresistivevaluedependingontheincidentlightintensity.Theresistancewilldecreasewithincreasinglightintensityandviceversa.Tobeabletocalculatetheresistanceofthesensors,anotherresistorneedtobeadded.Itcanbedonebyeitherapull-downorapull-upresistor.Usingapull-downresistor,theresistorisconnectedtothegroundasillustratedin.Apull-upresistorworksin the sameway but the resistor is instead connected to its voltage source (Mims III,2016).Thisphenomenon,toconnectaLDRinserieswitharesistorgivesacircuitcalledvoltagedivider,Figure1.
Figure1.Voltagedividerwithapull-downresistor
WhentheresistanceofthelightisdecreasingthetotalresistanceoftheLDRandthepull-down resistor will decrease, in turn the current flow through both the resistancesincreaseswhich leads to an increaseof thevoltage across the fixed resistor.Once theoutputofthevoltagedividerisknown,theresistanceofthesensorcanbecalculatedusingEquation1,
6
!"#$ = !&'()
(* + () (1)
where!"#$istheoutputvoltage,!&'istheinputvoltage,()theresistorand(*thephotoresistorsresistance(Adafruit,2015).
2.1.2 PhotodiodeAphotodiode convert light into voltage in direct proportion to the light intensity andconsistsofalensthatmakessurethatthelightisfocusedonacertainmaterialinthediodethatdetectslight(MimsIII,2016).Aphotodiodehastwolevelsofoutput,eitherit’soff,inaconditioncalledreversebias,whichmeansthatnocurrentflowthroughthediodeoron,when the light intensity is adequate and the diode will then allow a current to flow(ElectronicTurtorials,2016).Therefore,auseofaphotodiodeispositivewhencontrolofthe light intensity is needed,while anLDR is preferredwhenvarying light intensitiesneedstobemeasured.Opposite tothe lightdependentresistorwhichreacts invisiblelight,aphotodiodeismoresensitivetolightinlongerwavelengthssuchasinfra-redlight.
2.2 Colour sensing Toenhancetheunderstandingofhowacoloursensordeviceworks, theknowledgeofhow colours are created and how humans perceive colour needs to be shared.Electromagneticradiationinthewavelengthfromca380-780nmaredefinedasvisiblelight, though the radiation need to be reflected on a surface before colour can bedistinguished.(JohJoh,KheeBoon,&Leong,2006).Thecombinationofanobject,alightsource and an observer iswhat creates colour nuances,where each colour representdifferentwavelengthsasillustratedinFigure2.
Figure2.Colourdiagramforthedifferentwavelengths
Coloursarerepresentedbythecombinationofthethreeprimarycolours,red,blueandgreen (ColorMatters,2016).These three colours constitute theadditive colourmodelcalledRGB.ThismodelshowshowthesethreecolourscanproduceavarietyofdifferentcoloursdependingonhowtheycombineasshowninFigure3.
Colour Wavelength
Red
Orange
Yellow
Green
Cyan
Blue
Indigo
Violet
~590-625nm
~565-590nm
~520-565nm
~500-520nm
~450-500nm
~430-450nm
~380-430nm
~625-740nm
7
Figure3:RGBcolourmodel
Acoloursensoriscreatedtomimicthehumaneyeasmuchaspossibleandcanadjustdifferingbrightnessanddetectcolourswhichgivesahighresolutionofcolourimages.AnRGBsensorisconstructedofseveralphotodiodesbehindcolourfiltersandacurrenttovoltageconversioncircuit(JohJoh,KheeBoon,&Leong,2006).Whenlightfallsonthephotodiodeitwillbeconvertedtoaphotocurrentandthesensorproducesanoutput.ThecolourcanbedeterminedbyinterpretingthesethreevoltagesandshowsinFigure4.
Figure4.Coloursensor
2.3 Motor control Motor control is about regulating and targeting themechanisms that are essential formovements.Amotordriverisacontrollingdeviceusedtocontrolthespeedanddirection
Red
Green
Blue
RGB Colour filter
Photodiode
Current-to-voltage-converter
Reflective or trans-mitted color light
IR
IG
IB
VROUT
VGOUT
VBOUT
8
ofthemotorsi.e.tomaketherobotturncorrectly.Anessentialcomponentinafunctionalmotordriver isanH-bridgewhichcanbeseen inFigure5, this is thecomponent thatmakesitpossibleforthemotorstoturnindifferentdirections.
Figure5:SchematicofanH-bridge
Thetopofthebridgeisconnectedtothepowersupplyandbottomisgrounded.S1-S4aretheswitchingelements,usuallytransistors.Thedirectionofthemotorsiscontrolledbythecurrentflowsthroughthemotorsinthedirectiondeterminedbytheswitches.IfS1andS4areconnectedtheleftleadofthemotorwillbeconnectedtothepowersupplyandtherightleadtotheground.Thecurrentflowsthroughthemotoranditstartsspinningandthemotorwillgoforward. IfS2andS3areconnected,thecurrentwill flowinthereversedirectionandthemotorwillgobackwards.TheadvantageofanH-bridgecircuitis the possibility to drive backwards and forwards at any speed, optionally using anindependentpowersource(McManis,2006).Inthesamewayasthedirectionofthemotorscanbecontrolledisitpossibletocontrolthe speedof themotors.The speed canbe controlledwith aPulse-Width-Modulation,PWM, which is a method to create a continuous variable power supply. Instead of acontinuouslyvaryinganaloguesignal,aPulse-Width-Modulationsignaldeliversenergythroughasectionofpulses.Digitalcontrolisusedtocreateasignalbetweenonandoff,somethingcalledsquarewave(Arduino,2016).Thecontrolof thePWMsignal isdonewithtwoparameters,theclockcycleandthedutycycle.Theclockcycleisthefrequencyofthesignalandthedutycycleislinkedtotheswitchingtime.Thedurationofon-timeiscalled pulse width and by increasing and decreasing the pulse width, the controllerregulatestheaverageDCvoltageappliedtothemotorthatchangesthespeedofthemotor.Dutycycleistheproportionofon-timetotheperiodoftime.Figure6illustratesaPWMsignalanditsmeanvalue,inthiscaseisa50%dutycycle.Highmeansthatitsuppliesthemotorwiththefullamountofavailablevoltage,whichalsocanbedescribedasa100%dutycycle.Lowdoesn’tsupplythemotorwithvoltageatallandmeanistheaverageofhighandlow.
Vin
S1 S3
S2 S4
M
9
Figure6:PWMsignalwitha50%dutycycle
Voltage
Time
High
Mean
Low
Pulse Width
Period
10
11
3 DEMONSTRATOR
Thischapterpresentthedevelopingprocessofthedemonstratoraswellasthefinalresult.
3.1 Problem formulation As stated in the purpose, the scientific question to be evaluated in this project is thepossibility to control a robotusingonly light.Thiswas reduced to an investigationofwhichaspectsoflightsthatareneededtocontrolthetrackingrobot.Thedemonstratorshouldbeabletoaccuratelysteeraccordingtotheinputfromthelightsensors and the RGB sensor i.e. to steer towards the higher light intensity and avoidobstaclesusingtheinputfromtheRGBsensor.TheobstacleavoidancewillbebasedonacolourcodingsysteminspiredbythenavigationsystemusedatseaandtheprincipleforthesystemcanbevisualizedinFigure7.Whentherobot isapproachinganobstacle itshouldperformeitheraleftorarightturnbasedontheobstaclescolour.
Figure7.Principlefortheobstacleavoidance
3.2 Software Thesoftwarecanbedividedintwosubsystems,oneforcomparinglightintensityandonefordetectingobstacles.Thedemonstratorare constructedwitha left anda right lightsensor,asdescribedinFigure9.Thefirstsystemisbasedontheinputfromtheleftandtherightlightsensorandthesecondsystemisbasedontheinputfromthecoloursensor.Thelightsensorsmeasurethelightintensitylevelsandtheseslevelsarethencomparedtodetermineinwhichdirectiontherobotshoulddrivei.e.thePWMsignaltoeachpairofmotors. To keep the robot from constantly turning, an additional condition has beensetup. For the robot to turn the sensordifferencebetween the left and the right lightsensorneedstobehigherthanathresholdvaluethathasbeenexperimentallysettothenumericalvalue45.TheRGBvaluesthatwereusedforavoidingobstaclesarecomparedtoathresholdvaluethatwassetasapercentageofthemeasuredclearlightvalue.Thisway the robot can drive in different light environments and still be able to sense anobstacle.AflowchartofthesteeringsystemisillustratedinFigure8.
12
Figure8.Flowchartofthesoftwaresystem.
3.3 Electronics Inthefollowingsectiontheelectricalcomponentsandhowtheyareconnectedwillbedescribed.InFigure9anoverallconstructionofthevehicleandtherelationbetweenthecomponentsispresented.
13
Figure9.Schematicofthedemonstratorcontrol
3.3.1 MicrocontrollerArduinoUNOisamicrocontrollerbaseddevelopmentboardwithopensourcehardwareandsoftware.TheboardisusedtotransmitinformationfromthesensorsandcontrolthefourDCmotorsthroughthemotordriver.Ithas14digitalI/Opinsofwhich6canbeusedasPWMoutputsand6analogueinputs(Arduino,2016).TheArduinocallstheLDRandwhen itgetsanewreading fromthesensors it adjusts themotorspeedanddirectionaccordingtotheprogrammedinstructions.ThespeedadjustmentsaredonebysendingaPWMsignaltothemotordriver,whichprocessthesignalandforwardsittothemotors.Sincethemotorsineachsetareparallel,therightandleftsidearecontrolledseparately,whichenablesthesteering.
Right motorLeft motor
Left motor Right motor
Motor driver
Arduino UNO
Left sensor Right sensor
Colour sensor
Left sensor Right sensor
14
3.3.2 MotordriverThemotordriverchosentopowerandcontrolthemotorsisaL298NDualH-BridgeMotorDriverShield(ArtofCircuits,2015).EachchannelontheL298Niscapableofdeliveringanoutputcurrentupto2A, thus itcaneasilydrivetwosetsofbrushedDCmotorsasillustratedinFigure10.
Figure10.DC-motorcontrol
Twoenable inputs areprovided to enableordisable themotors independentlyof theinputsignals.Moreover,themotordriverhasfourpinsusedforcontrollingdirectionofthemotors,andtwopinswhereitreadsthePWMsignalthatissenttothemotors.Themotorsinthesameseti.e.thetwomotorsonthesamesideareinparallel,whichmeansthatthePWMoutputisthesameforthetwomotorsonthesameside.Themotordriverisconnectedtoanexternalpowersource,inthiscasea7,4VbatterypackwiththebenefittopowerthemotorsdirectlywithouthavingtogothroughtheArduino.
3.3.3 LightsensorThelightsensorsusedinthisthesiswherethetypeofsensorsthatconvertsthemeasuredlightintensitytoanumericalvalue.Twodifferentlightsensorsofthattypeweretestedandevaluated.ThelightsensorsthatweretestedweretheLDRandthephotodiodeandtheirfunctionalityaredescribedinSection2.1.The photodiodewas of the type TSL 252R (Elfa, 2016) and shown in Figure 11. ThephotodiodewasonlyusedinthetestdescribedinSection1.4.1thusnotmountedonthedemonstrator.
L298N Driver
ENAIN1IN2
IN4IN3
ENB
Arduino UNO
AOUT2VINGNDBOUT1
M
M
+-
Power supply AOUT1
BOUT2
M
M
PWM
PWM
PWM
PWM
AN
AN
15
Figure11.Photodiode
ThelightsensorsusedforthedemonstratorandtocontroltherobotsrightorleftturnsattheforwardrunaretwoLDR:softypeB906032(Elfa,2016),showninFigure12.AsmentionedinSection2.1.1thelightsensorswereconnectedtoapull-downresistorandtheinputfromthesensorsgoesthroughtheanalogueinputsA0andA1totheArduinoasillustratedinFigure14.Thepull-downresistorwascalculatedwithEquation1to270Ω.Togetsomedistancebetweenthesensorstheyaremountedontopofthevehiclewithanarrangement similar to the feelers of an insect. Themounting is described further inAppendixB:Thefinishedrobot.
Figure12.LightDependentResistor
3.3.4 ColoursensorThecoloursensorusedinthisprojectwasaTCS34725,asshowninFigure13(Adafruit,2016),whichhasbothRGBandclearlightsensingelements.ThesensorfeaturesanIRblockingfilterthatminimizestheIRspectralcomponentoftheincominglightandallowscolourmeasurementstobemadeaccurately.Sincethehumaneyecan’tseeinfraredlight,the IRblocking filterwillmake the sensingmore realistic.TheRGB-sensorhas7pinslabelled,LED,INT,SDA,SCL,3V3,GNDandVIN.Fortheapplication,SDA,SCL,GNDandVIN pins are used. The serial interface SCL is used to synchronize all data transfersbetween theArduino and the rest of the components,while SDA is the data line. TheconnectionsbetweentheArduinoandsensorareillustratedinFigure14.
Figure13.RGBcoloursensor
16
Figure14.DescriptionovertheconnectionbetweenthesensorsandtheArduino
3.4 Hardware 3.4.1 ChassisThedemonstratorisbasedonafourwheeledrobotchassissuppliedbytheMechatronicinstitution at the Royal Institute of Technology. The chassis features four DCmotorswhichareoperatingbetween3-6V.Thecurrentpowerconsumptionofeachmotorvariesfrom100mAto300mAdependingonrotationalspeedandload(Curriculum,2015).Thechassiswasbuiltwiththreelevels.Thefirstlevelispreparedforthetwobatterypackages,a ZIPPY Flightmax 5000mAh battery pack to supply themotors and a 2200mAhUSBpower bank for the Arduino. On the second level themotor driver and sensorsweremountedandtheArduinowereplacedonthetoplayer.Thelightsensorandthecoloursensorweremountedona3Dprintedconstruction,modelledintheCADprogramSolidEdgeTM.
3.5 Results Thispartcoverstheresultfromthedifferentteststhatweredoneduringtheproject.
3.5.1 LightsensorsThischapterrevealstheresultsyieldedfromtheperformedtests,moreorlessdividedintoparagraphsbasedontheperformedtestsdescribedinSection1.4.The registered sensor output during the test described in Section 1.4.1 are sortedaccordingtothemeasuredluxvaluesandplottedbelowinfigure15.ThefigureshowstheLDRandphotodiodesresponsestodifferentlightintensitylevels.
LDR
LDR
RGB Colour sensor
Arduino UNO
A0A1
SCLSDA
GND
5V
LEDINTSDASCL
VINGND
17
Figure15.Graphoverthelightsensorresponsetodifferentlightintensitylevels
FromthetestdescribedinSection1.4.2,thesensingdistanceoftheLDRwasmeasuredto7minadarkroomandtheresultsofthelightsensorsresponseispresentedinTable1below.Themeasuredvaluesarethenumericalsensorresponsetotheflashlightputatdifferentdistancesfromthesensor.
Table1.TheLDR:sresponsetoaflashlight
Flashlightdistance(m) Litroom DarkroomNoflashlight 345 0
3,0 351 222,5 356 252,0 360 411,5 372 841,0 401 1630,5 446 342
Whendoingthetestonthelightsensorsrange,theambientvaluewas348inthelitroomand0inthedarkroombeforetheflashlightwasturnedon.ThesensoroutputregisteredatdifferentanglesarepresentedbelowinTable2.
Table2.Thenumericalvaluesonthesensingrangetest
Deviation(°) Litroom Darkroom0 394 18811 378 16221 375 14330 367 11338 365 5745 352 4950 350 2354 347 22
020040060080010001200
0 114 175 274 373 462 789 1136 1433 2179134196Numericalsensoroutput
Lux
LDR Photodiode
18
BasedontheresultsdescribedinTable2thesensingrangeoftheLDRwasdeterminedandareillustratedinFigure16.
Figure16.SensingrangeoftheLDR
3.5.2 ColoursensorTheresultfromthetestdescribedinSection1.4.3areratherextensive,whereforethebulkofthedatacanbefoundinappendixA.PlottedbelowinFigure17-Figure19aretheresultsfromthetestswithred,greenandblueobstaclesconductedinalightroom.They-axisshowsthenumericalsensoroutput,andthex-axisshowsthedistancefromthesensormeasuredinmeters.
Figure17.Thecoloursensorsresponsetoaredobstacle.
50°
2 m
7 m
0
50
100
150
200
250
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5
Redobstacle
R: G: B:
19
Figure18.Thecoloursensorsresponsetoagreenobstacle.
Figure19.Thecoloursensorsresponsetoablueobstacle.
050100150200250300350400
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5
Greenobstacle
R: G: B:
050100150200250300350400
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5
Blueobstacle
R: G: B:
20
21
4 DISCUSSIONANDCONCLUSIONS
This chapter summarize and analyse the previous given resultswith a discussion and aconclusion.
4.1 Discussion 4.1.1 LightsensorFromthetheresultinSection3.5.1andthetheorybehindlightsensorsthatwascollectedduringinformationretrievalthemostsuitablelightsensorforatrackingrobotcouldbedeterminedtobetheLDR.ThegraphinSection3.5.1showsclearlythattheLDRhasaquickerresponsetochangesinlightintensity,whichisanecessarypropertyforatrackingrobot. The major difference between the two sensors is probably because the LDRrespondbettertothevisiblelightspectrumthanthephotodiodewhichrespondbetterintheinfraredspectra.The idea of driving the prototype in indoor light was a lot more problematic thanexpected.Somethingthatnotfirsthadbeentakentoconsiderationwasthelightsensorssensibilitytodisturbancesfromvariouslightintheroom,whichbecameaproblemwhentryingtosteertherobot.Inadarkroomthelightsensorsworkedasexpected,thentherobot could sense the lightwithnodisturbances fromother lightor reflections in theroom.ThiswassolvedbyaddingaLEDstriponthefloor,withamuchbrighterlightthanthesurroundedlightanddisturbancesfromvariouslightwerereduced.
4.1.2 ColourssensorThe results from Section 3.5.2 shows only a slightly difference between the sensorsresponseinacompletelydarkroomandalightedroom.FromFigure17-Figure19itcanbedeterminedthatthesensorsensestheredobstacleapproximatelyatthedistance0.7m,thegreenobstacleat0.5mandtheblueobstacleat0.3m.Probablyduetothattheredcolourhasahigherwavelength,asdescribedinSection2.2,whichcontributestoalowerspreadofthecolourintheroom.Theredcolourismoreconcentratedandwillbeseenbythecoloursensorearlier.Thebluecolourhastheshortestwavelengthofthisthreecolourandthereforethebluecolourisdetectedfromtheshortestdistance.Thisresultedintheuseofredandthegreenlightedobjectsasobstacles.Figure17showsthatwhendetectingredlight,theblueandgreenvalueswereverylow,whichisgoodwhentryingtodetectingaspecificcolour.However,thiswillgiveaquitenarrowuseofthiskindoftrackingrobot.Tobeabletobuildacompleteconstructionthatonlyuseslightforselfdriving,agreatvarietyoflightandcolourintensityfromtheobstaclesmustbejudgedotherwiseitwillnotwork.Themeasurementsweredonewithanondrivingvehicle.AccordingtotheresultsfromSection3.5.2thecoloursensorarepossibletosensethecolouredilluminatedobstacleswithinadistancelongenoughtomaketherobotabletoturnandavoidtheobstacleintime. Inpractice itdidn’tworkasexpected.Withadrivingvehicleaproblemwith thecoloursensorandthevehiclesresponsivenesstothesensorsinputoccurred.Thecoloursensorsmeasuredthecolourdifferencestooslowanditresultedinthecrashingintotheobstacle,sinceitwasn’treactingfastenough.Thisproblemwassolvedbychangingthe
22
colour sensors measuring speed to measure faster and the reaction time could bereduced.
4.2 Conclusions Thepossibilitytocontrolarobotbyusingonlylightmaynotbethemostaccurateway.Itis not impossible to follow a track but it is surrounded by certain limitations. It isachievableiftherobotissupposedtofollowacertainlightasaflashlightoralighttrail,but the ability to let the robot freely drive in a normally lit room and seek after thebrightestlightsourceisunattainablewithoutaddingothersensorstoavoidobstacles.Althoughitisnotthebestpossiblewaytoconstructatrackingrobot,couldaconclusionstillbedrawnbasedontheinformationdeterminedduringthisthesis.Forthiskindoftrackingrobot,theLDRwasselectedasthemostsuitablelightsensor.Theabilitytogettherobottoavoidobstaclesbyusingonlycolouredlightwerepossiblewiththeuseofacolour sensor and the colour easiest to detect was the red colour, due to its longwavelength.To sum this up, using light sensing for a tracking robot are an easy and inexpensivemethod,butshouldbeusedasacomplementtoothersensingdevicesnotasastandalonemethod.
23
5 RECOMMENDATIONSANDFUTUREWORK
Thischaptergivesrecommendationsformoredetailedsolutionsandfuturework.
5.1 Recommendations Asdescribedinpreviouschapterthecoloursensorismountedstraightaheadandonthelowerpartofthevehiclewithascreenontopofthesensor.Thismeansthatthelightedobstacles need to be placed at a certain height above the groundwhichmight not bepracticalinreallife.Tosolvethis,moresensorswithawiderrangecouldbeadded.Furtherthecoloursensorwassetinananglethatmightnothavebeenthemostoptimalangleordirection.Calculationandconsiderationofthebestdirectionandangletoputthelightsensorsincouldbeinvestigatedfurther.Asthecoloursensorisalsoalightsensingdevicethesurroundinglightinaroomcouldaffect the sensors signal, as the light contains different colours depending on theenvironment, forexamplelight influorescent lampshasabluerlightthana light-bulb.Thecoloursensorshouldthereforebecalibratedtobeabletoworkindifferentlightedenvironments.Itcanbedonebyputtingawhiteandablackpaperinfrontofthesensorandsetthesevaluesasreferencevaluestotheinputfromthesensor.Thesensorreadingscould then be compared to these values, this way environmental differences anddisturbancesfromsurroundinglightcouldbeavoided.
5.2 Future work The demonstrator and the control system can be improved in a lot of aspects. Aconstruction of a tracking robot using only light is possible, but as described earliercertain limits are required. To construct a complete tracking robot, the demonstratorneedtobeequippedwithmoresensorsandfurtherdevelopedsoftwaretoworkcorrectly.Onemainproblemwiththedemonstratorwhendrivingindoorwithindoorlightwasitsabilityofavoidingwallsandopendoors.Implementinganultrasonicsensororinfra-redsensorcouldbeasolutiontotheproblem.Thedemonstratorshouldalsotobeequippedwithastartandstopsystem.Inaddition, itcouldbeinterestingtofurtherdeveloptheabilitytoregulatethespeedofthevehicle.ThedemonstratorcouldalsobedevelopedwithanIPSsystemforindooruseorGPSforoutdooruse,dependingonitspurpose.Withhelpofthatsystemtherobotcouldscanthelight intensityof adefinedarea andposition itswayback to thebrightest spotof thescannedarea.It’sanideathatcouldbeusedforaself-drivingmower,chargedwithforexamplesolarcells.Insteadofneedingahumaninputtocarrythemowertoitschargingstation,themowercouldonitsownfindthesunandchargeitselfusingsolarcells.Tousethiskindoftrackingrobotinenvironments,notoptionalforhumans,suchasminesorairportswouldalsorequiremoresensors.Fortheuseinamineamappingsystemandalocalnavigationsystemwillbeneeded.Touseitonanairportabettersafetysystemisneeded, AIS system,which is a system to see otherswith AIS systems, and a sensingsystemforafixedreferenceintheground(RL,2016).Areferencesystemintheground
24
willgivetherobotpositioninghelpandalightedlinewillgiveexactprecision.Theconceptwithredandgreencoloursensingcanalsobeusedinshipping lanesfornavigationofautonomousshipsandboats.
25
REFERENCES
Adafruit,2015.Usingaphotocell.Availableat:https://learn.adafruit.com/photocells/using-a-photocell.[Accessed:2016-03-09]
Adafruit,2016.Datasheet-TCS3472.Availableat:https://cdn-shop.adafruit.com/datasheets/TCS34725.pdf.[Accessed:2016-04-19]
ArduinoUno,2016.Arduino–ArduinoBoardUno.Availableat:https://www.arduino.cc/en/main/arduinoBoardUno.[Accessed:2016-04-10]
Arduino,2016.Arduino–PWM.Availableat:https://www.arduino.cc/en/Tutorial/PWM.[Accessed:2016-03-09]
ArtofCircuits,2015.Datasheet-L298N.Availableat:http://www2.st.com/content/ccc/resource/technical/document/datasheet/82/cc/3f/39/0a/29/4d/f0/CD00000240.pdf/files/CD00000240.pdf/jcr:content/translations/en.CD00000240.pdf.[Accessed:2016-03-20]
BusinessInsider,2015.10millionself-drivingcarswillbeontheroadby2020.Availableat:http://www.businessinsider.com/report-10-million-self-driving-cars-will-be-on-the-road-by-2020-2015-5-6?IR=T.[Accessed:2016-04-19]ColorMatters,2016.ColorSystems–RGB&CMYK.Availableat:http://www.colormatters.com/color-and-design/color-systems-rgb-and-cmyk[Accessed:2016–04-17]Curriculum,2015.DC-motors.Availableat:http://curriculum.vexrobotics.com/curriculum/speed-power-torque-and-dc-motors/dc-motors.[Accessed:2016-05-08]ElectronicTutorials,2016.Lightsensors.Availableat:http://www.electronics-tutorials.ws/io/io_4.html.[Accessed:2016-03-21]Elfa,2016.Datasheet-B906032.Availableat:https://www.elfa.se/Web/Downloads/_t/ds/photocells_eng_tds.pdf?mime=application%2Fpdf.[Accessed:2016-03-20]Elfa,2016.Datasheet-TSL252R.Availableat:https://www.elfa.se/Web/Downloads/_t/ds/tsl250r-2r_eng_tds.pdf?mime=application%2Fpdf.[Accessed:2016-02-09]Eriksson,Patrik,2003.Ljus-ochbildsensorer.Availableat:http://www8.tfe.umu.se/courses/elektro/FSE/Kompendier/ljusochbildsensorer.pdf.[Accessed:2016-03-09]
Google,2016.GoogleSelf-DrivingCarProject.Availableat:https://www.google.com/selfdrivingcar/.[Accessed:2016-04-19]
26
JohJoh,KheeBoonandLeong,2006.Usecolorsensorsforprecisemeasurement.OptoelectronicProductsDivisionAvagoTechnologies
MimsIII,ForrestM.AmateurScientist:ExperimentingwithLightandDarkSensors.Availableat:http://makezine.com/projects/make-38-cameras-and-av/light-and-dark-sensors/.[Accessed:2016-03-20]McManis,Chuck,2006.H-Bridge:TheoryandPractice.Availableat:http://www.mcmanis.com/chuck/robotics/tutorial/h-bridge/.[Accessedat:2016-04-17]RL,2016.AIS(AutomaticIdentificationSystem)Decoding.Availableat:http://rl.se/ais_eng. [Accessed at: 2016-05-07]VolvoCars,2016.Autonomousdrivingexplained.Availableat:http://www.volvocars.com/intl/about/our-innovation-brands/intellisafe/intellisafe-autopilot/this-is-autopilot/autonomous-drive-in-detail.[Accessedat:2016-04-17]
I
APPENDIXA:TESTTHREETheresultfromthetestinthedarkroomdescribedinSection1.4.3areplottedbelowinFigureA1-FigureA3.
FigureA1.Thecoloursensorsresponsetoaredobstacleinadarkroom.
FigureA2..Thecoloursensorsresponsetoagreenobstacleinadarkroom.
020406080100120140160180200
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5
Redobstacle
R: G: B:
0
50
100
150
200
250
300
350
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5
Greenobstacle
R: G: B:
II
FigureA3..Thecoloursensorsresponsetoablueobstacleinadarkroom.
0
50
100
150
200
250
300
350
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5
Blueobstacle
R: G: B:
III
APPENDIXB:THEFINISHEDROBOT
FigureB1.Frontalviewofthefinishedrobot
IV
FigureB2.Topviewwithboxesshowingthedifferentcomponents.
FigureB3.Frontwithboxesshowingthedifferentcomponents
V
FigureB4.Sideviewwithboxshowingthemotordriver
ThecomponentsinFigureB2–FigureB4areasfollows:1.ArduinoUNO2.LightDependentResistor3.RGBColourSensor4.3Dprintedconstructionforthesensors5.L298NDualH-bridgeMotorDriverShield
www.kth.se