document26

Click here to load reader

Post on 22-Oct-2014

24 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

I have declared Line Follower Robot Using PID Controller is the result of my own research except as cited in the references. This thesis has not been accepted for any degree and is not concurrently submitted in candidature of any other degree Signature: __________________________________ Name: AHMAD NOR KASRUDDIN B NASIR Date: 13 NOVEMBER 2008

LINE FOLLOWER ROBOT USING PID CONTROLLER.

ABD AZRIN FIRDAUS A RAHIM

This thesis is submitted as partial fulfillment of the requirement for the award of the Bachelor Degree of Electrical Engineering (Electronic)

Faculty of Electrical & Electronic Engineering University Malaysia Pahang

NOVEMBER 2008

ii

DECLARATION

All the trademark and copyrights use here in are property of their respective owner. References of information from other sources are quoted accordingly, otherwise the information presented in this report is solely work of the author.

Signature Author Date

: ____________________________ : ABD AZRIN FIRDAUS A RAHIM. : 13 NOVEMBER 2008.

iii

DEDICATION

Specially dedicate to My beloved parents, brothers and sisters.

iv

ACKNOWLEDGEMENT

First, I would like to express my acknowledgment and gratitude to my supervisor, Encik Ahmad Nor Kasruddin B Nasir for the guidance and co-operation that been given throughout the progress and to complete this project. I also deeply thank to my family whose have giving me chance to continue my study at Universiti Malaysia Pahang and support me for all these year. Thanks for their encouragement, support, love, my little brother, sister and many more.

ALHAMDULILLAH. Finally, my great appreciation to my house mate that giving me so many opinion till I dont know which one to comprehend, thanks for their brilliant idea and my class mate whom involve directly or indirectly with this project. Thank You very Much.

v

ABSTRACT

Robot becomes widely used in industrial due to their characteristics. Robot able to work in 24 hours continuously without feeling tired unlike human that confine to certain time. The cost to setup the robot nowadays becomes more affordable and their long term prospect is bright judging from their capacity to perform. But in reality, there is no robot able to function perfectly and still making error. A better controller needed here, to allow the robot performs efficiently and make less error. This project try to implement a PID controller on mobile robot to see whether the robot perform efficiently. This mobile robot has a line tracking module, where it will follow the track that made from black tape. This is area where the PID implemented, the robot will be able to follow the black tape effectively and moving along the track smoothly.

vi

ABSTRAK

Robot semakin digunakan secara meluas dalam industri kerana ciri-ciri robot yang baik untuk keadaan di dalam kilang. Robot boleh melakukan kerja 24 jam secara berterusan tanpa henti di mana robot tidak pernah merasa letih tidak seperti manusia yang mempunyai had masa akibat keletihan. Kos untuk memasang robot menjadi semakin murah dan prospek masa panjang yang baik di mana robot dapat melakukan kerja dengan baik dan memuaskan. Tetapi secara realitinya, robot tidak semestinya dapat menjalankan kerja dengan sempurna dan besar kemungkinan melakukan ralat. Di sini suatu sistem di perkenalkan iaitu sistem kawalan yang dapat membantu robot melakukan kerja dengan lancer dan kurang melakukan ralat. Projek ini cuba mengaplikasikan pengunaan kawalan PID ke atas robot untuk menentukan samaada robot dapat berfungsi dengan baik atau tidak. Robot ini menpunyai modul mengikut garis, dimana garis diperbuat daripada pita hitam itu dianggap sebagai landasan untuk diikuti oleh robot. Inilah kawasan dimana pengaplikasian kawalan PID ke atas modul ini dan dapat dilihat samaada robot dapat mengikuti landasan tanpa terkeluar di samping dapat mengikutinya dengan lancer.

vii

TABLE OF CONTENTS

CHAPTER

ELEMENTS

PAGE

DECLARATION DEDICATION ACKNOWLEDGEMENT ABSTRACT ABSTRAK TABLE OF CONTENTS LIST OF TABLES LIST OF FIGURES LIST OF ABREVIATIONS LIST OF APPENDICES

ii iii iv v vi vii x xi xiii xiv

CHAPTER 1

INTRODUCTION

1.1 1.2 1.3 1.4 1.5

Overview Objective Scope of Project Problems Statement Thesis Organization

