Over the past decade, mobile robots have penetrated publicspacessuchashospitals,schools,andordinaryhomes, movingawayfrommilitaryandindustrialcorridors.While manyoftheserobotsforcivilpurposesaretechnicallystable, such as 'Aibo,' the Sony robotic dog, or four wheeled intelligentvacuumcleaners,theSegwaypersonaltransport isonethateverydayonlookerswouldfindawe inspiring.It's amechanicallyunreliable,two wheelself balancingmodeof transportation that's been used by police enforcement, tourists,andindividuals.TheSegwaymightbeclassifiedasa robot since it can never stay upright without the sensory capabilitiesandadvancedcontrolsthatcomewitharobot. WhiletheSegwayisawell knowncommercialproduct,there hasbeenalotofstudyonhowtooperatesuchamechanical device.
Volume: 09 Issue: 03 | Mar 2022 www.irjet.net p ISSN: 2395 0072 2022, IRJET Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal 1056

AsidefromtheSegway,therehasbeenalotofstudyon two wheel self balancing robots. JOE [1] and nBot [2], for example,arebothearlyversionsfeaturinginertiasensors, motorencoders,andonboardmicrocontrollers.Sincethen, there has been significant research on control design for suchsystems,includingnonlinearbacksteppingcontrols,PID controllers, application of discrete Kalman filters, fuzzy neural control, Linear quadratic regulators (LQR), and combinationsoftheaforementioned[3][4].Todealwiththe equilibriumproblemposedbywheeledinvertedpendulums, several intelligence approaches have been developed, including fuzzy control [5][6], control systems based on support vector machines [7], operant conditioning theory [8,]andsoon.
Mr. Rajvardhan Shendge1, Mrs. Tejashree Shendge2
2Student, Electronics and Telecommunication Engineering, Fr. C. Rodrigues Institute of Technology(India) ***
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056
1Student, Computer Engineering, Ramrao Aidik Institute of Technology(India)
Abstract- The design, manufacture, andimplementationofa revolutionary controlsystem for atwo wheeledself balancing robot are covered in this research paper. A pair of DC motors, anArduinoUnoR3 microcontroller board, a 3 axis gyroscope, anda 3 axis accelerometer (for altitude measurement)areall part of the system design (employed for altitude determination). The two wheeled robot that was constructed is essentiallya real time modelofaninvertedpendulumopen loop system that is inherently unstable without feedback control and has nonlinear dynamics. The recommended balancing solution entails utilizing the backpropagation algorithm to train a feedforward neural network to learn to balance the bot through supervised learning on the basis of a training routine that runs at startup. In addition, gyro drifts are compensated for using the linear quadratic estimation technique (LQE) and a complementary filter. Our findings demonstrate that the suggested feedforward neural network balancing approach can learn to balance the bot in a short amount of time, with far less oscillations around the equilibrium point than a traditional PID controller, resulting in a more elegant system. Our bot is a modest, low cost prototype that demonstrates artificial neural networks' (ANNs) efficiency and complex learning capabilities (ANNs).
| Page
The wheeled mobile robot and the inverted pendulum mechanismarecombinedin thetwo wheeled robot[9]. It also entails the idea of establishing a mode of human transportation. The inverted pendulum is a dynamically unstable and nonlinear open loop system with a single input,multi outputsystemconfiguration(SIMO),inwhich thesystem'scenterofmassislocatedabovethepivotpoint. As a result, this system has become a classic problem in dynamics and control theory, and it is often used as a benchmark for assessing control system solutions. The wheeled inverted pendulum is not self propelled and requires human balancing to remain upright. It uses gyroscopesandaccelerometerstodetecttheinclinationof theverticalaxis,andthecontrollerprovidestorquesignals toeachmotortocounteracttheinclinationandpreventthe systemfromfalling.It'sacontrolsystemparadigminwhich anitemcanonlybechangedbyaddingmoreweighttoit.As aresult,wheeledinvertedpendulumshavebecomeanew topic, and developing balancing algorithms to solve their equilibrium problem has piqued the interest of many specialists.Although
therearemanystudiesinthisfield,onlyafew havefocusedonmakingmeaningfulcomparisonsbetween traditional control system techniques like PID controllers and LQR feedback controllers and the relatively new artificial intelligencebasedneuralnetworkcontrollers.That ispreciselywhatweareaimingfor.Wewillinvestigatethe self balancing system using dynamic theory, establish a mathematicalmodel,andexplainthebehavioroftheneural netinthemostdetailedandclearmannerpossible,aswellas
©
Design and Implementation of a Self-Balancing Two-Wheeled Robot Driven by a Feed-Forward Backpropagation Neural Network
Key Words: Two Wheeled robot; Self Balance control; Proportional Integral Derivative Controller; Kalman Filter; Arduino Uno R3; Digital Motion Processing (DMP); Backpropagation Algorithm; Feedforward Neural 1.INTRODUCTIONNetwork.
|
6. JUMPERWIRES:Wiresthatconnectmalestomales andfemalestomales.
1. ACRYLIC SHEET CHASIS: Our frame is made out of acrylicsheets.Toholdourthree tieredstructurein place,weusedmetallicrodswithadiameterof3mm. Thegyroscopesensorand9Vbatteriesarehousedin theupperhalf.TheArduinoUnoR3microcontroller board and another 9V battery are located on the middlesheet.Finally,thedrivermotorcontrollerand two DC geared motors are housed in the bottom layer.
3. MOTORCONTROLLER:TheL298Nmotorcontroller is a dual H bridge motor driver that allows us to regulatethespeedanddirectionoftwoDCmotorsat thesametime.ThemodulecanrunDCmotorswith voltagesrangingfrom5to35Vandpeakcurrentsof upto2A.
Volume: 09 Issue: 03 | Mar 2022 www.irjet.net ISSN: 2395 0072 Factor value: 7.529
2. CONSTRUCTION OF THE ROBOT
5. ARDUINO UNO R3: The Arduino Uno R3 is a microcontroller board that uses the ATmega328P header,crystal,PWMdigital(datasheet)microcontroller(datasheet).Thereare14input/outputpins(sixofwhichmaybeusedasoutputs),sixanaloginputs,a16MHzquartzaUSBconnection,apowerconnector,anICSPandaresetbuttonontheboard.
© 2022, IRJET | Impact
e
2. MOTORS:Themotorswe'veselectedarestandardDC gearedmotorsthatrunon12Vandprovide1.5kg cm oftorqueat300rpm.
4. GY 521MODULE:Thismodulemeasurestherobot's tiltangle.Thevaluesofthesamearecalledusinga function. The MPU 6050 MEMS (Microelectromechanical system) has a 3 axis gyroscope,a 3 axis accelerometer, a digital motion processor(DMP),andatemperaturesensor.TheGY 521moduleisa breakoutboardfortheMPU 6050 MEMS (Microelectromechanical system). Complex algorithmsmaybecomputeddirectlyontheboard using the digital motion processor. Typically, the DMPrunsalgorithmsthatconvertthesensor'sraw data intoaccuratelocationdata.Thesensordatais gathered via the I2C serial data bus, which only requirestwowires(SCLandSDA)(SCLandSDA).We used the MPU6050 Arduino library, which has reverse engineered functions that calculate yaw, pitch,androllusingtheDMPon boardtheMPU6050.
| ISO 9001:2008 Certified Journal | Page1057
International Research Journal of Engineering and Technology (IRJET) ISSN: 2395 0056

