laboratory guide 2 DOF Inverted Pendulum Experiment for MATLAB /Simulink Users Developed by: Jacob Apkarian, Ph.D., Quanser Hervé Lacheray, M.A.SC., Quanser Michel Lévis, M.A.SC., Quanser Quanser educational solutions are powered by: Captivate. Motivate. Graduate.
PREFACE Preparing laboratory experiments can be time-consuming. Quanser understands time constraints of teaching and research professors. That s why Quanser s control laboratory solutions come with proven practical exercises. The courseware is designed to save you time, give students a solid understanding of various control concepts and provide maximum value for your investment. Quanser 2 DOF Inverted Pendulum courseware materials are supplied in a format of the Laboratory Guide. The Lab Guide contains lab assignments for students. This courseware material sample is prepared for users of The MathWorks s MATLAB/Simulink software in conjunction with Quanser s QUARC real-time control software. A version of the course material for National Instruments LabVIEW users is also available. The following material provides an abbreviated example of in-lab procedures for the 2 DOF Inverted Pendulum experiment. Please note that the examples are not complete as they are intended to give you a brief overview of the structure and content of the courseware materials you will receive with the plant.
TABLE OF CONTENTS PREFACE... PAGE 1 INTRODUCTION TO QUANSER 2 DOF INVERTED PENDULUM COURSEWARE SAMPLE... PAGE 3 LABORATORY GUIDE TABLE OF CONTENTS... PAGE 3 BACKGROUND SECTION SAMPLE... PAGE 4 LAB EXPERIMENTS SECTION SAMPLE... PAGE 5
1. INTRODUCTION TO QUANSER 2 DOF INVERTED PENDULUM COURSEWARE SAMPLE Quanser courseware materials provide step-by-step pedagogy for a wide range of control challenges. Starting with the basic principles, students can progress to more advanced applications and cultivate a deep understanding of control theories. Quanser 2 DOF Inverted Pendulum courseware covers topics, such as: Obtain an open-loop state-space representation of a 1 DOF Rotary Inverted Pendulum system Design and tune an LQR-based state-feedback controller Simulate the closed-loop response of the 1 DOF Rotary Inverted Pendulum system. Implement state-feedback controller on the 2 DOF Inverted Pendulum system and evaluate its actual performance 2. LABORATORY GUIDE TABLE OF CONTENTS The full Table of Contents of the Quanser 2 DOF Inverted Pendulum Laboratory Guide is shown here: 1. INTRODUCTION 2. BACKGROUND 2.1. MODELING 2.1.1.1. MODEL CONVENTION 2.1.2. NONLINEAR EQUATIONS OF MOTION 2.1.3. LINEARIZING 2.1.4. LINEAR STATE-SPACE MODEL 2.2. CONTROL 2.2.1. STABILITY 2.2.2. CONTROLLABILITY 2.2.3. LINEAR QUADRATIC REGULAR (LQR) 2.2.4. FEEDBACK CONTROL 3. LAB EXPERIMENTS 3.1. SIMULATION 3.1.1. PROCEDURE 3.1.2. ANALYSIS 3.2. IMPLEMENTATION 3.2.1. PROCEDURE 3.2.2. ANALYSIS 4. SYSTEM REQUIREMENTS 4.1. OVERVIEW OF FILES 4.2. SETUP FOR SIMULATION 4.3. SETUP FOR RUNNING ON 2 DOF INVERTED PENDULUM REFERENCES
3. BACKGROUND SECTION - SAMPLE Control In Section 2.1, we found a linear state-state space model that represents a single rotary inverted pendulum system. This model is used to investigate the stability properties of the system in Section 2.2.1. In Section 2.2.2, the notion of controllability is introduced. Using the Linear Quadratic Regular algorithm, or LQR, is a common way to find the control gain and is discussed in Section 2.2.3. Lastly, Section 2.2.4 describes the state-feedback control used to control the servo position while minimizing link deflection. Stability The stability of a system can be determined from its poles ([8]): Stable systems have poles only in the left-hand plane Unstable systems have at least one pole in the right-hand plane and/or poles of multiplicity greater than 1 on the imaginary axis Marginally stable systems have one pole on the imaginary axis and the other poles in the left-hand plane The poles are the roots of the system's characteristic equation. From the state-space, the characteristic equation of the system can be found using (2.12) where det() is the determinant function, s is the Laplace operator, and I the identity matrix. These are the eigenvalues of the state-space matrix A. Controllability If the control input, u, of a system can take each state variable, x i where i = 1... n, from an initial state to a final state then the system is controllable, otherwise it is uncontrollable ([5]). Rank Test The system is controllable if the rank of its controllability matrix equals the number of states in the system, (2.13) (2.14) Linear Quadratic Regular (LQR) If (A,B) are controllable, then the Linear Quadratic Regular optimization method can be used to find a feedback control gain. Given the plant model in Equation 2.6, find a control input u that minimizes the cost function (2.15) where Q and R are the weighting matrices. The weighting matrices affect how LQR minimizes the function and are, essentially, tuning variables. Given the control law u = -Kx, the state-space in Equation 2.3 becomes
4. LAB EXPERIMENTS SECTION - SAMPLE Simulation In this section we will use the Simulink diagram shown in Figure 3.1 to simulate the closed-loop control of the 1 DOF Rotary Inverted Pendulum system. Recall in Section 2.1 the 2 DOF Inverted Pendulum is modeled as two independent and identical rotary pendulum systems. We will only be examining the 1 DOF portion. The Rotary Inverted Pendulum is simulated using the obtained linear state-space model. The Simulink model uses the state-feedback control described in Section 2.2.4. The feedback gain K is found using the Matlab LQR command (LQR is described briefly in Section 2.2.3). The goal is to find a gain that will stabilize the pendulum while tracking a given servo setpoint. Figure 3.1: Simulink diagram used to simulate 1 DOF Rotary Inverted Pendulum. IMPORTANT: Before you can conduct these experiments, you need to make sure that the lab files are configured according to your setup. If they have not been configured already, then you need to go to Section 4 to configure the lab files first. Procedure Follow these steps to simulate the rotary pendulum: 1. Make sure the LQR weighting matrices in setup_2dip.m are to and 2. This automatically generates the gain
Remark: When tuning the LQR, Q(1; 1) effects the servo proportional gain while Q(3; 3) effects the servo derivative gain (which reduces the overshoot). Increasing Q(4; 4) attenuates the motions of the pendulum. Finally, tuning Q(5; 5; ) effects the servo integral gain. 3. To generate a 0.025 Hz square wave reference, ensure the Signal Generator is set to the following: Signal type = square Amplitude = 1 Frequency = 0.025 Hz 4. Set the Amplitude (deg) gain blocks to 30 to generate a step with an amplitude of 30 degrees (i.e. square wave goes between 30 which results in a step amplitude of 60). 5. Open the servo gear position scope, theta l (rad), the pendulum angle scope, alpha (deg), and the motor input voltage scope, Vm (V). 6. Start the simulation. By default, the simulation runs for 50 seconds. The scopes should be displaying responses similar to Figure 3.2. Note that in the theta l (rad) scopes, the yellow trace is the setpoint position while the purple trace is the simulated position. Figure 3.2: Simulated closed-loop response.
Over ten rotary experiments for teaching fundamental and advanced controls concepts Rotary Servo Base Unit 2 DOF Inverted Pendulum Inverted Pendulum Flexible Link Flexible Joint Ball and Beam Double Inverted Pendulum Gyro/Stable Platform 2 DOF Robot 2 DOF Gantry Multi-DOF Torsion Quanser s rotary collection allows you to create experiments of varying complexity from basic to advanced. Your lab starts with the Rotary Servo Base Unit and is designed to help engineering educators reach a new level of efficiency and effectiveness in teaching controls in virtually every engineering discipline including electrical, computer, mechanical, aerospace, civil, robotics and mechatronics. For more information please contact info@quanser.com 2013 Quanser Inc. All rights reserved. INFO@QUANSER.COM +1-905-940-3575 QUANSER.COM Solutions for teaching and research. Made in Canada.