1 1 2 2 2

CHAPTER 2

LITERATURE REVIEW 2.1 Introduction 4

viii

2.2

Electric Motor 2.2.1 DC Motor 2.2.2 AC Motor 2.2.3 Stepper Motor 2.2.4 Servo Motor 2.2.5 Brushless Servomotor

5 6 6 7 8 10

CHAPTER 3

HARDWARE AND SOFTWARE DEVELOPMENT

3.1 3.2 3.3 3.4

Introduction Basic Design and Requirement Basic Operation Input System 3.4.1 IR Sensors 3.4.2 Comparator 3.4.3 LM 324 3.4.4 Arrangement of Sensors

13 13 14 14 15 16 16 18 20 23 23 24 25 25

3.5

Processing System 3.5.1 Voltage Regulator 3.5.2 IC 7805 3.5.3 Oscillator

3.6

Output System 3.6.1 Use of Driver

ix

3.6.2 IC L293D 3.7 3.8 Circuit Integration Pulse Width Modulation (PWM) 3.8.1 Use of PWM 3.9 PID for Line Following Robot 3.9.1 Behavior Following Line

26 27 28 29 30 30

3.9.2 PID Hardware Configuration 32 3.9.3 PID Formula 3.9.4 PID Implementation 3.10 Software Configuration 3.10.1 PIC kit 2 Programmer 3.10.2 Proteus 7 Simulator 3.10.3 Programming 16F877A 3.11 Summarization 32 33 37 37 39 40 41

CHAPTER 4

RESULT AND DISCUSSION 4.1 4.2 Introduction Simulation of motor Speed 4.2.1 Robot without PID 4.2.2 Robot with PID 4.3 4.4 Costing Commercialization 42 42 43 46 50 50

x

CHAPTER 5

CONCLUSION AND RECOMMENDATION 5.1 5.2 Conclusion Future Recommendation 51 51

REFERENCES APPENDIX A APPENDIX B APPENDIX C APPENDIX D APPENDIX E

53 54 57 58 62 68

xi

LIST OF FIGURES

FIGURE NO. 2.1 2.2 2.3

TITLE Typical PM servomotors Permanent magnet Trapezoidal input voltage and square wave current waveforms

PAGE 9 10 11

2.4 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18

Three winding waveform

12

Block diagram of line follower robot using PID controller 14 IR sensor and surfaces voltage divider Comparator schematic LM324 schematic Top and side view of sensors sensors position IR sensors circuit schematic PIC 16F877A pins Voltage Regulator circuits Oscillator Schematic PIC basic circuit L293D schematic Motor connection Circuit connection PWM graph Circuit analogy PWM system 15 15 16 18 19 19 20 22 24 24 25 26 27 28 28 29 29

xii

3.19 3.20 3.21 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12 4.13 4.14

PIC kit 2 Programmer interface Interface of Proteus 7 Professional Simulator Programming flow Sensors detection Graph PWM Right sensors Right PWM Left sensors Left PWM Right sensors Right PWM Greater right sensors Greater right PWM Left sensors Left PWM Greater left sensors Greater left PWM

38 39 40 43 43 44 44 45 45 46 46 47 47 48 48 49 49

xiii

LIST OF ABBREVIATIONS

PWM

-

Pulse Width Modulation

x

LIST OF TABLE

TABLE NO. 3.1 3.2 3.3 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8

TITLE Binary value and position robot Binary and numerical values Port and functions Straight line Right PWM Left PWM Right PWM Greater right PWM Left PWM Greater left PWM Cost of components

PAGE 32 33 40 44 44 45 46 47 48 49 50

xiv

LIST OF APPENDICES

APPENDIX

TITLE

PAGE

A B C D E

Source codes Pictures of robot Datasheets L293 D Datasheets PIC 16F877 A Datasheets LM324 D

54 57 58 62 68

1

CHAPTER 1

INTRODUCTION

1.1

OverviewRobot becomes widely used in industrial due to their characteristics. Robot able

to work in 24 hours continuously without feeling tired unlike human that confine to certain time. The cost to setup the robot nowadays becomes more affordable and their long term prospect is bright judging from their capacity to perform. But in reality, there is no robot able to functions perfectly and still making error. A better controller needed here, to allow the robot performs efficiently and make less error.

