Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
DEGREE PROJECT IN TECHNOLOGY, FIRST CYCLE, 15 CREDITS STOCKHOLM, SWEDEN 2016
Advanced RC car
Avancerad radiostyrd bil
FILIP LENSUND
JOHAN ERKERS
KTH ROYAL INSTITUTE OF TECHNOLOGY SCHOOL OF INDUSTRIAL ENGINEERING AND MANAGEMENT
i
Thispagehasbeenintentionallyleftblank.
ii
BachelorThesisMMKB2016:31MDAB092
AdvancedRCcar
FilipLensund JohanErkers
Approved
2016-06-07Examiner
MartinEdinGrimhedenSupervisor
NihadSubasic
ABSTRACT This report contains improvementsof the radiocontrolledcarwhich isdevelopinganelectronic differential and a speed controller. The report contains theory of enginemodelling, steering and testing of these theories. Ackerman steering is used to getdifferentsteeringradiusoftheinnerandouterwheelwhencornering.Inordertoregulatethe velocity of the rearwheels they are individually controlled by implementing twoseparatecontrollersoneforeachwheel.TocontrolthesystemPD-controllersisusedforafastrisetime,twotypesofPD-controllersaretested,feed-backandfeed-forward.Ademonstratorwasconstructedtoexecutethetwotests,oneofthetestwastodeterminetheelectronicdifferentialsefficiencybymeasuringthecorneringabilityofthecarwithandwithoutdifferentialatdifferentspeeds.Thesecondtestwasperformedtodeterminewhich regulator gave the fastest controlling of the speed. This by exposing bothcontrollerswithdifferenttestscenarios.Based on our tests the conclusion is drawn that the electronic differential had a verypositiveimpactontheturningradius.Whiletesting,thecontrollersshowedonlyasmalldifference,wherethefeed-forwardcontrollerwasslightlyfasterinsomeofthetests.
iii
Thispagehasbeenintentionallyleftblank.
iv
KandidatarbeteMMKB2016:31MDAB092
Avanceradradiostyrdbil
FilipLensundJohanErkers
Godkänt
2016-06-07Examinator
MartinEdinGrimhedenHandledare
NihadSubasic
SAMMANFATTNING Rapportenbehandlarförbättringaravdenradiostyrdabilenmedfokuspåutvecklingavenelektroniskdifferentialsamtregleringavhastigheten.Irapportenkommerteorikringmotormodellering och styrning, samt tester av dessa teorier. Ackerman-styrninganvändesförattfåolikaradiepåinnerochytterhjulenvidkurvtagning.Förattkunnareglerahasighetenpåbakhjulenindividuelltimplementeradestvåseparataregulatorer.FörregleringavhastighetpåbakhjulenanvändesPD-regulatorerförensnabbstigtid,tvåtyperavPD-regulatorertestadesenfeed-backochenfeed-forward.En demonstratör konstruerades för att möjliggöra tester av forskningsfrågorna. Detförstatestetutfördesförattundersökadenelektroniskadifferentialaxelnsinverkanpåbilens förmåga att ta kurvor i olika hastigheter. Det andra testet genomfördes för attundersöka vilken regulator som gav den snabbade regleringen av hastigheten. Dettagenomattutsättaregulatorernaförolikatestsenarior.Utifråntesternakundeslutsatsendrasattdenelektroniskadifferentialenharenmycketstorpositivinverkanpåbilenssvängradie.Medantesternaavregulatorernaendastgaven marginell skillnad men Feed-Forward regulator var något snabbare i en del avtesterna.
v
Thispagehasbeenintentionallyleftblank.
vi
PREFACE Wewould like to thankour supervisorNihad Subasic for feedbackandour dear friendsSimonGärtnerandAntonDahlquistforthehelpandsupport.
FilipLensund&JohanErkers
Stockholm,June2016
vii
Thispagehasbeenintentionallyleftblank.
viii
NOMENCLATURE Fortheconvenienceofthereaderallthesymbolsandabbreviationshavebeengatheredunderthischapter.
Symbols
Symbol Description
𝜃 Angle of the Ackerman-Steering (degrees)
𝐿# lengthbetweenwheelaxis(m) 𝐿$ lengthbetweenfrontwheels(m)𝑅# Radius outer wheel (m)
𝑅$ Radius inner wheel (m)
𝑋' Estimation(position)𝐾' KalmanGain𝑍' Measuredvalue
𝑋'*# Previousestimation(position)U Voltage(V)R Resisters(ohm)i Current(A)L Inductance(H)𝑒,-. Backelectromotiveforce(V)
𝜏- Torqueproducedbymotor(Nm)𝜏0 TorqueproducedbyWheel(Nm)𝜑- Angle(rad)𝜑- Angularvelocity(rad/s)𝐾2 Armatureconstant(Nm/A)𝐾, Motortorqueconstant(V/A)𝜑0 Velocitywheel(rad/s)𝜑0 Accelerationwheel(rad/s2)𝑟 Radius(m)𝑣 Speed(m/s)𝐽0 Momentofinertiaforwheel(kgm2)𝐽- Momentofinertiaformotor(kgm2)𝑑 Dynamicfrictioncoefficient(𝜇)
ix
N Gearratio𝐾8 Proportionalpartparameter𝐾9 Derivativepartparameter
Abbreviations
CAD ComputerAidedDesignDC DirectcurrentDMP DigitalMotionProcessorDPS Degreespersecond𝐼$𝐶 Inter-integratedCircuitIMU InternalMeasurementUnitKTH KungligaTekniskaHögskolan(RoyalInstituteofTechnology)MATLAB ComputerAidedEngineeringPWM Pulse-widthModulationRC RadiocontrolledRpm Revolutionperminute
x
CONTENTS ABSTRACT........................................................................................................................................................IISAMMANFATTNING......................................................................................................................................IVPREFACE..........................................................................................................................................................VINOMENCLATURE........................................................................................................................................VIIICONTENTS........................................................................................................................................................X1 INTRODUCTION....................................................................................................................................11.1 BACKGROUND.......................................................................................................................................................11.2 PURPOSE...............................................................................................................................................................11.3 SCOPE....................................................................................................................................................................11.4 METHOD................................................................................................................................................................2
2 THEORY...................................................................................................................................................32.1 ELECTRONICDIFFERENTIAL..............................................................................................................................32.2 ACKERMANSTEERING........................................................................................................................................42.3 IMU........................................................................................................................................................................42.4 ENCODER..............................................................................................................................................................52.5 KALMANFILTER..................................................................................................................................................52.6 SMOOTHFILTER...................................................................................................................................................52.7 MODELOFTHESYSTEM......................................................................................................................................52.7.1 ModeloftheDC-motor................................................................................................................................62.7.2 ModeloftheGearboxandWheel............................................................................................................6
2.8 PD-CONTROLLER.................................................................................................................................................72.8.1 TransferfunctionPD-controller.............................................................................................................82.8.2 Pol-placement.................................................................................................................................................92.8.3 Implementation............................................................................................................................................10
3 DEMONSTRATOR................................................................................................................................113.1 PROBLEMFORMULATION...............................................................................................................................113.2 SOFTWARE.........................................................................................................................................................113.2.1 Thesoftwarestructureforthehandunit.........................................................................................113.2.2 Thesoftwarestructureinthecarunit...............................................................................................11
3.3 ELECTRONICS....................................................................................................................................................123.3.1 Microcontroller............................................................................................................................................123.3.2 Battery.............................................................................................................................................................123.3.3 InternalmeasurementunitorIMU.....................................................................................................123.3.4 Xbee...................................................................................................................................................................123.3.5 H-bridge...........................................................................................................................................................133.3.6 DC-motorandgearbox..............................................................................................................................133.3.7 Servomotor....................................................................................................................................................133.3.8 Encoder............................................................................................................................................................133.3.9 Blockdiagram...............................................................................................................................................13
3.4 HARDWARE.......................................................................................................................................................143.4.1 Lasercut..........................................................................................................................................................143.4.2 3D-printed......................................................................................................................................................143.4.3 Soldering.........................................................................................................................................................14
3.5 THEDEMONSTRATOR......................................................................................................................................143.5.1 SteeringwiththeIMU................................................................................................................................143.5.2 Thehandandcarunit...............................................................................................................................15
xi
4 RESULTS................................................................................................................................................164.1 RESULTSFROMTHECORNERINGTEST.........................................................................................................164.2 RESULTSFROMTHETESTOFTHECONTROLLERS.......................................................................................17
5 DISCUSSIONANDCONCLUSIONS...................................................................................................185.1 DISCUSSION.......................................................................................................................................................185.1.1 Partsusedintheproject...........................................................................................................................185.1.2 Results..............................................................................................................................................................185.1.3 Errorsources.................................................................................................................................................18
5.2 CONCLUSIONS....................................................................................................................................................186 RECOMMENDATIONSANDFUTUREWORK...............................................................................196.1 RECOMMENDATIONS.......................................................................................................................................196.2 FUTUREWORK..................................................................................................................................................19
REFERENCES..................................................................................................................................................20APPENDIXA:DATAFROMCORNERINGTEST.....................................................................................22APPENDIXB:DATAFROMCONTROLLERTEST.................................................................................23
1
1 INTRODUCTION This chapter contains an introduction to the project. It will introduce the background,purpose,scopeandmethod.
1.1 Background Theradiocontrolledcar,orRCcarwasinventedin1966byanItaliancompanynamedElettronicaGiocattio.InthebeginningtheRCcarswererunbygasolineornitrogen[1].Todaythecarsrunonelectricityorgasolineandarepopular,funandexcitingtoys.Eversincethebeginning,thecarshavebeencontrolledwithleversorawheelonahandheldremote.TheideaistomakeanewwaytocontrolthecarandotherRC-toysandimplementan electronic differential instead of the classicmechanic differential and implement acontroller for the speed on the rear wheels. Research has been done in the area ofcontrollingthecarwhitanIMUandafewsimilarhobbyprojects[2]havebeenfoundbutnoscientificstudies.
1.2 Purpose Thepurposeofthisprojectistodesignanelectronicdifferential,acontrollerforthespeedofthebackwheelsandanewwaytocontrolaRCcarandotherremotecontrolledvehicles,for example boats and airplanes. The static controller is replaced with an IMU andWirelesscommunicationplacedonthedriver’sarm.ThenewcontrolunitconsistsofanXbee,ArduinoNANOandanIMU[3].TheArduinoandXbeeareplacedontheforearmsonoextraweight isputonthehandwheretheIMUisplaced,thiswillmakeiteasiertomovethehand.Whenthehandistiltedforwardthecarwillgoforwardandifthehandistiltedtoeithersidethecarwillturnrightorleft.TodrivethecarforwardtwoDC-motorsare used. For an exact steering the DC-motors will act as an electronic differential,meaningthatthebackwheelswillhavedifferentspeedswhenturning.Thisthesiswillcoverthefollowingresearchquestions:
• Howwilltheelectronicdifferentialeffectcorneringatdifferentspeeds?• Which control theory will be best for the task, a feed-back or a feed-forward
controller?
1.3 Scope ThisprojectiscompletedforaBachelorthesisatKTHandextendsoveraperiodof16weeks.Theprojectbudgetis1000Swedishcrowns.TocontrolthesystemanArduinoUNOisprovidedbyKTHandisanopensourceplatform.TheArduinoNANO,IMU,H-bridge,DC-motors,servoandwheelshavebeenpurchased.TheKalmanfilter,smoothfilter,encodercounterand𝐼$𝐶bushavebeenobtainedfromopensourcelibraries,andareredesignedsothattheywillworkwiththeelectronicsthatareused.Theobtainedopensourcelibrarieswillbeexplainedbriefly,sincetheyareverycomplex.Thefocusinthisprojectwillbetocreateacontroller(chapter2.7)andmakeanelectronicdifferential.
2
1.4 Method Theprojectstartedwitharesearchabouthowthecomponentsisusedinanefficientandsmartway.Twounitsareincorporated,onehandunitfortheremotecontrolandonecarunit.Betweenthemthereisawirelessconnectiontotransferdatafromtheremotecontrolto the car unit using an Xbee (chapter 3.3.4). To be able to investigate the researchquestionsademonstratorwasmade.Todeterminehowthecarsturningradius isaffectedbyanelectronicdifferential, fourdifferentspeedsweretestedwiththesamesteeringangleandnodifferential.Toachievethefourdifferentspeeds,thePWMsignalweresetto255(maxspeed),205,155and105.10 testwasperformed for each speedand the radiusof the cars routewasmeasured(figure1).Forthetestwithelectronicdifferentialthesamespeedwassetasinthefirsttesttotheouterwheel.Fortheinnerwheelthespeedwassettomatchtheinnerradiusoftheturningcircle.
Figure1.Testoftheturningradius
Thesecondtestwastodeterminewhichcontrollerisbestsuitedforcontrollingthespeedontherearwheels,afeed-backorfeed-forwardcontroller.Thetestwasdividedintofourdifferentscenarios,duringtheteststimeandspeedwasmeasuredusinganencoderandArduinosbuiltintimer.Thefirstscenariowasexecutedbylettingthecaraccelerateduptomaximumspeedfromastandstill.Thesecondtestwastoletthecaraccelerateto50%ofthemaxspeedformastandstill.Thethirdtestwasaccelerationfromaconstantspeedat50%oftopspeeddowntoastop.Thelasttestwasaccelerationfromconstanttopspeedtoastandstill.Allfourscenariosweretestedfivetimesinordertoprovidemoreeventestresults.
3
2 THEORY Thischapterdescribesallthetheorybehindtheproject.Itgivesanunderstandingofhowthedifferentpartswork.
2.1 Electronic differential Whencornering theouterwheel travels a greaterdistance then the innerwheel.Thismeansthattheouterwheelneedsagreaterangularvelocitythentheinnerwheel.Tosolvethisproblemadifferentialisused.Thetwoaxesshaftsinfigure2canrotateatdifferentspeedthankstothedifferentialpiniongear.Thetheorybehinditisthatifoneoftheaxleshaftsrotatesslowerthedifferentialsidegearandpiniongearforcestheotheraxletorotatefaster[4].
Figure2.Mechanicaldifferential[4]
Theelectronicdifferentialusesthesametheoryasthemechanical,butinsteadofusingamechanicaldifferentialtheelectronicusesanindividualelectricmotorforeachwheel.
4
2.2 Ackerman steering TheAckermann-principleisbasedonthattheaxesofthesteeringknucklealwayscuttingthe rearaxis at the samepoint (figure3).Whencornering, the frontwheelswillhavedifferent turning radius, the principle is that thewheelswill have different angels toprevent them from sliding on the surface [5]. To enforce this the angle is calculatedbetweenthesteeringknuckleandthewheelarch(equation1).
𝜃 = arctan𝐿$2 ∙ 𝐿#
(1)
Figure3.Ackermansteeringprincipal.
TheradiusoftheouterandinnerwheelwasdeterminedusingSolidedgeCADandiscalculatedto286mm.
2.3 IMU AnIMUisanelectroniccomponentthatmeasuresthespecificforceandangularrate.TheIMU uses combinations of an accelerometer, which measures force and a gyroscope,whichmeasuresangularvelocitytodeterminethesensormovement.Thesensorsreadthemovementsaroundallthreeaxes.Themovementsaredefinedasroll,pitchandyaw,seefigure4.TheIMUusesadigitalmotionprocessor(DMP)toprocessthedatafromthesensors[3].
Figure4.HowRoll,YawandPitchisdefined.
5
2.4 Encoder Theencoderusestwopulsestodeterminethedirectionoftheturningwheel.TheAandBpulseusesanoffsetasseeninfigure5todeterminewhichwaytheencoderisturning.If theApulsechangesfromhighto lowwhiletheBpulse is lowthemotionis likethearrowinfigure5.IftheApulsechangesfromhightolowandtheBpulseishighthemotionisreversed[6].
Figure5.Pulsetrainoftheencoder[6].
Therearedifferentwaystocountpulses.InthewaydescribedaboveonepulseiscountedwhentheApulsechangesfromhightolow,thisiscalledFalling.ThesecondwaytocountpulsesiswhenAchangesstatefromlowtohigh,thisiscalledRising.ThethirdwayistocountoneverychangesofstateontheApulseandthisiscalledChange.Thebenefitofcountingonchangeisthatthepulsesofeachrevelationwilldouble.
2.5 Kalman filter TheKalmanfilterisanalgorithmthatusesaseriesofmeasurementstomakeapredictionofwhatthenextmeasuredvaluewillbe.Thisisusefulwhenthemeasuredvaluehasalotoffluctuations.TheKalmanfilterusesameanvaluewhichisthevaluethatisthemostlikelyandavariance.Theestimatedvaluetendstobemoreprecisethanthemeasured.Byimplementingequation(2)totheIMU,anaveragemeasurementisreceived[7]
𝑋' = 𝐾'. 𝑍' + 1 − 𝐾' . 𝑋'*# (2)
where the𝐾' is the Kalman gain𝑍' is themeasured value and𝑋'*# is the previousestimation.TheKalmanfilterisusedforfilteringthesignalfromtheIMU.
2.6 Smooth filter SincethedatareceivedfromtheXbee(chapter3.3.4)containsnoise,aSmoothfilter[8]isimplemented.TheSmooth filter isadigital low-pass filter forsmoothingout the inputsignal to the servo. An internal buffer stores data and limits the amount of new dataenteringthesystem.
2.7 Model of the system To be able to calculate the control parameters for the feed-back and feed-forwardcontrollers,amodelofthesystemwasdeveloped.
6
2.7.1 Model of the DC-motor
To describe the model of the DC-motor an example from Control Tutorials [9] wasfollowed.Figure6bellowshowstheDC-motorscircuit.
Figure6.ModelofaDC-motor.
The supplyvoltage isU.RandLare themotor resistanceand inductance,𝑒,-. is theinducedmotorvoltageandithecurrent.𝜏-isthetorqueproducedbythemotor,𝜑-theangleand𝜑-istheangularvelocity,bisthedynamicmotorfrictionandJmisthemotorsmomentofinertia.AccordingtoKirchhoff’slaw[9]thevoltageUcanbedescribedas
𝑈 = 𝑅𝐼 + 𝐿𝑑𝑖𝑑𝑡 − 𝑒,-.
(3)
andthetorqueisgivenby[9]
𝜏- = 𝐾2𝑖 (4) where𝐾2isthearmatureconstantandtheback𝑒,-.isgivenby
𝑒,-. = 𝐾,𝜑- (5)
where𝐾, isthemotortorqueconstantwhichisequalto𝐾2so𝐾 = 𝐾, = 𝐾2 .
2.7.2 Model of the Gearbox and Wheel
Theangularvelocity𝜑0onthewheelontheoutgoingaxisfromthegearboxisgivenby[8]
𝜑- = 𝑛𝜑0 (6) andthetorqueisgivenby
𝜏- =1𝑛 𝜏0
(7)
Figure7.Motoraxisintothegearboxandwheelaxisoutofthegearbox.
7
where𝜑-istheanglevelocityonthemotorshaft,𝜑0istheanglevelocityonthewheelaxisand𝑛thegearratioofthegearbox.Forthewheelinfigure7thespeed𝑣andtorque𝜏0isgivenby[10][9]
𝑣 = r𝜑0 (8)
𝜏0 = 𝐽0𝜑0 + 𝑑𝜑0 (9)
whererbeingtheradiusofthewheel,𝐽0themomentofinertiaanddthedynamicfrictioncoefficientofthewheel.
Figure8.Aturningwheel.
Theparametersforthesystemcanbefoundintable1.
Table1.Motordata.
Symbol Value ReferenceResistance R 4Ω MeasuredVoltageconstant 𝐾, 176,9 ∗ 10*T𝑉/𝐴 CalculatedArmatureconstant 𝐾2 176,9 ∗ 10*T𝑁𝑚/𝐴 CalculatedMotormomentofinertia 𝐽- 212,1 ∗ 10*T𝐾𝑔𝑚$ SolidedgeCADWheelmomentofinertia 𝐽0 51013 ∗ 10*T𝐾𝑔𝑚$ SolidedgeCADGearratio N 48 Datasheet
2.8 PD-controller ThereasontouseaPD-controllerwasthatthedriverwillcorrectanytypeofstaticerrorand a fast rise time is required. Two types of control theorywill be tested, feed-backcontrolfigure9andfeed-forwardcontrolfigure10.Boththeoriesareusingtheerror𝑒(𝑡)whichisthedifferencebetweenthereferencesignal𝑟(𝑡)fromtheIMUandthecalculatedspeed𝑦(𝑡).Thedifferencebetweenthetwotheoriesisthatfeed-forwardnotonlyusestheerror𝑒(𝑡),italsomakesaneducatedguessaboutwhattheoutputsignal𝑢(𝑡)shouldbe.Thecontrolfunctionforthefeed-forwardis𝐹.. 𝑠 = 1/𝐺(𝑠).Theoutputsignal𝑢 𝑡 foraPD-controlleris[11]
𝑢 𝑡 = 𝐾8𝑒 𝑡 + 𝐾9𝑑𝑑𝑡 𝑒(𝑡)
(10)
𝐾8and𝐾9areparametersthatcanbechangedtogetthesystemtobehaveasdesired.
8
Theparameter𝐾8determineshowthecontrollerreactsproportionaltotheerrorand𝐾9determineshowthecontrollerreactsonthederivativeoftheerror.Thetransferfunction𝐺(𝑠)andhowtoobtainitisdescribedandcalculatedinchapter2.8.1.
Figure9.Feed-backcontrol.
Figure10.Feed-forwardcontrol.
2.8.1 Transfer function PD-controller
Thetransferfunctionis
𝐺 𝑠 =𝑉 𝑠𝑈 𝑠
(11)
where𝑉 𝑠 isthevelocityand𝑈 𝑠 istheoutputvoltage.Toobtainthetransferfunctionthemodelandequationsinchapter2.7areused.Thetorqueofthemotorcanbewrittenas[9]
𝜏- = 𝐽-𝜑- + 𝑏𝜑- (12)
Equations3,4,5and12areused,withtheassumptionthattheinduction𝐿 ≈ 0thenthemotionofthemotorcanbedescribedas
𝐽-𝜑- + 𝑏𝜑- =𝐾𝑅 𝑈 + 𝐾𝜑- (13)
Todescribethemotionofthewheeltheequations6,7,8and9areusedin13
𝜑0 + 𝜑0𝑛𝐾$ + 𝑑
𝐽0= 𝑈
𝑛𝐾𝐽0𝑅
(14)
Laplacetransformation[12]ofequation8and13gives
𝑉(𝑠) = 𝑟𝑠𝜑0(𝑠) (15)
9
𝑠$𝜑0 𝑠 + 𝑠𝜑0 𝑠𝑛𝐾$ + 𝑑
𝐽0= 𝑈 𝑠
𝑛𝐾𝐽0𝑅
(16)
byusingandsimplifyingequation11,15and16thetransferfunctionisobtained
𝐺 𝑠 = fghijklml(gnmo)
- (17)
2.8.2 Pol-placement
Therequirements for thecontroller is tomake it as fastaspossible,withouthavingasystemthatoscillates.Theclosedloopsystemcanbedescribedas[13]
Figure11.Feed-backcontrol.
Thetransferfunctionisequalto[13]
𝐺ph 𝑠 =𝑆𝐴
𝐴𝑅 + 𝐵𝑆 =𝑆𝐴𝐴-𝐴s
. (18)
wheretheoutputsignalfromtheregulatorcanbewrittenas
𝑢 𝑡 =𝑆𝑅 (𝑟 𝑡 − 𝑦(𝑡)) (19)
Equation17andfigure9gives
𝐵𝐴 =
𝑛𝐾𝑟𝑠𝐽0𝑅 + 𝑅(𝐾$ + 𝑑) (20)
andforthecontrollerfunctionforthefeed-back𝐹.t(𝑠)
𝑆𝑅 =
𝑃𝑠 + 𝐷𝑠 + 𝑟s
(21)
Fromthistheequation22isobtained
𝐴wx = 𝐴𝑅 + 𝐵𝑆 (22) were𝐴-isapolynomialthathavethesameorderasAand𝐴wx isapolynomialofthesameorderas𝐴-𝐴s.Thepoles𝛼and𝛽canthenbechosenas
𝐴- = 𝑠 + 𝛼 (23)
𝐴s = 𝑠 + 𝛽 (24)
10
Bychoosing𝛼 = 1and𝛽 = 5thesystemhasarisetimeof6,58 ∗ 10*|secondsthismeetstherequirementsofthedesiredsystem.Infigure12,astepresponsefortheclosedloopsystemisshown.
Figure12.Stepresponsefortheclosedloopsystem.
2.8.3 Implementation
Themicrocontrollerworksindiscretetimestepssothecontrollerfunctionforthefeed-backandfeed-forwardmustbediscretized.ThisisdoneusingTustinsapproximation[14]
𝑑𝑢𝑑𝑡 = Δ2𝑢(𝑡) (25)
whereΔ2𝑢(𝑡)is
12 (Δ2𝑢 𝑡 + Δ2𝑢 𝑡 − 𝑇 ) =
1𝑇 (𝑢 𝑡 + 𝑢 𝑡 − 𝑇 ) (26)
wereTbeingthesampletime.WhitcalculationsinMATLABthisgivesthediscretesystemforthefeed-back(equation27)andfeed-forward(equation28)
𝑢.t = 𝑎#𝑒 𝑡 + 𝑏#𝑒 𝑡 − 𝑇 − 𝑐#𝑢(𝑡 − 𝑇) (27)
𝑢.. = 𝑎$𝑒 𝑡 + 𝑏$𝑒 𝑡 − 𝑇 − 𝑐$𝑢(𝑡 − 𝑇) (28)
weretheconstantscanbefoundintable2.
Table2.constantsoftheoutputsignalforfeed-backandfeed-forward.
𝑎# 14,47𝑏# -14,10𝑐# 0,65𝑎$ 0,08𝑏$ 0,02𝑐$ 1
11
3 DEMONSTRATOR Thischapterdescribestheproblemswhichwillbefacedwhenbuildingthedemonstrator,anditdescribesthesoftware,electronicsandhardwarethatareused.
3.1 Problem Formulation Togetafunctionaldemonstratorthefollowingproblemsweretobesolved.
• Theweightofthehandunitmustbelight.• Thepartsonthecarmustbestrongsotheydonotshatterwhencollidingwith
objects.• Thefrontwheelsmusthavedifferentturningradius.• Thespeedmustbeindividuallycontrolledonthebackwheels.
3.2 Software Thesoftwareisdividedintotwosubsystems,oneforthehandunitandoneforthecar.ThePrograminglanguagesforbothunitswasprimarilyC.
3.2.1 The software structure for the hand unit
ThesoftwareforthehandunitrunsonanArduinoNANO.Thehandunitstartstoreadtheroll (X-axis)andthepitch(Y-axis) fromthe IMUgyroscopeandaccelerometer therollrepresentingthesteeringandthepitchrepresentingthedrivingsignals.The incomingdatafromtheIMUisfilteredthroughanopensourceKalman-filter(chapter2.5).Therolland pitch angle is rescaled to PWM-signals and transmitted to the car by the Xbeetransmitter(figure13).
Figure13.Flowchartoftheprogramonthehandunit.
3.2.2 The software structure in the car unit
ThesignalsfromtheXbeetransmitterarereceivedbytheXbeereceiver.ThePWM-signalsarethensmoothedoutthroughanopen-sourcelowpassfilter(chapter2.6)toeliminateanynoisecausedbytheXbeecommunication.ThePWM-signalforcontrollingthesteeringisprocessedand sent to the servo (chapter3.3.7).Whencornering,both steeringanddrivinginputsarenecessaryforcalculatingtheindividuallyspeedforeachbackwheeltocreatetheelectronicsdifferential(chapter2.1).ThebacktiresareindividuallycontrolledbytwoPD-controllersforthespeedcontrolthatwasdevelopedandtestedinMatlab.Theoverallstructureofthesystemisdescribedintheflowchartbelow(figure14).
12
Figure14.Flowchartofthecarprogram.
3.3 Electronics Oneachunitthereisacoupleofelectricalcomponents.Below,allelectricalcomponentswill be reviewed. In chapter 3.3.9 are two figures which contains flowcharts of thecomponentsoneachunit.
3.3.1 Microcontroller
TocontrolthesystemonthecaranArduinoUNO[15]isuse.ItisanopensourceplatformandusesC/C++languageandhasaclockspeedof16MHz.Theboardhas14digitalpinswhichcanbeusedasinputsoroutputs,italsohas6analoginputs.OnthehandunitanArduinoNANO[16] isusedandtheNANOboardhasthesamelayoutastheUNO.ThedifferencebetweentheboardsisthattheNANOhas8analogpins.TheUNOispoweredwith7,4VandtheNANOwith9V.
3.3.2 Battery
Astandard9ValkalinebatterywillpowertheArduinoNANOonthehandunit.Thebatteryonthecarisa7,4VlithiumbatteryandwillpowerthemotorsandtheArduinoUNO.
3.3.3 Internal measurement unit or IMU
TheIMUisaninertialmeasurementunitoftypeMPU-6050[3]andcanmeasureanglesandaccelerationupto±2000𝑑𝑝𝑠(degreespersecond)and±16𝑔inthreeaxes.Thisismuchfaster thannecessarysotherefreshratewasset to±200𝑑𝑝𝑠and±2𝑔 togiveamore exact reading. The IMU has six degrees of freedombut to solve the problem ofdrivingandsteeringthecaronly fourwillbeneeded(twoangles in theplaneandtheacceleration).
3.3.4 Xbee
ForthewirelesscommunicationasystemoftwoXbeesseries2[17]areused.OneoftheXbeesisconfiguredascoordinatorandthisunitreceivesthedatatothemicrocontroller.Theotheroneisconfiguredasendpoint,thisXbeetransmittheoutputsfromtheArduino
13
NANO.TheXbeesareusingZigbeeforthewirelesscontrolwithafrequencyat2,4GHz.Thesemodulesareveryenergyefficientandhavearangeof40metersindoorsandupto100metersoutdoors.
3.3.5 H-bridge
TheH-bridge[18]isadualmotordriveandmakesitpossibletodrivethemotorsinbothdirections.Ithas2inputsand2outputsforeachmotor.ByusingthePWMsignal[19]thevoltagetothemotorcanbecontrolled.Withcontinuousdriving,theoutputcurrentcanbeupto1,5Ampereandpeakscanbeupto2Ampereforashortperiodoftime.
3.3.6 DC-motor and gearbox
TheDC-motorsandgearbox[20]areoftypeDG02Sandcanbedrivenonvoltagesfrom0-8Vandhaveanoloadcurrentof125mAandanoloadspeedof140rpm.Thegearboxhasagearratioof48:1.
3.3.7 Servo motor
Theservomotor[21]isusedforthesteeringofthecar.IntheservothereisaDC-motorandgearboxwithahighgearratio.Tocontroltheoutputangle,theservousesitsowncontroller.Theservohasarangeof180degreesandrunsat5V.
3.3.8 Encoder
TomeasurerthespeedofeachwheelanencoderoftypeM,512CPT[22]isplacedontheaxisofthewheel.Ithas2channelsandanA-,andB-pulsewith512pulsesperrevolution.Thismakesispossibletodeterminewhichwaythewheelsareturningandhowfastbycountingthepulsespertimeunit.
3.3.9 Block diagram
Figure15andfigure16showsablockdiagramofalltheelectronicpartsonthehandunitandcarunitandhowtheyworktogether.
Figure15.Handunitwiththecomponents.
Figure16.Carunitwiththecomponents.
14
3.4 Hardware Themethodsofcreatingthedifferentcomponents forthedemonstratorarepresentedbelow.Thefourwheelsandthegearsfortheencoderwerepurchased.
3.4.1 Laser cut
Thebaseofthecarwasmadefrom6mmthickacrylicplastic.Theshapeandsizeofitisoptimisedsothatallthecomponentswillhaveanarrowfitandthecariskeptsmall.
3.4.2 3D-printed
TheholderfortheArduinoUNO,servoandbatteryis3D-printed.Tofastentheholderonto thebaseof thecar theholder isglued.Theholder for theXbee,ArduinoNANOandbatteryare3D-printedaswellastheholderfortheIMU.Thebenefitsof3D-printingarethatthepiecesarelightandeasytomake.
3.4.3 Soldering
Thecircuitboardforthehandandcarunitwasmadefromaperfboard.Theperfboardisforprototypingelectricalcircuits.Ithaspremadeholesandhasgoodfunctionality.
3.5 The demonstrator 3.5.1 Steering with the IMU
Figure17showshowtooperatethecarwiththeIMUplacedonthehand.
Figure17.Topleft:forward,topright:rightturn,bottomleft:break/back,bottomright:leftturn.
15
3.5.2 The hand and car unit
Thefinalresultofthehandandcarunitisshownbelowinfigure18.
Figure18.Handandcarunit
16
4 RESULTS Theresultsofthetwotestarepresentedinthischapter.
4.1 Results from the cornering test Infigure19thetestresultsfromnoelectronicdifferentialarepresented.All10differenttestsofeachspeedisdisplayedaswellastheaverageturningradius.
Figure19Turningradiuswithoutelectronicdifferential.
All10differenttestisdisplayedandtheaverageturningradiusisdisplayedinfigure20.Onlyonetestwasexecuted,thisbecauseofthenearperfectresultatmaximumspeed.Testsatlowerspeedswasunnecessary.
Figure20Turningradiuswithelectronicdifferential.
17
Table3.Averageturningradiusandpercentimprovementwithdifferential.
AverageradiusNodifferential[mm]
Averageradiuswithdifferential[mm]
Percentimprovementwithdifferential[%]
PWM255 846 298 64,8Table3showstheaverageradiusinthetwodifferenttestsformaximumspeed.ForallmeasureddataseeappendixA.
4.2 Results from the test of the controllers Theresultsfromthetestsofthecontrollersperformanceareshowninfigure21.Thebluelines represent the feed-back controllers average test performance and the red linesrepresentthefeed-forwardsaveragetestperform.Theplotoftest1isfrom0%to100%ofthemaxspeed,test2isfrom0%to50%ofthemaxspeed,test3isfrom50%ofthemaxspeedto0%andtest4isfrom100%ofmaxspeedto0%.Withtimeinmillisecondsonthex-axisandspeedmeasuredinrad/sonthey-axis.TheexactdatafromthetestscanbefoundinappendixB.
Figure21.Plotoftheaveragetestresultsfromthefeed-errorandfeed-backcontroller.
18
5 DISCUSSION AND CONCLUSIONS Inthischapterconclusionsaredrawnfromthetestsinpreviouschapterandtheprojectisdiscussed.
5.1 Discussion 5.1.1 Parts used in the project
• The DC-motors that drives the car should have been of better quality. It wasdifficult to find information and a datasheet of the motors. The associatedgearboxesforthemotorshasahighgearratio,whichleadstoalowspeed.
• Thebatteryusedon the car is large andhas ahigh capacity.Thebetter choicewouldbetohaveasmallerbatterytosavespaceandweightonthecar.
• The angle velocity for the servo is low, this means that the steering is not soresponsive.
5.1.2 Results
• IntheorytheFeed-forwardcontrollershouldperformbetter[23]becauseitusesboththefeed-backandfeed-forwardsignalasdescribedinchapter2.8.Onereasonfor thismay be bad components and primarily themotors due to inconsistentperformance,anotherreasonisthatthemodelofthesystemisnotentirelycorrect.
• The variation in the test results of the electronic differential could have beenaffectedbythesurfacethecarwastestedon.
5.1.3 Error sources
• The two different motors have different speeds for the same PWM-signal orvoltage,thereforetheresultsofdrivingwhiteoutdifferentialonaconstantPWM-signalcanhaveanerrormargininthemeasurements.
• Formodellingofthesystemthemomentofinertiaforboththemotorandwheelare calculated in Solid edge CAD. The partsmade in Solid edge CAD are not aperfectreplicaoftherealmotorsandthisaffecttheparametersofthecontroller.
5.2 Conclusions Conclusionsafterconductingtestsonthedemonstratorandanalysingthedata.
Howwilltheelectronicdifferentialeffectcorneringindifferentspeeds?
Fromthetestinchapter4.1theconclusiontobedrawnisthattheelectronicdifferentialwillclearlyhelpthecartotakethecornerataradiusclosertothecalculatedturning
radius.
Whichcontroltheorywillbebestforthetask,afeed-errororafeed-forwardcontroller?
Fromthetestinchapter4.2theconclusionisthatthereisnotabigdifferenceinresults,partfromtest2figure21whereitisclearthattheFeed-forwardcontrolleris
75Msfastertoachieve50%ofmaxspeedandmorestable.
19
6 RECOMMENDATIONS AND FUTURE WORK Recommendationsformakingtherobotandthingsthatcouldbemadeinthefuture.
6.1 Recommendations ForbuildingademonstratorlikethisanArduinoisrecommendedduetotheopen-sourcelibraries.ItiseasytofindcodefortheXbee,IMUandotherelectricalcomponents.Itisfuntomakethemechanicalpartsforthedemonstratorbutitrequires3D-printersandlasercutters, if not available the parts can be bought in various stores. When selectingelectronicparts,itisrecommendedtobuyqualityproductsthatareaccurateratherthencheapercopies.ForchoosingDc-motorsforaprojectlikethisitisrecommendedtochoosemotorsofgoodqualityandgooddatasheets.
6.2 Future work Thebaseofthecarunitcouldbewidersothatthecargetsalowercentreofgravity.Theclearinginbetweenthepartsofthesteeringcouldbetighter,thiswillgiveamoreexactsteering.Anothertypeofconstructionofthesteeringcouldbechosensothatthesteeringwould be faster. For a greater speed of the car a DC-motor with higher rpm isrecommended.Topreventthecarfromdrivingintoobjectsanultrasonicsensorcouldbefittedtotheroofonthecar.Thehandunitcouldusea flexiblecablebetweentheIMUholderandthebattery/Xbee/ArduinoNANOholder.Theholderforthebattery,XbeeandArduinoNANOcouldbesmallersothatitwillbelighterandmorecomfortable.Tomakethecontrollerfaster,astatespacecontrollercouldbeconstructed.
20
REFERENCES 1. HistoryofRadioControlledCars.Availableat:
http://www.classic.rc-junkies.net/?page_id=637[Accessed:2016-02-23]
2. Inspirationproject,2015-11-03.Availableat:https://developer.mbed.org/users/Xiaofei/notebook/imu-controlled-robot/[Accessed:2016-02-23]
3. Invensense,MPU-6050,2011-10-24.Availableat:https://cdn.sparkfun.com/datasheets/Components/General%20IC/PS-MPU-6000A.pdf[Accessed:2016-02-23]
4. Mechanicaldifferential.Availableat:http://constructionmanuals.tpub.com/14050/css/Figure-11-17-Typical-differential-and-axle-assembly-with-ring-and-pinion-272.htm
5. Encodertheory.Availableat:
https://www.pjrc.com/teensy/td_libs_Encoder.html[Accessed:2016-04-23]
6. Ackermansteering.Availableat:http://www.rctek.com/technical/handling/ackerman_steering_principle.html[Accessed:2016-04-25]
7. KalmanFilter,2015-08-11.Availableat:http://www.bzarg.com/p/how-a-kalman-filter-works-in-pictures/[Accessed:2016-04-16]
8. SmoothFilter,2007.Availableat:http://playground.arduino.cc/Main/Smooth[Accessed:2016-03-12]
9. ControlTutorialDC-motor.Availableat:http://ctms.engin.umich.edu/CTMS/index.php?example=MotorSpeed§ion=SystemModeling[Accessed:2016-04-10]
10. MaskinelementHANDBOK2008vol.1.Instutionenförmaskinkonstuktion,KTH. pp.7
11. Reglerteknik,grundläggandeteori2015vol.4:13.TorkelGlad&LennartLjung. pp.19
12. Reglerteknik,GrundläggandeTeori.2015vol.4:13.TorkelGlad&LennartLjung.pp.232
13. DynamicsandmotioncontrolLieFenghttps://www.kth.se/social/files/56b9a1f9f2765457b115e464/C3_Feedback_2016.pdf
21
14. Reglerteknik,GrundläggandeTeori.2015vol.4:13.TorkelGlad&LennartLjung.pp.211
15. ArduinoUNOBoard.Availableat:https://www.arduino.cc/en/main/arduinoBoardUno[Accessed:2016-02-10]
16. ArduinoNANOBoard.Availableat:https://www.arduino.cc/en/Main/ArduinoBoardNano[Accessed:2016-02-10]
17. BuildingWirelessSensorNetworks.2011vol1.RobertFaludipp3,25-31.
18. H-bridgeDatasheet,2015-07.Availableat:http://www.ti.com/lit/ds/symlink/drv8833.pdf[Accessed:2016-04-25]
19. PWMsignalAvailableat:https://www.arduino.cc/en/Tutorial/PWM[Accessed:2016-04-28]
20. DC-motor.Availableat:http://www.dagurobot.com/goods.php?id=86[Accessed:2016-04-28]
21. Servomotor,2011-10-24.Availableat:https://www.parallax.com/sites/default/files/downloads/900-00005-Standard-Servo-Product-Documentation-v2.2.pdf[Accessed:2016-03-10]
22. Encoder,2015-04.Availableat:http://www.maxonmotor.com/medias/sys_master/root/8816813441054/15-353-354-EN.pdf[Accessed:2016-04-27]
23. ControlSystemDesignLecturenotesforKarlJohanÅström,EngineeringUniversityofCalifornia,SantaBarbara2002.http://www.boti.oil.gov.iq/book/english%20ebooks/%D8%A7%D9%84%D9%83%D9%87%D8%B1%D8%A8%D8%A7%D8%A1/control%20sys/CSYS%20%203-Control%20System%20Design.pdf[Accessed:2016-03-10]
22
APPENDIX A: DATA FROM CORNERING TEST Datafromthecorneringtest.
WithoutDIFF(mm)
WithDIFF(mm)
Testnr
PWM255
PWM205
PWM155
PWM105 PWM255
1 1305 1010 630 294 3202 1374 976 617 280 3003 1354 1005 636 270 2954 1522 943 643 268 3105 1499 947 605 276 3156 1535 920 575 258 2807 1350 962 570 280 2958 1390 1022 576 284 2959 1060 947 578 260 30510 1070 945 572 268 270
23
APPENDIX B: DATA FROM CONTROLLER TEST Datafromthecontrollertest.
24
TRITA MMKB 2016:31 MDAB092
www.kth.se