Vous êtes sur la page 1sur 116

Project Code: D06

CONTROL AND STABILITY OF AN INVERTED PENDULUM SYSTEM: STRATEGIES AND IMPLEMENTATION

VYOM JAIN 2007ME10532

MUDIT GOEL 2007ME10508

VINAYAK SINGH 2007ME10531

Supervisor (s)

Prof. S.P.Singh

Prof. S.K.Saha

Examiner

Prof. K. Gupta

Department of Mechanical Engineering IITD

ii

Certificate

This is to certify that the project on Control and Stability of Inverted Pendulum is being pursued to my satisfaction and that the goals set upon at the outset of this endeavour have been worked upon to the best of the students abilities and resources. I hereby allow this project to be presented for evaluation and dissertation with full consent.

Supervisors:

Prof. S.K.Saha Mechanical Engineering Department Indian Institute of Technology, Delhi

Prof. S.P.Singh Mechanical Engineering Department Indian Institute of Technology, Delhi

iii

iv

Acknowledgment

We would like to express our sincere gratitude to Prof. S.P. Singh and Prof. S.K. Saha for giving us the opportunity to work under their supervision. Their never ending support, close supervision, monitoring and expedient tips helped us immensely in our work. We would also like to thank Mr. Madhu (Vibration Research Lab) and Mr. Jaitley (Mechatronics Lab) for extending their full support towards the realization of this project. We would also like to thank Mr. Arun, Ph.D student under Prof. S.K. Saha, for helping us throughout the semester regarding all the electronics-related issues. Also, we would like to thank Kamal Gupta and Sanjay Dhakar, members of the Robotics Club, IIT Delhi for helping us in the manufacturing of motor driver circuit.

MUDIT GOEL 2007ME10508

VYOM JAIN 2007ME10532

VINAYAK SINGH 2007ME10531

vi

Abstract
The work seeks to implement a control strategy to carry out the self-balancing of an inverted pendulum mounted on a cart moving on a slider and powered by a DC motor. The project entails both simulation as well as manufacturing. A rig, details of which are mentioned later, was manufactured to carry out the implementation physically. Selection of various parts for the system has been done and the selected components have been mentioned appropriately. CAD models of the various parts manufactured were also developed. LABVIEW is used to simulate the control strategy. Finally, various control strategies have been implemented and studied on which included SISO control strategies to balance pendulum angle and cart position individually. Also cascaded PID logics to balance both cart position and pendulum angle simultaneously has been implemented. Keywords: Inverted pendulum, PID, Self-balancing, LABVIEW Simulation

vii

Contents
Certificate............................................................................................................................................... iii Acknowledgment .................................................................................................................................... v Abstract ................................................................................................................................................. vii List of Figures ......................................................................................................................................... ix List of Tables ......................................................................................................................................... xii Nomenclature ...................................................................................................................................... xiii Chapter 1. Chapter 2. Chapter 3. 3.1 3.2 3.3 4.1 4.2 4.3 4.4 4.5 4.6 Introduction .................................................................................................................... 1 Literature Review and Objectives ................................................................................... 3 System Modelling............................................................................................................ 6

Analytical Modelling ............................................................................................................... 6 Modelling in MATLAB............................................................................................................ 15 Modelling in LabVIEW ........................................................................................................... 18 Parts Selection and Procurement ................................................................................. 23 Mechanism Comparison ....................................................................................................... 23 Slider Mechanism.................................................................................................................. 23 Motor Selection .................................................................................................................... 26 Encoder Selection ................................................................................................................. 28 Motor Driver ......................................................................................................................... 28 Data Acquisition Card (DAQ) ................................................................................................. 29 Equipment Design and Fabrication ............................................................................... 31 Developing of Sensing and Actuation of system........................................................... 43

Chapter 4.

Chapter 5. Chapter 6. 6.1 6.2 7.1 7.2 7.3

Encoder Interfacing ............................................................................................................... 43 Motor Driver Fabrication ...................................................................................................... 45 Control Implementation ............................................................................................... 50 SISO Control of Cart Position(x) ............................................................................................ 50 SISO Control of Pendulum Angle()...................................................................................... 57 Cascaded PID logic to control Pendulum Angle and Cart Position ....................................... 65 Conclusions and Future Scope ...................................................................................... 80

Chapter 7.

Chapter 8.

References ............................................................................................................................................ 82 Appendix-A............................................................................................................................................ 83 Appendix B ............................................................................................................................................ 88 Appendix C ............................................................................................................................................ 93 Appendix D .......................................................................................................................................... 100 Appendix E .......................................................................................................................................... 103

viii

List of Figures
Figure 1.1: Schematic of an inverted pendulum ..................................................................................... 1 Figure 2.1 Gantt Chart of Part 1 of the work .......................................................................................... 5 Figure 2.2 Gantt Chart of Part2 of work ................................................................................................. 5 Figure 3.1 FBD of the inverted pendulum setup..................................................................................... 6 Figure 3.2: DC Motor block diagram (Ogata[2008]) ............................................................................... 9 Figure 3.3 Schematic for SISO theta control ......................................................................................... 13 Figure 3.4 Schematic of cascaded PID logics for control ...................................................................... 14 Figure 3.5 Schematic of Parallel PID logics for control ......................................................................... 15 Figure 3.6 - Quadrant-wise division of pendulum angle ....................................................................... 16 Figure 3.7 - Pendulum Angle with time ................................................................................................ 17 Figure 3.8 - Cart Position with time ...................................................................................................... 17 Figure 3.9 - Cart velocity with time ....................................................................................................... 18 Figure 3.10: LabVIEW Code for simulation of control of cart position X of inverted pendulum .......... 19 Figure 3.11: Front Panel of simulation for PID control of only cart position ........................................ 19 Figure 3.12: Block Diagram of simulation for only angle theta control ................................................ 20 Figure 3.13: Front Panel for only theta-control .................................................................................... 20 Figure 3.14: Block Diagram for simulating cascading control of PID logics .......................................... 21 Figure 3.15: Front Panel for simulating cascading of PID logics ........................................................... 22 Figure 4.1 - Igus Toothed Belt Axis........................................................................................................ 24 Figure 4.2 - Dry LIne - Low Profile Linear Guide System NK-01/02-40 ................................................. 25 Figure 4.3 - Dry Line - Low Profile Linear Guide Systen NK-02-80 ....................................................... 25 Figure 4.4 - Moment rating of selected igus slider ............................................................................... 26 Figure 4.5 - Characteristic curves of selected igus slider ...................................................................... 26 Figure 4.6 - RoboKits Motor - selected motor ...................................................................................... 27 Figure 4.7 - Incremental Encoder BI-52S-2500-PU ............................................................................... 28 Figure 4.8 - Motor Driver (www.dimensionengineering.com) ............................................................. 29 Figure 4.9 - DAQ NI-PC 6221 Port Drawing ........................................................................................... 30 Figure 5.1 - Final CAD model ................................................................................................................. 31 Figure 5.2 - Igus Slider ........................................................................................................................... 32 Figure 5.3 - Cart along with the pendulum ........................................................................................... 32 Figure 5.4 - Driving Mechanism ............................................................................................................ 33 Figure 5.5 - Driven Mechanism Assembly ............................................................................................. 33 Figure 5.6 - Stand on the ends of the slider .......................................................................................... 34 Figure 5.7 - Middle Stand ...................................................................................................................... 34 Figure 5.8 : Stands after TIG Welding ................................................................................................... 35 Figure 5.9 : 5mm Aluminium plates ...................................................................................................... 35 Figure 5.10 : Plates used to support the driving and the driven shaft assemblies ............................... 35 Figure 5.11 : Timing belt 3.5m long and 10mm wide ........................................................................... 36 Figure 5.12 : Profile of the timing pulleys ............................................................................................. 36 Figure 5.13 : 8mm roller bearing .......................................................................................................... 36 Figure 5.14 : Bearing with housing ....................................................................................................... 37 ix