This project try to implement a PID controller on mobile robot to see whether the robot perform efficiently. This mobile robot has a line tracking module, where it will follow the track that made from black tape. This is area where the PID implemented, the robot will be able to follow the black tape effectively and moving along the track smoothly.

1.2

ObjectivesThe main objective of this project is to design a line follower robot with PID

controller and compare effect of PID.

2

1.3

Scope of projects

This project is focused to design and build the prototype line follower robot and implement PID controller. Therefore, this prototype will cover scope as followed: i. ii. Design line follower robot using PIC 16F877A. PID controller implementation through programming in PIC 16F877A by using BASIC LANGUAGE. iii. In the end of project, we compare a robot movement with PID and without PID controller by inspecting the pattern of movement of the robot while following the track.

1.4

Problem statementsLine follower robot can be easily designed by using concept on and off. But

this type of design will make robot not be able to follow the smoothly and sometimes robot tends to move out of the track. So to overcome that problem, we need a better controller to make robot follow the line smoothly and make less error. In this project, we are using PID controller because of easy to understand and implement on mobile robot.

1.5

Thesis organizationsThis thesis consists of five chapters. This chapter discuss about overview of

project, objective research, project scope, problem statement and thesis organization.

Chapter 2 contains a detailed description of Line follower robot and PID controller. It will explain about the concept of algorithm of line follower robot and PID implementation on robot.

3

Chapter 3 includes the project methodology. It will explain how the project is organized and the flow of process in completing this project. Also in this topic discusses the methodology of the system, circuit design, software design and the mechanical design.

Chapter 4 will be discussing about the result obtained in this project and a discussion about the result.

Finally, the conclusions for this project are presented in chapter 5. This chapter also discusses about the recommendation for the project and for the future development.

4

CHAPTER 2

LITERATURE REVIEW

2.1

IntroductionThe line follower robot using PID controller is a self operating that detect and

follows track drawn on floor. The track consists of the black tape on white surface. The control system used to sense the line and maneuver the robot to stay on course while constantly correcting the wrong moves using feedback mechanism, thus might forming effective closed loop system. We have found two scope of system in developing the robot and PID controller.

(i)

The motion control of a two wheel vehicle is more complex than the balance control. There are some reciprocal relations between the two wheel vehicle velocity and the tilt angle that are difficult to modify. To control the two wheel vehicle motion and reduce the NN complexity, a NN-like PID control method was developed. The proposed control scheme consists of a self-tuning PID decoupling controller and two selftuning PID controllers. As the two wheel vehicle motions are relative to the tilt angle magnitude, it is necessary to make the tilt angle follow a designed trajectory. The two wheel vehicle designed tilt angle depends on the velocity response. In this paper, a self-tuning PID velocity controller and a self-tuning PID tilt angle controller are presented. The self-tuning PID controllers guarantee that the two wheel vehicle is stable, traces the tilt angle command and follows the forward desired velocity. The TWV rotation motion is dependent upon the velocity difference between the

5

two wheels. The self-tuning PID decoupling controller is an electrical differential mechanism that distributes the wheel velocity and torque. The decoupling controller appropriately assigns the current command to two DC motors to drive the two wheel vehicle. The results of the experiment demonstrate the feasibility and reliability of the proposed control scheme, along with the stability issues [1]. Such a design allows the maneuver robot on the track with the implementation of PID controller.

2.2

Electric motors

Another part that we will be approach is the use of motor. Firstly, we should know the definition of an electric motor. An electric motor is a device that converts electrical energy to mechanical energy [2]. For the reverse task, the device converts mechanical energy to electrical energy. This is not related to electric motor but this function always known as generator or dynamo. Frequently, an electric motor will apply the electromagnetism concept. The fundamental principle upon which electromagnetic motors are based is that there is a mechanical force on any currentcarrying wire contained within a magnetic field. The force is described by the Lorentz force law and is perpendicular to both the wire and the magnetic field [2]. The motor will have two types. First is rotary motor and second one is linear motor. However, must of magnetic motor, it will rotate. In a rotary motor, the rotary part is called as rotor and the stationary part is called as stator. When the rotor rotate, the torque will be developed based on the rotors axis. The motor contains

