* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Untitled - (FKE), UTM - Universiti Teknologi Malaysia
Switched-mode power supply wikipedia , lookup
Control system wikipedia , lookup
Buck converter wikipedia , lookup
Mains electricity wikipedia , lookup
Voltage optimisation wikipedia , lookup
Induction motor wikipedia , lookup
Brushed DC electric motor wikipedia , lookup
Stepper motor wikipedia , lookup
Opto-isolator wikipedia , lookup
Potentiometer wikipedia , lookup
Variable-frequency drive wikipedia , lookup
i i “I hereby declare that I have read this thesis and in my opinion this thesis is sufficient in terms of scope and quality for the award of the degree of Bachelor of Electrical Engineering (Mechatronics)” ii DEVELOPMENT OF POLE BALANCING MOBILE ROBOT NOORAZMI B AB RAHMAN Submitted to the Faculty of Electrical Engineering in partial fulfillment of the requirement for the degree of Bachelor in Electrical Engineering (Mechatronics) Faculty of Electrical Engineering Universiti Teknologi Malaysia MAY 2009 iii I declare that this thesis entitled “Development of Pole Balancing Mobile Robot” is the results of my own research except as cited in the references. The thesis has not been accepted for any degree and is not concurrently submitted in candidature of any other degree. iv To my beloved father and mother Abdul Rahman Bin Hj. Salleh Faridah Bte Majid v ACKNOWLEDGEMENT All praise to the Almighty Allah, the Most Gracious, Most Merciful and Most Benevolent for giving me an opportunity to study for higher education and giving me strength and patience in completing this final year project report. First of all, I would like to take this opportunity to thank my project supervisor, Associate Professor Dr. Rosbi Bin Mamat whom had actually provided me with all the valuable, precious information to complete this report of PSM 2, which carries up to four credits. Without the passionate supports, guidance encouragement and advices given by him, it would have been very hard to complete this project. As such this report is very important to me. My outmost thanks also go to my course mate for all their support and helps given to me while my project is still in progress for their guidance, support and not to forget their precious time spent for me to provide information and equipments needed. Their views and tips are useful definitely. Next up, I would like to thank to all my friends for their continuous support and encouragement. Thanks to my parents, Ab Rahman & Faridah Bte Majid, for their unconditional love and support, I would not have made it this far without their sacrifices. Finally, thanks to individuals that has contributed either directly or indirectly to make this thesis project. From the bottom of my heart, thank you once again. vi ABSTRACT The research on balancing robot has gained momentum over the last decade in a number of robotics laboratories around the world. This is due to the inherent unstable dynamics of the system. Recently many robots have widely been used anywhere especially in manufacturing and industrial sectors. In recent years, researchers have applied the idea of a mobile inverted pendulum model to various problems like designing walking gaits for humanoid robots, robotic wheelchairs and personal transport systems. All of this uses a concept of ability to balance freefalling pole on its wheels and spin on the spot similar to inverted pendulum. This mobile robot has become much more familiar nowadays since it is already equipped with lots of intelligences where it is beneficial to human. In conjunction with the development of balancing system on the robot itself, the pole balancing mobile robot has been successfully designed for this project. In this project, microcontroller PIC 16F877A is used as the brain of the robot to control the robot’s movements where all the data and information would be processed. It is also equipped with potentiometer 50k as a sensor of the balancing mobile robot. It gives a reading of differential angle to the microcontroller as it process the data to moves the DC motor with a correct PWM reading. To complete this, a pole must mounted to the potentiometer as the differential angle reading are comes from the movement of the pole. C language is used to program this microcontroller via MicroC, so that it will properly function as desired. vii ABSTRAK Penyelidikan dan pembangunan berkenaan keseimbangan robot telah menerima impak momentum yang ketara sejak sedekad yang lalu seiring dengan pertumbuhan makmal robotik di seluruh dunia. Hal ini adalah disebabkan oleh faktor semulajadi ketidakseimbangan sistem dinamik. Baru-baru ini aplikasi penggunaan robot semakin bertambah dan global terutamanya dalam bidang pembuatan dan sektor industri. Sejak beberapa tahun ini, penyelidik telah berexperimentasikan penggunaan idea berkenaan model tiang diseimbangkan pada robot gerakan bebas untuk pelbagai masalah dan penggunaan seperti keseimbangan pergerakan bagi robot manusia, kerusi roda robot dan sistem pengangkutan persendirian. Robot ini akan lebih bermakna dan digunakan selalu jika ia dilengkapi dengan sistem pintar dan berguna untuk kemudahan manusia. Bersempena dengan pembangunan sistem keseimbangan pada robot itu sendiri, robot gerakan bebas berasaskan keseimbangan telah berjaya direkabentuk untuk projek ini. Dalam projek ini, mikropengawal PIC 16F877A digunakan sebagai otak kepada robot ini untuk mengawal pergerakan robot dimana semua data dan informasi diproses. Ia turut dilengkapi dengan perintang boleh laras 50k sebagai pengesan untuk keseimbangan robot gerakan bebas ini. Ia memberi bacaan bezaan sudut kepada mikropengawal dimana data akan diproses untuk member nilali bacaan PWM yang betul kepada DC motor. Pelengkap bagi sistem ini ialah sebatang tiang yang akan dicantum dengan perintang boleh laras sebagai pembaca data Bahasa C telah digunakan untuk memprogram mikropengawal menggunakan Mikro C supaya ia dapat berfungsi seperti yang diingini. viii TABLE OF CONTENTS CHAPTER TITLE PAGE TITLE PAGE ii DECLARATION iii DEDICATION iv ACKNOWLEDGEMENT v ABSTRACT vi ABSTRAK Error! Bookmark not defined. TABLE OF CONTENTS Error! Bookmark not defined.i 1 2 LIST OF FIGURES xi LIST OF TABLE xii LIST OF ABBREVIATIONS xiv INTRODUCTION 1 1.1 Robot and Mobile Robot Definitions 1 1.2 Balancing Robot 2 1.3 Objectives of Research 3 1.4 Problem Statement 4 1.5 Scope of Work 4 1.6 Research Methodology 6 LITERATURE REVIEW 7 2.1 Segway HT 9 2.2 Balance Bot 12 2.3 Nbot Balancing Robot 13 2.4 Scaled Down Prototype of a Digital Signal Processor Controlled Two-Wheel Vehicle 15 ix 2.5 3 5 16 ROBOT DESIGN 17 3.1 Robot Structure 18 3.2 Mechanical Design 20 3.2.1 21 Motor Positioning and Installation 3.3 Base 21 3.4 Gearbox 22 3.5 DC Motor 23 3.5.1 24 Pulse with Modulation 3.6 Pole 25 3.7 Main Electronics Component 25 3.7.1 Motor Driver (L298) 26 3.7.2 Potentiometer 27 3.7.3 Microcontroller 28 3.7.4 Power 31 3.7.5 Voltage Regulator 31 3.7.6 Wheel 32 3.8 4 Summary Conclusion 33 CIRCUIT DESIGN 35 4.1 Overview 35 4.2 L298 and Potentiometer Circuit 35 4.3 Main Controller Circuit 37 4.4 Connecting the Microcontroller to PC Circuit 39 SOFTWARE DEVELOPMENT 41 5.1 Overview 41 5.2 Microsoft Excel 41 5.3 MicroC 42 5.3.1 PWM Change Duty via MikroC 43 x 6 5.4 WinPic800 45 5.5 Programming Languages 47 RESULT AND DISCUSSION 49 6.1 Overview 49 6.2 Calibration 50 6.3 Calculation and Analysis 51 6.3.1 Speed versus Angle 53 6.3.2 Control system 53 6.4 7 Programming 54 CONCLUSION AND RECOMMENDATION 57 7.1 Conclusion 57 7.2 Recommendation 58 REFERENCES 59 APPENDICES 60 Source code for Pole Balancing Mobile Robot 61 xi LIST OF FIGURES FIGURE NO. TITLE PAGE Figure 1.1 Flow Chart for Project Methodology 6 Figure 2.1 Segway HT 9 Figure 2.2 Features of Segway HT. 10 Figure 2.3 Balance Sensor Assembly 11 Figure 2.4 Balance Bot 12 Figure 2.5 Nbot Balancing Robot 14 Figure 2.6 Scaled Down Prototype of a Digital Signal Processor Controlled Two- Figure 3.1 Figure 3.2 Wheel Vehicle 14 Mechanical Structure Plan-Views 19 Base of the Project (in the beginning) 19 Figure 3.3 DC Motor (Gearbox) Positioning 20 Figure 3.4 Gearbox of Control Racing Car 22 Figure 3.5 System Inside Gearbox 23 Figure 3.6 PWM Signal of Varying Duty Cycles 24 Figure 3.7 Rod Aluminium 25 Figure 3.8 Main Electronic Components 26 Figure 3.9 Motro Driver (L298) 27 Figure 3.10 Potentiometer and its Symbol 27 Figure 3.11 PIC 16F877A 29 xii Figure 3.12 PIC 16F877A Pin Notation 30 Figure 3.13 Battery Nickel-Cadmium 9.6V 31 Figure 3.14 Voltage Regulator Circuit 32 Figure 3.15 Pole Balancing Tire 32 Figure 3.1 Side View 33 Figure3.2 Back View 33 Figure 3.3 Front View 34 Figure 3.4 Plan View 34 Figure 4.1 L298 and Potentiometer Circuit 36 Figure 4.2 Block Diagram of L298 37 Figure 4.3 Real View of L298 and Potentiometer Circuit 37 Figure 4.4 Basic PIC Microcontroller Circuit 38 Figure 4.5 PIC Microcontroller Circuit 39 Figure 4.6 Real View of PIC Microcontroller Circuit 39 Figure 5.1 MicroC 44 Figure 5.2 WinPic800 46 Figure 5.3 PIC detected 16F877A 46 Figure 5.4 Writing HEX File Succeds 47 Figure 6.3 Graph of Angle versus Voltage(in dec) 52 Figure 6.4 Block Diagram of Closed-Loop System 54 Figure 6.5 Flow Chart of the Programming 55 xiii LIST OF TABLES TABLE TITLE PAGE Table 3.1.3 PIC 16F87XA features 30 Table 6.1 Table of Angle versus Voltage 50 Table 6.2 Table of hex value 51 xiv LIST OF ABBREVIATIONS d.o.g - degree of freedom DC - Direct Current PIC - Programmable Interface Controller UTM - Universiti Teknologi Malaysia MCU - Microcontroller Unit HT - Human Transporter BSA - Balance System Assembly EEPROM - Electrically Erasable ROM MIN/MAX - Minimum/Maximum IC - Integrated Circuit EMF - Electric Magnetic Field LED - Light Emitter Diod e.g - exempli gretis EPROM - Erasable Programmable ROM MCU - The Microcontroller Unit VBA - Visual Basic for Application ADC - Analog-Digital Converter xv DEC - Decimal 1 CHAPTER 1 INTRODUCTION Balancing robots are characterized by the ability to balance on its two wheels and spin on the spot similar to inverted pendulum. The inverted pendulum problem is common in the field of control engineering thus the uniqueness and wide application of technology derived from this unstable system has drawn interest from many researches and robotics enthusiasts around the world. In recent years, researchers have applied the idea of a mobile inverted pendulum model to various problems like designing walking gaits for humanoid robots, robotic wheelchairs and personal transport systems. Balancing is one of the main functions in making a robot. It uses a sensor as a balance orientation. There are many types of balancing sensor in this robotic area. Examples of the sensors are accelerometer, inclinometer, tilt sensor, gyroscope and potentiometer. Balancing systems that are now having an enormously influence towards world development and technologies promising to change and upgrade the dynamic of the systems to be more stable and balance. In this project, the inverted pendulum was replaced with a pole as it function are exactly the same and importantly more suitable for this project. This chapter will discuss definition of robot, objective of research, scopes of research, literature review and thesis outline. Literature review will focus on pole balancing mobile robot and other mobile robot which functioned and equipped with balancing system that have been researched earlier. 2 1.1 ROBOT AND MOBILE ROBOT DEFINITIONS In this project, it involves mobile robot as a transport and a medium to balance the pole. Before going any further, let’s define what the meaning of robot and mobile robot is. From the website it state that, “A robot is a machine designed to execute one or more tasks repeatedly, with speed and precision. There are as many different types of robots as there are tasks for them to perform. A robot is a machine that resembles a human and does mechanical, routine tasks on command or any machine or mechanical device that operates automatically with humanlike skill.” Definition robot from the Longman Dictionary is “machine that can move and does of the work of a person and usually controlled by a computer.” Based on the definition of the two facts collect from the net and one from the dictionary, as a conclusion, a robot must be an automatic machine and be able to deal with the changing information received from the environment. As for the mobile robot (type of robot) it has the capability to move around in their environment and is not fixed to one physical location. It can move freely in any directions; forward, backward, left, and right and also in any angle as long as it is programmed to move so. Mobile robots can be found in the industry, military, security environment and in local universities labs which it is used to some research programmed. For people who like to play with something, mobile robot can be used in robot competition. 1.2 BALANCING ROBOT Balance has a difference meaning according to Oxford Fajar Dictionary. The best meaning contribute to this project is “keep or put in a state of balance or be or put something in a state of balance”. According to the definition of robot before it 3 can be conclude that pole balancing robot is an any mechanism which supports an inverted pendulum or pole which is free to swing around a horizontal this with one degree of freedom and balances it to keep it vertical by moving the point of support. In this project a mobile robot will be used to balance the pole that place on top of it. The mobile robot drove back and forth in response to tipping movements of the pole as sensed by a potentiometer at its base. In order to move from one place to another, the mobile robot (car) had to drive it away from the goal to unbalance the pole toward the goal. In order to balance again at the destination, the car moved past the destination until the pole was upright again with no forward velocity. It then moves back to the goal. The pole balancing model would become important for studying balancing in legged locomotion has been widely recognized since 1938.Late 1970s that experimental work on balancing for legged systems gained momentum. 1.3 OBJECTIVES OF PROJECT The objectives of this project is to design and develop a mobile robot which equipped with a pole on top of it, mounted to a potentiometer where it able to measure the differentiate angle given as it was the mobile robot sensor balancing. Besides, it also has been one of the objectives in this project to design and construct a motherboard consists of microcontroller, motor driver (LM298) and other electronic components such as potentiometer sensor and regulator. Other objective is to investigate the feasibility of PIC programming in balancing pole upon the hardware platform. To let the functions properly, enable to get the relationship between angle, voltage and velocity in order to balance the pole. Of course after all of this done, programming the robot using C language is needed to test the balance of the system. 4 1.4 PROBLEM STATEMENTS To start making this project there are many things need to be consider. Firstly, is the size of the robot. This mobile robot with a small space and dimension hold a 60mm length of pole. In order to maintain the position of pole the base must made from strong structure likes Perspex and aluminum. The Perspex will be cut into rectangular shape to be the base of the mobile robot. Two holes were made to place the back tire position For the front tire, use a bolt and nut to combine it with the Perspex. This part is a little bit difficult because it must be done correctly without mistake to avoid wrong size fitters after cutting the Perspex. After that mounted the pole on the potentiometer. To do this make a hole on the bottom of the pole with a diameter smaller than the shaft potentiometer diameter Then, push the shaft into the hole until it stuck and manage to move easily(right and left). Lastly, solder the potentiometer terminal to the motor driver circuit that already install on the mobile robot base. For the PIC circuit, it is easier to locate it at the front of the robot, and link it with a motor driver circuit that located at the middle of the base. The balance happens here because the gearbox and the motor are located at the back of the robot. 1.5 SCOPE OF WORKS In this project, there are four major scopes of works, which are focusing on the concept of pole balancing mobile robot, designing and develop a small hardware, an autonomous pole balancing robot(move on microcontroller) and the control system(close loop system). General idea of creating this pole balancing robot is making a mobile robot balancing a pole that mounted on potentiometer on top of the base mobile robot. In response to the tipping movements of the pole(tip forward and backward) , the 5 mobile robot as known as the car will move faster to straight up again the pole, means that the angle and the velocity is (0) zero. If the pole tipping forward, the car will move forward in order to get its origin position. This concept is similarity to the Fuzzy Logic Controller concept. For mechanical parts, focusing on designing and developing the base of the robot, the location of the pole and how to mount it on potentiometer and the most appropriate material that can be used to develop the body of the robot have become the aims of this project. While constructing the mechanical parts of the robot, it is also required to know the best location of most of electronics board and other components to be located at the base. It is essential to ensure that the robot does not look messy and crowded eventually. For the pole, this robot used an aluminum rod, length of 60mm to control the movement of the car either forward or backward. All outputs are depend on the input that microcontroller received. An autonomous pole balancing robot means that the robot move depend on microcontroller decisions. For microcontroller, this project will focusing on PIC microcontroller, PIC 16F877A as the main component, studying how it can interfaced with potentiometer as the important item in this balancing project. The designed programming in C language however should be able to control the movement of the wheel and DC motors, which control the balance of the pole. All these components have to be properly interfaced together so that the robot will only be function, implement the tasks as programmed without error. However, for the control systems, this project use close loop system as it is required to balance the pole. From the origin center, if there if a forces applied and the pole tipping (means there is a different in an angle value), the sensor will give a signal to the PIC microcontroller. The brain processed the signal and give appropriate value of PWM to the output. If there is an error of actual angle the system wills doing again the same procedure until the pole come back to its initial position. 6 1.6 RESEARCH METHODOLOGY Start Title, objective and scope of the project was given Search literature review focus on pole balancing mobile robot Mechanical design Designing the circuit of the motor driver and PIC Redesign Decide material Suitable and easy to construct Not suitable/expensive Built mobile robot and circuit Improvement of the robot YES Troubleshooting Programming NO Ok? YES End Figure 1.1: Flow Chart for Project Methodology 7 Methodology and procedure to perform this final year project must be systematic to ensure the healthy progress of the project. First of all, title and objective of the project will be searched and discussed with the supervisor to get some opinion about the effectiveness of the title After the title was confirm, literature review must be done. Some project which was related to the title chosen is revised to get an idea, concept and theory in order to design our own project. Information or finding of this project can be found in books, articles, internet, e-books and etc. The next step is to understand the project. This project was about building and develops a pole balancing mobile robot. The structures and behaviors of the autonomous mobile robot will be explained and should be already determined in by now before designing the circuit. After circuit is designed, the fabrication of the autonomous mobile robot can be constructed using specific hardware materials. This is the most important part in building and constructing the robot. Several basic movements will be programmed and burned to the microcontroller chip to test the autonomous mobile robot. The mechanical and electronic design will be changed whenever there are errors in the testing phase. Just after completing the design of mechanical and electronics parts, it proceeds to built and constructs the motherboard followed by developing the software in C programming. Trouble shoot will always be done as long as there is an error in final testing to get the final result. 8 CHAPTER 2 LITERATURE REVIEW Literature review is vital to the research because from the previous researches, it can be guidelines to this project. In other words, it can bring a various idea and method to make this project a success. It also become a study case for this project to overcome with the new idea and different design compared to the previous project. Otherwise, from the literature review references it can develop the contents to this research. Below is a few listing that been done from the previous project. This chapter focuses on the related fields and knowledge pertaining to the accomplishment of the thesis itself. Reading includes such as reference books, papers, websites, conferences articles and any documentation concerning the related applications and research works. 9 2.1 SEGWAY HT Figure 2.1: Segway HT As can be seen from Figure 2.1 above, the Segway Human Transporter [11] (HT) is a truly 21st-century idea. A similar and commercially available system, ‘SEGWAY HT’ has been invented by Dean Kamen, who holds more than 150 U.S. and foreign patents related to medical devices, climate control systems, and helicopter design. A two-wheeled electric vehicle that's practical, efficient, slightly miraculous, and an undeniably fun way of getting around, it's as different from a bicycle or motorcycle as the original personal computers were from their lumbering, mainframe predecessors. The ‘SEGWAY HT’ is able to balance a human standing on its platform while the user traverses the terrain with it. This innovation uses five gyroscopes and a collection of other tilt sensors to keep itself upright. Only three gyroscopes are needed for the whole system, the additional sensors are included as a safety precaution. Below are the features that this robot has: 10 Controller board Gearbox battery Balance Sensor Assembly Battery pack Motor Figure 2.1.2: Features of Segway HT Emissions free, powered by rechargeable NiMH battery packs. To balance the robot, it uses five gyroscopes and a collection of other tilt sensor. Two sophisticated controller boards from Delphi Electronics provide both brains and brawn for the system. Delphi Electronics was chose in the production of high-volume, high-quality automotive electronics for such demanding applications as airbag modules. The tire are from Michelin company designed using a unique tread compound, a silica-based compound giving enhanced traction and minimized marking on indoor floors. The motors use brushless servo technology. Gearbox that use a thermoplastics rim injection molded around a forged steel hub. 11 Focusing on the sensor system, Segway HT has a powerful balance sensor to achieve the goal of this system. Figure 2.1.3 shows the Segway HT sensor system, Figure 2.1.3: Balance sensor assembly The Balance System Assembly (BSA), supplied by Silicon Sensing Systems, is an elegantly designed, extremely robust, and yet incredibly sensitive piece of equipment. This small cube, 3 inches on a side, is packed with five solid-state, vibrating-rings, angular-rate sensors ("gyroscopes") that use the Coriolis Effect to measure rotation speed. These tiny rings are electromechanically vibrated in such a way that when they are rotated, a small force is generated that can be detected in the internal electronics of the sensor. Each "gyro" is placed at a unique angle that allows it to measure multiple directions. Segway's onboard computers constantly compare the data from all five gyros to determine if any of the five is supplying faulty data--in this condition, it can compensate and use data from the remaining sensors to continue balancing through a controlled safety shutdown. Two tilt sensors filled with an electrolyte fluid provide a gravity reference in the same way your inner ear does for your own sense of balance. The BSA is monitored by two independent microprocessors and is split into two independent halves for redundancy. Even the communication between sides is performed optically to avoid electrical faults on one side propagating to the other. 12 2.2 BALANCE BOT Figure 2.2: Balance Bot The Balance Bot [8] is a computer-controlled motorized cart that balances a thirty inch long aluminum pole, much like balancing a broomstick on your finger. So far this model has the best design and development for the pole balancing mobile robot. The brain of the Bot is a high speed SX52 microcontroller made by Ubicom. To monitor the tilt of the pole and produce correction signals to the wheel motors, a fuzzy logic program is used. 13 In operation, the fuzzy logic program takes into account both the angle and angular velocity of the pole to calculate the appropriate voltage for the wheel motors. Actually, the SX52 continuously applies correction voltages to the motors, at the rate of hundreds of times per second, until the pole is finally standing upright. The tilt of the pole is measured by a low-noise optical angle sensor. The sensor signal is digitized and sent to the SX52. Angular velocity of the pole is calculated over a six millisecond period and sent to the fuzzy logic. Two external EEPROMs are used to store lookup tables in order to reduce the calculation time. The fuzzy logic translates the input signals into five-member antecedent functions, and then applies twenty-nine rules with a MIN/MAX algorithm to produce a fivemember consequent output. The output functions are combined using a set of Center of Gravity values stored in the 32K EEPROM. The final "crisp" output value is loaded into one of the SX52 timers which produce a pulse-width-modulated drive signal for the motors. The whole process takes about 550 microseconds with the SX52 running at fifty megahertz. Below are the lists of features of Balance Bot; SX52 microcontroller made by Ubicom The tilt sensor is a low-noise optical angle sensor Two external EEPROMs high-speed servos and used direct motor control with a Pololu serial motor controller two easy roller motor wheel 12V, 200rpm dual motor driver, L298 potentiometer 1k, 3 turn 14 2.3 nBot BALANCING ROBOT Figure 2.3: nBot Balancing Robot Another one example of the balancing robot is nBot balancing robot [4]. This robot was featured as NASA's Cool Robot of the week for 19 May 2003. The basic idea for a two-wheeled dynamically balancing robot is pretty simple: drive the wheels in the direction that the upper part of the robot is falling. If the wheels can be driven in such a way as to stay under the robot's center of gravity, the robot remains balanced. In practice this requires two feedback sensors: a tilt or angle sensor to measure the tilt of the robot with respect to gravity, and wheel encoders to measure the position of the base of the robot. Four terms are sufficient to define the motion and position of this "inverted pendulum" and thereby balance the robot. These are 1) the tilt angle and 2) its first derivative, the angle velocity, and 3) the platform position and 4) its first derivative, the platform velocity. These four measurements are summed and fed back to the platform as a motor voltage, which is proportional to torque, to balance and drive the robot. 15 This balancing mobile robot uses the gyroscope and accelerometer combined with complementary filters to provide an inertial reference sensor. The ADXL202 accelerometer provides accurate static tilt information, when the robot is not accelerating. The gyroscope can be integrated to provide accurate dynamic tilt information, but the integration tends to drift over time. Combining the two sensors provides a robust inertial measurement. 2.4 SCALED DOWN PROTOTYPE OF A DIGITAL SIGNAL PROCESSOR CONTROLLED TWO-WHEELED VEHICLE Researchers at the Industrial Electronics Laboratory at the Swiss Federal Institute of Technology have built a scaled down prototype of a Digital Signal Processor controlled two–wheeled vehicle[4] based on the inverted pendulum with weights attached to the system to simulate a human driver. Figure 2.4: Prototype of Digital Signal Processor controlled two-wheel vehicle 16 A linear state space controller utilizing sensory information from a gyroscope and motor encoders is used to stabilize this system. Advantage of this system prototype is it uses gyroscope as it balancing sensor. Gyroscope capable of detecting angular input rates about two orthogonal axes without the use of slip rings. 2.5 SUMMARY From the literature review discussed in this chapter, it shows only a few of the researcher do the balancing mobile robot by using a pole. It is hard to find a model that would become my references to this project. However, the input and information given really helps me in improving my robot development. 17 CHAPTER 3 ROBOT DESIGN Inherently, robotics is an interdisciplinary field that ranges in scope from the design of mechanical and electrical components to sensor technology, computer systems and artificial intelligence. The mechanical and electrical components include mechanical frame, motor, pole and wheel while the electrical components consists of microcontroller and sensing system. The sensing system will allow the robot to interact directly with environment. 18 3.1 ROBOT STRUCTURE The structure of the robot can be classified into two parts: 1) Mechanical Design 2) Electrical design 3.2 DESIGN MECHANICAL Mechanical structures should be designed as accurate as possible to avoid unbalancing while robot starts its movement. All the possibilities should be aware and taken seriously because minor mistakes will cause a major trouble to the robot system. The selection of the best materials that will be used should be done wisely. The pro and cons of any taken action influence the performances of the robot later on The mechanical structure of the balancing mobile robot consists of the chassis of the mobile robot, pole for the balancing system and the driving mechanism, which is one DC, motors (gearbox) and wheels. Perspex is used for the body structure as it is easy to fabricate, light and worked on. Weight is an important factor here, as the robot will need to move smoothly. To catch up the tipping pole, the robot must move faster so it must be made by a light material. An aluminum rod is chosen for the pole because it is light, firm and easy to mount on potentiometer. These conditions are important because in order to balance the pole, its material must be easy to move to get back to its initial condition (straight). 19 These projects only have one layer and it consists of PIC microcontroller and motor driver circuit, potentiometer and a pole. (Refer to Figure 3.1) The pole Motor Driver and sensor circuit Figure 3.1: Mechanical Structure-Plan View PIC microcontroller circuit Figure 3.2: Base of the project (in the beginning) 20 3.2.1 MOTOR POSITIONING AND INSTALLATION Gearbox is located at the back side Figure 3.3: DC Motor (Gearbox) Positioning There is one DC motor in a gearbox used in Pole Balancing Mobile Robot. Function of this motor is to make the mobile robot move forward and backward. It located at the back side of the robot. The reason of using only one DC motor is because the motor is capable enough to move the four tires that the robot have. Secondly it can reduce the weight of the robot as the circuit overall situated at the front of the robot. It makes the weight in front and the back of the mobile robot balance as it is important due to the balancing factor. Generally, the DC motors are used in drive systems for two reasons. The first reason involves the relationship between the speed and the torque of the DC motor. The torque of the DC motor can change over a wide range of application. That is, as the load applied to the motor increases, the torque at the motor also increases. Nevertheless, this increased torque tends to slow the motor down. Additional current supplied to the motor will overcome the torque and keep the speed of the motor 21 constant. The second reason DC motors are used is that DC motors can easily be interfaced with electronic components. The DC motor was recognized because it is small, light and of course it is available at market with reasonable price compare to the others. Furthermore, the programming to operate DC motor is quite simple compare to stepper motor. DC motor must attach to gear to make it ABLE to carry more loads. If it is not attach to gear, maybe the robot cannot move at all. The supply voltage for each DC motor is 5 Volts. 3.3 BASE It is important to choose a suitable shape in making a robot especially when it involves a balancing part. A rectangular is choose to be the shape of the body because it is balance and have a much space for the mechanical and electrical component to place on compare to other shape. In fact, a four tires mobile robot looks stable and neatness with the shape that have four edges. The purpose of this project is balancing. With a proper shape and design of the mobile robot base, it helps a lot in maintaining the stability of the system. The base will be equipped with four pairs of infrared sensors tracking lines purposes. A pole is located on top of the robot, mounted on the potentiometer in a same circuit with a motor driver. All of this is attached together on the base and that is why the base must have a large space and rectangular shape is the answer of the problem. 22 3.4 GEARBOX Figure 3.4: Gearbox of Control Racing Car A gearbox is an enclosed system of assembled gears that transmits mechanical energy from a prime mover to an output device. A gearbox can also change the speed, direction, or torque of mechanical energy. In this project, a gearbox from the remote control racing car is chosen to be the gearbox of the robot. The advantage is, it cost no money because it is free (gift from friends). Below are the features of gearbox; Gear set Nozzle Cylinder Piston M100 Spring Metal bushings To know the gearbox features, below is the figure show the system of the gearbox. 23 Cylinder/piston Gear Nylon/electrics Trigger Motor 3.5 Figure 3.5: System inside Gearbox DC MOTOR Refer to the Figure 3.5; the DC motor is in the gearbox. It stores in the same casing because both of the material are coming from the same remote control racing car. Motors are inductive devices since they draw mush more current at startup that when they are running at a steady speed. Generally, a DC motor has two terminals on it. If the positive and negative leads from a power source (battery, power supply) are connected to the terminals of the motor, the motor will spin in one direction. If the connections are swapped, the motor will spin in the opposite direction. A few things that should be known about the motor that will be used as the following; what voltage it is designed to work at, how much current it draws when running, and how much current it draws at stall. For this project, the DC motor has a starting current more than 1.5A, need a power of 12V and it has a small torque. 24 3.5.1 PULSE WIDTH MODULATION Figure 3.6: PWM signals of varying duty cycles Pulse Width Modulation (PWM) allows microcontrollers to dim lights, control motor speeds, fan speeds and generate analog voltages. By changing the length of the pulse, the output can be controlled. The pulse occurs at a regular frequency, the modulation frequency. The length of the pulse ratio to period time is called the duty cycle. The larger the duty cycle the higher the output is. PWM is a powerful technique for controlling analog circuits with a microprocessor’s digital outputs. PWM is employed in a wide variety of application ranging from measurement and communication to power control and conversation. The PWM signal is still digital because, at any given instant of time, the full DC supply is either fully on or fully off. The voltage or current source is supplied to the analog load by means of a reporting series of on and off pulses. The on-time is the time during which the DC supply is applied to the load, and the off-time is the periods during which that supply is switched off. Given a sufficient bandwidth, any analog value can be encoded with PWM. 25 Figure 3.7 shows three different PWM signals. For the first, it shows a PWM output at a 20% duty cycle. That is, the signal is on for 20% of the period and off the other 80%. Next PWM outputs at 50% and 80% duty cycles, respectively. These three PWM outputs encode three different analog signals values. 3.6 POLE From a definition a pole (rod aluminum) is a long (usually round) rod of wood or metal or plastic. In this project, rod aluminum with a length of 60mm is used to be the pole of the balancing mobile robot. It is light, has a round shape, cheap and easy to get. Below is the picture of rod aluminum. Figure 3.7: Rod Aluminum 3.7 MAIN ELECTRONIC COMPONENTS 26 POWER SUPPLY CIRCUIT SENSOR/POTENTIO METER MICROCONTROLLER MOTOR DRIVER CIRCUIT Figure 3.8: Main Electronic Component 3.7.1 MOTOR DRIVER (L298) To control the movement of motor this project needs motor driver, L298 to do the job. The L298 is a strong, useful dual-motor driver IC but it’s tough to use by it. The L298 chip is the bigger brother to the L293 chip (a popular small-motor driver IC), but the L298 handles more current, and more voltage. The motor operates in a high current and high voltage and L298 is perfect enough to be its motor driver because it can function in high current until 4A. L298 can drive inductive loads such as relays, solenoids, DC and stepping motors. Two enable inputs are provided to enable or disable the device independently of the input signals. It is a Bidirectional DC motor control means that Dual L298 Motor Driver can control four DC motors. The most important thing about L298 is, it easy to mounting and setup on the circuitry board. Below are the characteristics of L298; 6 to 26V operation, 27 4A total drive current Accessible 5V regulated voltage Motor tor direction indicator LEDs EMF protection diodes Small 40mm (1.527”) square footprint Figure 3.9: Motor Driver L298 3.7.2 POTENTIOMETER Electronic symbol (Europe) (US) Figure 3.10: Potentiometer and Its symbol 28 A potentiometer is a three-terminal resistor with a sliding contact that forms an adjustable voltage divider. If only two terminals are used (one side and the wiper), it acts as a variable resistor or Rheostat. Potentiometers are commonly used to control electrical devices such as a volume control of a radio. Potentiometers operated by a mechanism can be used as position transducers, for example, in a joystick. Potentiometers are rarely used to directly control significant power (more than a watt). Instead they are used to adjust the level of analog signals (e.g. volume controls on audio equipment), and as control inputs for electronic circuits. For example, a light dimmer uses a potentiometer to control the switching of a TRIAC and so indirectly control the brightness of lamps. Potentiometers are sometimes provided with one or more switches mounted on the same shaft. For instance, when attached to a volume control, the knob can also function as an on/off switch at the lowest volume. In this project, potentiometer 50k is chosen to be the sensor because it is easy to get, mounted with a pole and has a tolerance of 5%-10%. 3.7.3 MICROCONTROLLER A microcontroller is a computer-on-a-chip. It is a type of microprocessor emphasizing high integration, low power consumption, self-sufficiency and costeffectiveness, in contrast to a general-purpose microprocessor (the kind used in a PC). In addition to the usual arithmetic and logic elements of a general purpose microprocessor, the microcontroller typically integrates additional elements such as read-write memory for data storage, read only memory, such as flash for code storage, EPROM for permanent data storage, peripheral devices, and input/output 29 interfaces. Power consumption while sleeping may be just nano watts, making them ideal for low power and long lasting battery applications. This project used PIC16F877A, manufactured by Microchip has been chosen as the main controlling unit of pole balancing robot. This chip was selected based on several reasons It is small in size and equipped with enough input\output ports Free samples can be applied from the Microchip website It has interrupt capabilities Easy-learning programming language Figure 3.11: PIC 16F877A Below is the figure of PIC pin notation and its features. 30 Figure 3.12: PIC 16F877A pin notation Figure 3.13: PIC 16F87XA features 31 3.7.4 POWER There are many powers offered in market nowadays. It is included power such AC-DC Adapter, Transformer, Rechargeable Battery, Lead Acid Battery, LiPo Battery Charger and Cell Battery respectively. In making decision on which power is more appropriate, few specifications should be revealed such as per-cell voltage, amp-hour current, weight and reusability. For this project, battery nickel-cadmium 9.6V has been chosen as the power supply since it is cheap, light, powerful, small, easy to carry and easy to design.(see figure 3.14) Figure 3.14: Battery Nickel-Cadmium 9.6V The battery that being used as the input power supply is +9.6 V. This circuit is to generate 5V which is needed by the PIC 16F877A Microcontroller from a 9V battery. Terminal positive of the battery is connected to “+9V” and the terminal negative of the battery is connected to “ground”. 3.7.5 VOLTAGE REGULATOR PIC microcontroller needs constant 5V power supply. So, there is additional circuit that will supply this amount of voltage. This circuit will change 9.6V power 32 supply from the battery to constant 5V by using voltage regulator LM 7805. Figure 3.15 shows the voltage regulator circuit. Voltage regulator 9.6V Figure 3.15: Voltage Regulator Circuit 3.7.6 WHEEL Figure 3.16: Pole balancing tire At the beginning, it was hard to find an exact tire for the mobile robot. A few factors have to analyze before the base can be installed by a tire. The factors are; Small and sturdy Easy to spin forward and backward Match with the robot shape and look neat Flexible 33 After making some choices, finally the result is to use a tire from the same remote control racing car that the gearbox and motor was taken. It fixes to all criteria that been analyze before. 3.8 CONCLUSION As a conclusion for this chapter, the pole balancing mobile robot mechanical and electronic structure manages to combine together and form the robot successfully. To see the result, below is the figure showing of the complete robot of pole balancing robot. Figure 3.17: Side View Figure 3.18: Back View 34 Figure 3.19: Front View Figure 3.20: Plan View 35 CHAPTER 4 CIRCUIT DESIGN 4.1 OVERVIEW In this chapter, it will discuss all the circuits that had been used for this project. The circuits are microcontroller circuit, sensor (potentiometer) circuit and motor driver circuit. 4.2 L298 AND POTENTIOMETER CIRCUIT. Figure 4.1 is a L298 and sensor (potentiometer circuit). In This project, one L298 and one potentiometer will be used for controlling the movement of the mobile robot and the balancing of the pole. There are fifteen pins in LM298 and each of the pins has a function to do. The statements below are the pin and their function. Figure 4.2 shows the pin of the L298 36 All of this pin must connect correctly because if wrong the L298 will short circuit and the device cannot be use again. As we can see, the middle pin of potentiometer will be connected to pin RAO from the PIC to convert the analog value to digital value. Other pins are connecting to Vcc and ground. To control the PWM of the motor, enable pin from the L298 must interface with enable pin from the PIC microcontroller. This will control the speed of the motor. Output pin will connect to motor to give directly signal from PIC. Input pin will change the direction of the motor either it want to move forward or backward. It also setting the time delay between the changing directions happens. Figure 4.1: L298 and Potentiometer Circuit 37 Figure 4.2: Block Diagram of L298 Figure 4.3: Real view of L298 and Potentiometer circuit 38 4.3 MAIN CONTROLLER CIRCUIT Figure 4.4: Basic PIC Microcontroller Circuit Figure 4.4 is the basic microcontroller circuit. The Microcontroller Unit (MCU) main circuit consists of crystal, reset switch, and 5 volts supply from voltage regulator. Crystal is connected to the OSC1 and OSC2 pins to establish oscillation. Figure 4.4 shows the basic PIC microcontroller circuit. Pins 11 and 32 is connected direct to 5 volts voltage regulator (not shown in figure), and pins 12 and 31 is grounded. The configuration of crystal and reset switch is shown in the Figure 4.4. Vdd is 5 volts regulated voltage from voltage regulator circuit. A 20 MHz crystal is choose as the oscillator to ensure the execution time of each instruction is fast enough. By referring to PIC16F877A datasheet, it is necessary to connect 1533picoFarad ceramic capacitors to increase the stability of the oscillator. Figure 4.5 shows the overall circuit for the PIC microcontroller circuit and figure 4.6 shows the real view for this circuit. 39 Figure 4.5: Main Controller Circuit Figure 4.6: Real View of Main Controller Circuit 4.4 CONNECTING THE MICROCONTROLLER TO PC CIRCUIT This project need some circuit to interfacing data from computer to microcontroller. The PIC 16F877A is requires either TTL or CMOS logic, therefore before connecting direct to RS232 port, max 232 is using to transform the RS232 level into 0 and 5 Volts since RS232 has some electrical specifications as below: 40 Logic 0: between +3V and +25V Logic 1: between -3V and -25V The region between +3V and -3V is undefined MAX232 has two receives and transmitters in the same package that proves need in this system.RS232 is the most known serial port used in transmitting the data in communication and interface. Even though serial port is harder to program than the parallel port, this is the most effective method in which the data transmission requires less wires that yields to the less cost. The RS232 is the communication line, which enables the data transmission by only using three wire links. The three links provides ‘transmit’, ‘receive’ and common ground. 41 CHAPTER 5 SOFTWARE DEVELOPMENT 5.1 OVERVIEW There are three software are used in this project. Microsoft Excel is used for the calculation of data and graph plotting before it can transfer the data to do a programming. Second is MikroC compiler used to compile the C code to the hex code, and WinPic800 which used to load program into the microcontroller. 5.2 MICROSOFT EXCEL Microsoft Excel is a spreadsheet-application written and distributed by Microsoft for Microsoft Windows and Mac OS X. It features calculation, graphing tools, pivot tables and a macro programming language called VBA (Visual Basic for Applications). It has been the most widely used spreadsheet application available for these platforms since version 5 in 1993. Excel is part of Microsoft Office. 42 5.3 MIKROC MikroC is a powerful, feature rich development tool for PIC microcontrollers developed by mikroElektronika. It is designed to provide the programmer with the easiest possible solution for developing applications for embedded systems, without compromising performance or control. MikroC provides a lot of useful and handy libraries for example, LCD interface, UART, I2C, SD card access and many more. Below is the MikroC sample for sending "Hello World!" to LCD. Lcd_Init(&PORTB); // Initialize LCD connected to PORTB Lcd_Cmd(Lcd_CLEAR); // Clear display Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off Lcd_Out(1, 1, "Hello World!"); Code Explorer Code Editor Debugger watch Error Window Figure 5.1: MikroC window PIC and C fit together well. PIC is the most popular 8-bit chip in the world, used in a wide variety of application, and C, prized for its efficiency, is the natural 43 choice for developing embedded systems. MikroC provides a successful match featuring highly advanced IDE, ANSY compliant compiler, broad set of hardware libraries. MikroC allows user to quickly develop and deploy complex applications. The C source code can be written using the built-in Code Editor (Code and Parameter Assistants, Syntax Highlighting, Auto Correct, Code Templates, etc.). The MikroC libraries are also included to dramatically speed up the development; data acquisition memory, displays, conversions, communication and many more. Practically all PIC series likes P12, P16, and P18 chips are supported. In this project, C language will be used in programming this Pole Balancing Mobile Robot. So, the MikroC software is needed to compile the C-language into machine code before programmed into microcontroller. This compiler provides a number of useful libraries for user to use as ADC and USART. By using this library user do not need to configure the register of the microcontroller manually if they want to use say the ADC module of the microcontroller, the compiler will do it for the user. What users have to do is to know how to use the library. 5.3.1 PWM CHANGE DUTY VIA MIKROC To control the speed of the motor, it depends totally from the PWM. By using mikroC, PWM can be control by changing its duty ratio. In PWM programming there are four terms that are important; PWM_Init PWM_Start PWM-Change_Duty, 44 PWM_Stop First thing that has to been set up is PWM_Init. PWM_Init initializes the PWM module with duty ratio 0. Parameter freq is a desired PWM frequency in Hz This routine needs to be called before using other functions from PWM Library. This is an example of PWM_Init; Initialize PWM module at 5 KHz: Pwm_Init(5000); Secondly, after call the PWM_Init, PWM_ Start have to been to call to start the PWM. PWM_Init must been call first before to write this function. It is written as below; Pwm_Init(5000); // Initialize PWM module }//~ void main() { InitMain(); j = 80; // Initial value for j oj = 0; // oj will keep the 'old j' value Pwm_Start(); // Start Pwm Lastly, is PWM_Change_Duty. It is important to know that this function changes PWM duty ratio. Parameter duty takes values from 0 to 255, where 0 is 0%, 127 is 50%, and 255 is 100% duty ratio. Other specific values for duty ratio can be calculated as (Percent*255)/100. Requires for this function is Pwm_Init must be called before using this routine. Example below; Set duty ratio to 75%: Pwm_Change_Duty(192); PWM_Stop is required to stop the PWM. 45 The example changes PWM duty ratio on pin RC2 continually. If LED is connected to RC2, you can observe the gradual change of emitted light. // microcontroller: P16F877A // PWM module is set on RC2. unsigned short j, oj; void InitMain() { PORTB = 0; TRISB = 0; ADCON1 = 6; PORTA = 255; TRISA = 255; PORTC = 0xFF; TRISC = 0; Pwm_Init(5000); }//~ void main() { InitMain(); j = 80; oj = 0; Pwm_Start(); // Set PORTB to 0 // PORTB is output // All ADC pins to digital I/O // PORTA is input // Set PORTC to $FF // PORTC is output // Initialize PWM module // Initial value for j // oj will keep the 'old j' value // Start PWM while (1) { // Endless loop if (Button(&PORTA, 0,1,1)) // button on RA0 pressed j++ ; // increment j if (Button(&PORTA, 1,1,1)) // button on RA1 pressed j-- ; // decrement j if (oj != j) { Pwm_Change_Duty(j); oj = j; PORTB = oj; } Delay_ms(200); // If change in duty cycle requested, // set new duty ratio, // memorize it, // and display on PORTB // Slow down a bit } } WINPIC800 WinPIC800 is software that used in this project to load the hex file into the microcontroller. This software will be used together with the programmer which being called JDM programmer or also it can be used with the USB programmer. Below are the figures about the process of WinPIC800 46 Figure 5.2: WinPIC 800 Click here Figure 5.3: PIC detected 18F452 47 Click here to program all Figure 5.4: Writing HEX file succeeds 5.5 PROGRAMMING LANGUAGES Programming languages are used to facilitate communication about the task of organizing and manipulating information, and to express algorithm precisely. In this project, C programming language had been chosen to code the major task including interpret the data from the potentiometer and control the PWM to perform desired task. The advantages of using C programming language are: It is a general purpose programming language that provides code effectively, elements of structured programming and has a rich set of operators. 48 Convenient and effective programming solution for a wide variety of software task. Can be written faster than assembly code thus reduces cost and easier to be understood. 49 CHAPTER 6 RESULT AND DISCUSSION This chapter will discuss about the result and finding of this project. Besides, the analysis conducted in this project also will be presented. 6.1 OVERVIEW This chapter will discuss the result, findings and the assessment from the analysis conducted in this project. After the design and development of the Pole Balancing Mobile Robot took place, the robot will be analyzed to measure the effectiveness, stability and to ensure the objectives successfully achieved. There are four steps to do before the final result obtain. The steps are; Calibration Calculation and analysis Programming Testing 50 6.2 POTENTIOMETER CALIBRATION This is a first step in finding the result of the project. An experiment must be done to calibrate the value of voltage correspond to the different angle given from the potentiometer. It takes at least three times calibration before going to the next step. Below are the table of the data contain of the different angle of potentiometer and its voltage. Angle,(θ) Voltage,(V) -20 2.23 -15 2.30 -10 2.41 -5 2.47 0 2.55 5 2.65 10 2.75 15 2.86 20 2.93 Figure 6.1: Table of Angle versus Voltage To write a programming about the input voltage comes from the potentiometer to the PIC , the analog value that comes from the sensor must be convert to digital value. Figure 6.2 shows the digital value of the analog voltage. The hex value will be compare to the reference voltage or full scale voltage. In this project the full scale voltage is 5V. It means for the 5V analog value it is same as 1024 in hex values. (Refer to the PIC 16F877A datasheet) 51 Analog Calculation Hex value 2.23Volt 2.23V 1024 456.7 5V $1C8 2.30Volt 2.30V 1024 471.04 5V $1D7 2.41Volt 2.41V 1024 493.57 5V $1ED 2.47Volt 2.47V 1024 505.86 5V $1F9 2.55Volt 2.55V 1024 522.24 5V $20A 2.65Volt 2.65V 1024 542.72 5V $21E 2.75Volt 2.75V 1024 563.2 5V $233 2.86Volt 2.86V 1024 585.73 5V $249 2.93Volt 2.93V 1024 600.06 5V $258 value Figure 6.2: Table of hex value 6.3 CALCULATION AND ANALYSIS After get the hex value, the complete data will be measured through Microsoft Excel. All the calculation and plotting the graph will be done by the 52 software. Figure 6.3 shows the graph resulting from the angle versus voltage (in decimal value). angle vs voltage(in dec) y = 0.273x - 143.7 25 20 15 Equation of the graph 10 angle 5 0 0 100 200 300 400 500 600 700 Series1 -5 -10 -15 -20 -25 voltage(in dec) Figure 6.3: Graph of angle versus voltage (in decimal value) From the graph, it can be analyze that the angle is directly proportional to the voltage. The result produce a straight line graph shows the system will possibly result a stable condition among both value. It also yields a linear line equation that is Y=0.273x-143.7 Y = angle X = voltage (in decimal) 53 6.3.1 SPEED VERSUS ANGLE For this data, the calibration cannot be done because it is difficult and take a lot of time to do it. To make the analysis easier, the same concept of Fuzzy Logic Controller was use to obtain the relationship between speed/PWM and angle. The Fuzzy Logic Controller is given in the form of If-Then rules a shown: - If θ is medium negative and dθ is medium negative then the force is large negative. - If θ is 0 and dθ is medium negative then the mobile moving backward - If θ is small negative and dθ is small negative then the mobile also moving backward with a medium speed - If θ is 0 and dθ is 0 then the speed also zero - If θ is small positive and dθ is small positive then the mobile moving forward with a medium speed - If θ is small negative and dθ is small positive then the speed is zero - If θ is medium positive and dθ is medium positive then the mobile moving forward with a high speed From this, assumption can be making and the PWM can be set and control according to the corresponding different angle given. 6.3.2 CONTROL SYSTEM After getting all the data needed, it is important to initialize the control system in this project. The control system in this project is a closed loop system which is automatically changes the output based on the difference between the feedback signals to the input signal. Below is the figure of the close loop system for this project. 54 Initial condition, θ=0 θ + - PIC Speed/ PWM Angle from potentiomet er Error of actual angle Figure 6.4: Block Diagram of the Closed Loop System At first the pole is in initial condition whereas θ=0. After giving some forces to the mobile robot, the pole will began tipping. The angle of the pole change and it also change the voltage of the potentiometer. This signal was sent to the PIC to process the data as it was programmed before. With a Fuzzy Logic Controller concept before, the motor will moving according to the If-Then rule. It will straight up again the pole until the pole comes back to its initial condition. If there is an error occur, which the mobile robot too fast or too slow, this error will feedback again the system and be anew input for this system until the θ=0. 6.4 PROGRAMMING After finish the calibration and calculation, all the input will be programming using MikroC. Figure 6.5 show the flow chart of the programming. 55 NO YES Move backward with high speed PWM=200 NO YES Move backward with high speed PWM=200 56 NO YES Stay with 0 speed PWM =0 NO YES Move backward with high speed PWM=200 Figure 6.5: Flow chart of the programming This flow chart was not show all the data programming but overall the programming is the same. 57 CHAPTER 7 CONCLUSION AND RECOMMENDATIONS 7.1 CONCLUSION This project discusses the development of Pole Balancing Mobile Robot which actuated DC motor, L298, a pole, and a Potentiometer. The potentiometer is an easy and a cheap sensor together comes with a full package to be the balancing sensor. Along with the potentiometer is Microcontroller 16F877A process all data using C programming language. The pole balancing robot has been successfully developed and actually has trained me to learn many skills; hardware and software skills besides soft skill. In this learning process, the researcher gain many knowledge and experience in making a robot before jump into the industry one day. It is hoping that this project will contribute something in balancing mobile robot system and will be able to compete with another balancing robot whenever it is equipped with many features and functionality. In addition, not much advanced technology can be applied since the duration time to complete it only one year. However, it can be proceed later with much more additional intelligences and advanced approach as collections or even to commercialize after this. 58 7.2 RECOMMENDATIONS There are a few recommendations for the future research for this robot. • Firstly, the system must have encoder. More accurate to calibrate the data. • Secondly must do state space or fuzzy logic controller after doing the mechanical hardware and experiment. It will make the system in a balance condition. • Use other sensor such as accelerometer or gyroscope that is much better compare to potentiometer. • Must calibrate the weight of the base, pole and any other material so that we know our systems are in incredibly stable in weight. • Use a stepper motor. More accurate and steady compare to Racing car motor • Focusing more on the programming and the mechanical structure of the robot • Must find the right way to mount the pole into the potentiometer. As for future enhancement, more features can be added to the mobile robot using others balancing sensor such as encoder and accelerometer or maybe gyroscope. This will help the system to be more balance and stable all the time. 59 REFERENCES [1] Meng Joo Er, Bak Heng Kee and Chee Chong Tan, “Design and Development of an Intelligent Controller for a Pole-Balancing Robot”, thesis.School of Electrical and Electronic Engineering, Nanyang Technological University,Singapore,2001 [2] H.Hemami,C.L Golliday Jr., ‘The Inverted Pendulum and Biped Stability, Mathematical Biosciences 34”,pp 95-110,1977 [3] K. Yamazaki, The Design and Control of SCOUT I, M. Eng. thesis, McGill University, 1997 [4] Rich Chi Ooi, “Balancing a Two-Wheeled Autonomous Robot”, thesis,The University of Western Australia,School of Mechanical Engineering. [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] Grasser, Felix, Alonso D’Arrigo, Silvio Colombi & Alfred C. Rufer. “JOE: A Mobile, Inverted Pendulum”, IEEE Transactions on Industrial Electronics, Vol 49. 2002 Herdawatie Binti Abdul Kadir, “Modelling And Control Of A Balancing Robot Using Digital State Space Approach”,thesis,Faculty of Electrical Engineering, University of Technology Malaysia,2005. Mori,S.,Nishira,H.,and Furuta,K, “Control Of Unstable Mechanical System CONTROL OF PENDULUM”,Int.J.Contr.,Vol 23:pp 673-692,1976. http://www.robotstoreuk.com/ http://www.nexrobotics.com/products/motor-controllers / http://en.wikipedia.org/ www.bossbi.com/scooter/segway/iseries.php http://www.iiisci.org/Journal/CV$/sci/pdfs/S406IQ.pdf http://www.geology.smu.edu/~dpa-www/robo/nbot/ http://www.microchip.com www.cytron.com 60 APPENDIX SOURCE CODE OF DEVELOPMENT OF POLE BALANCING MOBILE ROBOT 61 Source Code signed double angle; unsigned data; //-------------------------------------------------------------------------void kiri1() { portd.f0=0; portd.f1=1; Pwm1_Change_Duty(250); delay_ms(1000); portd.f1=1; portd.f0=0; Pwm1_Change_Duty(200); } void kiri2() { portd.f0=0; portd.f1=1; Pwm1_Change_Duty(250); delay_ms(1000); portd.f1=1; portd.f0=0; Pwm1_Change_Duty(200); } 62 void kiri3() { portd.f0=0; portd.f1=1; Pwm1_Change_Duty(250); delay_ms(1000); portd.f1=1; portd.f0=0; Pwm1_Change_Duty(200); } void kiri4() { portd.f0=0; portd.f1=1; Pwm1_Change_Duty(180); delay_ms(1000); portd.f1=1; portd.f0=0; Pwm1_Change_Duty(150); } void stay() { portd.f0=0; portd.f1=0; Pwm1_Change_Duty(0); } 63 void kanan1() { portd.f0=1; portd.f1=0; Pwm1_Change_Duty(180); delay_ms(1000); portd.f1=0; portd.f0=1; Pwm1_Change_Duty(150); } void kanan2() { portd.f0=1; portd.f1=0; Pwm1_Change_Duty(180); delay_ms(1000); portd.f1=0; portd.f0=1; Pwm1_Change_Duty(150); } void kanan3() { portd.f0=1; portd.f1=0; Pwm1_Change_Duty(180); delay_ms(1000); 64 portd.f1=0; portd.f0=1; Pwm1_Change_Duty(150); } void kanan4() { portd.f0=1; portd.f1=0; Pwm1_Change_Duty(180); delay_ms(1000); portd.f1=0; portd.f0=1; Pwm1_Change_Duty(150); } void terus() { portd.f0=1; portd.f1=0; Pwm1_Change_Duty(180); delay_us(1000); } void main() { 65 TRISC=0; TRISD=0; TRISA=0xFF; ADCON1=0; PORTD=0; Pwm_Init(5000); Pwm_Start(); while(1) { delay_us(100); data=Adc_Read(0); angle=0.273*data-143.7; if((angle>-20)&&(angle<-15)) kiri1(); else if((angle>-15)&&(angle<-10)) { kiri2(); } else if((angle>-10)&&(angle<-5)) { kiri3(); } else if((angle>-5)&&(angle<0)) { kiri4(); } else if(angle<0.1) { stay(); } else if((angle>0)&&(angle<5)) { kanan1(); 66 } else if((angle>5)&&(angle<10)) { kanan2(); } else if((angle>10)&&(angle<15)) { kanan3(); } else if((angle>15)&&(angle<20)) { kanan4(); } else if(angle>20) { terus(); } } }