Available online at www.ijiere.com International Journal of Innovative and Emerging Research in Engineering e-issn: 2394 3343 p-issn: 2394 5494 Auto-Balancing Two Wheeled Inverted Pendulum Robot Om J. Sawant a, Shubhada Deshpande b, Ashish Lele a, Sejal Jamsandekar a and Rohit Patil a a Pursuing B.E., Department of Electronics, PVPPCOE, Sion, Mumbai, India b Professor, Department of Electronics, PVPPCOE, Sion, Mumbai, India ABSTRACT: The inverted pendulum platform is an example of classic unstable control system [4]. Although it is a fairly tested and documented concept, it draws attention of many researchers due to its application in auto balancing twowheeled robots. Auto balancing two wheeled robot is characterized by its ability to balance on coaxial two wheels and to spin on a smaller base space. This provides with enormous advantage to maneuver in small and tidy work spaces, which is a drawback issue in case of conventional four wheeled robots. The work presented here focuses on implementation of inverted pendulum auto balancing robot by means of a stable control system. This paper enlightens the use of Kalman filter and PID controller algorithms to achieve the desired stability of the inverted pendulum system by discrete digital algorithmic approach. Keywords: Inverted Pendulum, Control system, Kalman Filter, Sensor fusion, PID controller. I. INTRODUCTION A. Problem statement: Auto balancing two wheeled robot will come out as an effective and unconventional way of maneuverability which is needed in many robotic applications. However, inverted pendulum platform is an unstable control system and hence faces stability issues [3]. Various control system models are proposed to stabilize the IP system. The output of inertial sensors used is noisy and filtering of raw output of sensors is required before it is fed to the microcontroller for reliable performance. Also, due to the nonlinear behavior of control system, we face linear filtering problem of discrete data. Another major problem can be data sampling rate and computation time required by microcontroller to run control algorithm. Excessive computation delay leads to more time for correction of the tilt angle of inverted pendulum and leaves the system out of vertical equilibrium position. As compared to conventional robots, it is observed that the power required for driving DC motors to maintain equilibrium position is very high in case of auto balancing robots. Taking into consideration the higher design complexity and lower design flexibility, the cost of some components can lead to the question of cost effectiveness of entire project. B. Problem solving: The self-balancing robot structure is modeled on inverted pendulum problem. The goal of presented work will be to investigate the use of digital control algorithm implemented on a microcontroller as solution to above problem. The digital control algorithm used is Proportional-Integral-Derivative controller, which works to minimize the error and attain the vertical equilibrium position of the inverted pendulum to make the system stable. The sensors used are inertial sensors viz. accelerometer and gyroscope to give information about tilt angle of the inverted pendulum. To filter the noisy outputs of these sensors, the use of Kalman Filter algorithm is vital feature of this project. Kalman filter algorithm is estimating in nature and can also be used for fusing the outputs of both the sensors to give reliable tilt angle information. Over the period of time microcontrollers are providing versatile, quicker, cheaper and reliable options. This project will be built around a powerful but cost effective development board having ARM Cortex M0+ core microcontroller architecture. The Kalman Filter algorithm and PID controller logic will be implemented on the above said microcontroller. This provides the required cost effectiveness along with low power consumption. High torque DC motors will be used to drive the inverted pendulum to its vertical equilibrium and to balance entire physical structure. Keeping track of speed and direction of rotation of motors is important; because the same information is fed back to microcontroller in a feedback loop to minimize the error while achieving equilibrium. Frequency to voltage encoder such as tachometer can be used as feedback element to complete the closed loop digital control system. 163
II. PHYSICAL AND MATHEMATICAL MODEL As given in Joe: A mobile, inverted pendulum [2], considering the robot with its three degrees of freedom, it is able to rotate about its z axis (pitch). A movement described by angle θ P and corresponding angular velocity ω P. The linear motion of robot is given with X RM and velocity V RM. Additionally, the vehicle can rotate around its vertical axis (yaw) with the associated angle δ and angular velocity δ. Various disturbances are the forces acting on, the center of gravity (CG) of the vehicle, f dp, the center of the left wheel, f drl, the center of the right wheel, f drr. The vehicle is controlled by applying a torque C L and C R to the corresponding wheels. In order to successfully control the system, the state-space variables have to be quantified. X RM, V RM, δ and δ can be easily determined with the help of encoders mounted on the two wheels (provided θ P and ω P are known). Figure 1. Free-body diagram of robot [2] For developing an efficient control system for the robot, its mathematical model has to be designed. The following variables have been chosen to describe mathematical model of robot. J RL, J RR moment of inertia of the rotating masses with respect to the axis; M RL, M RR mass of the rotating masses connected to the left and right wheels; J Pθ moment of inertia of the chassis with respect to the axis; J Pδ moment of inertia of the chassis with respect to the axis; M P mass of the chassis; R radius of the wheels; D lateral distance between the contact patches of the wheels; L distance between the axis and the CG of the chassis. The following set of equations of motion can be obtained from free body diagram: For wheels x RLM RL= f drl H L + H TL y RLM RL = V TL M RLg - V L θ RLJ RL = C L H TLR For the Chassis x PM P = f dp + H R + H L y PM P = V R + V L M Pg + F Cθ θ PJ Pθ = (V R + V L).L.sinθ P (H R + H L).L.cosθ P (C L + C R) δ J Pδ = (H L H R)D/2 Where H L, H R, H TL, H TR, V L, V R, V TL, V TR represent the reaction forces acting on different parts of free body. Modifying equations 1 to 7 and then linearizing the result around the operating point (X RM = 0; θ P = 0 and δ = 0) the system s state-space representation can be written in matrix form as: 164
Figure 2. State-space representation This state-space representation can be used for designing control system. III. IMPLEMENTATION This part of the paper proposes the implementation of the Auto-Balancing Two Wheeled Robot. The task of balancing inverted pendulum is very complex if we try to derive a single Transfer Function equation considering the project as a single control system. This may be achieved theoretically but practical implementation will not be as per expectation. Due to the large number of physical unknown parameters governing the state of control system, the single transfer function approach would be impractical to achieve stability in real time implementation of project. To avoid this complexity we will break the control system into basic blocks. Every block dealing with the fixed number of variables and serving its successive block. The blocks used for implementation of project are specified with block diagram. A. Block Diagram: Figure 3. Block diagram B. Sensors: Sensors used in this project include accelerometer and gyroscope. These are inertial sensors used to provide tilt angle and rate of fall of angle i.e. angular rate. The data from the sensors will give sense of angular displacement of the inverted pendulum from its vertical zero equilibrium position. As the primary goal of this project is to maintain zero degree vertical angle of inverted pendulum, the measurement of instantaneous angle of structure becomes very important. The digital rate gyroscope gives information about instantaneous rate of change of angle. The rest state offset value of gyroscope must be measured and the device should be calibrated. But it is observed that gyroscope produces a significant drift when operating. This drift may be due to temperature or inherent characteristics of gyroscope itself. On the other hand, accelerometer gives absolute measure of tilt angle. But it is observed that the output signal is often corrupted with significant amount of noise. Generalized sensor equations: For Gyroscope ADC resol = V cc / 2 nbit GYRO resol = (ADC resol / GYRO sensitivity) GYRO offset = (V static. 2 nbit ) / V cc ANGULAR_RATE = (ADC resol GYRO offset). GYRO resol For Accelerometer ADC resol = V cc / 2 nbit 165
ACCL resol = ( 1g. ADC resol ) / 1000mV ACCL offset = (V offset. 2 nbit ) / V cc A x = (ADC resol ACCL offset). ACCL resol Pitch = sin -1 (A x/1g) From above discussion about sensors one can state that the use of any of the sensor alone to achieve tilt angle information is not sufficient in order to balance the robot. Because the information provided by sensors is insufficient and unreliable. To get rid of this problem, use of signal level sensor fusion becomes mandatory. Sensor fusion refers to combining output signals of sensors to give an improved and reliable signal. Kalman Filter is used for the same, which uses accelerometer signal to eliminate the drift problem in gyroscope output and gives accurate estimate of tilt angle and its derivative term. C. Kalman Filter: Kalman filter is basically recursive digital algorithm which can be used for estimation of state of any process [5] [6]. Due to its state estimating nature it provides reliable state estimate. Kalman filter also has a feature of minimizing mean square error. Hence it can be applied to control systems operating in noisy environment. Kalman filter processes the output signals from sensors and minimizes square error. Then this noise free signal can be fed to control system for reliable output response. Kalman filter estimates the state of discrete time controlled process given in linear stochastic difference equation form: x k = Ax k 1 + Bu k 1 + w k 1 Measurement: z k = Hx k + v k Random variables v k and w k are measurement noise and process noise respectively. They have normal probability distribution as: p(w) = N(0, Q) p(v) = N(0, R) Where Q is process noise covariance matrix and R is measurement noise covariance matrix. Matrices A and H are state matrices relating state of next time step and measurement state respectively. Matrix B is related to control input u of process x. Kalman filter equations can be distinguished in two states, predictions state and correction state. The prediction state is nothing but time updating phenomenon. In prediction state, considering current time state and error covariance estimate, new state is estimated. The correction state produces a feedback to generate estimate of next measurement. Table 1. Kalman filter equations Prediction state: Correction state: Estimation of state ahead Kalman Gain calculation x k = Ax k 1 + Bu k 1 K k = P k H T (HP k H T + R) 1 Estimation of Error Covariance ahead Measurement estimation P k = AP k 1 A T + Q X k = x k + K k (z k Hx k ) Error covariance update P k = (I K k H)P k D. PID controller: The digital control algorithm that is used to maintain the balance of the auto-balancing two wheel robot is the PID controller. The proportional, integral, and derivative (PID) controller is well known as a three term controller. The PID controller has been the popular choice in industrial process control. As micro-processors and micro-controllers have become popular in control engineering, the PID controller has become a popular embedded software implementation. The PID control algorithm is a simple algorithm that provides the necessary output system response to control a process. One unique feature of the PID controller is that it is capable of manipulating the process inputs based on the history and rate of 166
change of the signal. It uses closed loop control system approach. The algorithm is best suited when the process under control is modeled as a linear system. The PID controller consists of proportional, integral, and derivative terms. The KP, KI, and KD are referred as the proportional, integral, and derivative constants. The terms of the PID controller are summed up to create a controller output signal. Each term performs a different task in the control process. The controller terms also have different effects on the system output response. It is also referred as a negative feedback system. The basic idea of a negative feedback system is that it measures the process output y using a sensor. The measured process output gets subtracted from the reference set-point value to produce an error. The error is then fed into the PID controller, where the error gets processed in three ways. The error will be used on the PID controller to execute the proportional term, integral term reduces the steady state errors, and the derivative term handles overshoots. After the PID algorithm processes the error, the controller produces a control signal u. The PID control signal u will try to drive the process to the desired reference set-point value. In the case of the two wheel robot, the desired set-point value is the zero degree vertical position. Equations given below represents PID controller in continuous time domain. T D and T I are time constants for derivative and integral term respectively. error = ref y u(t) = K p (error(t) + 1 1 derror(dt) error(t)dt + T T D ) I 0 dt Where, K I = K P T I, K D = K P T D 1 derror(dt) u(t) = K p error(t) + K I error(t)dt + K D 0 dt Discrete PID controller algorithm: As we are implementing PID algorithm on a micro-controller, it is necessary to design the PID equations in discrete time domain. Trying to develop PID software algorithm that follows discrete time domain notations is practically not possible. Only approach to achieve PID controller algorithm in discrete time domain notations is by approximation of terms of PID controller equations in continuous time domain given above. The discrete representation of the controller makes it easier to implement the PID algorithm on a micro-controller The equations given below represents PID controller in discrete form: 1 error(t)dt T S error(k) 0 derror(t) dt k=1 error(k) error(k 1) T S u(k) = K p (error(k) + T S Where, K I = K P T S T I error(k) + T D T k=1 (error(k) error(k 1)) ) I T S K D = K P T D T S u(k) = K p error(k) + K I error(k) + K D (error(k) error(k 1)) k=1 E. DC MOTORS AND MOTOR DRIVER: The selection of motors is an important aspect in designing the Auto Balancing Robot System. The motors should have adequate torque rating and also should have appropriate RPM value for proper functioning of the self- balancing mechanism. Also, the motors should be of moderate voltage and current requirement to keep the power supply less bulky and make the driver circuit less complex. To suit the requirements of the project, two DC motors of the following specifications have been proposed: Maximum Supply Voltage: 9V DC Torque Rating: 2kg/cm RPM at no load: 100 The output current provided by the development board is of the order of a few miliamperes. The DC motors require a considerably high value of current to function which cannot be provided by the development board. Hence, a separate motor driver circuit is required so that adequate current can be supplied for proper functioning of the motors. 167
The motor driver circuit L298N is being used in this project. The circuit is a high voltage, high current dual full bridge driver. The features of the driver module are as follows [7] :. OPERATING SUPPLY VOLTAGE UP TO 46 V. TOTAL DC CURRENT UP TO 4 A. LOW SATURATION VOLTAGE. OVERTEMPERATURE PROTECTION. LOGICAL "0" INPUT VOLTAGE UP TO 1.5 V (HIGH NOISE IMMUNITY) F. Encoder: Encoder is an important block in the closed loop control system. It consists of a tachometer which measures the frequency of rotation of wheels and converts the frequency into corresponding voltage signal. Hence encoder is nothing but frequency to voltage converter. Voltage signal produced by encoder is fed as negative feedback to the PID controller. In this way encoder completes the negative feedback in PID controller. By comparing the signal given by encoder with the set-point condition, error will be calculated and then PID controller processes the error to minimize it. IV. CONCLUSION It can be concluded that, after implementation of this project, the stability of Auto-Balancing Two Wheeled Inverted Pendulum Robot can be achieved with improved response time. We have considered the system of robot as a classical control system and proposed the algorithmic approach to stabilize the system. Through this paper we are implementing Kalman filter algorithm and PID controller digital control algorithm on a micro-controller, which gives cost-effective option for solving Inverted Pendulum control system problem with reduced oscillations and improved stability. Our emphasis is on achieving zero degree vertical equilibrium of robot body when it is in rest or when it is in a straight line motion, in shortest possible time. Further study can be done on achieving the stability of robot while rotating about its vertical axis. ACKNOWLEDGMENT This work is supported by Department of Electronics Engineering, Padmabhushan Vasantdada Patil Pratishthan s College of Engineering, Sion, Mumbai. REFERENCES [1] Spong M.W., Hutchinson S., Vidyasagar M.: Robot modeling and control, Wiley, 2006 [2] F. Grasser, A. D Arrigo, S. Colombi, and A. Rufer, Joe: A mobile, inverted pendulum, IEEE Trans. Ind. Electron., vol. 49, no. 1, pp.107 114, Feb. 2002 [3] Li Chaoquan, Gao Xueshan, Li Kejie, Smooth Control the Coaxial Self-Balance Robot under Impact Disturbances, International Journal of Advanced Robotic Systems, ISSN 1729-8806, pp 59-67 Vol. 8, No. 2. (2011) [4] Kent H. Lundberg, James K. Roberge, Classical Dual-Inverted-Pendulum Control, THE 2003 IEEE CONFERENCE ON DECISION AND CONTROL, 2003 [5] R. E. Kalman, A New Approach to Linear Filtering and Prediction Problems, Transaction of the ASME Journal of Basic Engineering, pp. 35-45 (March 1960). [6] Welch & Bishop, An Introduction to the Kalman Filter, UNC-Chapel Hill, TR 95-041, July 24, 2006 [7] Data sheet, L298N Duel Full Bridge Driver, www.st.com 168