electromagnets that are wound on a frame. This frame is often called as armature. Correctly, the armature is that part of the motor across which the input voltage is supplied. Depending upon the design of the machine, either the rotor or the stator can serve as the armature.

6

2.2.1

DC motor

When the coil is powered, a magnetic field is generated around the armature. First, the left side of the armature is pushed away from the left magnet and drawn toward the right, causing rotation. Second, the armature continues to rotate.

Third, when the armature becomes horizontally aligned, the commutator reverses the direction of current through the coil, reversing the magnetic field. The process then repeats. If the shaft of a DC motor is turned by an external force, the motor will act like a generator and produce an Electromotive force (EMF) [2]. During normal operation, the spinning of the motor produces a voltage, known as the counter-EMF (CEMF) or back EMF, because it opposes the applied voltage on the motor. This is the same EMF that is produced when the motor is used as a generator (for example when an electrical load (resistance) is placed across the terminals of the motor and the motor shaft is driven with an external torque). The CEMF is proportional to motor speed, when an electric motor is first started or is completely stalled, there is zero CEMF [2]. Therefore the current through the armature is much higher. As the motor spins, the CEMF increases until it is equal to the applied voltage, minus the parasitic voltage drop. Generally, the rotational speed of a DC motor is proportional to the voltage applied to it, and the torque is proportional to the current. Speed control can be achieved by variable battery tapping, variable supply voltage, resistors or electronic controls. The direction of a wound field DC motor can be changed by reversing either the field or armature connections but not both.

2.2.2

AC motor

A typical AC motor consists of two parts. First is an outside stationary stator having coils supplied with AC current to produce a rotating magnetic field, and second is an inside rotor attached to the output shaft that is given a torque by the rotating field [2]. There are two fundamental types of AC motor, depending on the type of rotor used. First is the synchronous motor, which rotates exactly at the supply frequency or a sub multiple of the supply frequency. Second is the induction motor,

7

which turns slightly slower, and typically (though not necessarily always) takes the form of the squirrel cage motor. Three-phase AC induction motor is commonly used especially for high powered motor. The phases differences between the three phase of electrical supply create a rotating electromagnetic field in the motor. In the rotor, the current will be induced by the rotating magnetic field caused by electromagnetic induction, which in turn sets up a counterbalancing magnetic field that causes the rotor to turn in the direction the field is rotating.

The rotor must always rotate slower than the rotating magnetic field produced by the polyphase electrical supply; otherwise, no counterbalancing field will be produced in the rotor.

2.2.3

Stepper motor

Stepper motors are special motors that are used when motion and position have to be precisely controlled [3]. The stepper motor is closely related in design to three-phase AC synchronous motors where an internal rotor containing permanent magnets or a large iron core [2] with salient poles is controlled by a set of external magnets that are switched electronically. A stepper motor may also be thought of as a cross between a DC electric motor and a solenoid. As each coil is energized in turn, the rotor aligns itself with the magnetic field produced by the energized field winding. Unlike a synchronous motor, in its application, the motor may not rotate continuously; instead, it "steps" from one position to the next as field windings are energized and de-energized in sequence. Depending on the sequence, the rotor may turn forwards or backwards. Simple stepper motor drivers entirely energize or entirely de-energize the field windings, leading the rotor to "cog" to a limited number of positions; more sophisticated drivers can proportionally control the power to the field windings, allowing the rotors to position "between" the "cog" points and thereby rotate extremely smoothly. Computer controlled stepper motors are one of the most versatile forms of positioning systems, particularly when part of a digital servo-controlled system. Stepper motors can be rotated to a specific angle with ease, and hence stepper motors are used in computer disk drives, where the high precision

8

they offer is necessary for the correct functioning of, for example, a hard disk drive or CD drive. Only very old hard drives (from the pre-gigabyte era) use stepper motors; newer drives use systems based on voice coils. Stepper motors were upscaled to be used in electric vehicles under the term SRM (switched reluctance machine). The stepper motor is turned one step at a time or can turn at a specific rate [4] (specified by the speed in which the steps are executed). In term of hardware interface, the stepper motor requires a bit more complex to wire and more current. But this motor has more advantages in software control. A stepper motor can be controlled by stepper-motor controlled chips, such as the UC1517.

2.2.4

Servo motor