createasimulationthatdemonstratesitsfunctionalityand efficiency.
Fig. 1: Schematicmodelforawheeledinvertedpendulum

Fig. 2: Frontviewofconstructedrobot
Fig. 3: Topviewofconstructedrobot

p

3.2 FEEDFORWARD NEURAL NET APPROACH

Research Journal of Engineering
|
AlgorithmtoadjustKp,KiandKdvalues:
In order to reverse engineer the DMP (Digital Motion Processing)algorithmoftheGY 521BreakoutBoard,which uses the InvenSense MPU 6050 6 Axis Accelerometer and GyroscopeModule,weusetheKalmanfilter,alsoknownas
Volume: 09 Issue: 03 Mar 2022 www.irjet.net ISSN: 2395 0072
6:
3. ALGORITHMS USED
Fig 5: PIDControllerBlockDiagram
Fig CircuitSchematic
•Ifthefirstattempt does notprovidesatisfactory results, resetthePIDsettingsandrepeatthetechniqueaboveuntil yougetasatisfactoryresult.
3.1 PID CONTROLLER APPROACH


•WemodifythevalueofPaftersettingtheIandDtermsto 0 so that the robot begins to oscillate around the mean position. P should be large enough for the robot to move aboutin,butnottoolargethatithinderssmoothmovement.
4:
e
Therobotshouldbeabletobalanceitselfforatleastafew secondsifPandIareadjustedcorrectly.
•Duringfinetuning,thePIDvaluesareconfinedtonearby values,andtheireffectsareseeninreal worldsituations.
Weinvestigatetwostrategiesforkeepingtherobotupright. ThefirstmethodistouseaPIDcontroller.TheProportional Integral Derivative controller (PID) is a feedback control loop mechanism that is widely used in industrial control systems and a variety of other applications that need continually modulated control [10]. The PID controller continuously calculates an error value as the difference betweenthedesiredsetpoint(SP)andthemeasuredprocess variable (PV) and initiates a correction based on proportional, integral, and derivative terms, which are denotedbyP,I,andD,respectively,andgivethecontroller itsname.Technically,itisacontrolfunctionthattransmits accurateandresponsivecorrection.PIDismadeupofthree sections:(1).Theproportionalcomponentisusedtochange the response's magnitude directly. The system becomes unstable if the value of Kp is too high or too low. (2). The integral partisused tosmoothout prior inaccuracies and acceleratetheprocess'sprogresstowardthesetpoint.(3). The derivative element predicts future errors based on previous error variations. Simply adding these three variables together yields the final control value. The followingistheformula:
•WhenPiscorrectlyrecognized,Iisincreased,causingthe robottoacceleratemorequicklywhenitisoffbalance.
A feedforward neural network is used in our proposed approachtocontrolatwo wheeledself balancingrobot.The robot is incapable of doing anything other than self balancing,andthereisnowaytoregulateitsdirection.The programusesaneuralnetworkwithasingleinputnode,two hidden nodes, and a single output node to get around the ArduinoUno's2KSRAMlimitation.Theprogramstartswith atrainingprocedurethattakesjustafewsecondsandmay berepeatedeverytimetherobotislaunched.Thebotmust bekeptuprightwhenthebackpropagationapproachisused toteachtheneuralnetworkroutine.Theinputsensorvalues (therobot'stiltangle)areconvertedtoanumberbetween0 and1.Thisvalueisfedintotheneuralnetworkmodel,which subsequently generates a sigmoid activation layer output thatrangesfrom0to1.Finally,wetransformtheseoutput numberstoausefulvalueforDCmotors,inthiscasefrom 255to255.
Fig FeedforwardNeuralNetworkArchitecture
International and Technology (IRJET) ISSN: 2395 0056