Figure 5.15 : Driving Motor with housing ............................................................................................. 37 Figure 5.16 : Encoder along with housing ............................................................................................. 38 Figure 5.17 ; Driving shaft assembly ..................................................................................................... 38 Figure 5.18 : Driven shaft assembly ...................................................................................................... 39 Figure 5.19 : Cart assembly ................................................................................................................... 39 Figure 5.20 : Pendulum ......................................................................................................................... 40 Figure 5.21 : Joint between cart and timing belt .................................................................................. 40 Figure 5.22 : Joint between wooden block and stand .......................................................................... 41 Figure 5.23 : Support for the slider ....................................................................................................... 41 Figure 5.24(a) and (b) : Final setup of inverted pendulum ................................................................... 42 Figure 6.1 : 2 output signals generated by incremental encoder(NI Developer Zone forum) ............. 43 Figure 6.2 : Simplified Counter/Timer Model of DAQ........................................................................... 43 Figure 6.3 : Layout of the connector block of NI-6221 ......................................................................... 44 Figure 6.4 : Block diagram of the code to measure encoder's position ............................................... 44 Figure 6.5: L7805 chip (http://www.mindkits.co.nz/store) .................................................................. 45 Figure 6.6: picture showing pinouts of L7805 chip(http://www.mindkits.co.nz/store) ....................... 45 Figure 6.7: ATmega16 chip (http://www.futurlec.com/Atmel/ATMEGA16.shtml).............................. 46 Figure 6.8: Pinouts of Atmega 16 (Appendix B) .................................................................................... 46 Figure 6.9: Soldering in progress for Atmega 16 Base .......................................................................... 47 Figure 6.10: Soldered Atmega 16 Base, crystal, ISP port and L7805 chip on matrix board .................. 47 Figure 6.11: L298 chip (Appendix C) ..................................................................................................... 48 Figure 6.12: Connections for L298N for driving DC motor (Appendix C) .............................................. 48 Figure 6.13: Soldered L298 chip ............................................................................................................ 49 Figure 6.14: Motor Driver card ............................................................................................................. 49 Figure 7.1: Block Diagram for real time x-control ................................................................................. 51 Figure 7.2 Simulation results for Kp=10, 25,50,100 .............................................................................. 52 Figure 7.3 Real-time results for Kp=100, 150, 300, 500........................................................................ 53 Figure 7.4 Simulation results for Ki=100,500,1000,5000 ...................................................................... 54 Figure 7.5 Real-time results for Ki=3000, 30000, 60000, 80000 .......................................................... 55 Figure 7.6 Simulation results for kd=0.001, 0.01, 0.1, 1 ....................................................................... 56 Figure 7.7 Real-time results for Kd=0.003, Kd=0.3, kd=3...................................................................... 57 Figure 7.8: Block Diagram for theta-control real-time implementation............................................... 58 Figure 7.9 Simulation results for Kp=40, 75, 200, 500 .......................................................................... 59 Figure 7.10 Real-time results for Kp=200, 450, 700.............................................................................. 60 Figure 7.11 Simulation results for KI=0.005, 0.01, 0.05 ........................................................................ 61 Figure 7.12 Real-time results for Ki=5, 10, 50, 100 ............................................................................... 62 Figure 7.13 Simulation results for Kd=0.002, 0.02, 0.2 ......................................................................... 63 Figure 7.14 Real-time results for Kd=0.35, 0.1, 1.................................................................................. 64 Figure 7.15: Block Diagram for real-time implementation fo cascading of PID logics ......................... 65 Figure 7.16 Simulation results for Cart Position Gains Kp=0.25, Ki=0.001, kd=0.01(Cascaded PID) .... 66 Figure 7.17 Simulation results for Cart Position Gains Kp=0.6, Ki=0.001, kd=0.01(Cascaded PID) ...... 66 Figure 7.18 Simulation results for Cart Position Gains Kp=0.8, Ki=0.001, kd=0.01(Cascaded PID) ...... 66 Figure 7.19 Real-time results for Cart Position Gains Kp=0.2, Ki=0, kd=0.001(Cascaded PID) ............. 67 Figure 7.20 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.001(Cascaded PID) ........... 67 Figure 7.21 Real-time results for Cart Position Gains Kp=0.7, Ki=0, kd=0.001(Cascaded PID) ............. 67 x

Figure 7.22 Simulation results for Pendulum Angle Gains Kp=40, Ki=3000, kd=0(Cascaded PID) ....... 68 Figure 7.23 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000, kd=0(Cascaded PID) ...... 68 Figure 7.24 Simulation results for Pendulum Angle Gains Kp=100, Ki=3000, kd=0(Cascaded PID) ..... 68 Figure 7.25 Real-time results for Pendulum Angle Gains Kp=200, Ki=45, kd=0.45(Cascaded PID) ...... 69 Figure 7.26 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.45(Cascaded PID) ...... 69 Figure 7.27 Real-time results for Pendulum Angle Gains Kp=700, Ki=45, kd=0.45(Cascaded PID) ...... 69 Figure 7.28 Simulation results for Cart Position Gains Kp=0.6, Ki=0.0001, kd=0.01(Cascaded PID) .... 70 Figure 7.29 Simulation results for Cart Position Gains Kp=0.6, Ki=0.001, kd=0.01(Cascaded PID) ...... 70 Figure 7.30 Simulation results for Cart Position Gains Kp=0.6, Ki=0.01, kd=0.01(Cascaded PID) ........ 70 Figure 7.31 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.001(Cascaded PID) ........... 71 Figure 7.32 Real-time results for Cart Position Gains Kp=0.45, Ki=0.1, kd=0.001(Cascaded PID) ........ 71 Figure 7.33 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.001(Cascaded PID) ........... 71 Figure 7.34 Simulation results for Pendulum Angle Gains Kp=50, Ki=1000, kd=0 (Cascaded PID)....... 72 Figure 7.35 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000, kd=0 (Cascaded PID)....... 72 Figure 7.36 Simulation results for Pendulum Angle Gains Kp=50, Ki=3500, kd=0 (Cascaded PID)....... 72 Figure 7.37 Real-time results for Pendulum Angle Gains Kp=450, Ki=10, kd=0.45 (Cascaded PID) ..... 73 Figure 7.38 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.45 (Cascaded PID) ..... 73 Figure 7.39 Real-time results for Pendulum Angle Gains Kp=450, Ki=70, kd=0.45 (Cascaded PID) ..... 73 Figure 7.40 Simulation results for Cart Position Gains Kp=0.6,Ki=0.0005,kd=0.001 (Cascaded PID) ... 74 Figure 7.41 Simulation results for Cart Position Gains Kp=0.6,Ki=0.0005,kd=0.01 (Cascaded PID) ..... 74 Figure 7.42 Simulation results for Cart Position Gains Kp=0.6,Ki=0.0005,kd=0.015 (Cascaded PID) ... 74 Figure 7.43 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.0005 (Cascaded PID) ........ 75 Figure 7.44 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.001 (Cascaded PID) .......... 75 Figure 7.45 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.005 (Cascaded PID) .......... 75 Figure 7.46 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000,kd=0.01 (Cascaded PID) .. 76 Figure 7.47 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000, kd=0.1 (Cascaded PID).... 76 Figure 7.48 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000, kd=1 (Cascaded PID)....... 76 Figure 7.49 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.1 (Cascaded PID) ....... 77 Figure 7.50 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.45 (Cascaded PID) ..... 77 Figure 7.51 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.7 (Cascaded PID) ....... 77 Figure 7.52 Settling time variation with change in Kp values for cart position .................................... 78 Figure 7.53 Settling time variations with change in Ki values for cart position.................................... 78 Figure 7.54 Settling time variations with change in Kd values for cart position .................................. 78 Figure 7.55 Settling time variations with change in Kp values for pendulum angle............................. 79 Figure 7.56 Settling time variations with change in Ki values for pendulum angle .............................. 79 Figure 7.57 Settling time variations with change in Kd values for pendulum angle............................. 79

xi

List of Tables

Table 4.1 Table showing comparison of various mechanism considered ............................................ 23 Table 4.2 Comparative Analysis of various sliders ................................................................................ 24

xii

Nomenclature
Symbol mc mp F mb N P Kb Tm Meaning Mass of Cart Mass of pendulum Angle of pendulum from vertical Force transferred from the motor to the cart Mass of bob Length of pendulum Inertia of cart and pendulum about pulley Inertia of pendulum about hinge point Acceleration due to gravity Total mass of cart, pendulum and bob Friction coefficient DC Motor Torque current constant DC motor armature inductance DC motor armature resistance Radius of pulley Cart position Reaction force between cart and pendulum in x-direction Reaction force between cart and pendulum in y-direction Motor Back Emf Constant Torque applied by motor

xiii

Chapter 1. Introduction
Inverted Pendulum designs are not based on obscure or abstract mechanics. The simple example of a walking man can be considered conceptually equivalent. The inverted pendulum problem is one of the most important problems in control theory and has been studied excessively in control literatures. It is well established benchmark problem that provides many challenging problems to control design. The system is nonlinear and unstable. Our project deals with the implementation of this idea to balance an inverted pendulum with respect to a reference (= 0). In simple understandable terms, it depends on the torque generated by a motor to counteract any perturbation in the natural inverted position of the pendulum in the non inertial reference frame of the cart the pendulum is attached to. According to control purposes of inverted pendulum, the control of inverted pendulum can be divided into two aspects. The rst aspect is the swing-up control of inverted pendulum. The second aspect is the stabilization of the inverted pendulum. This project mainly focuses on stabilization of inverted pendulum. Various strategies to control inverted pendulum along with its base (cart) position are also discussed and implemented.

Figure 1.1: Schematic of an inverted pendulum

The stroke length, RPM and torque requirements of the motor were determined using the cardinal values obtained rigorously (Lagrangian Modeling) and the assumed reasonable values of parameters like mass of the cart, mass of the pendulum etc.

The other portion was the comparison of various designs to implement the idea of an inverted pendulum. A brief idea of the implementation is also presented to give a sense of the project. In nut shell, the design consists of a slider mechanism (ideally frictionless), a cart with the pendulum and an encoder mounted on it, a motor according to the torque and RPM requirements, a compatible motor driver card, bearings to support the rotating shafts, belt type mechanism to transfer the power of the motor, an encoder as the input to the control system and a PID controller. The applications of the model are aplenty. Any two wheeled drive like skate boards, the robot torsos, and even unicycles can incorporate this to achieve balancing in one plane.

Chapter 2. Literature Review and Objectives


The literature on control strategies for inverted pendulum can be roughly split into two parts: local control (i.e. in a region slightly displaced from the desired upright position) and global control (including swing up say from the bottom most position of the pendulum). While the local control is essentially linear, global control is grounded in the use of switching logics or advanced mathematical tools for linearization. The control itself can differ on the basis of the type of control strategy (PID, fuzzy logic etc) or the mode of implementation (type of software used, like MATLAB or LABVIEW). Finally, system itself can be different with respect to the number of pendulums, type of base used (rotary base, moving cart etc). The basic analytical modelling procedure of an Inverted Pendulum has been shown in Altas(2005). The Free Body equations of the system are linearized and their Laplace is taken. Then the author describes the derivation of the transfer function between pendulum angle and applied force and illustrates elementary state space modelling. Further, he applies basic Proportional-Integral-Derivative (PID) controller and studies the response by varying the constants in PID controller. Saha S.K. (2008) presents a detailed analysis of the Lagragian modelling and focuses on the techniques for doing so. Craig(2007) talk about taking sensor inputs in LabVIEW and gives a walk through of the necessary steps to implements a basic controller. Dockhorn(2006) describes the steps from data acquisition, simulation of the system, development of the PID controller circuit, and implementation of the controller applied to a real system. One of the challenges in the case of cart type inverted pendulum is to prevent the cart from going off the tracks. This problem is dealt with by adding an offset to the angle measured. The offset is proportional to the distance of the cart from the centre. Thus cart is mostly around the centre of the rail. Ogata(2008) discusses the modelling parameters and modelling procedure for a DC motor. The relevant literature comprise of transfer function between torque and voltage. This transfer function is directly used (in this project) in conjunction with the plant (inverted pendulum) model and the overall transfer function has been developed.

