Application of Kalman Filtering and Pid Control For
Total Page:16
File Type:pdf, Size:1020Kb
APPLICATION OF KALMAN FILTERING AND PID CONTROL FOR DIRECT INVERTED PENDULUM CONTROL ____________ A Project Presented to the Faculty of California State University, Chico ____________ In Partial Fulfillment of the Requirement for the Degree Master of Science in Electrical and Computer Engineering Electronic Engineering Option ____________ by José Luis Corona Miranda Spring 2009 APPLICATION OF KALMAN FILTERING AND PID CONTROL FOR DIRECT INVERTED PENDULUM CONTROL A Project by José Luis Corona Miranda Spring 2009 APPROVED BY THE DEAN OF THE SCHOOL OF GRADUATE, INTERNATIONAL, AND INTERDISCIPLINARY STUDIES: _________________________________ Susan E. Place, Ph.D. APPROVED BY THE GRADUATE ADVISORY COMMITTEE: _________________________________ _________________________________ Adel A. Ghandakly, Ph.D. Dale Word, M.S., Chair Graduate Coordinator _________________________________ Adel A. Ghandakly, Ph.D. TABLE OF CONTENTS PAGE List of Figures............................................................................................................. v Abstract....................................................................................................................... vi CHAPTER I. Introduction.............................................................................................. 1 Purpose of the Project................................................................... 2 Limitations of the Project ............................................................. 3 II. Review of Related Literature.................................................................... 4 BallBot.......................................................................................... 5 Battlefield Extraction Assist Robot.............................................. 7 nBot and Legway.......................................................................... 9 Segway ......................................................................................... 10 Kalman Filte ................................................................................. 11 PID Control System...................................................................... 13 III. Balancing Robot System Overview.......................................................... 15 Robot Physical Structure .............................................................. 15 PIC32 Microcontroller.................................................................. 16 Sensors.......................................................................................... 17 DC Motors.................................................................................... 23 Logomatic-v2 ............................................................................... 23 DC Motor Drivers......................................................................... 25 Power Supply................................................................................ 26 IV. Methodology............................................................................................. 29 Kalman Filter................................................................................ 29 PID Controller .............................................................................. 39 iii CHAPTER PAGE V. Results and Performance Evaluation........................................................ 52 Kalman Filter Results................................................................... 53 PID Controller Results ................................................................. 61 VI. Summary, Conclusion, and Recommendations........................................ 67 Summary....................................................................................... 67 Conclusion.................................................................................... 68 Recommendations ........................................................................ 69 References .................................................................................................................. 71 Appendix A. Application Source Code.......................................................................... 73 iv LIST OF FIGURES FIGURE PAGE 1. Two Wheeled Robot Platform.................................................................. 16 2. Two Wheeled Robot General System Block Diagram ............................. 18 3. ADXL-203 Accelerometer........................................................................ 19 4. ADXL-203 Output Voltage Response vs. Orientation ............................. 20 5. IDG-300 Gyroscope.................................................................................. 22 6. Tamiya DC Motor with Foam Wheel....................................................... 24 7. Logomatic Serial Data Logger.................................................................. 25 8. VNH2SP30 DC Motor Driver .................................................................. 26 9. Nickel-Metal Hydride battery................................................................... 27 10. Nickel-Metal Hydride Cell Batteries ........................................................ 28 11. Kalman Filter Estimation Algorithm Cycle.............................................. 32 12. Kalman Filter Algorithm Equations.......................................................... 32 13. Gyroscope and Accelerometer Sensor Test Setup .................................... 34 14. Gyroscope Measurements with Drift........................................................ 35 15. Noisy Accelerometer Measurements ........................................................ 37 16. Continuous PID Controller....................................................................... 40 17. Closed Loop Control System with PID Controller ................................... 41 18. PID Algorithm in Time Domain Representation...................................... 42 v FIGURE PAGE 19. PID Controller Characteristics.................................................................. 44 20. PID Controller Discrete Representation ................................................... 45 21. Ziegler-Nichols PID Tuning Parameters................................................... 47 22. Ziegler-Nichols Close Loop Tuning Test ................................................. 48 23. Example.................................................................................................... 49 24. Typical Close Loop Output Response....................................................... 50 25. Functional Block Diagram for Balancing System..................................... 53 26. Process and Measurement Noise Covariance Matrices ............................ 54 27. Not Properly Tuned Kalman Filter ........................................................... 55 28. Kalman Filter Output Response Varying Q Matrix .................................. 57 29. Optimal Kalman Filter Q Matrix Values.................................................. 59 30. Kalman Filter Output Response Varying R Matrix .................................. 60 31. Kalman Filter Motionless Gyroscope Result............................................ 62 32. Measured System Output Response.......................................................... 63 33. PID Controller Input Error........................................................................ 64 34. PID Controller Output............................................................................... 65 vi ABSTRACT APPLICATION OF KALMAN FILTERING AND PID CONTROL FOR DIRECT INVERTED PENDULUM CONTROL by José Luis Corona Miranda Master of Science in Electrical and Computer Engineering Electronic Engineering Option California State University, Chico Spring 2009 Robotic mobility technologies over the past few years have gain popularly in both commercial and government sectors. There been a variety of techniques suggested to increase robotic mobility on dynamic environments. One such popular technique used to provide greater mobility to a robotic platform is based on the inverted pendulum model. The presented document will demonstrate the techniques involved in balancing an unstable robotic platform. The objective is to design a complete discrete digital con- trol system that will provide the needed stability. The platform will be an ideal test bed for the implementations of both PID digital control and Kalman filter algorithms. Both algorithms will provide the necessary control for the system. Therefore the presented vii project will investigate the performance of both PID digital control and Kalman filter al- gorithms. Test software was written to gather performance results for both the PID con- troller and Kalman filter. The control system performance is directly dependent on Kal- man filter and PID controller input parameters. The results clearly show how the adjust- able parameters on the control system directly affected the overall system performance. The results also demonstrate the performance and the need of the Kalman filter to remove sensor noise. The almost reliable sensor data increases PID controller performance to drive the robotic platform to vertical equilibrium. The gathered results for the Kalman filter were compared against the raw noisy sensor data. The plots for such comparison are shown on the Kalman filter results section. PID controller output response data was also collected and plotted. The PID output response results were used in the controller tuning process. viii CHAPTER I INTRODUCTION “The research on balancing robots has gained momentum over the last decade in