© 2022, IRJET | Impact Factor value: 7.529 | ISO 9001:2008 Certified Journal | Page1058
•Next,thevalueofDischosensothattherobotmaymove aboutitsbalancedpositioninamorefriendlymanner.There shouldalsobenosignificantovershoots.
4. METHODOLOGY
p
ThevalueofKd wassetat2.15sinceanyvaluemore thanthatmadetherobotjitterandanyvaluelessthan thatmadetherobotfall.
Thehyperparameterssetfortheneuralnetareasfollows
| ISO
©
TheRoll.Pitch
However,code.
Thedesiredsetpointwassetas6.10(degreesfromthe vertical).
Fig.7:SigmoidActivationFunction
RatherofmeddlingwithalloftheKp,Ki,andKdparameters required by the PID Controller, we just call a training procedureattherobot'sstartingduringwhichthebotmust be kept upright and steady. The bot uses this vertical tilt angle as the training set's input angle and calculates the Theerror.Sigmoid
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056

ThenextapproachwastheNeuralNetapproachwherethe followingstepsweretaken
Thevalueoftheoption'Success'hasbeensetto0.0015.The differencebetweentherequisiteSetPoint(verticaltiltangle) andtheCurrentAngle(Real TimeTiltAngle)isanticipated tobelessthanthevalueofsuccessinordertokeeptherobot upright,andtheneuralnetprovidesthenecessaryoutput. Thisvalueisthenlinearlytranslatedintothe0 255range. ThemagnitudeofthePWMsignal isthencalculatedusing thisnumber.Asaresult,thegreaterthevalueprovidedto thePWMsignal,thegreaterthetorquecreatedbythemotor, allowingthebottomaintainitsuprightposition.
Weemployedbothapproachesonourconstructedrobot,in ordertocompareandinfer astowhichalgorithmworked Thebetter.first
valueisthenusedtointerpretandcalculatethe robot's vertical tilt angle, allowing the robot to restore its alignmentafterwards.ThisisaccomplishedbyusingPulse WidthModulatedSignals(PWM)tocontrolthespeedofthe motorsbasedonthetiltangle.BecausePWMsignalsmaybe sentintherangeof 255to255,aPIDcontrollerisusedto decide the value to be delivered as PWM. To compute the PWMvalue,wemustfirstsubmitaninputandaSetpointto thePIDcontroller,whichwillcalculatetheerror(Setpoint Input)andthenprovideanoutputthatwillreducetheerror.
p ISSN: 2395 0072 2022, IRJET Impact Factor value: 7.529 9001:2008
ThevalueofKpafterextensiveexperimenting,wasset to90asitwasoptimalandmadethebotoscillateabout thebalanceposition.
approachwasthePIDControllerapproachwhere thefollowingstepsweretaken
Table 1: OptimizedHyperparametervaluesofFNN