Vizins(2010) examines various control strategies that can be adopted to control a two degree of freedom system by just one output. The first strategy is of modifying the effective set-point of pendulum angle and is similar to that discussed by Dockhorn(2006). The second strategy comprises of simultaneous control of cart position and pendulum angle by adding the individual control actions of each input variable, viz. Pendulum angle and cart position. So, the net control signal or the voltage sent to the motor is algebraic summation of two control signal. Lam(2004) describes swing up pendulum control. This paper describes two methods to swing a pendulum attached to a cart from an initial downwards position to an upright position and maintain that state. A nonlinear heuristic controller and an energy controller have been implemented in order to swing the pendulum to an upright position. After the pendulum is swung up, a linear controller has been implemented to maintain the balanced state. The heuristic controller outputs a repetitive signal at the appropriate moment and is finely tuned for the specific experimental setup. The energy controller adds an appropriate amount of energy into the pendulum system in order to achieve a desired energy state. The linear controller is a stabilizing controller based on a model linearized around the upright position and is effective when the cart-pendulum system is near the balanced state.

Objectives of the Project


In order to study the control logics on an inverted pendulum, it was essential to setup a basic test bench so that the control logics can be applied. The current work mainly focuses on the practical implementation of inverted pendulum using PID control. So, the objectives of the work have been defined as the following: Simulation of the Inverted Pendulum Dynamics using MATLAB by doing an analytical modeling of the system before Designing of the entire setup for implementation of Inverted Pendulum Control Fabricating the setup along with the electrical hardware to actuate the system Interfacing of the setup to the computer using NI-DAQ Card and LabVIEW Implementation of PID control in the form of a stabilized inverted pendulum design Simulating PID control of Inverted Pendulum in LabVIEW

Work Plan
The figure 2.1 and 2.2 show the work methodology followed in the part 1 and part 2 of the project respectively.
AUGUST W2 W3 GANTT CHART SEPTEMBER W1 W2 W3 W4 OCTOBER W2 W3 NOVEMBER W1 W2 W3

W1 Literature Review System Modeling Simulation on MATLAB Mechanism Options Market Survey Finalizing Mechanisms Electrical Components Study Selection Ordering CAD Market Visit Manufacturing LABVIEW Study Simulation Techniques Report Making

W4

W5

W1

W4

M i n o r 1

M i n o r 2

M i d S e m B r e a k

Figure 2.1 Gantt Chart of Part 1 of the work

W1 Learning LabVIEW Procurement of material Manufacturing DAQ Card Repair Encoder Testing Setting up of system in lab Motor Driver card manufacturing Testing of motor driver card Report Making Control Study Testing of motor Learning control on Labview Implementation of SISO control on pendulum angle Implementation of SISO control on cart position Implementation of MISO control PID Gains tuning Report Making

JANUARY W2 W3 W4

GANTT CHART FEBRUARY W1 W2 W3

W4

W2

MARCH W3

W4

W1

APRIL W2 W3

W4

M I N O R s

S E M B R E A K

M I N O R S

Figure 2.2 Gantt Chart of Part2 of work

Chapter 3. System Modelling


The system was modelled and the results were simulated on several platforms. Before working on any platform, analytical modelling of the system which is done in Section 3.1. Analytical modelling helps in calculating all the transfer functions required which are then used to simulate the system on MATLAB and LabVIEW covered under Section 3.2 and Section 3.3 respectively.

3.1

Analytical Modelling

Figure 3.1 FBD of the inverted pendulum setup(Altas[2005])

Starting from basic Free Body Equations as described by Altas(2005), the cart position function and pendulum angle functions are derived. Figure 3.1 shows the FBD of the inverted pendulum system. Putting the values of constants as Mass of cart, = 620
Mass of pendulum, = 40 Mass of bob, = 135 Length of pendulum, = 325

Inertia of cart and pendulum about pulley, = 1.13 103 2 Inertia of pendulum about hinge point, = 4 103 2
= 9.81 / 2 = + mp + mb = 0.79 Frictional drag, = 1 / Motor Torque Constant, = 0.3 / Motor Back Emf Constant, = 0.3 / Motor Inductance, = 4 Motor armature resistance, = 1.5 Radius of cart, = 0.0325

Tm=Torque applied by motor F = Force applied by motor on cart V = Voltage supplied to motor P and N are the reaction forces between cart and pendulum in x and y directions respectively Free Body Equations: For cart:
+ =

. . . . . . . . . . . . . . . . . . . . . . . . . . (3.1)

+ + = . . . . . . . . . . . . . . . . . . . . . . . . . . (3.2)

For pendulum:
= + + + 2 cos + 2 2 sin . . . . . . (3.3)

For Pendulum: Force balance along the pendulum length:


sin + cos + sin = + 2 + + cos . . . . (3.4)

For Pendulum: Force balance perpendicular to the pendulum length:


7

sin cos = . . . . . . . . . . . . . . . . . . . . . . . . . . (3.5)

Substituting N in equation 3.1


+ + 2 cos + + 2 2 sin = . . . (3.6)

[ + ( + 2 ) 2 ] + ( + ) sin = + cos . . . . . . . . . . . . . (3.7)

On linearizing the above equation, we get


[ + ( + 2 ) 2 ] + ( + ) = ( + ) . . . . . . . . . . . . . . . . . . (3.8) [ 2 + ( + )] + + 2 = . . . . . . . . . . . . . . (3.9)

On solving for x by taking Laplace Transforms, we have:


= [+ + 2 2 + () . . . . . . . . . . . . . . . . . . . . . . . . . . (3.10) 2

On substituting the values in equation 3.10, we get


= 0.004 + 0.04 + 0.27 0.1625 0.04 + 0.135 0.1625 = 0.428
2

10 () . . . . . . . . . . . . . . . . . . . . (3.11) 2

10 . . . . . . . . . . . . . . . . . . . . . . . . . . (3.12) 2

On substituting the values in equation 3.9, we get


1.07 + 0.175 2 + 0.05 2 = 1.245 2 + 0.05 2 = . . . . . . . . . . . . . . . . . . . . . . . . (3.13)

On substituting for x from Equation 3.12, we get


1.245 0.428 10 10 2 + 0.428 2 0.05 2 = . . . . . . . . . . . . . . . . . . . . (3.14) 2 10 0.05 2 = . . . . . . . . . . . . . . . . . . . . . . . . . . (3.15)

0.532 2 12.45 + 0.428

0.4828 3 12.45

10 + 0.428 2 = . . . . . . . . . . . . . . . . . . . . . . . . (3.16)

0.4828 3

+ 0.428 2 12.45 10

. . . . . . . . . . . . . . . . . . . (3.17)

On substituting for from Equation 3.12, we get


= 0.428 10 2 3 + 0.428 2 12.45 10 0.4828 . . . . . . . . . . . . . . . (3.18)

(0.428 2 10) . . . . . . . . . . . . . . . . . . . . . . . . . . (3.19) (0.428 4 + 0.428 3 12.45 2 10)

Modelling of DC Motor

Figure 3.2: DC Motor block diagram (Ogata[2008])

Motor Torque Constant, = 0.3

Motor Back Emf Constant, = 0.3 Motor Inductance, = 4 Motor Armature Resistance, = 1.5 Radius of pulley, = 0.0325 Ogata (2008) gave a detailed analysis of the modelling of DC motor. This modelling is applied here for deriving open loop transfer function for control for rotation angle.
= . = . (3.20)

( ) . . . (3.21) +

Substituting the value of F from Equation 3.21 in Equation 3.19, we get:


9

0.4828 3 12.45

10 + 0.428 2 = . (3.22) +

On simplifying, we get:
= . . (3.23) [0.482 4 + 0.482 + 0.428 3 + 0.428 12.45 0.428 2 12.45 10 (10 + 10)

On substituting the motor constants in equation 3.23:


9.23 = . . . (3.24) 4 + 0.724 3 + 0.6755 2 18.68 15.9 0.000193

The model presented above incorporates the fact that the mechanical system/plant is perfectly ideal, and does not give desired results. So, further assumptions can be made and the model is more simplified in order to obtain desired results. As per the real system/rig, the friction present in the cart is significant and the pendulum motion does not result in counter motion in cart. Therefore, for the cart position control, the cart and the pendulum can be assumed to lumped masses. The resulting modelling is presented below.
= + + . . . . . . . . . . . . . . . . . . . . . . . . . . (3.25)

On taking Laplace, we obtain


= + + 2 . . . . . . . . . . . . . . . . . . . . . . . . (3.26) 1 = + + 2 + . . . . . . . . . . . . . . . . . . . . . . . . . (3.27)

1 = . . . . . . . . . . . . . . . . . . . . . . . . . . (3.28) 0.79 2 +

On combining equations 3.28 and 3.12, we get:


1 = 0.79 2 + 2 0.428 2 10 . . . . . . . . . . . . . . . . . . . . . . . . . . (3.29)

= . . . . . . . . . . . . . . . . . . . . . . . . . . (3.30) 3 + 0.428 2 7.9 10 0.338

10

On substituting for F from equation 3.25 in Equation 3.21, we get:


= + . . 3.31 ( + )

On taking Laplace Transforms and simplification, we get:


= . . 3.32 3 + + 2 + +

On substituting values in equation 3.26, we get


0.3 = 3 + 0.0385 + 0.00013 2 + 0.0487 + 2.77 0.0001027 1 = . . . . . . . . . . . . . . . . . . . . . . (3.33) 3 + 0.128 2 + 9.4 0.000342

Similarly solving for


2 = . = 0.428 2 10 3 + + 2 + +

On substituting the values, we get


2 = 0.428 2 10 0.3 . . (3.34) + 0.038 + 0.00013 2 + 0.0487 + 2.77 0.3 + 0.03813 2 + 2.8187

0.000103 3

2 = 0.428 2 10

0.000103 3

. . (3.35)

= . (3.36) 4 + 0.0543 3 + 4 2 1.271 94 0.000146

Equations 3.36 and Equation 3.33 are the equations that are used as transfer functions to model the plant in the simulation.

11

Control equations:

For implementing State space control, the requisite modelling has been done below: Putting values in Equation 3.8 and 3.9, we get:
= 10.64 + 12.34 + 10.64 . (3.37) 0.0325 . (3.38) 0.0325

= 2.08 + 25.95 + 2.088

Writing in State-Space notation:


0 1 0 0 10.64 12.34 = 0 0 0 0 2.08 25.95 0 0 0 10.64 + . (3.39) 1 0 0 2.088

12

Now first PID SISO control of pendulum angle is illustrated.


= = = + + . . (3.40)

Controller

Plant

Let plant Transfer function be H1 for

Figure 3.3 Schematic for SISO theta control

Let plant Transfer function be H1 for


= = . (3.41) 4 + 0.0543 3 + 4 2 1.271 94 0.000146

On combining, we get:
= + + 0.000146 4 + 0.0543 3 + 4 2 1.271 94 = 1 + + + 0.000146 4 + 0.0543 3 + 4 2 1.271 94 . . (3.42) 1 +

13

Now simultaneous control of pendulum angle and cart position is presented through two strategies. Control Strategy 1 Cascaded- Offsetting of setpoint of pendulum angle
= 10 = 0.428 2

0 = + + . . . (3.43)
x

Controller x

Plant H2

Controller

Plant H1

So combined Closed Loop Control Transfer Function:

Figure 3.4 Schematic of cascaded PID logics for control

So combined Closed Loop Control Transfer Function:


= . . . (3.43) 1 +

14

Control Strategy 2 Parallel- Addition of control actions of pendulum angle and cart position
= 10 = 0.428 2

0 = + + . (3.44)
x

Controller x

Plant H2

Controller

Plant H1

So combined Closed Loop Control Transfer Function:

Figure 3.5 Schematic of Parallel PID logics for control

So combined Closed Loop Control Transfer Function:


= . . (3.45) 1 +

3.2

Modelling in MATLAB

The main purpose of simulating the system on MATLAB was to understand the amount of force required to move the cart. Also, before actually proceeding to manufacturing, it was important to calculate the stroke length of the carriage rails. So, to simulate the actual control algorithm, the force applied on the cart was kept constant. But only its direction was changed on the basis of the quadrant in which the pendulum was present and the angular velocity of the pendulum. The convention used for the quadrants has been shown in the Figure 3.6.

15

Fourth IV Quadrant

Vertical

First Quadrant

Horizontal Slider
Third III Quadrant Second II Quadrant

Negative Direction of Force

Positive Direction of Force

Figure 3.6 - Quadrant-wise division of pendulum angle

1. If the pendulum was in the II or III quadrant, the direction of the force will be same as that of the angular velocity of pendulum, that is, if the angular velocity of pendulum is clockwise, then a positive force will be applied to the cart. 2. If pendulum lies in I quadrant and the pendulums angular velocity is greater than 0, negative force will be applied to the cart. 3. If the pendulum lies in IV quadrant and the pendulums angular velocity is lesser than 0, positive force will be applied to the cart.

Mass of the cart, mass of the pendulum and the force applied by the motor are taken as inputs. Since it is difficult to solve the equations analytically, hence the equations are solved numerically using ode45 solver. The complete code used for the purpose is attached in the appendix-A. The simulation was done for Mass of Cart=2 Kg and Mass of pendulum=0.5kg. The results obtained were plotted and the following were results.

16

Figure 3.7 - Pendulum Angle with time

As can be seen from the Figure 3.7, pendulum is brought to the upright position from the lowermost position within 3 seconds. After the pendulum reaches this position, linear control will be implemented and the system will be controlled in the upright position. A sharp drop seen in the above figure is due a change in the angle from 360 degrees to 0.

Figure 3.8 - Cart Position with time

As can be seen from the Figure 3.8, the cart position varies within [-0.6.0.6] m. Hence, a stroke length of 1.2 m is suitable for our system. So, an igus slider of length 1.5 m is used to accommodate for the mechanical blockers at the ends of the slider.

17

Figure 3.9 - Cart velocity with time

As can be seen from the Figure 3.9, the cart velocity varies within [-2, 2] m/s. Hence, the motor selected for this purpose has been selected so as that the speed of the motor can account for this range. The force used for the simulation was 10N and a frictional force of 5N is also taken into account. So, in a nutshell, we can say that the motor selected has to meet the torque and the rpm required. If we select a pulley of diameter 80mm, the motor required should have a torque of 0.4Nm. To incorporate the account of resistance of air and also to have some safety limits, the motor required has to have a torque of 1Nm.With this diameter of pulley. Speed of the motor = 2 = 470
260

3.3

Modelling in LabVIEW

To implement the control system in real, it was necessary to build the control platform on the computer. LabVIEW files were created to interface the input and output to the computer via DAQ cards thereby enabling the user to manipulate the control logic and the gain values chosen easily for the control. SISO control on cart position X: Before creating the files to do real-time control, simulation was done by modelling the plant with a transfer function. Figure 3.10 shows the
18

LabVIEW graphical code for simulating an inverted pendulum system. Only feedback of the cart position X has been taken i.e. only PID control with 1 input has been implemented.

Figure 3.10: LabVIEW Code for simulation of control of cart position X of inverted pendulum

Figure 3.11 shows the front panel of the LabVIEW code shown in Figure 3.10. The panel provides user the options to change the set point for the cart position and PID gains. These can be varied before the start of the simulation as well as during run-time.

Figure 3.11: Front Panel of simulation for PID control of only cart position

19

SISO Control on angle theta: Here cart position X was not taken into account. The transfer function for calculation of angle from the motor voltage was used to do the simulation. Figure 3.12 shows the block diagram for the simulation of the control of only angle theta.

Figure 3.12: Block Diagram of simulation for only angle theta control

Figure 3.13 shows the front panel for theta-control. Here, again like Figure 3.11, user has the options to carry the gains of the PID logic and set-point.

Figure 3.13: Front Panel for only theta-control

20

Cascading of PID logics for cart position x and angle theta: This logic has been unsuccessfully implemented by Dockhorn[2]. In this work, this logic has been used successfully in simulation. Since a PID can handle only 1 input and 1 output at a time, it is not possible to give both cart position and theta as inputs and hence cant give separate gains to each of them. Hence this technique takes use of the concept of cascading of PID logics. So, first PID logic is implemented on the cart position and the resultant output is used to adjust the set-point of theta for the next PID logic. It takes the form 0 = 0 + + + (3.46)

As can be seen in the equation 3.46, the set-point of theta gets adjusted every time cart position sways away from its set-point. Hence, the only stable position for the system becomes the point where set-points of both theta and cart position are reached. For example, if the cart is moving in positive direction to control theta, set-point of theta changes so to maintain it, cart has to move in opposite direction so as to ensure that cart position doesnt sway away much from its set-point. Figure 3.14 shows the block diagram of the simulation for cascading of this technique.

Figure 3.14: Block Diagram for simulating cascading control of PID logics

21

Figure 3.15 shows the front panel displaying all the parameters like the current values of pendulum angle theta, cart position and control action value.

Figure 3.15: Front Panel for simulating cascading of PID logics

22

Chapter 4. Parts Selection and Procurement


System comprises of many components and hence all of them were dealt individually. This chapter focuses on all those various components.

4.1

Mechanism Comparison

Table 4.1 shows comparison of various mechanisms considered.


Table 4.1 Table showing comparison of various mechanism considered

Rack and
ACTUATOR TYPE/ Parameter

Rack and Pinion (Pinion Moving) ++ ++ ++ Rack+Bench length to be increased +++ +++ ++ Chain+Bench length to be increased
Reference:

Pinion (Rack Moving)

Chain

Rubber Belt

Linear Actuator

Inertia Friction Space Considerations Stroke Adjustability

+ +++ + Rack+Bench length to be increased

+++ +++ ++ Belt+Bench length to be increased


+++ Good

++++ +++ +++

No Adjustibility
+ Bad

++ Average

From the above comparison, it was decided to use chain or Belt actuated mechanism. According to our requirements of stoke length of 1.2 m, on doing the calculations, the length of the rubber belt comes out as 3.3 m. To prevent backlash error, a module of at least less than 6mm should be used. Finally, a timing belt and gear pulleys of module 4mm were used.

4.2
4.2

Slider Mechanism

Comparative analysis of various slider mechanism was done and has been shown in the Table

23

Table 4.2 Comparative Analysis of various sliders

SLIDER TYPE/ Parameter Smoothness Load Bearing Capacity Length Available Cost Weight of Carriage

IGUS Sliders

Conventional Rails

Telescopic Channels +++ +

+++ +++

++ ++

+++

+++

++ +++

+++ ++

++ +

Reference:

+++ Good

++ Average

+ Bad

From the above comparison, it was decided to use IGUS Sliders. The following parts were considered for the mechanism. IGUS ZLW Belt Drive Figure 4.1 shows the sliding drive system considered for the system.

Figure 4.1 - Igus Toothed Belt Axis

Although this belt drive system from IGUS, would have simplified the designing process but, due to very high cost, it was rejected IGUS Dryline N Series Guide Systems width 40 mm Figure 4.2 shows the slider rails considered for the system.

24

Figure 4.2 - Dry LIne - Low Profile Linear Guide System NK-01/02-40

Reason for rejection: Since the width of the cart required was about 100 mm, therefore, we would have to use two of the above sliders in parallel. This would cause problems of misalignment between the two sliders.

IGUS Dryline N Series Guide Systems width 80 mm Figure 4.3 shows the slider mechanisms of width 80mm finally selected for the system.

Figure 4.3 - Dry Line - Low Profile Linear Guide Systen NK-02-80

Since the product fulfilled all the purposes and the cost was within the acceptable limit. So, further analysis for the above slider was done and shown below. Selection of IGUS Sliders The IGUS slider with width 80 mm was selected.
25

The maximum moment and load carrying capacity of the sliders is shown in the figure 4.4:

Figure 4.4 - Moment rating of selected igus slider

The maximum speeds possible at various loads is shown in the figure 4.5.

Figure 4.5 - Characteristic curves of selected igus slider

The following criteria were satisfied:

1. The maximum vertical load and maximum moment applied is far less than the capacity of the slider. 2. Since, the applied load is far less than applied, sufficiently high speeds can be reached.

4.3

Motor Selection

The servo motor has some control circuits and a potentiometer (a variable resistor, aka pot) that is connected to the output shaft. In the picture above, the pot can be seen on the right side of the circuit board. This pot allows the control circuitry to monitor the current angle of the servo motor. If the shaft is at the correct angle, then the motor shuts off. If the circuit finds
26

that the angle is not correct, it will turn the motor the correct direction until the angle is correct. The output shaft of the servo is capable of travelling somewhere around 180 degrees. Usually, its somewhere in the 210 degree range, but it varies by manufacturer. A normal servo is used to control an angular motion of between 0 and 180 degrees. A normal servo is mechanically not capable of turning any farther due to a mechanical stop built on to the main output gear. To modify a motor so that it can rotate more than 180 degrees, the mechanical stop inside the motor needs to be removed. By doing this, we lose position control, although speed control is gained. So, a potentiometer based servo motor cant be used. Hence, we have to used an optical based servo motor which essentially is a DC motor along with an optical encoder. Therefore, it was decided to use a DC motor and an encoder separately.

The figure 4.6 shows the motor finally selected and used.

Figure 4.6 - RoboKits Motor - selected motor

Motor specifications:

450RPM 12V DC motors with Metal Gearbox 25000 RPM base motor 6mm shaft diameter Gearbox diameter 37 mm. Motor Diameter 28.5 mm Length 63 mm without shaft Shaft length 15mm 300gm weight 20kgcm torque
27

No-load current = 800 mA(Max), Load current = upto 9.5 A(Max) Price: Rs. 900

4.4

Encoder Selection

Two encoders are required for the application; one to measure the rotation of the motor and the other one to measure the angle of the pendulum. Since the angle of the pendulum moves only varies from 0-360 degrees, to know the number of rotations of the pendulum an absolute encoder has to be used for that purpose. On the other hand, to note the current position of the cart, it is required to note more than one rotation and hence, an incremental encoder has to be used. The encoders have been procured from BTH which is a multinational company and provides service for its products and hence the parts are standard which can be procured for the project later on. An incremental encoder has 4 signals which ultimately calculate the direction of rotation of the shaft and also the speed of movement. The encoder has been shown in the Figure 4.7.

Figure 4.7 - Incremental Encoder BI-52S-2500-PU

4.5 Motor Driver


A motor driver has to be used to control the voltage given to the motor. This motor driver takes analog inputs provided by the DAQ Card. This motor driver takes analog voltage as input and then calculates the voltage that has to be supplied to the motor. Input Voltage Range=0-5V Input Current Range = 0-30mA Output Voltage Range= 0-12V

28

This has been procured from the Robotics Club, IIT Delhi as this has been tried and tested successfully by them. This is made by the company DimensionEngineering and is a standard part that can be procured later at any stage of the project. The figure 4.8 shows the motor driver. The data sheet of this has been attached in the Appendix-E.

Figure 4.8 - Motor Driver (www.dimensionengineering.com)

4.6 Data Acquisition Card (DAQ)


DAQ Card is required to transfer the reading from the encoders to the computer and then give the controlled outputs back to the motor. The Data Acquisition card present in the Lab was studied and checked for compatibility. Two models were available in the lab but the model relevant for the project has been selected. Model Number: NI PCI-6221 Specifications: OUTPUT PORTs: Two 16-bit analog outputs (833 kS/s) INPUT/OUTPUT PORT: 24 digital I/O COUNTER: 32-bit counters

Required Inputs: Two Angular Encoders Digital Inputs

Required Outputs: One Motor Driver Card Analog output


29

The figure 4.9 shows the port of the DAQ which has 68 pins and all the pins have been marked for their corresponding functions.

Figure 4.9 - DAQ NI-PC 6221 Port Drawing

30

Chapter 5. Equipment Design and Fabrication


The Figure 5.1 shows the final CAD Drawing of the complete system.

Figure 5.1 - Final CAD model

31

The figure Figure 5.2 shows the CAD Model of the Igus slider that has been ordered.

Figure 5.2 - Igus Slider

After this, the cart along with the pendulum has been designed and the Figure 5.3 shows the CAD Model for that.

Figure 5.3 - Cart along with the pendulum

This cart has now been attached to the slider. After this, to move the cart along the slider, a chain and sprocket system has been designed. So, on one side of the slider, we have a driving mechanism. On the other side, there is a driven mechanism. The driving mechanism consists
32

of a motor attached to a shaft which is further connected to an incremental encoder to measure the rotation of the motor so as to calculate the position of the cart. The assembly is supported by the bearings which in turn are mounted on a plate. The Figure 5.4 shows the CAD model of the driving mechanism.

Figure 5.4 - Driving Mechanism

The driven mechanism assembly consists of a idler sprocket supported by 2 bearings on a plate. The Figure 5.5 shows the CAD Model of the driven mechanism.

Figure 5.5 - Driven Mechanism Assembly

To support the slider, the driving mechanism and the driven mechanism, three stands are made. Two of the three stands are identical which are at the ends and the Figure 5.6 shows the CAD model of that stand. The shape of this stand has been made so as to support the

33

driving (or driven) mechanism and the slider. Also, provision has been made to accommodate the chain of the pulley.

Figure 5.6 - Stand on the ends of the slider

The Figure 5.7 shows the CAD Model of the middle stand.

Figure 5.7 - Middle Stand

After procuring the components for the setup like aluminium box channels, shafts, couplers etc. in the last semester, the manufacturing was started. First of all, the stands were made which had to support the complete setup. The channels were cut as per the requirements and were taken to a manufacturer outside IIT where they were welded using TIG Welding. Figure 5.8 shows the welded stands. One fork of the left stand supports the driving motor and the other stand supports the IGUS Sliders.

34

Figure 5.8 : Stands after TIG Welding

Then plates were cut using sheet metal cutter to support the sliders. Figure 5.9 shows the 5mm Aluminium plates used in the setup.

Figure 5.9 : 5mm Aluminium plates

To support the driving shaft assembly and the driven shaft assembly, the 5mm plates were bent so as to take in account the profile of the gear. Figure 5.10 shows both the plates.

Figure 5.10 : Plates used to support the driving and the driven shaft assemblies

35

Further, to drive the system, timing belt was selected. To prevent any mismatch, the timing pulleys of the same module as the belt were obtained. Figure 5.11 shows the timing belt and figure 5.12 shows the profile of the timing pulleys thus obtained.

Figure 5.11 : Timing belt 3.5m long and 10mm wide

Figure 5.12 : Profile of the timing pulleys

To drive the system, 8mm shaft was selected and was cut according to the CAD Model. Thus 8mm bearings were selected. Outer diameter of the selected bearings was 16mm. Figure 5.13 shows the selected bearings.

Figure 5.13 : 8mm roller bearing

36

To mount the bearings in the system, aluminium housing was made from a 25mm diameter aluminium rod. The bearings were fitted into the housing with a tight fit. A 2mm strip was welded tangentially to the rod for base of the housing. Figure 5.14 shows the close-up view of the bearing fitted into housing.

Figure 5.14 : Bearing with housing

To mount the motor and the encoder on the support, L-shaped housings were made and connected to them. Figure 5.15 and figure 5.16 shows the motor and the encoder along with their housings. Two incremental encoders were used and both have the similar housings.

Figure 5.15 : Driving Motor with housing

37

Figure 5.16 : Encoder along with housing

To connect the motor and the encoder to the 8mm shaft, muff couplings were used as per the CAD drawings. The driving assembly was made by assembling the motor with the shaft and that with the encoder. The shaft was supported by 2 bearings and to level the bearings, the bearing supports were made. Figure 5.17 shows the driving shaft assembly.

Figure 5.17 ; Driving shaft assembly

Similarly, the driven shaft assembly was made. The shaft was simply mounted using the two bearings and their stands. Figure 5.18 shows the driven shaft assembly.

38

Figure 5.18 : Driven shaft assembly

Now, to make the cart, a 5mm plate was first attached to the Igus slider. The remaining assembly was fixed over the cart. To hold the pendulum, a shaft was made with provision to attach the encoder on one side and pendulum on the other side. The shaft along with the bearing and encoder were supported on the cart plate. The bearing was supported by a bearing support to level the encoder with the bearing. The complete cart assembly including the encoder, its housing, shaft, cart, bearing is shown in the figure 5.19.

Figure 5.19 : Cart assembly

The pendulum was made by attaching an 8mm aluminium rod to a steel cylinder. The steel cylinder was attached as a bob to increase the moment of inertia of the pendulum about the pivot point so as to reduce the air drag caused while oscillations. Figure 5.20 shows the pendulum.

39

Figure 5.20 : Pendulum

The complete system was mounted on the sliders and the stands. Now to drive the cart, the motor was attached to the cart using a timing pulley. The belt was wound tightly on the pulley and the open ends of the belt were fixed to the cart by attaching 2 plates on the cart. The bolts on the pulley could be tightened to hold the belt in tension. Figure 5.21 shows the close-up view of the joint between cart and belt.

Figure 5.21 : Joint between cart and timing belt

40

The complete setup was assembled and placed in the Vibrations Research Lab. Due to the uneven heights of all the stands, the setup was not stable. To solve the problem, it was required that the system be fixed to a heavy base. Hence, a wooden board with the dimensions of the setup was obtained from the carpentry workshop. The setup was joined to the setup using 6mm bolts and the joint is shown in the figure 5.22. Further, counter-boring was done on each of the holes so that the setup rests on the wooden base and not on the heads of the bolt.

Figure 5.22 : Joint between wooden block and stand

Since, the slider was of the shape of a strip, to prevent bending, it was necessary to provide it some support. Hence, to increase the stiffness of the slider a 3x1 cross-sectional aluminium channels was attached. Figure 5.23 shows the arrangement done for the same.

Figure 5.23 : Support for the slider

Finally, the setup was assembled and the figure 5.24(a) and (b) shows the final setup thus made.

41

Figure 5.24(a) and (b) : Final setup of inverted pendulum

42

Chapter 6. Developing of Sensing and Actuation of system


To interface the system with the computer, it was required to interface the encoder(Section 6.1) to the DAQ Cards and the voltage generated by the DAQ Card should be sent to the motor. But since DAQ Card can only supply a very small current, a motor driver is required to amplify the signal via a battery. This has been discussed in Section 6.2.

6.1

Encoder Interfacing

An incremental encoder takes 2 signals as inputs one 5V and the other one, ground. It generates various output signals. For the current purpose, it was required to measure the angular rotation of the encoder. So, only 2 signals are required one is waveform A and other is waveform B. Figure 6.1 shows a general output of the 2 waveforms. When

waveform A leads waveform B by a phase of 90 degrees, it implies that the encoder is moving in clockwise direction, and when it lags, it indicates that encoder is moving in counter-clockwise direction.

Figure 6.1 : 2 output signals generated by incremental encoder(NI Developer Zone forum)

Hence, the measurement must be made continuously to ensure that the final reading takes into account this. THE NI-DAQ has 2 counters to do this function. Each counter has a source and up/down line which automatically calculates the final output. Figure 6.2 illustrates this.

Figure 6.2 : Simplified Counter/Timer Model of DAQ

43

The NI-6221 DAQ card has 2 counters and the figure 6.3 shows the pins of connector block SCB-68 that correspond to the source and up/down line.

Figure 6.3 : Layout of the connector block of NI-6221

As can be seen from the figure 6.3, pin 37 correspond to the source of counter 0 and pin 45 corresponds to auxiliary line of counter 0.To test the counter, a labview code was made to read from the counter and display the final angle in a numeric indicator. Figure 6.4 shows the block diagram of the code.

Figure 6.4 : Block diagram of the code to measure encoder's position

The encoder was tested and the code worked fine. The numeric indicator continuously showed the current position of the encoder as per a reference position given.

44

6.2

Motor Driver Fabrication

A motor driver has to be used to control the voltage given to the motor. This motor driver takes analog inputs provided by the DAQ Card. This motor driver takes analog voltage as input and then provides the required amount of voltage, current and energy to the motor. The whole motor driver circuit is composed of three modules: 1. L7805: The L7806 chip is three-terminal positive regulator package, making it useful in a wide range of applications. This regulator can provide local on-card regulation, eliminating the distribution problems associated with single point regulation. Each chip employs internal current limiting, thermal shut-down and safe area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltage and currents. Figure 6.5 shows a typical L7805 chip. Data-sheet of L7805 chip is attached in Appendix-D.

Figure 6.5: L7805 chip (http://www.mindkits.co.nz/store)

This chip was used to generate a regulated supply of +5 Volts to be given to Atmega 16. The pinouts and connections are shown in figure 6.6.

Figure 6.6: picture showing pinouts of L7805 chip(http://www.mindkits.co.nz/store)

45

2. Atmega 16: This takes the analog input voltage corresponding to the rpm of the motor from the DAQ card and then calculates the energy to be given to the motor. The output is in the form of PWM (Pulse Width Modulation) at a high frequency. The voltage at the output is only +5 Volts and the current is also in milli-amperes. So, this has to be stepped up to 12 V and the current current ~ 2 Amperes has also to be provided. The Atmega 16 is shown in Figure 6.7. Data-sheet of AtMega 16 is attached in Appendix-B.

Figure 6.7: ATmega16 chip (http://www.futurlec.com/Atmel/ATMEGA16.shtml)

The pinouts of this micro-controller are shown in Figure 6.8.

Figure 6.8: Pinouts of Atmega 16 (Appendix B)

The Atmega 16 controller was connected to a base before mounting on the matrix board. The input signals were given on Pin 40 (Analog Input) and the PWM output is obtained on pin 19. Figure 6.9 shows the soldering in progress for the base.
46

Figure 6.9: Soldering in progress for Atmega 16 Base

The status of matrix board after soldering of Atmega 16 base, crystal, ISP and L7805 chip is shown in figure 6.10.

Figure 6.10: Soldered Atmega 16 Base, crystal, ISP port and L7805 chip on matrix board

3. L298N: It is a high voltage, high current dual full-bridge driver designed to accept standard TTL logic levels and drive inductive loads like DC motors. Figure 6.11 shows a typical L298N chip. Data-sheet of L298N is attached in Appendix-C.

47

Figure 6.11: L298 chip (Appendix C)

The L298 chip takes the following inputs: Power supply: 12 V Logic Supply: 5V Ground PWM (logic form) Direction of rotation (logic Form)

The L298 chip gives the output to the motor by two terminals. Figure 6.12 shows all the pin connections of the L298 chip.

Figure 6.12: Connections for L298N for driving DC motor (Appendix C)

48

The L298 chip was soldered onto a base to allow for easy dismounting of the chip. The view of soldered L298 chip is shown in Figure 6.13.

Figure 6.13: Soldered L298 chip

All the chip connections were made and soldered. Figure 6.14 shows the final motor driver card.

Figure 6.14: Motor Driver card

49

Chapter 7.

Control Implementation

After the complete setup has been installed and the necessary electrical connections have been setup, control implementation was done. To get familiarity with the labVIEW, basic experiments were done e.g. synchronising counter with the encoder to calculate the final displacement of the encoder, and taking measurement from a simple potentiometer. As has been discussed in Section 3.3, before proceeding to the real-time control implementation, labVIEW codes were created to simulate the plant using values from the analytical model of the plant. After the simulation was done, real-time implementation was done and the results were compared. As the trend observed with the change in control logic parameters in simulation were similar to real-time system, trends in simulation results were used to vary the parameters in real-time system to obtain the desired characteristics. As discussed in Section 3.3, first of all SISO controls for cart position and pendulum angle were applied individually and then cascaded PID logic was used to balance both cart position and pendulum angle simultaneously. This section focuses on the results obtained from simulation and real-time system and their comparison with each other.

7.1

SISO Control of Cart Position(x)

For real-time implementation, the voltage calculated by the PID logic was supplied to motor as voltage and values of cart position and angle theta of the pendulum were taken by the encoders mounted on the plant. Figure 7.1 shows the block diagram of the labVIEW code used for real-time control.

50

Figure 7.1: Block Diagram for real time x-control

The PID logic used consists of 3 parameters Kp, Kd, Ki. To understand the variation and the effect of each of these on the control characteristics, each of them was varied keeping the other two fixed. First of all, proportional constant Kp was varied keeping Kd, Ki constant. Figure 7.2 shows the simulation results for 3 different values of Kp and values of Ki and Kd have been kept constant at 500 and 0.01 respectively. The set-point of the cart has been set at 0.08m and simulation is done for 10 seconds at a sampling time of 1 ms. Results show the value of 2 parameters cart position X and control action.

51

Figure 7.2 Simulation results for Kp=10, 25,50,100

As can be seen from Figure 7.2,with increase in Kp values from 10 to 100, damping of the system increases and the settling time decreases monotonously. Also, rise times constantly decrease. Similar analysis is also done for the real-time system. But since there are unwanted differences in the modelling and the actual system, the values obtained are different from the simulation results. Hence, only trends have been focussed at in this work. Figure 7.3 shows the results obtained with the real-time system for change in Kp values from 100-300.

52

Figure 7.3 Real-time results for Kp=100, 150, 300, 500

For real-time system also, damping of the system increases monotonously with increase in Kp values. Settling time of the system and rise time also decrease continuously. Hence, the trends match exactly with the simulation results. As with Kp, similar operations were performed with Ki and Kd. Figure 7.4 shows the results obtained for the simulation by varying Ki from 100 to 4000 whereas Kp and Kd have been kept constant at 25 and 0.01 respectively.

53

Figure 7.4 Simulation results for Ki=100,500,1000,5000

As can be seen from Figure 7.4, damping decreases with increase in Ki and settling time increases continuously. To compare the results with the real-time system, their results are displayed in Figure 7.5. Here, Kp and Kd have been kept constant at 300 and 0.003 respectively but Ki has been varied from 3000 to 80000.

54

Figure 7.5 Real-time results for Ki=3000, 30000, 60000, 80000

For the real-time system also, results match with the simulation. With increase in Ki, damping decreases and settling time increases continuously. Finally, trends were studied were studied for variation in Kd. Figure 7.6 show variation of results on changing values of Kd from 0.001 to 1 whereas Kp and Ki have been kept constant at 25 and 500 respectively.

55

Figure 7.6 Simulation results for kd=0.001, 0.01, 0.1, 1

Results from the simulations suggest that with increase in Kd, damping decreases and settling time increases continuously. Figure 7.7 shows the variation in a real-time system. Values of Kp and Ki have been kept constant at 300 and 30000 respectively whereas Kd has been varied from 0.003 to 3 respectively.

56

Figure 7.7 Real-time results for Kd=0.003, Kd=0.3, kd=3

The results show that with increase in values of Kd, damping of the system increases and settling time does not change significantly. Unlike Kp and Ki, trend of Kd is different from what is observed in simulation. This signifies that there is feature of the system that has bot been captured in the simulation models.

7.2

SISO Control of Pendulum Angle()

To do real-time control implementation, like Figure 7.1, motor voltage was given to the motor via DAQ Card and similarly, angle theta and cart position are measured by encoders and supplied to the labVIEW code via DAQ Cards. Figure 7.8 shows the block diagram for the simulation.

57

Figure 7.8: Block Diagram for theta-control real-time implementation

Like Section 7.1, in this section also, 3 parameters of the PID logics Kp, Ki, and Kd are varied to study and observe the trends. Both simulation and the real-time system have been studied so that any differences, if any, can be commented upon. Figure 7.9 shows the simulation results for 3 different values of Kp. The set-point of the angle has been set at 0.057 radians and simulation is done for 2 seconds at a sampling time of 1 ms. Results show the value of 3 parameters cart position X, pendulum angle and control action.

58

Figure 7.9 Simulation results for Kp=40, 75, 200, 500

As can be seen from Figure 7.9, with increase in values of Kp from 40 to 500, damping of the system decreases monotonously. The settling time also decreases continuously. Figure 7.10 shows the results obtained for the real-time system. Here Ki and Kd have been kept constant at 5 and 0.35 respectively but Kp is varied from 200 to 700. Since, the position of the cart is not controlled, hence the cart goes out of the desired limits very soon. So, pendulum can be kept within limits only for 1-2 seconds without any manual intervention. The graphs have been obtained only for the region where there was no manual intervention. On start-up, pendulum was left at its swing up position, and unlike simulation, stability of the pendulum is studied only.

59

Figure 7.10 Real-time results for Kp=200, 450, 700

As can be seen from the Figure 7.10, as values of Kp increases, the stability of the pendulum increases and hence, its tendency to sway away from the centre decreases. But due to noise in the surroundings, the control action keeps fluctuating and hence theta keeps on oscillating. The pendulum stays within range only for 2-3 seconds because in its effort to control pendulum angle, it moves rapidly on the cart and hence crosses the boundaries. Hence, similar analysis has been done for Ki and Kd. Figure 7.11 shows the results for the simulation of variation in values of Ki. Kp and Kd have been kept constant at 75 and 0.002 respectively.

60

Figure 7.11 Simulation results for KI=0.005, 0.01, 0.05

As can be seen from Figure 7.11, as values of Ki increase from 0.005 to 0.1, damping of the system decreases. Steady state error of the system also increases with time continuously whereas the settling time decreases continuously. In real-time system also, results were measured for changing values of Ki from 5 to 100 keeping Kp and Kd constant at 450 and 0.35 respectively. Figure 7.10 show the results obtained.

61

Figure 7.12 Real-time results for Ki=5, 10, 50, 100

Figure 7.12 suggest that with increase in values of Ki from 5 to 100, system becomes more stable and less sensitive to noise. Its tendency to sway away from the centre decreases. This is explicit from noticing that that oscillations in the system decrease due to noise with increase in Ki. Finally, simulation was done by varying values of Kd from 0.002 to 0.2 respectively. Kp and Ki have been kept constant at 75 and 0.05 respectively. Figures 7.13 show the results obtained.

62

Figure 7.13 Simulation results for Kd=0.002, 0.02, 0.2

Figures 7.13 suggest that as value of Kd increases from 0.002 to 0.2, damping decreases continuously. Also, settling increases continuously. Now, similar readings are obtained for the real-time system. The graphs obtained are shown in Figures 7.1. Here, Kp and Ki have been kept constant at 450 and 5 respectively.

63

Figure 7.14 Real-time results for Kd=0.35, 0.1, 1

As with Ki and Kp, similar results are also obtained i.e. with increase in values of Kd, stability of the system increases and its tendency to sway away from the centre decreases.

64

7.3

Cascaded PID logic to control Pendulum Angle and Cart Position

Figure 7.15 shows the real-time implementation of this technique. Here also, encoders values for theta and cart position is measured and sent to LabVIEW via DAQ Cards. So, feedback loop is not present in the code but is in the plant itself.

Figure 7.15: Block Diagram for real-time implementation fo cascading of PID logics

The logic used has been discussed in detail in Section 3.3. Since there are 6 parameters of the PID logic used here, we do variations of each of these 6 parameters (Kp, Kd and Ki for pendulum angle, Kp, Kd and Ki for cart position) in simulation and compare the result with the real-time system. First of all, simulation was done by varying values of Kp for cart position. Figure 7.16, 7.17, 7.18 show the results obtained.

65

Figure 7.16 Simulation results for Cart Position Gains Kp=0.25, Ki=0.001, kd=0.01(Cascaded PID)

Figure 7.17 Simulation results for Cart Position Gains Kp=0.6, Ki=0.001, kd=0.01(Cascaded PID)

Figure 7.18 Simulation results for Cart Position Gains Kp=0.8, Ki=0.001, kd=0.01(Cascaded PID)

As can be noted from Figures 7.16, 7.17, 7.18, this control logic is able to balance both pendulum angle and x-position simultaneously. As the value of Kp increases, damping of the system increases and the settling time decreases continuously. One interesting thing to note is that there is a steady state error in the value of x which also decreases continuously. Similar variations were also done on the real-time systems and Figures 7.19, 7.20, 7.21 show the results obtained.

66

Figure 7.19 Real-time results for Cart Position Gains Kp=0.2, Ki=0, kd=0.001(Cascaded PID)

Figure 7.20 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.001(Cascaded PID)

Figure 7.21 Real-time results for Cart Position Gains Kp=0.7, Ki=0, kd=0.001(Cascaded PID)

As can be noted from the Figures 7.19, 7.20, 7.21, the system is not able to become stable. The cart position keeps on oscillating and the amplitude keeps on increasing. With increase in Kp values, time period of oscillation decreases i.e. frequency increases and hence within the specified cart position limits, system remains for longer time. Like the simulation results, damping of the system increases with increase in values of Kp, but for further increase in values, mechanical system starts vibrating, a phenomenon called actuator saturation, and hence system becomes noisy and difficult to handle which in turn makes the system more unstable. Also, after 2-3 oscillations, system just loses control and cart position increases suddenly. This problem arises from the fact that since motor can be given voltage only upto a limit, hence some limit has to be set on the control output. So, when the calculated control

67

output by the system increases than the limits, then it gets clipped and hence the system doesnt get the actual control values and hence it becomes unstable. Like Kp, variation of Kp of pendulum angle was also done. Figures 7.22, 7.23, 7.24 show the simulation results.

Figure 7.22 Simulation results for Pendulum Angle Gains Kp=40, Ki=3000, kd=0(Cascaded PID)

Figure 7.23 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000, kd=0(Cascaded PID)

Figure 7.24 Simulation results for Pendulum Angle Gains Kp=100, Ki=3000, kd=0(Cascaded PID)

As can be seen from the results, with increase in values of Ki, damping decreases and settling time increases continuously. The steady state error also decreases marginally. Figures 7.25, 7.26, 7.27 show the results obtained in real-time system of the variation of Kp of pendulum angle.

68

Figure 7.25 Real-time results for Pendulum Angle Gains Kp=200, Ki=45, kd=0.45(Cascaded PID)

Figure 7.26 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.45(Cascaded PID)

Figure 7.27 Real-time results for Pendulum Angle Gains Kp=700, Ki=45, kd=0.45(Cascaded PID)

As can be seen from results, as the values of Kp of pendulum angle increases, amplitude of oscillation decreases. But the oscillations due to noise in the control action increase vigorously thereby making it cross the limits very early.

69

After Kp values, simulation was done by varying Ki values of cart position x. Figures 7.28, 7.29, 7.30 show the results.

Figure 7.28 Simulation results for Cart Position Gains Kp=0.6, Ki=0.0001, kd=0.01(Cascaded PID)

Figure 7.29 Simulation results for Cart Position Gains Kp=0.6, Ki=0.001, kd=0.01(Cascaded PID)

Figure 7.30 Simulation results for Cart Position Gains Kp=0.6, Ki=0.01, kd=0.01(Cascaded PID)

As can be seen from the simulation results, with increase in Ki values, damping decreases and settling time increases. There is not much change in steady state due to Ki. Figures 7.31, 7.32, 7.33 show the results by varying Ki of cart position for the real-time system.

70

Figure 7.31 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.001(Cascaded PID)

Figure 7.32 Real-time results for Cart Position Gains Kp=0.45, Ki=0.1, kd=0.001(Cascaded PID)

Figure 7.33 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.001(Cascaded PID)

As can be seen from the results, as Ki increases, damping decreases. This is because the time in which cart reaches its limits decreases. This characteristic matches with the simulation. The system is unstable in all the conditions, although the level of instability increases with increase in Ki.

71

Also, simulation results were generated for different values of Ki of pendulum angle. Figures 7.34, 7.35, 7.36 show the results obtained.

Figure 7.34 Simulation results for Pendulum Angle Gains Kp=50, Ki=1000, kd=0 (Cascaded PID)

Figure 7.35 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000, kd=0 (Cascaded PID)

Figure 7.36 Simulation results for Pendulum Angle Gains Kp=50, Ki=3500, kd=0 (Cascaded PID)

As can be seen from the above results, with increase in Ki values of pendulum angle, damping increases and settling time decreases continuously. Figures 7.37, 7.38, 7.39 show the results obtained for real-time system for variation in values of Ki of pendulum angle.

72

Figure 7.37 Real-time results for Pendulum Angle Gains Kp=450, Ki=10, kd=0.45 (Cascaded PID)

Figure 7.38 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.45 (Cascaded PID)

Figure 7.39 Real-time results for Pendulum Angle Gains Kp=450, Ki=70, kd=0.45 (Cascaded PID)

Finally, the simulation results were calculated by varying Kd for cart position and pendulum angle. Figure 7.40, 7.41, 7.42 show the simulation results for different Kd values for cart position.

73

Figure 7.40 Simulation results for Cart Position Gains Kp=0.6,Ki=0.0005,kd=0.001 (Cascaded PID)

Figure 7.41 Simulation results for Cart Position Gains Kp=0.6,Ki=0.0005,kd=0.01 (Cascaded PID)

Figure 7.42 Simulation results for Cart Position Gains Kp=0.6,Ki=0.0005,kd=0.015 (Cascaded PID)

As can be seen from the results, as Kd increases, damping increases and settling time decreases monotonously. This variation was also performed for real-time system and Figures 7.43, 7.44, 7.45 show these results.

74

Figure 7.43 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.0005 (Cascaded PID)

Figure 7.44 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.001 (Cascaded PID)

Figure 7.45 Real-time results for Cart Position Gains Kp=0.45, Ki=0, kd=0.005 (Cascaded PID)

And at last, simulation results by varying Kd values of pendulum angle were obtained. Figure 7.46, 7.47, 7.48 show these variation.

75

Figure 7.46 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000,kd=0.01 (Cascaded PID)

Figure 7.47 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000, kd=0.1 (Cascaded PID)

Figure 7.48 Simulation results for Pendulum Angle Gains Kp=50, Ki=3000, kd=1 (Cascaded PID)

As can be seen from the results, as Kd value increases, damping decreases and settling time increases. Also, real-time results were obtained for this variation and these results have been shown in Figures 7.49, 7.50, 7.51.

76

Figure 7.49 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.1 (Cascaded PID)

Figure 7.50 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.45 (Cascaded PID)

Figure 7.51 Real-time results for Pendulum Angle Gains Kp=450, Ki=45, kd=0.7 (Cascaded PID)

As can be seen from the Figures 7.49, 7.50, 7.51, damping decreases as the cart takes more time to cross its limits. Further, the level of stability of the system decreases continuously as the rate of increase in the amplitude of oscillation decreases with increase in Kd values. Finally, all the settling times obtained on simulating the results in cascaded PID logics for different parameter changes have been plotted and shown in Figures 7.52, 7.53, 7.54, 7.55, 7.56, 7.57.

77

Figure 7.52 Settling time variation with change in Kp values for cart position

Figure 7.53 Settling time variations with change in Ki values for cart position

Figure 7.54 Settling time variations with change in Kd values for cart position

78

Figure 7.55 Settling time variations with change in Kp values for pendulum angle

Figure 7.56 Settling time variations with change in Ki values for pendulum angle

Figure 7.57 Settling time variations with change in Kd values for pendulum angle

79

Chapter 8. Conclusions and Future Scope


This project was intended to design and manufacture the setup/rig of inverted pendulum and implement control strategies for SISO control of pendulum angle and cart position. Additionally, MISO control strategies for simultaneous control of pendulum angle and cart position were also developed. The setup has been manufactured and has been installed in Vibrations Research Lab (IITD). The system has been interfaced to the computer via NI 6221 DAQ-Card. To control the motor speed, a motor driver card has also been made. The SISO control of pendulum angle and cart position has been simulated through Proportional-Integral-Derivative (PID) controller. A comprehensive variation of gains (PID) has been done and the results have been interpreted. The results were experimentally verified by implementing the same controller on the self-constructed experimental setup/rig. For simultaneous control of pendulum angle and cart position, two control strategies have been developed. The first strategy includes loop inside loop approach (or cascaded). The other strategy is the parallel implementation of two PID controllers wherein addition of individual errors forms the net error and is controlled. Real time tests were conducted and the results captured and analysed. The real time trends showed coherence with the simulation results. The practical work has gone a long way in helping us understand and develop an insight into the designing of control systems for SISO (Single Input Single Output) systems. Although this project accomplishes all the goals that were initially proposed and a working mechanical system was developed along with an accurate feedback network, some minor improvements can be done to improve its working. The mechanical system could be modified to reduce friction in the belt drive. Although this project was aimed at creating minimal user interface and implement basic control using PID logic. A variety of control designs could be implemented like state space and Fuzzy Logic. Additionally swing-up of the pendulum can be implemented. And further, one more pendulum can attached and control of double pendulum can be established. This project can be used as a very useful tool in studying control theories and transient and steady

80

state response of an inherently unstable system. This project can also be used as a teaching tool while teaching control theory. The foundation has been laid for future research.

81

References
1. Craig K and Kleinigger M, 2007, System Control Implementation Using LabVIEW 8.0, RPI Mechatronics Laboratory, Department of Mechanical Engineering, California Institute of Technology, California 2. Dockhorn M, Haas OCL, Wstenkhler G, 2006, From simulation to hardware implementation of a pid controlled system for a new control engineering laboratory, Control Theory and Application Centre, Coventry University 3. Vizins K, Kjellberg J, Khan A, 2010, Automatic Control-Project Course Inverted Pendulum Final Report, Mechanical Engineering Department, KTH Royal Institute of Technology, Sweden 4. Lam J, 2004, Control of an Inverted Pendulum, Advanced Control design laboratory report, Mechanical Engineering Department, University of California 5. Ogata, K., 2008, Modern Control Engineering, 3rd edition, Prentice Hall, Upper Saddle River, New Jersey 07458 6. Saha, S.K., 2008, Introduction to Robotics, The Mc-Graw Hill Companies, New Delhi, pp. 172-179 7. Altas I, 2005, Inverted Pendulum, Electrical and Electronics Engineering, Karadeniz Technical University

82

Appendix-A

User Manual The following code has been made in MATLAB Version 7.4. This can be compiled on any machine having the above or higher version of MATLAB. The processing power used for compiling this code is 2GB RAM and a typical code takes 5 seconds to work. The processing speed may vary as per the computer used. The program can be simply run using normal MATLAB methods. However, to vary the simulation results and to test it for various mass of cart, pendulum etc, you need to change them. Appropriate comments have been added to the code. The user is required to refer them and as per his requirements vary the inputs. Program Code
function Inverted_Pendulum

clc clear all close all

global cart_acc cart_vel cart_pos pend_angular_acc pend_angular_vel pend_angle count

global mat_cart_acc mat_pend_angular_acc

count=0; cart_acc=0; pend_angular_acc=0;

global m M l fric_force Force Back_Force

m=0.5; M=2; l=0.4; fric_force=5;

% mass of pendulum % mass of cart % length of pendulum % frictional force

83

Torque=0.6; Radius=0.03; Force=10; Back_Force=Torque/Radius;

Inicon(1)=150*pi()/180; Inicon(2)=0; Inicon(3)=0; Inicon(4)=0;

% pendulum angle % pendulum angular velocity % cart position % cart velocity

Tinit=0; Tfin=3.5; Tspan=[Tinit Tfin]; options = odeset('InitialStep',0.001,'MaxStep',0.003);

[time,X]=ode45(@simulation_Inverted,Tspan,Inicon,options);

figure % axis([-0.5, 10, -1, 1]) % hold on plot(time,mod((X(:,1)*180/pi()),360)); title('Pendulum Angle'); xlabel('Time( in sec )') ylabel('Pendulum Angle( in degrees )')

Y(:,1)=X(:,3); Y(:,2)=0; Y(:,3)=X(:,3)+(l*sin(X(:,1))); Y(:,4)=l*cos(X(:,1));

figure plot(time,Y(:,1)); title('Cart Position'); xlabel('Time( in sec )') ylabel('Cart Position( metres )')

figure plot(time,X(:,4)); title('Cart Velocity'); xlabel('Time( in sec )')

84

ylabel('Cart Velocity ( in m/s )')

figure('color','white'); axis([-5, 50, -2, 2]) xlabel('Time( in sec )') title('My Simulation!','Color',[.6 0 0])

for j = 1:10:length(Y(:,1))

plot([Y(j,1) Y(j,3)],[Y(j,2) Y(j,4)]); axis([-2, 2, -2, 2]); axis square; pause(0.002);

end

function dX=simulation_Inverted(t,X)

global m M l fric_force Force Back_Force cart_acc pend_angular_acc count

global F

global mat_cart_acc mat_pend_angular_acc

% angle in radians k=X(1); sine=sin(k); cosi=cos(k);

t=mod(X(1),2*pi()); X(1)=t;

if (X(1)<270*pi()/180) && (X(1)>90*pi()/180) if X(2)==0; F=Force; else F=Force*X(2)/abs(X(2)); end end

85

if (X(2)>0)&&(X(1)>0)&&(X(1)<90*pi()/180) F=-Force; end

if (X(2)<0)&&(X(1)>270*pi()/180)&&(X(1)<360*pi()/180) F=Force; end

if ((X(3)>.15)&&(X(2)>0)) F=-15; end

if ((X(3)>.15)&&(X(2)<0)) F=-15; end

if ((X(3)<-.15)&&(X(2)>0)) F=15; end

if ((X(3)<-.15)&&(X(2)<0)) F=15; end

cart_acc(length(cart_acc)+1)=(F-fric_force+(m*l*0.5*sine*(X(2)^2))(m*l*0.5*cosi*pend_angular_acc(length(pend_angular_acc))))/(M+m);

if isnan(cart_acc) a=0; end

pend_angular_acc(length(pend_angular_acc)+1)=((9.8*sine)(cart_acc(length(cart_acc))*cosi))*(3/2)/l;

dX(1)=X(2); dX(2)=pend_angular_acc(length(pend_angular_acc)); dX(3)=X(4); dX(4)=cart_acc(length(cart_acc));

86

if isnan(X(1)) a=0; end if isnan(X(2)) a=0; end if isnan(X(3)) a=0; end if isnan(X(4)) a=0; end

dX=dX';

87

Appendix B

88

89

90

91

92

Appendix C

93

94

95

96

97

98

99

Appendix D

100

101

102

Appendix E

103

Vous aimerez peut-être aussi