JOLRNAL OF SCIENCE & TECHNOLOG\ A PD SLIDING MODE CONTROLLER FOR TWO-WHEELED SELF-BALANCING ROBOT B O DIEU K H I E N PD TRU'OT CHO ROBOT HAI BANH TU CAN B A N G Nguyen Gia Minh Thao, Duong Hoai Nghia, Phan Quang An Ho Chi Minh City- University of Technology ABSTRACT This paper presents a method to design and control a two-wheeled self-balancing robot It focuses on hardware description and PD sliding mode controller design The signals from angle sensors are filtered by a discrete Kalman filter before being fed to the PD sliding mode controller Ttie objectives of the proposed controller are twofold: regulation of the pitch angle and tracking the desired position The proposed controller has two loops The first loop Is a sliding mode pitch angle regulator The second loop is a PD position tracking controller Simulations and experimental results show that the proposed controller has good performance and robust against disturbances Keywords: Two wheeled self-balancing robot, Discrete Kalman filter, PID control, Sliding mode control, Accelerator, Gyroscope TOM TAT Bii bio niy trlnh biy mdt phwgng phip di thiit ki vi diiu khiin robot hai binh tw cin bing Cic ndi dung chinh bao gdm md ta phin cirng robot vi thiit ki bd diiu khiin PD trwgt Cic tin hiiu tit dc cim biin gdc dwgc Igc bdi bg lgc Kalman trwdc dwa via bd diiu khtin PD trwgt Muc tieu cita bd diiu khiin dwgc di xuit li in dinh hda gdc nghieng thin robot vi robot bim theo vi tri mong mu6n Bd diiu khiin dwgc di xuit gdm hai vdng Vdng thir nhit li mgt bd diiu khiin trwgt di in dinh gdc nghieng thin robot Vdng thir hai la mgt bd diiu khiin PD di diiu khiin vi tri cua robot Cic kit qui md phdng va thirc nghiem cho thiy bd dtiu khiin dwgc di xuit cd chit Iwgng tdt vi bin virng vdi nhiiu approach to maintain the tracking error of the pitch angle at zero The second loop uses a PD controller to control the position of the robot I INTRODUCTION Two-wheeled self-balancing robot is a multivariable uncertain nonlinear system [1,2,7,8], The perfonnance of the robot depends heavily on the signal processing technique and the control method in use In recent years, the number of researches on sliding mode (SM) control has increased [4.5,6,9] The SM approach provides a powerful design tool for nonlinear system So it is of great interest and feasible to use SM approach to design a compatible controller for two-wheeled self-balancing robot when the mathematical model of the robot is identified II HARDWARE DESCRIPTION 2.1 The hardware of the robot The designed two-wheeled self-balancing robot is given in Fig.l Signals from angle sensors are filtered by a discrete Kalman filter before being fed to the PD sliding mode controller The purposes of the controller are to stabilize the robot and to keep the motion of the robot tracking a reference signal The proposed PD SM controller has two loops (Fig.~) The first loop is a nonlinear controller based oivSM Figure I The prototype two-wheeled self-balancing robot The prototype design of the robot is shown in Fig.l Fig.2 It has an aluminum chassis, two 24\-jOW DC-servo motors for actuation, an acceleration sensor and a gyroscope sensor for measuring the pitch angle 60 JOLRNAL OF SCIF.NCE & TECHNOLOGV and the angular velocity of the body, two incremental encoders for measuring the position of the wheels The signal processing and control algorithm are embedded in a ! 6-bit two-core MC9S12XDP512 The micro-controller operations of the robot (upright and balance, moving forward, moving backward, etc.) can be set from buttons on the central control module or from a RF remote controller (DlT«Cl control) Channel 10-bil A/D converter central control module (12y±I SAh) No 83B - 2011 An acceleration sensor, a gyroscope sensor and two incremental encoders provide full state of the robot {Fig.3) The signals from the acceleration sensor and the gyroscope sensor are filtered by a discrete Kalman filter (presented in Section 111) before being fed to the PD sliding mode controller III DISCRETE KALMAN FILTER The Kalman filter estimates a process by using a form of feedback control [3] The filter estimates the process state at some times and then obtains feedback in the form of measurements The equations of the discrete Kalman filter can be decomposed into two groups: Time Update equations and Measurement Update equations, as shown in Fig4 Person^ Con^uler (Dala c oiler nen) Channe/; * Ptise inpiU capture CT»F«* ft J Isolated H Bndge Dnver 0C-MC33932) BiBCTiei for two DC mot Dti (i4Vtk- ' ^Ah) Chiwnil Time l^pdrtte rPii'tliel-) Measurement lljidate '' Cev reel ) Isolated H Bndge Dnver (IC-MCii9n) {Feedback nelocity and poMton) Initial estimates Encoda (AB) Encods (AB) Figure The discrete Kalman filter algorithm • Figure Hardware description Time Update equations Project the state ahead 2.2, Sensor Signal Processing (1) nil Direction of tlie Icfl wheel Encoder of The Left Motor Project the error covariance ahead InpHt Cap t i u * Channel 0-1 SipialB wK -I- T^ P,:=AP,_,AUQ (2) Measurement Update equations Siyial A^ Encoder of T>,e Right Motor Input C.ipniTf CikPtmlS-? Xiti(hi ^ "iTlLRZU YD K,=P;HT(HP-H^ + R ) ' DttecttoD oflhe nghl-whtel SimalB Compute the Kalman gain Low paii Filter L'pdate estimate with measurement z^ IHVft) (4) Knlmnn Filter (3) Xj H=el Update the error covariance InetrfectbtCMtn itnscr eis.vte J.1: r.n is the desired time constant of the sliding phase We have ( M „ R + M|,L(COSX,))(COS\,) S = xe-l-e (M„l.(sinx,)(xJ ) Substituting (20),(21) into (23), we obtain 75(M„R+M„1.(COSX|))(COSX|)'| S = t(x,„f-X;)-^(X|„|.-x,) (23) = t(>^;„, - f , ( ^ ) - f ; ( x p X ) - g l ( X | ) C ) + x„ 0.7.S(M„R + MBL(cosX|))(l + (sinx,)M M|,L' e,(v,) :M,, + M „ (24) R Where C = C.