none of these parameters are required in our neural network application. We simply use the back propagationmethodandaddasingleinputnode,twohidden nodes,andasingleoutputnodeintheneuralnetwork.
the Linear Quadratic Estimation (LQR) algorithm, in conjunction with the Complementary filter to obtain informationabouttherobot'sspatialorientation.TheDMP proceduresarecalledandusedtogetpreciseandaccurate dataforourmechanicallyunstablesystem'sYaw,Pitch,and
ThevalueofKiwassetto250asitmadethebalancing moreefficientandprovidedmoretorquetothemotors athighertiltangles.
|
Asaninput,weprovidetherobot'stiltanglewhilekeepingit upright.Becausetheinputtiltanglevariesdependingonthe surfacewheretherobotishoused,wemustalterthevaluein the
5. RESULTS AND DISCUSSION
Certified Journal | Page1059
Volume: 09 Issue: 03 | Mar 2022 www.irjet.net
ActivationFunctionisusedfortheneuralnetin thissituation.Thefunction'sgraphisasfollows:
Themomentumandinitialweightsweresetas0.9and 0.5respectivelybasedonhitandtrial.
International Research Journal of Engineering and Technology (IRJET) e ISSN: 2395 0056

p
TheSuccessvaluewaskeptat0.0015sinceanynumber higher or lower than that resulted in a significant changeintheerrorcomputationandcausedtheDMP functiontobecalledmoreoftenthanrequired,causing therobottojitterexcessively.
© 2022, IRJET | Impact
Fig. 8: PWMMotorControlSignals
| ISO 9001:2008 Certified Journal | Page1060
Volume: 09 Issue: 03 | Mar 2022 www.irjet.net ISSN: 2395 0072 Factor value: 7.529
Inaddition,inordertoexamineandassessthemotorcontrol signalsunderwheelsynchronizationinFig.8,weusedthe serial graphplotterincludedintheArduinoIDE Software. The wheel synchronization can clearly be seen to be operating.
6. CONCLUSIONS
[1] F.Grasser,A.D.Arrigo,andS.Colombi,“JOE:Amobile, invertedpendulum,”IEEETrans.Ind.Electron.,vol.49, no.1,pp.107 114,Feb.2002.
Ahighlearningratemadetheoutputchangefrequently andthiscausedthemotorstofrequentlychangespeed, thusmakingtherobotoscillateandjitter.
REFERENCES
[2] http://www.geology.smu.edu/~dpa www/robo/nbot/
TheSerialGraphfeatureoftheArduinoIDE Softwarewas also used to create a graph between the tilt angle and the timeelapsed.Thesegraphswereshownforbothapproaches, and it can be shown in Fig. 9 that PID control has low stability.Meanwhile,theNeuralNetprovidessubstantially moreenhancedstability,andthetiltangledeviatesfarless whenusingtheNeuralNet.
Neural Net approaches for self balancing are not as commonlyemployedasPIDcontrollers,nonethelessbased on our complete analysis we can deduce that the FeedforwardNeuralNetworkwasabletobalancetherobot much better than the PID Controller. The Kp, Ki, and Kd parameters of the PID Controller need to be adjusted significantly,asshownbythedata.Thesevaluesareunique toasystemandvaryfromonetothenext.Asaresult,the identicalsettingsforonerobotcannotbeusedforanother. Theparameterscreatedintheneuralnet,ontheotherhand, are universal, hence this approach does not need any adjustments. Once the neural net code is loaded into the ArduinoUnoMicrocontroller,therobotwillbegintobalance itself.Finally,theNeuralNetapproachisafascinatingand trustworthywaytobalancetherobotsinceitcausesthebot to vary less around the balancing point and so keeps it steadyforalongerperiodoftime.Meanwhile,whenthePID controllerissubjectedtomanualdisturbances/imbalances, itperformsbetter.Whenthebotissuppliedwithatinypush andforcedtounbalance,thePIDcontrollerisabletodeliver thelargertorquerequiredandbalancesthebotwhereasthe NeuralNetoftenfailstodoso,allowingtherobottotumble. Finally,usinglow costcomponents,wewereabletodevelop a compact and cost effective two wheeled selfbalancing robot. A fine tuned PID controller and a 3 layered feedforward neural network trained using the backpropagation method were used to handle the selfbalancing problem, and pertinent comparisons were madebetweenthem.
Fig. 9: Experimentallyobtainedhistoryoftiltangle:PID controller(top),NeuralNet(Bottom)