Servomotors are available as AC or DC motors. Early servomotors were generally DC motors because the only type of control for large currents was through SCRs for many years. As transistors became capable of controlling larger currents and switching the large currents at higher frequencies, the AC servomotor became used more often. Early servomotors were specifically designed for servo amplifiers. Today a class of motors is designed for applications that may use a servo amplifier or a variable-frequency controller, which means that a motor may be used in a servo system in one application, and used in a variable-frequency drive in another application. Some companies also call any closed-loop system that does not use a stepper motor a servo system, so it is possible for a simple AC induction motor that is connected to a velocity controller to be called a servomotor.

Some changes that must be made to any motor that is designed as a servomotor includes the ability to operate at a range of speeds without overheating, the ability to operate at zero speed and retain sufficient torque to hold a load in position, and the ability to operate at very low speeds for long periods of time without overheating. Older-type motors have cooling fans that are connected directly to the motor shaft. When the motor runs at slow speed, the fan does not move enough air to cool the motor. Newer motors have a separate fan mounted so it will provide optimum cooling air. This fan is powered by a constant voltage source so that it will

9

turn at maximum RPM at all times regardless of the speed of the servomotor. One of the most usable types of motors in servo systems is the permanent magnet (PM) type motor. The voltage for the field winding of the permanent magnet type motor can be AC voltage or DC voltage. The permanent magnet-type motor is similar to other PM type motors presented previously. Figure 2.1 shows a cutaway picture of a PM motor and Fig. 2.2 shows a cutaway diagram of a PM motor. From the picture and diagram you can see the housing, rotor and stator all look very similar to the previous type PM motors. The major difference with this type of motor is that it may have gear reduction to be able to move larger loads quickly from a stand still position. This type of PM motor also has an encoder or resolver built into the motor housing. This ensures that the device will accurately indicate the position or velocity of the motor shaft.

Figure 2.1: Typical PM servomotors

10

Figure 2.2: permanent magnet

2.2.5

Brushless servomotor

The brushless servomotor is designed to operate without brushes. This means that the commutation that the brushes provided must now be provided electronically. Electronic commutation is provided by switching transistors on and off at appropriate times. Figure 2.3 shows three examples of the voltage and current waveforms that are sent to the brushless servomotor. Figure 2.4 shows an example of the three windings of the brushless servomotor. The main point about the brushless servomotor is that it can be powered by either ac voltage or dc voltage.

Figure 2.3 shows three types of voltage waveforms that can be used to power the brushless servomotor. Figure 2.3a shows a trapezoidal EMF (voltage) input and a square wave current input. Figure 2.3b shows a sinusoidal waveform for the input voltage and a square wave current waveform. Figure ll-85c shows a sinusoidal input waveform and a sinusoidal current waveform. The sinusoidal input and sinusoidal current waveform are the most popular voltage supplies for the brushless servomotor.

Figure 2.4 shows three sets of transistors that are similar to the transistors in the output stage of the variable-frequency drive. In Fig. 2.4a the transistors are connected

11

to the three windings of the motor in a similar manner as in the variable-frequency drive. In Fig. 2.4b the diagram of the waveforms for the output of the transistors is shown as three separate sinusoidal waves. The waveforms for the control circuit for the base of each transistor are shown in Fig. 2.4c. Figure 2.4d shows the back EMF for the drive waveforms.

Figure 2.3: Trapezoidal input voltage and square wave current waveforms. (b) Sinusoidal input voltage and sinusoidal voltage and square wave output voltage waveforms. (c) Sinusoidal input voltage and sinusoidal current waveforms. This has become the most popular type of brushless servomotor control.

12

Figure 2.4: (a) Transistors connected to the three windings of the brushless servomotor. (b) Waveforms of the three separate voltages that are used to power the three motor windings. (c) Waveforms of the signals used to control the transistor sequence that provides the waveforms for the previous diagram, (d) Waveform of the overall back EMF.

Mobile robot have been developed and applied by many company and other university. Otherwise, the past projects also make their project as their research and development. This chapter is likely to approach about the technical and engineering development of mobile robot. Therefore, the study of many issues about past project is important. To develop this project, the knowledge about the processor and controller are needed which they will be used for future. This project will use PIC microprocessor as the processor. Besides that, the implementation should consider the concept of the project. Past project always give new idea whether it can be used as improvement or new development for future project.