The value of Learning Rate was tinkered with, and it was found that a value of 0.3 made the bot balance perfectly without oscillating at high frequencies and causinglargedeviations.
Thedesiredsetpointwassetas6.10(degreesfromthe vertical).

[4] W. An and Y. Li, "Simulation and control of a twowheeled self balancing robot," 2013 IEEE InternationalConferenceonRoboticsandBiomimetics (ROBIO), Shenzhen, 2013, pp. 456 461, doi: 10.1109/ROBIO.2013.6739501.
Volume: 09 Issue: 03 | Mar 2022 www.irjet.net
| ISO
[10] S.CongandY.Liang,“PID likeneuralnetworknonlinear adaptive control for uncertain multivariable motion controlsystem,”IEEETrans.Ind.Electron.,vol.56,no. 10,pp.3872 3879,Oct.2009
Certified Journal | Page1061
[8] J.CaiandX.Ruan,“Bionicautonomouslearningcontrol of a two wheeled self balancing flexible robot,” J. of ControlTheoryandApplications,vol.9,no.4,pp.521 528,2011.
[7] L. Jiang, M. Deng, and A. Inoue, “Support vector machinebasedtwowheeledmobilerobotmotioncontrol in noisy environment”, J. of Systems and Control Engineering,vol.222,no.7,pp.733 743,2008.
International Research Journal of Engineering and Technology (IRJET)

J Intell Robot Syst 44, 25 46 (2005). https://doi.org/10.1007/s10846 005 9022 4
e ISSN: 2395 0056
©
[9] Kim, Y., Kim, S.H. & Kwak, Y.K. Dynamic Analysis of a NonholonomicTwo WheeledInvertedPendulumRobot.
|
[3] NguyenGiaMinhThao,DuongHoaiNghiaandNguyen Huu Phuc, "A PID backstepping controller for twowheeledself balancingrobot,"InternationalForum onStrategicTechnology2010,Ulsan,2010,pp.76 81, doi:10.1109/IFOST.2010.5668001.
[5] Q.Yong,LYanlong,ZXizhe,andL.Ji,“Balancecontrolof two wheeledself balancing mobilerobot based on TS fuzzymodel,”20116thInternationalForumonStrategic Technology(IFOST),pp.406,409,Aug22 24,2011.
[6] J.Wu,S.Jia,“T Sadaptiveneuralnetworkfuzzycontrol appliedintwo wheeledself balancingrobot,”20116th InternationalForumonStrategicTechnology(IFOST), pp.1023,1026,Aug22 24,2011.
p ISSN: 2395 0072 2022, IRJET Impact Factor value: 7.529 9001:2008