Stabilizing the Dual Inverted Pendulum: A Practical Approach by Taylor Wallis Barton Submitted to the Department of Electrical Engineering and Computer Science in Partial Fulfillment of the Requirements for the Degree of Master of Engineering in Electrical Engineering and Computer Science at the Massachusetts Institute of Technology February 2008 Copyright 2008 Taylor Wallis Barton. All rights reserved. The author hereby grants to MIT permission to reproduce and distribute publicly paper and electronic copies of this thesis document in whole or in part and in any medium now known or hereafter created. Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Department of Electrical Engineering and Computer Science February 1, 2008 Certified by . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . James K. Roberge Professor of Electrical Engineering Thesis Supervisor Accepted by . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arthur C. Smith Professor of Electrical Engineering Chairman, Department Committee on Graduate Students 2 Stabilizing the Dual Inverted Pendulum: A Practical Approach by Taylor Wallis Barton Submitted to the Department of Electrical Engineering and Computer Science February 1, 2008 In partial fulfillment of the requirements for the degree of Master of Engineering in Electrical Engineering and Computer Science Abstract A dual inverted pendulum system, consisting of two individual pendulums of different lengths on a single cart, was fully designed and implemented as a demonstration of classical control theory. This document contains an analysis of the complete control system for both a single and dual inverted pendulum system, as well as the results of the implementation. Also presented are the all-analog systems which were used along with an industrial permanent magnet linear synchronous motor to control and drive the pendulum cart, including a voltage-controlled oscillator, three-phase switching power amplifier, and acceleration feedback controller. Thesis Supervisor: James K. Roberge Title: Professor of Electrical Engineering 3 4 Acknowledgments I would like to express my sincere gratitude to Professor J. K. Roberge, who has been my advisor and mentor for the past four years. It was Professor Roberge who suggested that I attempt to implement the dual inverted pendulum system, and this project would not have been successful without his advice and support. I am grateful for his confidence in me and for the many opportunities he has given me over the past years. I would also like to thank Tracy Clark for making it possible for me to use one of MagneMotion, Inc.’s QuickStickTM motors. This project would likely not have been such a success without this motor at its foundation. Thanks to Redwire, LLC. for the use of equipment and components, and to Mariano for his ideas and suggestions, reading and editing of this document, and his constant support and encouragement. 5 THIS PAGE INTENTIONALLY LEFT BLANK 6 Contents 1 Introduction 15 2 Theory 17 2.1 2.2 2.3 Equations of Motion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2.1.1 Fast Pendulum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.1.2 Slow Pendulum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Single Pendulum Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 2.2.1 Position Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Dual Pendulum Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2.3.1 Position Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.3.2 Maximum Phase Margin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3 Mechanical Design 35 3.1 Pendulum Construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 3.2 Angle Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 3.3 Cart Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 4 Angle and Position Sensing 41 4.1 Angle Sensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.2 Position Sensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4.2.1 A Digital Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4.2.2 An Analog Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 5 Motor Drive 47 5.1 Speed/Direction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 5.2 VCO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 5.2.1 Amplitude Stabilization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 5.2.2 Direction Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 7 5.3 5.2.3 Offset correction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 5.2.4 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 5.2.5 Three Phase Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Power Electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 5.3.1 Switching Drive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 5.3.2 Power Supplies for Switching Drive . . . . . . . . . . . . . . . . . . . . . . . . 57 6 Motor Control 61 6.1 Acceleration Measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 6.2 Characterizing the Plant . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 6.3 Loop Compensation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6.3.1 72 Closed Loop Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Results 7.1 7.2 7.3 75 Single Inverted Pendulum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 7.1.1 Short Pendulum Position Feedback . . . . . . . . . . . . . . . . . . . . . . . . 80 Stabilizing the Dual Inverted Pendulum . . . . . . . . . . . . . . . . . . . . . . . . . 83 7.2.1 Position Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 A Temporary Single Inverted Pendulum 87 B An Alternative Single Pendulum Loop 91 C Operating Instructions 95 C.1 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 C.2 Startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 D List of Symbols 97 Bibliography 99 8 List of Figures 1-1 Sketches of various two-pendulum systems. The dual inverted pendulum in (a) was implemented for this thesis. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2-1 Ideal Inverted Pendulum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2-2 This construction method for the slow pendulum results in a high effective length while avoiding a physically large pendulum. . . . . . . . . . . . . . . . . . . . . . . . 20 2-3 Sketch of upper limit on long pendulum length (not to scale). . . . . . . . . . . . . . 22 2-4 Plot of effective length of long pendulum vs length ratio for the chosen mass ratio and short pendulum length. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2-5 Block diagram of the ideal single pendulum system. . . . . . . . . . . . . . . . . . . 24 2-6 Bode plots of ideal single pendulum system. . . . . . . . . . . . . . . . . . . . . . . . 25 2-7 Single pendulum system with position feedback. . . . . . . . . . . . . . . . . . . . . . 26 2-8 Bode and Nyquist plots of single pendulum system. . . . . . . . . . . . . . . . . . . . 27 2-9 Block diagram of single pendulum system with position feedback system and lag compensator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 2-10 Block diagram of the ideal dual pendulum system. . . . . . . . . . . . . . . . . . . . 29 2-11 Bode plots of dual pendulum major loop transfer function. 30 . . . . . . . . . . . . . . 2-12 The dual pendulum system is kept on the track with position feedback. A lag compensator is required for stability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2-13 Geometric derivation of maximum phase margin based on the ideal dual pendulum system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 3-1 Mechanical drawings of pendulum construction. . . . . . . . . . . . . . . . . . . . . . 36 3-2 Printed circuit board for the 2SA-10 angle sensor. The primary purpose of this board is alignment with the pendulum axle. . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 3-3 Mechanical arrangement for angle sensing. The same assembly is used for all pendulums. 37 3-4 Mechanical drawings of the pendulum cart. . . . . . . . . . . . . . . . . . . . . . . . 39 3-5 Photographs of the pendulum cart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 9 4-1 Angle measurement circuit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 4-2 Sketch of the location of Hall Effect sensors in the QuickStickTM stator. . . . . . . . 43 4-3 Generation of state machine input signals. . . . . . . . . . . . . . . . . . . . . . . . . 44 4-4 State machine diagram for rough position measurement. . . . . . . . . . . . . . . . . 44 4-5 The PIC outputs control which of four voltages are passed through as the position offset, as well as the offset sign. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 4-6 Schematic of the analog position measurement, including a zeroing circuit activated when the cart crosses the center of the track. . . . . . . . . . . . . . . . . . . . . . . 46 5-1 This absolute value circuit converts a velocity command into speed and direction components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 5-2 Schematic of voltage control oscillator with amplitude stabilization and direction control. 49 5-3 Root locus of (a) minor loop and (b) VCO. The minor loop sets a fixed rate of growth for the oscillations, which are then clipped at a fixed maximum value. . . . . . . . . 49 5-4 Block diagram for VCO, shown at various levels of complexity. The minor loop can generally be excluded from other analyses because it serves to approximate an ideal system. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 5-5 This circuit has either a gain of +1 or -1 depending on the switch state. . . . . . . . 52 5-6 Detailed version of the circuits represented as multipliers in Figure 5-2. . . . . . . . 53 5-7 These op amp circuits compute weighted sums of sine and cosine to create three signals separated by 120◦. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-8 Switching motor drive, one phase. 54 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 5-9 Waveforms demonstrating the hysteretic control. . . . . . . . . . . . . . . . . . . . . 57 5-10 Terminal voltage of a single battery with constant 2.5A discharge current. The spike in data at around 4.25AH is due to stopping and restarting the test. . . . . . . . . . 58 5-11 Power supplies for motor drive. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 5-12 Each phase of the motor drive is built up on a printed circuit board. . . . . . . . . . 60 6-1 A printed circuit board was built for the accelerometer. . . . . . . . . . . . . . . . . 62 6-2 Measurement configuration for results shown in Figure 6-3. . . . . . . . . . . . . . . 63 6-3 Measurements of the acceleration loop plant. . . . . . . . . . . . . . . . . . . . . . . 64 6-3 Measurements of the acceleration loop plant. . . . . . . . . . . . . . . . . . . . . . . 65 6-3 Measurements of the acceleration loop plant. . . . . . . . . . . . . . . . . . . . . . . 66 6-4 Acceleration loop compensator schematic. . . . . . . . . . . . . . . . . . . . . . . . . 68 10 6-5 Bode plot of the acceleration loop compensator, with and without the Sallen Key filter. The Sallen Key filter is at a sufficiently high frequency such that it does not affect the system phase margin. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 6-6 Accelerometer output for the open loop and closed loop systems with a 1Hz sinusoidal input. The closed loop system is considerably improved. . . . . . . . . . . . . . . . . 71 6-7 Final configuration for the acceleration loop . . . . . . . . . . . . . . . . . . . . . . . 72 6-8 Closed loop measurements of the acceleration loop. The loop behavior meets the system requirements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 7-1 Block diagram of single pendulum system with position feedback system and lag compensator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 7-2 Implementation of summing junction and lead compensator. . . . . . . . . . . . . . . 76 7-3 Root locus of single pendulum loop for two choices of placement for the lead compensator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 7-4 Measurement configuration for results shown in Figure 7-5. . . . . . . . . . . . . . . 77 7-5 Short pendulum system loop closed loop measurements. . . . . . . . . . . . . . . . . 78 7-6 Step response of the system shown in Figure 7-4. Top trace: measured angle output. Bottom trace: input angle command. . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 7-7 Position measurement output when position feedback is used on the short pendulum system without a lag compensator. This system is unstable. . . . . . . . . . . . . . . 80 7-8 Complete schematic of compensator implementation for single pendulum loop. . . . 81 7-9 Position measurement output when position feedback is connected around the dual position system with no additional compensation. . . . . . . . . . . . . . . . . . . . . 84 7-10 Circuit implementation of compensator for dual pendulum loop. . . . . . . . . . . . 85 A-1 An adjustable slew rate limiter was used to limit the acceleration to avoid slip when the motor was driven open loop. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 A-2 When the motor is driven open loop, an additional integration must be added in the single pendulum loop compensator. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 A-3 The single inverted pendulum compensator consists of an integrator and a zero around the natural frequency of the pendulum. . . . . . . . . . . . . . . . . . . . . . . . . . 89 B-1 Implementation of summing junction and lead compensator. . . . . . . . . . . . . . . 92 B-2 The single short pendulum system: closed loop measurement from dynamic analyzer. 93 B-3 Small signal response of short pendulum system without position feedback . . . . . . 94 C-1 Sketch of physical locations of switches on cart board. . . . . . . . . . . . . . . . . . 95 11 THIS PAGE INTENTIONALLY LEFT BLANK 12 List of Tables 6.1 Component and frequency values for acceleration loop compensator shown in Figure 6-4. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 7.1 Component values for compensator circuit shown in Figure 7-2. . . . . . . . . . . . . 77 7.2 Component values for single pendulum compensator shown in Figure 7-8. . . . . . . 82 7.3 Component values for dual pendulum compensator shown in Figure 7-10. . . . . . . 84 B.1 Various iterations of component values and gain and peak overshoot measurements for the compensator shown in Figure B-1. The small signal measurements for system (d) are shown in Figure B-2 and Figure B-3. . . . . . . . . . . . . . . . . . . . . . . . 92 C.1 Table of switch settings for various demonstrations. . . . . . . . . . . . . . . . . . . . 96 13 THIS PAGE INTENTIONALLY LEFT BLANK 14 Chapter 1 Introduction A system that is inherently unstable is particularly interesting to a designer of control systems because it will not function without feedback. The dual inverted pendulum is an example of such a system. The system plant consists of two independent pendulums constrained to fall in one plane and controlled by the movement of a single cart. The goal is to keep both pendulums simultaneously upright as sketched in Figure 1-1(a). This system is an extension of the single inverted pendulum [1]. It has been previously analyzed from a classical control approach in [2] and using modern control methods in [3]. The work presented in this thesis is based on a purely classical approach to analysis and control system design, with a focus on the practical details of implementation. The dual inverted pendulum system should be distinguished from the double inverted pendulum, which is a single pendulum assembly with a hinged middle as sketched in Figure 1-1(b). The double pendulum control problem has been analyzed in the literature using modern control techniques as in [4, 5]. Yet another variation on the inverted pendulum is the parallel-type dual inverted pendulum analyzed in [6]. This system is sketched in 1-1(c). (a) Dual inverted pendulum (b) Double inverted pendulum (c) Parallel-type dual inverted pendulum Figure 1-1: Sketches of various two-pendulum systems. The dual inverted pendulum in (a) was implemented for this thesis. 15 The dual inverted pendulum system implemented for this thesis is stabilized using classical control theory approaches and purely analog circuits. It is a demonstration of the sort of complicated systems that can be stabilized using classical control. The completed system is intended to serve as a lecture demonstration in the MIT course 6.302, Feedback Systems, a graduate level feedback course. Chapter 2 of this document introduces the equations governing the plant, as well as the theoretical approach to stabilization. Chapters 3 through 6 cover the various mechanical and circuit designs that provide the foundation for implementing the pendulum system: the angle and position measurement, the mechanical aspects of design, and the motor drive and motor control systems. Ultimately, it is the success of these systems that determines if it is possible to stabilize the pendulums. Finally, Chapter 7 describes the results of this implementation. 16 Chapter 2 Theory In this chapter, the plant transfer function is derived from basic principles. Both the ideal pendulum model and more precise models based on the pendulums built for this thesis are analyzed. Once the plant is known, the theoretical approaches to stabilizing the single and dual inverted pendulum systems are presented and analyzed. 2.1 Equations of Motion The transfer function for the inverted pendulum system is found by considering an ideal inverted pendulum consisting of a mass m at the end of a massless rod with length ℓ. Two forces act on the mass: the downward force from gravity (Fg ) and the horizontal force from the acceleration of the cart (Fc ) as shown in Figure 2-1. The components of these forces tangent to the circle of radius ℓ described by the pendulum contribute to torque, and hence angular acceleration, as follows: τg = ℓ × Fg = ℓmg sin θ (2.1) τc = ℓ × Fc = −ℓmẍ cos θ (2.2) where τg and τc are the torques from gravity and the cart acceleration, respectively, and ẍ is the acceleration of the cart. Positive rotation is taken to be in the clockwise direction. The angular acceleration is found from the relationship τ = J θ̈, where J is the moment of inertia of the pendulum. For the ideal pendulum consisting of a mass on the end of a massless rod, the moment of inertia is J = mℓ2 . The above equations thus combine to give X τ = J θ̈ = τg + τc = ℓmg sin θ − ℓmẍ cos θ 17 (2.3) Fcθ Fgθ Fc Fg ℓ θ Figure 2-1: Ideal Inverted Pendulum θ̈ = ẍ g sin θ − cos θ ℓ ℓ (2.4) These equations are linearized about the vertical (θ ≈ 0) with the approximations for small angles, i.e. sin θ ≈ θ and cos θ ≈ 1. θ̈ = g ẍ θ− ℓ ℓ ℓθ̈ − gθ = −ẍ (2.5) Taking the Laplace transform of Equation 2.5 gives the ideal pendulum transfer function P (s): P (s) = where the time constant is τ = −s2 −s2 /g Θ(s) = 2 = X(s) ℓs − g (τ s + 1)(τ s − 1) p ℓ/g. This expression for an ideal pendulum of course does not match the results for the pendulums built for this thesis, particularly since the massless rod is unattainable. The constructed pendulums have moments of inertia that are not J = mℓ2 but a more complex expression. The following sections derive the expected equivalent length of the pendulums in terms of their physical lengths. This analysis was used in the mechanical design of the pendulums. Once the pendulums were built, their natural frequencies were measured by swinging each pendulum in a non-inverted position. From this measurement an effective length can be calculated based on the ideal expression ℓ = τ 2 g. The mechanical details are described in Section 3.1. 2.1.1 Fast Pendulum The fast pendulum is built as a solid cylinder of steel, i.e. with the massless rod omitted. The moment of inertia for a solid rod of length L rotated about one end is derived by integrating the 18 inertia over the length of the pendulum: Jf = Z l=L l2 dm l=0 If the linear density of the cylinder is µ = m/L, with the incremental density µ = dm/dl, this integral can be rewritten as Jf = Z l=L µl2 dl = l=0 1 3 1 µL = mL2 3 3 The center of mass is L/2 from the point of rotation. With these substitutions for moment of inertia and center of mass, Equation 2.3 is rewritten as X τ= L L 1 mL2 θ̈ = mg sin θ − mẍ cos θ 3 2 2 θ̈ = 3 (g sin θ − ẍ cos θ) 2L Comparing this equation with Equation 2.4 reveals that the effective length must be ℓ = 23 L where L is the physical length of the mass and ℓ is the length of an ideal pendulum having the same natural frequency. The associated time constant for the fast pendulum is τf = s ℓ = g s 2L 3g A pendulum was built from a steel cylinder with length L = 15cm as described in Section 3.1. The natural frequency, determined by measuring its period when in a non-inverted position, indicates an effective length of 20cm which is twice as long as expected. This discrepancy is probably due to multiple factors: the T joint and axle contribute to the pendulum’s inertia, and the bearings and damping from air slow the pendulum. Additionally, a longer, light plastic tube is attached around the steel mass to give the pendulum greater visibility. This contributes to the pendulum’s inertia but was not accounted for in the analysis. 2.1.2 Slow Pendulum It is intuitive that having a greater ratio in lengths between the two pendulums simplifies compensation. Certainly, the system is impossible to stabilize if the two pendulums have equal lengths. The derivation of maximum phase margin in Section 2.3.2 quantifies this intuition. From these results, a minimum length ratio of 10 is desired, since this will give a maximum possible phase margin for the system of 31.3 degrees. A first attempt at a slow pendulum was made by attaching a mass (steel) to the end of a relatively light rod (PETG tube), as described in Section 3.1. This pendulum was designed to have an effective 19 m1 ℓ1 ℓ2 m′ 2 m′1 axis of rotation m2 Figure 2-2: This construction method for the slow pendulum results in a high effective length while avoiding a physically large pendulum. length of 1 meter based on an expected fast pendulum length of 10cm. When measured, however, the effective length was only 90cm, a factor of only 4.5 greater than the measured short pendulum length. Stabilizing a system consisting of these two pendulums would nearly be impossible due to the low phase margin. This pendulum was eventually used as a temporary pendulum for initial tests of the system. In order to construct a type of pendulum of this type with an effective length ten times that of the fast pendulum, the physical length would be excessive. In addition to simply being unwieldy, increased length leads to other problems such as flexing in the pendulum shaft. An alternative approach is to use a pendulum as shown in Figure 2-2 to get a longer effective length without having a physically awkward construction [7]. If the masses and lengths of the two opposing pendulums shown are equal, then the object will be balanced and will not exhibit a pendulum-like behavior. By incrementally increasing m1 or ℓ1 , this mechanism will behave as an inverted pendulum with a very slow time constant. In this figure, m1 and m2 are steel masses at the end of rods of length ℓ1 and ℓ2 , which have mass m′1 and m′2 respectively. If the masses of the rods are ignored, the total torque acting on this pendulum is Στg + Στc = ℓ1 m1 g sin θ − ℓ2 m2 g sin θ − ℓ1 m1 ẍ cos θ + ℓ2 m2 ẍ cos θ = (ℓ1 m1 − ℓ2 m2 )(g sin θ − ẍ cos θ) and the total rotational inertia is simply the sum of the inertias of the two masses at their respective lengths: J = m1 ℓ21 + m2 ℓ22 Making the appropriate substitutions in the analysis from Section (2.1) above gives an equation of motion θ̈ = ℓ 1 m1 − ℓ 2 m2 m1 ℓ21 + m2 ℓ22 20 (g sin θ − ẍ cos θ) The expression for the effective length of this structure is ℓs = m1 ℓ21 + m2 ℓ22 ℓ 1 m1 − ℓ 2 m2 and the time constant associated with the pendulum is p τs = ℓ/g = s m1 ℓ21 + m2 ℓ22 g(ℓ1 m1 − ℓ2 m2 ) These expressions can be generalized for design purposes. If m1 is chosen to be some multiple of m2 , i.e. m1 = km m1 = km m, the effective length can be rewritten as ℓs = km ℓ21 + ℓ22 km mℓ21 + mℓ22 = ℓ1 km m − ℓ2 m km ℓ1 − ℓ2 Similarly, choosing ℓ1 = kℓ ℓ2 = kℓ L gives ℓs = L km kℓ2 + 1 km kℓ − 1 where L is the physical length of the noninverted pendulum and m is the associated mass. This result is elegant and – as with the ideal pendulum – does not depend on the absolute values of the masses, only their ratio. However, from experience the mass of the rods should not be neglected. When m′1 and m′2 are included, the torque equation becomes 1 1 m1 ℓ21 + m′1 ℓ21 + m2 ℓ22 + m′2 ℓ22 = 3 3 ℓ2 ℓ1 ℓ1 m1 + m′1 g sin θ − ℓ2 m2 + m′2 g sin θ 2 2 ℓ1 ′ ℓ2 − ℓ1 m1 + m1 ẍ cos θ + ℓ2 m2 + m′2 ẍ cos θ 2 2 The above analysis is repeated on this equation, with m1 = km m2 = km m and ℓ1 = kℓ ℓ2 = kℓ L. The rod masses are proportional to the lengths as m′1 = ρr ℓ1 and m′2 = ρr ℓ2 . Likewise, the relationship between the density by length of steel and that of the plastic rod is written as ρm = kρ ρr . The length of the steel mass m2 is assumed to be 5cm. When the mass of the rods is included, the expression for effective length becomes ℓ′s = 0.05kρ L2 (km kℓ2 + 1) + 13 L3 (kℓ3 + 1) 0.05kρ L(km kℓ − 1) + L2 (kℓ2 − 1) Clearly the pendulum length can be chosen to be arbitrarily large by setting the denominator term to zero. However, there is a lower limit to natural frequency due to the finite length of the track. Assume the cart is at one end of the track and the pendulum leans in with the maximum allowed angle, approximately 5 degrees. The control system will be set up to accelerate the cart so 21 that the pendulum “sees” gravity as exerting a force in the opposite direction from actual. If this is the case, the distance x the cart must travel to bring the pendulum angle to zero is (ℓs sin θ), where ℓs is the effective length of the pendulum, as sketched in Figure 2-3. The maximum allowable pendulum length is therefore ℓs,max = 0.5m = 5.7m sin(5◦ ) A plot of ℓ′s vs kℓ is shown in Figure 2-4, for L = 15cm and for km = 0.75. The ratio of masses is chosen to be less than one to allow for a greater difference in the lengths. The ratio of densities is derived from the physical dimensions and from typical material densities found in [8]. It is clear from this plot that small changes in length have a large effect on the effective length of the pendulum. Furthermore, even the more precise expression for ℓ′s derived above neglects the inertia of the T and elbow joints used to connect the pendulum to its axle. With this in mind, the slow pendulum was designed with mass m1 initially moveable. By incrementing the length ℓ1 until the effective length fell within the allowed range shown in Figure 2-4, an effective length of 2.65 meters was measured. The mass was then fixed in this position. x ℓs θ x=0 Figure 2-3: Sketch of upper limit on long pendulum length (not to scale). 22 12 11 Mass ratio km = 0.75 10 Short pendulum length L = 15cm Effective length ℓ′s 9 8 7 maximum ℓ′s 6 5 4 3 minimum ℓ′s 2 1 0 1.1 1.2 1.3 1.4 Length ratio kℓ Figure 2-4: Plot of effective length of long pendulum vs length ratio for the chosen mass ratio and short pendulum length. 23 2.2 Single Pendulum Control The single pendulum control is based on the approach developed by Roberge in his undergraduate thesis [1] and is intuitive to anyone who has attempted to balance a yardstick in one hand. An angle from vertical results in a force on the pendulum, which must be corrected by an acceleration by the hand in the direction the yardstick is falling. If the pendulum base is accelerated at e.g. twice the rate of fall of the top of the pendulum, the pendulum will move towards vertical. The mechanical system takes this approach, accelerating the cart at some multiple of the pendulum angle. A block diagram of the ideal single pendulum system is shown in Figure 2-5. As shown, the system consists of the pendulum, the motor, and some compensator G(s). For this thesis the motor G(s) + Km s2 x + θ −s2 /g (τp s+1)(τp s−1) pendulum Figure 2-5: Block diagram of the ideal single pendulum system. motor was controlled with an acceleration control loop, so the ideal transfer function of the motor block is Km /s2 . The implemented control system is described in Chapter 6. If G(s) = 1, the loop transfer function has characteristics as shown in Figure 2-6(a). Because the uncompensated system is symmetric in the complex plane about the imaginary axis, the phase shift is always 180 degrees. When G(s) is a lead network, the system becomes stable as shown in Figure 2-6(b). Theoretically, lead frequency and loop gain can be increased without bound for a high crossover frequency. In practice, however, higher frequency poles begin to introduce negative phase shift that limits crossover. 2.2.1 Position Feedback One problem with this simple approach is a result of measurement error. If there is an offset measurement in the angle – which is inevitable in a real system – the system will drive the pendulum to a nonzero angle. This angle can be maintained with a constant cart acceleration, but the cart will quickly leave the track. Feedback must therefore be used to control the cart position. The position of the cart is measured and added as an offset to the angle measurement, as shown in Figure 2-7(a). The sign is chosen to result in positive feedback around the motor. As the cart moves to the end of the track, the position command leans the pendulum towards the center, causing the cart to move in that direction. 24 101 10−1 6 180 L (degrees) |L(jω)| 100 10−2 10−3 −1 10 100 101 102 ω (rps) (a) Uncompensated system 10 1 −90 −135 6 10−1 L (degrees) |L(jω)| 100 10−2 −180 10−3 −1 10 100 101 ωc 102 ω (rps) (b) Compensated with lead network Figure 2-6: Bode plots of ideal single pendulum system. 25 kp + jω motor G(s) Km s2 x ≈ + + θ σ −s2 /g (τp s+1)(τp s−1) pendulum (a) Block diagram (b) Plot of open loop pole and zero locations Figure 2-7: Single pendulum system with position feedback. This simple approach to position feedback does not result in a stable system. In root locus terms, the position feedback moves the two motor poles from the origin into the right and left half planes. The resulting pole-zero plot is shown in Figure 2-7(b). Stability can best be determined through Nyquist plots, which must show two encirclements of the −1 point since the open-loop transfer function has two poles in the right half plane. The plots in 2-8(a) and (b) indicate that for stability the phase must be more negative than −180 degrees at the low-frequency crossover, so that the Nyquist curve crosses the negative real axis. One way to achieve this negative phase shift is with air damping. Damping moves one of the zeros in the pendulum transfer function off of the origin and into the left half plane [1]. Now, this zero contributes a negative 90 degree phase shift at DC. For a sufficiently large damping coefficient, the angle will remain below −180 degrees when the magnitude is one. Plots of a damped system are shown in Figures 2-8(c) and (d). If the air damping coefficient is insufficient, an electrical equivalent can be used. By placing a lag network around the lower crossover frequency, the phase shift can be brought more negative than −180 degrees. The lag network Glag (s) in the resulting block diagram shown in Figure 2-9 has transfer function Glag (s) = τs + 1 ατ s + 1 Figures 2-8(e) and (f) demonstrate this system to be stable. 26 101 −90 −135 −1 6 10−1 L (degrees) |L(jω)| 100 10−2 −180 10−3 −2 10 100 10−1 101 ω (rps) 102 103 104 (a) Bode plot of system with position feedback 101 −90 0 −135 |L(jω)| 10−1 −180 10−2 STABLE −1 6 10−3 L (degrees) 10 (b) This system is unstable since n 6= 2 −225 10−4 10−5 −3 10 10−2 10−1 100 101 ω (rps) 102 103 −270 104 (c) If some damping is present, the system is stable with position feedback 101 (d) The damped system is stable in the region indicated −135 10−1 −180 10−2 −225 STABLE −1 6 |L(jω)| 100 L (degrees) −90 10−3 −2 10 10−1 100 101 ω (rps) 102 −270 103 (e) A lag network has the same effect as damping (f) The compensated system is stable in the region indicated Figure 2-8: Bode and Nyquist plots of single pendulum system. 27 kp + motor Km s2 G(s) + x + τ s+1 ατ s+1 −s2 /g (τp s+1)(τp s−1) Glag (s) pendulum Figure 2-9: Block diagram of single pendulum system with position feedback system and lag compensator. 2.3 Dual Pendulum Control It is evident that the two pendulums controlled must have different effective lengths. If they are the same length, then any acceleration of the cart would affect their angles equally so the difference between their angles would be constant. The intuitive way to stabilize two pendulums of different lengths, then, is to “catch” the shorter one first, since it falls more quickly, and to try to do so in a way that brings the taller one closer to vertical. The strategy is to drive the cart such that the short pendulum’s angle is always, say, twice that of the slow pendulum, so that the next cart move will bring both of them to upright. This intuitive approach describes a minor loop configuration, where the fast pendulum is set up as in the single pendulum case to take an angle command, and is driven as a function of the slow pendulum’s angle. An initial block diagram is shown in Figure 2-10. The minor loop is identical to the single pendulum system without position feedback shown in Figure 2-5 and is compensated in the same way. If the minor loop crossover frequency and loop gain can be made sufficiently high, its closed loop transfer can be approximated as −(τf s + 1)(τf s − 1) X (s) = Θ s2 /g When Gs (s) = 1, the loop transmission of the major loop is therefore L(s) = s2 /g (τf s + 1)(τf s − 1) (τf s + 1)(τf s − 1) = 2 (τs s + 1)(τs s − 1) s /g (τs s + 1)(τs s − 1) (2.6) This transfer function is plotted in Figure 2-11(a). Between 1/τs and 1/τf , the magnitude drops off as −40dB/decade, but the phase is always equal to −180 degrees because the system is symmetrical in the complex plane about the imaginary axis. In order to stabilize this system, a lead compensator 28 motor Gs (s) X + Gf (s) + Θf Km s2 −s2 /g (τf s+1)(τf s−1) fast pendulum Θs −s2 /g (τs s+1)(τs s−1) slow pendulum Figure 2-10: Block diagram of the ideal dual pendulum system. is added with the form Gs (s) = τs s + 1 τf s + 1 (2.7) This approach is similar to the one taken to stabilize the single pendulum, only in this case the location of the compensator pole has an upper limit equal to the natural frequency of the fast pendulum. If the pole is placed at a higher frequency, the magnitude will begin to increase because of the two zeros from the fast pendulum transfer function, lowering the gain margin. A Bode plot of the lead-compensated system is shown in Figure 2-11(b). 29 100 −180 6 10−1 L (degrees) |L(jω)| −135 10 −225 −2 10−2 10−1 100 ω (rps) 101 102 (a) Uncompensated system 10 1 −135 L (degrees) 100 6 |L(jω)| −90 φM 10 −180 −1 10−2 10−1 100 ω (rps) ωc 101 102 (b) Compensated with lead network Figure 2-11: Bode plots of dual pendulum major loop transfer function. 30 2.3.1 Position Feedback As with the single pendulum system, angle measurement offset makes this ideal analysis insufficient. To keep the cart on the track, the cart position is measured and added as an offset to the angle measurement as shown in Figure 2-12(a). Note that for this system, there is no position feedback in the minor loop, as the major loop position feedback corrects for any offsets in the minor loop. As in the single pendulum case, the effect of the position feedback is to move the two poles from the minor loop transfer function off of the origin and into the left and right half planes. The resulting system can again be compensated using a lag network, as shown in Figure 2-12(b) and (c). Because the open-loop system has two poles in the right half plane, the Nyquist plot demonstrates stability when there are two negative encirclements of the −1 point. kp motor X Km s2 Gf (s) Gs (s) Θf −s2 /g (τf s+1)(τf s−1) fast pendulum τ s+1 ατ s+1 −s2 /g (τs s+1)(τs s−1) lag slow pendulum (a) Block diagram of dual pendulum system with position feedback and lag compensator 101 10−1 −180 10−2 −225 10−3 −270 6 −135 |L(jω)| 100 L (degrees) −90 STABLE −1 10−4 10−5 −3 10 10−2 10−1 100 101 ω (rps) 102 103 104 (b) Bode plot of compensated system (c) Nyquist plot demonstrating system stability Figure 2-12: The dual pendulum system is kept on the track with position feedback. A lag compensator is required for stability. 31 2.3.2 Maximum Phase Margin Equations 2.6 and 2.7 lead to a relationship between the length ratio of the two pendulums and the maximum attainable phase margin. Assuming the loop compensator is a lead network as above, the maximum phase margin is set by the natural frequencies of the pendulums. The simplified ideal loop transfer function is L(s) = (τf s + 1)(τf s − 1) (τs s + 1) τf s − 1 = (τs s + 1)(τs s − 1) (τf s + 1) τs s − 1 as plotted in the complex plane in Figure 2-13. The peak phase shift from this system occurs at the geometric mean of the two frequency el√ ements, i.e. at ωc = ωf ωs . The net phase shift is equal to the difference between the phase contributed by the zero (θz ) and that contributed by the pole (θp ). This difference is equal to the angle labeled φM in Figure 2-13 by geometric construction. The trigonometric law of sines states that in a triangle, the ratios of each angle to its opposite leg are equal. Writing this relationship results in the equation sin φM sin(180 − θz ) = p ωf − ωs ωs (ωs + ωf ) p √ ωf ωs / ωf (ωf + ωs ) p = ωs (ωs + ωf ) 1 = ωf + ωs ωf − ωs φM = arcsin ωf + ωs This equation can be rewritten with the substitution ω = 1/τ = p g/L to relate the phase margin to the length ratio of the pendulums. For the length ratio of 13.3 used in this implementation, the maximum ideal phase margin is φM = arcsin ! p Ls /Lf − 1 p = 34.7◦ Ls /Lf + 1 A real-world system will have higher order poles that will have additional negative phase contributions at crossover. It is therefore very important when implementing this system to minimize this phase shift. 32 jω q ωs (ωs + ωf ) q φM √ ωf (ωf + ωs ) ωf ωs θz θp ωs ωf − ωs σ Figure 2-13: Geometric derivation of maximum phase margin based on the ideal dual pendulum system. 33 THIS PAGE INTENTIONALLY LEFT BLANK 34 Chapter 3 Mechanical Design Although the nominal topics of this thesis are feedback control and circuit design, a large portion of the work involved mechanical design and construction. This section describes the construction of each piece. Initial mechanical design was performed with the SolidWorksTM CAD Software Package. R Center water jet in the Where practical, flat pieces were cut out using the OMAX JetMachining Hobby Shop at MIT. In critical areas near the permanent magnets and magnetic angle sensors, ferromagnetic materials were avoided. 3.1 Pendulum Construction Three pendulums were built for this thesis: a medium-length (nominally 1 meter) temporary pendulum for initial testing, a fast (nominally 10cm) pendulum, and a slow pendulum (nominally 2.6 meters). All of the pendulums are constructed from the same basic materials. The axles are turned out of PET rod and press fit into delrin ball bearings with glass balls. These materials were chosen because the axle houses the magnetic angle sensor, so steel could not be used. A PVC T pipe fitting attaches the pendulum to its axis. This T is bolted to the axle to prevent rotation. The pendulums are constructed out of clear PETG hollow tube which fits into the T joint. Since this is not an exact fit, the gap is filled with epoxy. Each of the pendulums is sketched in Figure 3-1. The temporary pendulum is meant to approximate an ideal pendulum consisting of a mass at the end of a massless rod. Thus a 3.2cm steel cylinder is attached inside the end of the relatively massless hollow tube. The pendulum is stiffened by epoxying pieces of 3/16” diameter PETG rod inside the hollow rod across its diameter. The fast pendulum is constructed in a similar way to the temporary pendulum, except the steel pendulum is attached at the bottom of the PETG tube. The tube is extended above the steel to give the pendulum greater visibility for e.g. a lecture demonstration. The slow pendulum is constructed using the technique introduced in Section 2.1.2 to 35 steel mass stiffening rods hollow PETG rod T joint bearings pillow block (a) Temporary pendulum, end view (b) Temporary pendulum, side view hollow PETG rod mp T joint steel pendulum pillow block bearings (c) Short pendulum, end view (d) Short pendulum, side view steel mass elbow joint elbow joint T joint block for angle measurement pillow block steel mass (f) Long pendulum, side view (e) Long pendulum, end view Figure 3-1: Mechanical drawings of pendulum construction. 36 avoid an unwieldy length. By adding a pendulum in the noninverted position, the natural frequency is increased. This counterweight is attached with an elbow joint as shown in Figure 3-1. For the slow pendulum, both the T and elbow joints are threaded so that the two pendulum parts can be removed by unscrewing. This allows the slow pendulum to be removed for a demonstration of the single pendulum compensation loop. 3.2 Angle Measurement The angle measurement is made using the Sentron 2SA-10 magnetic sensing IC as described in Section 4.1. For this measurement, a magnet was inserted into a bored-out space in the pendulum axle. A printed circuit board was manufactured for the 2SA-10 sensor, with spring pins in matching holes in the board and pillow blocks to hold the board in alignment. The layout is shown in Figure 3-2. The two larger holes at the center sides hold the spring pins, and the three smaller holes match with tapped holes for screws. The mechanical setup with the pendulum axle and pillow block is shown in Figure 3-3. Figure 3-2: Printed circuit board for the 2SA-10 angle sensor. The primary purpose of this board is alignment with the pendulum axle. Figure 3-3: Mechanical arrangement for angle sensing. The same assembly is used for all pendulums. 37 3.3 Cart Design The motor at the heart of this thesis is a QuickStickTM Linear Synchronous Motor (LSM) lent for this thesis by MagneMotion, Inc. The QuickStickTM is made up of a one meter long rectangular stator and an array of permanent magnets. When the stator windings are energized, the resulting magnetic field interacts with the permanent magnets on the rotor to produce thrust. The motor drive designed for this system is discussed in detail in Chapter 5. In order for this drive to be useful, the permanent magnet array must be affixed to a cart that can move freely along the length of the motor. The pendulum cart designed for this thesis is a wheeled, U-shaped cart that fits loosely over the stator. This design was chosen to avoid constructing an alternative rail-type system because of the perceived difficulty of constructing a sufficiently straight track parallel to the motor. The U-shape is maintained by brackets that hold the aluminum sides and cart base together. The magnet array is sandwiched below the base of the cart with a piece of 1/8” delrin which in addition to a 1/16” clearance between the delrin and stator sets the motor gap. Mounting holes in the cart sides hold four rubber wheels and four inward-facing ball casters. Because of the spacing between the casters and stator, the casters do not typically touch the stator, so the typical frictional force is reduced. This design is based on the idea that a restorative force will keep the magnets aligned with the stator. In practice, however, the cart will sometimes drift to the side and the casters will come in contact with the stator. Figures 3-4 and 3-5 show mechanical drawings and photographs of the design. The pendulum cart base is a 5.75 inch by 10 inch solid piece of aluminum which serves as a mounting point for the various hardware on the cart. In addition to the two pendulums’ pillow blocks described above, the pendulum cart carries all of the circuits described in this document with the exception of the voltage-controlled oscillator and the power electronics for the motor drive. As a result, the single connection between the pendulum cart and the other circuitry is a RG-174 coax cable carrying the velocity command signal. Four nine-Volt batteries are mounted on the cart to power the control system. The nominal ±18V is regulated down to ±12V and +5V with LM7812, LM7912, and LM7805 linear regulators. The cart base is electrically grounded to provide some amount of shielding between the cart circuitry and the magnetic field from the stator windings. 38 Figure 3-4: Mechanical drawings of the pendulum cart. 39 Figure 3-5: Photographs of the pendulum cart. 40 Chapter 4 Angle and Position Sensing For an ideal system, only the angle of the pendulum(s) must be known to close a control loop. By measuring the angle with respect to vertical, a loop can be designed to drive the pendulum upright. Due to the inherent offsets in real-world angle measurements, however, the pendulum will not be precisely balanced when the angle measurement reads zero. To maintain this non-zero pendulum angle, the cart must move with some constant acceleration to offset the force of gravity. Without a position control loop, the cart will run off the end of the track. The position of the cart must therefore be measured in addition to pendulum angle so that two feedback loops can be used. This chapter describes how these two measurements are made. 4.1 Angle Sensing Both the fast and slow pendulum have an identical arrangement for measuring angle displacement. The angle is measured with Sentron’s 2SA-10 two axis magnetic sensing IC [9]. The 2SA-10 uses four sets of Hall Effect sensors to measure x- and y-components of the magnetic field parallel to its surface. When paired with a magnet polarized across its diameter, it can detect absolute angular position. The main advantage of the 2SA-10 is that it is a contactless measurement. Delrin bearings with glass balls are used so as not to disrupt the measurement magnetic field (see Chapter 3 for mechanical details). Interfering fields from the permanent magnet array and stator windings of the motor are shielded by a steel plate built into the back of the magnet array. The outputs of the 2SA-10 are X_Out, the x-component of the measured magnetic field; Y_Out, the y-component; and CO_Out, the reference voltage corresponding to zero magnetic field. The magnet is placed close to the sensor so that the full-scale field exceeds the 45mT range of the 2SA10 and the device saturates at peaks in the field. With the magnet oriented so that either the X or Y field is close to zero when the pendulum is vertical, the signal is increased in the range of angles 41 +5V R1 R2 +5V 100nF 2SA-10 R2 Cos(θ) Ref Sin(θ) AD524 (x34) angle R1 Figure 4-1: A single output of the 2SA-10 is used. By comparing it to the common output and amplifying the signal, an angle signal is generated that is centered at zero and is full scale when the angle corresponds to the maximum angle that can be stabilized. where the pendulum can be stabilized, and does not saturate until the pendulum is at least 30◦ off vertical. The 2SA-10 has a typical bandwidth of 0-15kHz so it does not contribute appreciable phase shift at the frequencies relevant to this system. As shown in Figure 4-1, the output of the 2SA-10 is amplified using a precision instrumentation amplifier configured to have a gain of 34. Since the 2SA-10 is operated from a single supply, the output must be offset by CO_Out to shift the signals so that a zero angle corresponds to zero Volts. The reference CO_Out is typically at 2.5V when the 2SA-10 is operated from a single 5V supply. Since it is difficult to align the magnet perfectly within the pendulum axle, potentiometers are used to trim the reference voltage so that the output of the amplifier is as close to zero as possible when the pendulum is vertical. Any further offset in the angle measurement is taken care of by the position feedback in the control system. The gain of the angle measurement was measured to be 1.6V/degree = 91V/radian. 42 4.2 Position Sensing Two methods of measuring linear position were explored for this thesis. First, a digital approach using a microcontroller was attempted, then an analog approach of integrating the velocity signal. 4.2.1 A Digital Approach The MagneMotion QuickStickTM has built-in Hall Effect sensor pairs that measure the magnetic field from the magnet array at eight points along the motor. The outputs from the Hall Effect sensors do not include the field from the stator windings (signal is only present when the magnet array is above the Hall Effect sensors), so the motor drive does not affect these signals. Figure 4-2 shows how the motor can be broken up into eight segments based on when each Hall Effect sensor pair is active. Note that this is a simplistic view as there is in fact overlap between neighboring pairs due to the length of the magnet array used. d b D C c f B A a E F e h G H g HES sensors motor HES sensors Figure 4-2: The motor can be arranged in eight sections based on which Hall Effect sensors are active. Lowercase letters indicate the range over which each Hall Effect pair has a non-zero output. Each of the lower case letters in Figure 4-2 represents the range over which a pair of Hall Effect sensors has a non-zero output. As the cart moves over a sensor pair, the two sensors output signals in quadrature as shown in Figure 4-3. By comparing these two outputs, a signal is generated that switches as the magnet array moves across it, and is constant when the magnet array is absent. Hysteresis prevents the comparator from switching when the sensor outputs are nominally equal. The switching signals are then used as the input to a state machine, with rising or falling edges triggering events. The state machine shown in Figure 4-4 sets the position output to one of eight values depending on which of the eight sections the cart is over. It assumes the cart begins in the center of the track, i.e. in the state A/E with a corresponding position output of zero. If the cart moves to the left, the active Hall Effect sensors are first only pair a, then pairs a and b. When b becomes active, the state machine transitions to state B and the position output is stepped up to a nonzero value. As the cart continues to the left, there will be a rising or falling edge from sensor pair c that triggers the machine to switch to state C. When in this state, as long as only b or c has rising or falling edges the state remains the same and the position output is set to a constant value. If the cart returns to 43 motor region B C A cart over pair b pair b sensor outputs cart over pair a pair a sensor outputs comparator b output event b comparator a output event a Figure 4-3: As the cart moves over the sensor pairs they output quadrature signals corresponding to the magnetic field from the permanent magnet array. Comparing the two outputs gives a switching signal which is used as an input to a state machine. the right, sensor pair a will switch and the state will be set to B. Finally, if the cart returns to the center the state does not switch back to A/E until the e pair is active. A PIC16F628A is used to implement this state machine. The output of the PIC is a three-bit indicator corresponding to the state of the state machine. The two least significant bits control a 4:1 analog switch which passes through the voltage levels corresponding to the different distances from the center. The MSB controls the sign of the output using a gain block with ±1 gain described in detail in Section 5.2.2. This circuit is shown in Figure 4-5. As the cart moves within one of the eight sections of the track, the position offset value will c b b D a C d d a e B c c f A/E b b e a F G e f H f g Figure 4-4: State machine diagram for rough position measurement. 44 g h g a e f h R R v1 v2 v3 v4 − R1 bit1 bit0 + vpos C1 R bit2 Figure 4-5: The PIC outputs control which of four voltages are passed through as the position offset, as well as the offset sign. remain constant even though the position is changing by up to 1/8 meter. This means that the effective voltage/position gain will vary. That is, the gain will have a step increase when the state machine changes state, then it will linearly decrease until the next transition. These changes in gain are acceptable for use in a feedback loop so long as the system is stable for both extremes. There is, however, a potential problem because the position measurement is added as an offset to the angle measurement. The steps in the position signal are interpreted as a step in pendulum angle by the system, which is not necessarily equipped to handle such an input. Therefore for the single long pendulum a low-pass filter is added at the output of this position measurement to smooth over the transitions. Although this is sufficient for the single long pendulum case, for the short pendulum and for the dual pendulum system it is necessary to reduce the size of the position signal steps by using a more accurate position measurement. This system is described in the next section. 4.2.2 An Analog Approach A position measurement can instead be derived by analog integration of the velocity command. This approach relies on two assumptions: first, that the velocity command is followed accurately by the cart, and second, that offsets do not cause the integration to drift over time. The first assumption is satisfied by the motor control loop described in Chapter 6. The integrator drift problem is avoided by resetting the position measurement to zero when the cart crosses the center of the track. Finally, the integrator is designed with a sufficiently low constant of integration such that the integrator will not saturate over the full length of the track. The reset command works by shorting across the integrating capacitor with an analog switch (AD7510). A center crossing is detected when a brush on the cart contacts a piece of copper foil on the floor of the track near the center. The copper foil is placed close to the stator so that the wheels do not run over it. When not in contact with the foil, this signal is held at ground with a pull-down resistor as shown in Figure 4-6. A Schottkey diode clamp and series resistance provide input protection from voltage spikes due to poor commutation. The AD7510 outputs are protected 45 +15V 1/4 AD7510 470Ω +5V 13kΩ 330Ω 2µF velocity − 100kΩ LF356 position + Figure 4-6: Schematic of the analog position measurement, including a zeroing circuit activated when the cart crosses the center of the track. with a series resistor to prevent excessive currents. This circuit was built and measured to have an output scale factor of 18.4V/meter. 46 Chapter 5 Motor Drive position feedback Gs (s) Gf (s) VCO motor/ ẍ cart motor drive 1/s2 x Ga (s) θf fast pendulum θs Glag (s) slow pendulum The QuickStickTM LSM used for this thesis is a three-phase synchronous linear motor with a permanent magnet rotor. Although MagneMotion also provided an associated control system and drive, for educational purposes a complete motor drive was designed and built. The motor drive described in this chapter takes a velocity command and converts it into a three-phase drive to appropriately move the rotor. The three-phase signals are generated by a VCO. Then a switching power amplifier for each phase drives the motor windings to move the pendulum cart. 5.1 Speed/Direction The velocity command input must be converted to speed and direction signals before going to the VCO for reasons described in the next section. The precision rectifier circuit used, a variation of one found in [10], is shown in Figure 5-1. The output of the circuit is vO = −vI − 2vA , where vA = 0 when the input is negative, and vA = −vI when the input is positive. For negative inputs, the transistor conducts, which both pulls vA to zero and provides the direction signal through R2 . It is also necessary to include a series diode because the reverse breakdown of the transistor is lower than the maximum signal swing. 47 +5V R2 direction R − + R vi R/2 R vA − + vo R Figure 5-1: This absolute value circuit converts a velocity command into speed and direction components. 5.2 VCO The speed and direction signals drive the quadrature voltage controlled oscillator (VCO) shown in Figure 5-2. The VCO generates two sinusoids of varying frequency that are 90 degrees out of phase. These signals, combined in the correct proportions, produce three sinusoids that are 120 degrees out of phase, which are then used to command the motor drive. The VCO in basic form is a pair of integrators with one inversion. By scaling the inputs to the two integrators by the same factor, the natural frequency can be changed to create an output frequency proportional to input voltage. The actual VCO is somewhat more complicated than this. Figure 5-4 shows a series of block diagrams breaking down the system into its various parts, which are described in detail in the following sections. 5.2.1 Amplitude Stabilization In the ideal case the two-integrator system would have a root locus with two poles starting at the origin and going up and down the imaginary axis. As long as there is no real component to the poles, the oscillations will not grow or shrink in magnitude. In practice, however, nonidealities such as capacitor ESR will place the poles off the origin in the left or right half plane. To ensure that the poles will act in a predictable way, then, a minor loop around one of the integrators is used to move one of the poles onto the real axis in the right half plane. The minor loop is shown in Figure 5-4(b). As shown in Figure 5-3, for positive loop gain the complex pole pair will be in the right half plane, so the oscillations will grow with each cycle. A limiting circuit is then used to clamp the magnitude of oscillations to a particular maximum value. As long as this value is not small relative to the growth in magnitude per cycle, the clamp will not introduce significant distortion. 48 +15 R2 R2 R1 R4 R5 R5 + R2 speed R2 − LM156 R2 R4 C1 speed − -15 − LM156 + LM156 + 1/4 AD7510 vo1 KR1 C1 R2 − vo2 R1 R2 − LM156 + LM156 + R2 1/4 AD7510 Figure 5-2: Schematic of voltage control oscillator with amplitude stabilization and direction control. jω jω σ σ (a) Positive feedback around one inte- (b) The VCO root locus now has comgrator moves its pole into the right plex poles in the right half plane. half plane. Figure 5-3: Root locus of (a) minor loop and (b) VCO. The minor loop sets a fixed rate of growth for the oscillations, which are then clipped at a fixed maximum value. 49 The minor loop has the closed-loop transfer function A H1 (s) = A KR1 C1 s 1− = AKR1 C1 s KR1 C1 s − A where A is the gain factor from the multiplier (determined by speed input voltage) and K is the amount of positive feedback. This gives a loop transfer function for the whole system of L(s) = A 1 R1 R2 C1 C2 s2 L(s) = AKR1 C1 s KR1 C1 s − A = A2 K R2 C2 s(KR1 C1 s − A) AK R2 C2 s KR1 C1 s A −1 There is one pole at the origin and one at A/KR1 C1 . The closed loop transfer function is H(s) = 1 AK RCs( KRC A s−1) AK + RCs( KRC A s−1) H(s) = = s2 − AK = − 1) + AK RCs( KRC A s A2 R2 C 2 A2 A RCK s + R2 C 2 = The natural frequency of the complex pole pair is ωn = KR2 C 2 2 s A AK − RCs + AK ω2 s2 + 2ζωn s + ωn2 A RC and the damping ratio is ζ = −1 2K . This means that the growth in oscillation per half-cycle is constant regardless of input voltage. eζπ = eπ/2K For a growth of 7.6% per cycle, ζ = 0.025, or K = 20. In theory, as the multiplier input A goes to zero the system should behave linearly. However, there is potential for some nonlinearity in the multipliers to bring the pole back out of the right half plane, resulting in a lower limit in output frequency. It is unclear whether this is in fact the limiting factor or if other factors in the circuit such as offsets, discussed below, set the lower frequency. One solution is to add a small amount of A-independent positive feedback in the minor loop so that positive feedback is always guaranteed. NB: It is this minor loop that requires the velocity command from the compensator to be broken up into speed and direction. For a negative A, the sign of the minor loop’s loop transmission would be inverted. 5.2.2 Direction Control By switching direction within the VCO itself, the sinusoidal signal can be “unwound,” a process that allows direction changes to occur without any discontinuities in the motor drive. If the VCO can be 50 vo1 speed speed speed + −1 R1 C1 s R −1 + dt −1 KR1 C1 s − dt R −1 R3 C2 s speed vo2 (a) Most basic block diagram. The outputs are taken after the integrators. (b) Block diagram with minor loop feedback. vo1 −1 R1 C1 s ±1 −1 R1 C1 s ±1 vo2 (c) Direction switching vo1 speed speed −1 R1 C1 s ±1 + −1 + −1 KR1 C1 s −1 R3 C2 s ±1 vo2 (d) Complete block diagram Figure 5-4: Block diagram for VCO, shown at various levels of complexity. The minor loop can generally be excluded from other analyses because it serves to approximate an ideal system. 51 R R vi − vo + R 1/4 AD7510 Figure 5-5: This circuit has either a gain of +1 or -1 depending on the switch state. thought of as producing the sine and cosine signals corresponding to travel around the unit circle, then the direction switching process simply corresponds to changing the direction of this travel. This can be done by reversing the sign of both integrators. The integrating capacitors hold their state, so that there is no discontinuity, while the sign reversal undoes the previous integration. By placing both ±1 gain blocks outside of the minor loop, the minor loop positive feedback can be maintained. The ±1 circuit block is shown in Figure 5-5. When the switch is open, the voltages at the inverting and noninverting inputs to the amplifier are the same and are equal to vi since there is no current into the noninverting terminal node. Thus there must be no current through any of the resistors and vo = vi . Conversely if the switch is closed, the noninverting terminal is held at ground and the circuit acts as a standard inverting configuration. The two ±1 circuits are driven by the direction output of the absolute value circuit in Figure 5-1. 5.2.3 Offset correction Offsets at the inputs to the op amps and multipliers can cause the VCO signals to saturate and thus limit the lower range in frequency. For any offset ∆V to exist at the input to the integrating op amp, there must be a corresponding offset at the input to the multiplier of ∆V /A. When the multiplication factor A is very small (corresponding to a low frequency of oscillation) this is clearly a problem because the multiplier input offset will be excessive. Thus the velocity command A has a lower limit below which the VCO will not oscillate. This situation can be improved by trimming the offsets in the circuit. The AD524 multiplier includes an offset adjustment pin, so that the output is equal to (X1 − X2 )(Y1 − Y2 )/10 + Zos . As shown in Figure 5-6, a potentiometer was used to help trim out the offsets associated with each multiplier/op amp pair. Input current to the op amps can also affect offsets when it is comparable to the currents charging the integrating capacitors. At low frequencies, the change in voltage across the capacitor is slow, so the charging current is correspondingly small. If the op amp input current is high, it will “steal” current from the nominal charging current. FET-input op amps are used to minimize this effect. 52 +15V in Vs VCO loop X1 + X2 − R R Y1 + − X2 − + AD532 R Z output Vos 10R trim R1 R2 R1 (X1 −X2 )(Y1 −Y2 ) 10V −Vs -15V Figure 5-6: Detailed version of the circuits represented as multipliers in Figure 5-2. 53 5.2.4 Results The circuit was built and tested with the integrator component values R = 31.6kΩ and C = 1µF. With this configuration, the maximum frequency (corresponding to an input voltage of 12V) is 5.4Hz. The minimum frequency after trimming is 170mHz when the input voltage is 0.4V. For lower input voltages the circuit does not oscillate. The transition between oscillating and not oscillating is not continuous – the sine and cosine outputs jump to the saturated value. This discontinuity will cause the cart to move suddenly. Furthermore, if the loop is operating properly the input to the VCO will be close to zero, so this condition is unavoidable. The input command voltage was therefore clamped such that the input cannot drop below this voltage. As a result, the cart is never stationary, a constraint that does not severely handicap the system. 5.2.5 Three Phase Generation The sine and cosine generated by the VCO are combined to generate three sinusoids separated in phase by 120 degrees. The three vectors are: A = − cos θ √ 1 3 sin θ + cos θ B=− 2 2 √ 1 3 C= sin θ + cos θ 2 2 The required vectors are generated by three opamp circuits, shown in Figure 5-7. R1 R1 cos θ − + A R3 R3 A √ 3R2 − B √ 3/2R2 R3 A + C − sin θ R2 + B Figure 5-7: These op amp circuits compute weighted sums of sine and cosine to create three signals separated by 120◦. 54 5.3 Power Electronics The three phase signals are used to control the power electronics that drive the motor. Originally, a linear amplifier topology was attempted. However, the dissipation in the output transistors was too great to reasonably drive the motor. The relatively low efficiency is especially troublesome because of the high power levels involved. In order to prevent the transistors from overheating, large heat sinks and fans are necessary. In order to improve efficiency, then, a switching drive was used. The design is based on a method described in [10] and first developed by Bose in 1963 [11]. 5.3.1 Switching Drive A single phase of the switching drive is shown in Figure 5-8. This circuit uses a hysteretic control scheme along with delay circuits that prevent shoot-through. The LM311 comparator, configured as a Schmitt trigger with positive feedback, makes up the control loop. Assuming the output of the comparator is high, and that the command input for now is zero, then the output voltage is +24V, and the 0.047µF capacitor is charging. The load behaves as a low-pass filter due to its inductance and series resistance. If the driver switching speed is assumed to be much faster than the corner frequency of the load, the charging can be taken to be roughly linear as shown in Figure 5-9. When the capacitor voltage reaches the upper limit of the hysteresis band, the comparator will switch to a low voltage. Now the output of the switching amplifier is -24V, and the capacitor therefore discharges until it reaches the lower limit of the hysteresis band. When the command is nonzero, it provides an additional charging current to the capacitor. In the extreme case, i.e. when the output is driven to the maximum voltage, the capacitor charges at twice the nominal rate and discharges at a nominally null rate. Since the maximum rate of charge is only twice the nominal rate, the minimum pulse width of the gate drive is limited to half of nominal. The frequency of the drive adjusts to match the average output voltage to the command. The pulse width limit reduces problems with short pulses on the gate drive (incomplete switching, high switching losses) that can occur in a system where the switching frequency is fixed. Since the switching drive is for an inherently slow mechanical system, the reduction in switching frequency is not problematic. Figure 5-9 shows a sketch of the response of the hysteretic control for a step change in command voltage. An advantage of this scheme is that the output voltage is always corrected to match the command within a single switching cycle. The choice of 100kΩ and 0.069µF gives this circuit a maximum switching frequency of 40kHz when the supplies are ±24V, which is well above the tens of Hertz frequencies in the rest of the pendulum control loop. Thus the phase shift from this drive will be ignored in stability analysis. 55 +V 0.1µF 1.1kΩ IRF5210 TC4427 0.1µF +15V MUR120 STPS20L15 +15V +5V 470Ω 5kΩ 74HC14 SAT command +5V R 1kΩ − LM311 0.047µF + 88.7kΩ 100kΩ Vc 887Ω A SIGNAL GND B 470Ω 5kΩ SAT C 2N2905 -15V 0.1µF -15V STPS20L15 IRFI1310 TC4427 MUR120 0.1µF 1.1kΩ -V +15V 0.1µF LM7805 0.1µF +5V 22µF 15V Figure 5-8: Switching motor drive, one phase. 56 command VC LM311 output Figure 5-9: Waveforms demonstrating the hysteretic control. 5.3.2 Power Supplies for Switching Drive Coming up with a reasonably priced power supply capable of supplying the necessary currents is not trivial. The final design, shown in Figure 5-11, uses four 12V, 7AH lead-acid batteries which are charged with two 30V wall transformers. Fuses protect the circuitry in case of a short. It is not recommended to run the motor while the transformers are plugged in as the current draw is too high and the transformers can fail. The ideal operation is to keep the transformers on a timer and charge the batteries for a few hours each night and between uses as necessary. The lead-acid batteries were tested to determine maximum run time of the system. Using a CBAII battery tester from West Mountain Radio, the battery was discharged at a constant rate of 2.5A until the terminal voltage reached 10V. This discharge rate was chosen based on the roughly constant 2A current meter reading when a variable power supply was used to power the system. The results of this test are plotted in Figure 5-10. As the data shows, the system can be run for about 2.4 hours at a current of 2.5A before the voltage begins to rapidly drop off. This is close to the nominal value of 7AH. A discrepancy is not unexpected as the amount of energy that can be extracted from a battery depends on the rate of discharge [12]. Although this section refers to the supplies as ±24V, therefore, this is only a nominal voltage that depends on the battery state-ofcharge. Since this system is primarily intended to be a lecture demonstration for a feedback course, this run time is sufficient. The ±15V supplies are generated using zener diodes. This design was introduced after initial tests using two separate supplies for ±24 and ±15. It was found that when the supplies where not applied at exactly the same time, the momentarily high voltage across the TC4427’s would damage them. Interestingly, another issue with using two sets of power supplies is that many supplies (for instance, non-synchronous switching supplies or linear regulators) are only equipped to source current from the positive terminal, not sink it. Because the TC4427 MOSFET drivers are powered between the +24V and +15V rails, the output current (at peak 1.5A) from these parts is supplied from the +24V rail into the +15V supply. This current brings up the +15V voltage. The low side 57 Figure 5-10: Terminal voltage of a single battery with constant 2.5A discharge current. The spike in data at around 4.25AH is due to stopping and restarting the test. drivers have the same problem, as the -15V rail must supply current to the -24V rail. One remedy for this problem is to continuously draw a few hundred milliamperes from the ±15V power supplies. This biases the supplies so that the source currents never go negative. A preferred solution is to use 5W zener diodes to generate the ±15V supplies, as they can handle currents in this direction without significant change in voltage. As shown in Figure 5-11, the zener diodes are kept at the required bias current with 5W, 100Ω resistors. Although zeners are not a particularly low-noise or (in this simple configuration) solid voltage source, they are practical for this circuit. Power Circuit Fabrication A printed circuit board was designed and fabricated for the switching drive. Each phase is built on a separate PCB to simplify replacement if a phase fails. Since size is not an issue in this application, critical signal paths and components on the board are spaced apart to avoid coupling. To keep the boards independent, each one has a separate set of zener diodes to generate the ±15V supplies. These are located between the high power, switching parts and the logic-level circuits. Separate high and low power ground planes are also used, with a single connection where the ground connector meets the board. Smaller copper planes are also used for the high-current traces. The board layout and a photograph of a populated board are shown in Figure 5-12. In this diagram, the ground and power planes are represented as outlines only. 58 Figure 5-11: Power supplies for motor drive. 59 120VAC 120VAC wall transformer, 30VDC/500mA wall transformer, 30VDC/500mA 20A 12V 12V 20A 20A 12V 20A 12V 0.1µF 0.1µF 22µF 35V 15V 5W 100Ω 5W 22µF, 35V 0.1µF PWR GND 35V 22µF 100Ω 5W 15V 5W SIGNAL GND single connection between grounds 0.1µF 22µF, 35V -24V -15V +15V +24V (a) PCB layout (b) Constructed PCB Figure 5-12: Each phase of the motor drive is built up on a printed circuit board. 60 Chapter 6 Motor Control position feedback Gs (s) Gf (s) VCO motor/ ẍ cart motor drive 1/s2 x Ga (s) θf fast pendulum θs Glag (s) slow pendulum The primary difficulty in stabilizing even a single pendulum when no feedback is used around the motor is that there is significant cogging in the mechanical system. Feedback can be used to reduce this effect. This chapter describes the acceleration loop that was implemented to control the motor. 6.1 Acceleration Measurement The signal of interest in this system is acceleration since it directly relates to the angle of the pendulum, so an acceleration loop is natural. This loop is particularly promising since acceleration is straightforward to measure. The ADXL213 accelerometer used is well-suited to this application √ as it has a relatively low full-scale range of ±1.2g and a typical noise floor of 160µg/ Hz [13]. This part has a PWM output for use with microcontrollers; fortunately it also provides analog outputs at the X_filt and Y_filt pins. A 100nF capacitor on the X_filt pin provides filtering at 1/(2π × 32k × 100nF) = 50Hz. The ADXL213 is not intended to be used with the X_filt pin as the output, thus the datasheet does not give a value for the scale factor [Volts]/[g]. This scale factor was measured by comparing 61 the output voltage of the accelerometer when held flat (0g) to the output when vertical (1g). When flat, X_filt is at 2.62V, and when vertical it is at 3.44V, for a gain of 820mV/g. This scale factor is not known very precisely since “flat” and “vertical” are determined as best as possible by holding the board to a standard level. The printed circuit board built for the accelerometer is shown in Figure 6-1. Because the intent is not to use the PWM output pins, jumpers are included between these pins and the header connectors. This prevents high-frequency signals from being routed around the board if unnecessary. Likewise, a jumper was used to allow the part to enter self-test mode, where the chip output corresponds to some known value. (a) PCB layout (b) Constructed PCB Figure 6-1: A printed circuit board was built for the accelerometer. 6.2 Characterizing the Plant An HP 3562A Dynamic Analyzer was used to characterize the plant of the acceleration loop, which consists of the VCO, motor drive, and motor. The HP 3562A is a dual-channel, fast-Fourier transform based analyzer with frequency capability from DC to 100kHz. By using the dynamic analyzer to produce Bode plots of the plant, loop compensators could be designed without having to know and model the exact sources of the plant dynamics. The plant is measured by placing the A probe at the input to the VCO and the B probe at the output of the accelerometer as shown in Figure 6-2. For this measurement, the motor is driven openloop. In this configuration the system behaves as a differentiator, so there is no difficulty keeping the cart on the track, thus no position feedback is necessary. In fact, the dynamic analyzer used has such a balanced output signal that the cart does not drift on the track during the duration of the measurement. The system is measured on the dynamic analyzer as shown in Figure 6-3. For this measurement a gain of 2 is inserted before the VCO to give a full-scale input when combined with the 5V maximum signal out of the dynamic analyzer. Results are shown in Figure 6-3. Since the dynamic analyzer cannot be left in the paused state for too long (or it seems to assume the measurement 62 is completed), the measurement had to be made in sections. The time between measurements was also used to recharge the batteries powering the system. The low-frequency behavior of the plant looks like a differentiator as expected. As frequency increases, the phase begins to drop off because of higher order poles in the mechanical system. At around 80Hz, for instance, there is clearly a resonance. The phase shift of the plant crosses −180 degrees at around 40Hz. 6.3 Loop Compensation Once the plant is well known it is straightforward to compensate the acceleration loop. A crossover frequency of at least 15Hz is desirable so that the closed-loop system behaves as a double integration for frequencies at more than a decade above the short pendulum’s natural frequency. Evidently, a higher crossover frequency is preferred, both for the effect on the loop this block will be a part of and for increased low-frequency gain in the acceleration loop for disturbance rejection. In order to close the loop, the sign of the feedback must be determined. This depends on many factors, such as the order of the motor windings and the physical orientation of the accelerometer. Thus it was necessary to experimentally determine the sign of the feedback. Since the command signal and acceleration measurement are added at the summing junction, for negative feedback they should have opposite signs. This can be tested by first driving the system open-loop with a constant, positive voltage and observing that the cart accelerates to the right under that condition. Then the signal is removed and the cart manually accelerated to the right. For negative feedback, the acceleration signal must go negative. The loop is compensated with an integrator for high low-frequency gain, followed by a zero a factor of 4 in frequency below crossover. An additional lead network around crossover ensures plenty A source + loop opened VCO plant 2 Ks Km τm s+1 ka s 2 τa +1 accelerometer B Figure 6-2: Measurement configuration for results shown in Figure 6-3. 63 (a) Dynamic Analyzer measurement, 300mHz-9Hz, 50 averages, 5V source (b) Dynamic Analyzer measurement, 7Hz-12Hz, 50 averages, 5V source Figure 6-3: Measurements of the acceleration loop plant. 64 (c) Dynamic Analyzer measurement, 10Hz-17.8Hz, 20 averages, 2V source (d) Dynamic Analyzer measurement, 14Hz-20Hz, 20 averages, 2V source Figure 6-3: Measurements of the acceleration loop plant. 65 (e) Dynamic Analyzer measurement, 16Hz-40Hz, 20 averages, 5V source (f) Dynamic Analyzer measurement, 38Hz-80Hz, 20 averages, 5V source Figure 6-3: Measurements of the acceleration loop plant. 66 of phase margin. At crossover, the net phase shift from the integrator plus zero is φ=6 4 ωc jωc +1 jωc ! = tan−1 (4) − π = −14◦ 2 and the phase from the lead is φ=6 √ ! 10 ωc jωc + 1 √ 1 jωc + 1 10ωc = 72.5◦ − 17.5◦ = 55◦ so the net phase shift from the compensator is 41 degrees. The schematic of this acceleration loop is shown in Figure 6-4. A Sallen Key filter is inserted in the feedback path to filter out the coupling in the accelerometer output due to the coils switching at 20kHz immediately below the sensor. As derived in [10], when the resistors are chosen to be equal the transfer function of this filter is 1 Vo (s) = 2 2 Vi (s) s /ωn + 2ζs/ωn + 1 where 1 ωn = √ R C1 C2 and ζ = r C1 C2 In this case, ωn is chosen to be around 1kHz and ζ to be roughly 0.707. With component values R = 4.99kΩ, C1 = 0.022µF, and C2 = 0.047µF, ωn = 991Hz and ζ = 0.68. The exact component values are not critical, as some variation in cutoff frequency or even peaking around 1kHz will not significantly affect the system operation. This allows the use of generic ceramic capacitors, which may have tolerances of up to ±20%. This filter reduces problems associated with putting a high frequency signal into a lead network, as well as simply making the signals easier to observe. Since the cutoff frequency is approximately a factor of 30 above the loop crossover frequency, its phase contribution can be ignored. The compensator transfer function, excluding the Sallen Key filter, is 1 (R3 C2 s + 1)((R1 + R2 )C1 s + 1) vo = vi R1 C2 s(R2 C1 s + 1) A first attempt was made with this compensator to cross over at 20Hz in order to confirm that the system works as predicted. The component values for this compensator are shown in Table 6.1(a). This system was built and tested. It shows considerable improvement over the open loop system. Most notably, the visible cogging from the motor is no longer detectable. With the compensator design confirmed, a more ambitious control loop was attempted. Since the compensator gives a 41◦ phase bump at the crossover frequency, for a 45◦ phase margin crossover should be chosen at the frequency at which the plant has just under 180◦ negative phase shift. According to the measurements in Figure 6-3, this occurs around 38Hz. Component values are 67 +5V DEMOD ADXL213 32k 32k Y-filt PWM X Filt 100nF 68 100k AD524 (×50) command offset adjust + − 5.11k 22nF 100k 5.11k R2 47nF C1 R1 − + 100k Figure 6-4: Acceleration loop compensator schematic. + − C2 R3 to VCO chosen for the compensator as follows. The first zero should be around 1/R3 C2 = ωc /4 = 59.8rps. Capacitor C2 also sets the gain 1/R1 C2 of the system, which needs to be about 20.8dB based on the dynamic analyzer measurements and the frequency response of the compensator. The value C2 = 194nF (nominally 0.22µF) was chosen from the available components. Then R3 must be 86kΩ, but due to limited availability of resistor values 91kΩ was used instead as the closest value above nominal. Resistor R1 is set by the gain requirement to be 21.6kΩ. For a pole/zero separation of α = 10 centered about the crossover frequency, this choice dictates that C1 = 465nF and R2 = 2.7kΩ. The resulting compensator transfer function is plotted in Figure 6-5 and summarized in Table 6.1(b). This system was built and tested, showing improvement over the open loop system as with the 20Hz loop. Furthermore, the output of the accelerometer, which looks entirely non-sinusoidal in the open loop system with a sinusoid input at low frequencies, has a much improved characteristic. Scope traces are shown in Figure 6-6. For Figure 6-6(a), the loop is broken after the Sallen Key filter. The circuit is driven with a sine wave at the input to the summing junction and the output is taken at the output of the AD524. A 1Hz signal in response to the command is just barely discernible. Figure 6-6(b) an identical input signal is applied to the system with the loop closed. For both cases, the cart can be observed to move back and forth, but the motion with the loop closed is significantly smoother. Table 6.1: Component and frequency values for acceleration loop compensator shown in Figure 6-4. (a) (b) R1 R2 R3 C1 C2 31kΩ 25.4kΩ 3.6kΩ 2.7kΩ 32.4kΩ 91kΩ 680nF (measured) 465nF 1µF (measured) 194nF ωz1 ωz2 ωp ωc 4.9Hz 6.8Hz 65.0Hz 20Hz 9.0Hz 11.9Hz 126.8Hz 38Hz 69 103 90 45 |L(jω)| 102 0 101 ωc 100 0 10 10 1 2 10 ω (rps) 6 L −45 10 −90 3 10 4 (a) Compensator without filter 10 3 90 45 101 0 100 −45 10−1 −90 10−2 −135 |L(jω)| 102 10−3 0 10 6 L −180 101 102 ωc 103 ω (rps) 104 105 106 (b) Compensator including filter Figure 6-5: Bode plot of the acceleration loop compensator, with and without the Sallen Key filter. The Sallen Key filter is at a sufficiently high frequency such that it does not affect the system phase margin. 70 (a) Open Loop System (b) Closed Loop System Figure 6-6: Accelerometer output for the open loop and closed loop systems with a 1Hz sinusoidal input. The closed loop system is considerably improved. 71 A source + Ga VCO plant (R3 C2 s)((R1 +R2 )C1 s+1) 1 R1 C2 s (R2 C1 s+1) K s Km τm s+1 position ka s 2 τa +1 accelerometer B Figure 6-7: Final configuration for the acceleration loop, showing the dynamic analyzer measurement setup for the results in Figure 6-8. 6.3.1 Closed Loop Operation The closed loop transfer function of the acceleration loop was measured with the dynamic analyzer with the configuration shown in 6-7 as shown in Figures 6-8. For these plots, the amplified output of the accelerometer is taken as the output, and the input is the command signal in Figure 6-4. The low-frequency behavior of this loop clearly behaves as an ideal double integration as expected. The upper bandwidth is measured to be approximately 32Hz, somewhat lower than the 40Hz expected. The phase, however, does not start to drop off until about 6Hz, just above the intended crossover frequency of the loop of which this block will be a part. Thus this loop accomplishes the goal of not contributing significant phase shift at all relevant frequencies. When the accelerometer is driven with a 24V pk-pk (i.e. full-scale) signal, the output of the accelerometer is 22.6V pk-pk. For an instrumentation amplifier gain of 50, an output of 11.3V from the accelerometer corresponds to 11.3V g 1 = 0.275g 50 800mV Thus the closed loop gain of the acceleration block is 0.024g/V. 72 (a) Dynamic Analyzer measurement, 200mHz-200Hz, 2 averages (b) Dynamic Analyzer measurement, 2Hz-10Hz, 100 averages Figure 6-8: Closed loop measurements of the acceleration loop. The loop behavior meets the system requirements. 73 THIS PAGE INTENTIONALLY LEFT BLANK 74 Chapter 7 Results Before attempting to stabilize the dual pendulum system, the simpler problem of a single inverted pendulum was demonstrated. An initial attempt, described in Appendix A, justified the need for a linear position measurement and a closed-loop motor drive. With these elements included, the fast pendulum was stabilized as described Section 7.1. Since this single inverted pendulum will form the minor loop of the dual pendulum system, there are certain requirements for the closed-loop system which are discussed below. Finally, the dual pendulum system was implemented as described in Section 7.2. 7.1 Single Inverted Pendulum The single, fast pendulum was stabilized using the approach proposed in Section 2.2. The system block diagram is reproduced in Figure 7-1. Initially, the position feedback and lag compensation were omitted, and only the loop consisting of the lead network, motor, and pendulum was closed. As described in Section 2.2, the lead network introduces a phase bump that sets the system’s phase kp + motor Km s2 G(s) + x + τ s+1 ατ s+1 −s2 /g (τp s+1)(τp s−1) Glag (s) pendulum Figure 7-1: Block diagram of single pendulum system with position feedback system and lag compensator. 75 Rpos R3 position + angle Rang R1 − − input to motor loop + Rf Ri C R2 Figure 7-2: Implementation of summing junction and lead compensator. jω −60 −40 −20 jω −100 σ −80 −60 −40 −20 σ (a) Root locus when the lead zero is placed (b) Root locus when the lead zero is placed below the pendulum poles in frequency. above the pendulum poles in frequency. Figure 7-3: Root locus of single pendulum loop for two choices of placement for the lead compensator. margin. The circuit implementation of the summing junction and lead network is shown in Figure 7-2. This circuit has transfer function R3 (R1 + R2 )Cs + 1 R1 R2 Cs + 1 There are two approaches possible when choosing component values for this compensator. That is, the lead zero can be placed either below or above the natural frequency of the pendulum. The root locus for an ideal system using each of these approaches is shown in Figure 7-3. As these root locus plots show, moving the lead network up in frequency does allow for a higher frequency crossover, but unless the gain is sufficiently large it results in a closed-loop system with complex poles. Furthermore, it is important to note that there are additional high frequency poles and zeros from e.g. the acceleration loop which contribute additional phase shift at higher frequencies. Because of these elements there is an upper limit to the crossover frequency of this single pendulum loop. Through experimentation it was determined that this limit corresponds to a loop gain that 76 Table 7.1: Component values for compensator circuit shown in Figure 7-2. Summing Junction Lead Network Rang Rpos Ri Rf R1 R2 R3 C 27.4kΩ 91kΩ 10kΩ 50kΩ 160kΩ 14.3kΩ 160kΩ 1µF results in dominant complex poles. The closed-loop transfer function therefore has some peaking in the frequency domain. This peaking must be avoided when the single pendulum is used as a minor loop because it significantly lowers the gain margin of the system. Although a higher frequency lead network should ideally result in a “better” system, then, the slower lead network preferred in this case due to nonidealities and because this loop will be part of another system. Both types of compensator were built and tested for this thesis. The results from the higher frequency lead network compensator are discussed in Appendix B. The compensator shown in Figure 7-2 was built with the component values as indicated in Table 7.1. This choice of values places the compensator zero at 1.04Hz, just below the pendulum natural frequency. Figure 7-5 shows the closed loop measurement of the system when the input is an angle command and the output is the measured pendulum angle as indicated in Figure 7-4. This loop meets the requirements outlined above: specifically it has no peaking in the frequency domain. Furthermore, this loop has a relatively high bandwidth, with the magnitude dropping by 3dB at √ a frequency of about 7Hz. The dual pendulum loop will be ideally closed at ωf ωs = 3.67rps = 0.58Hz. At this frequency, the plot in Figure 7-5(a) shows no measurable negative phase shift. The step response shown in Figure 7-6 confirms that the closed loop poles are on the real axis. A motor G(s) Km s2 x + θ −s2 /g (τp s+1)(τp s−1) pendulum B Figure 7-4: Measurement configuration for results shown in Figure 7-5. 77 (a) Dynamic Analyzer measurement, 500mHz - 5Hz, 2 averages (b) Dynamic Analyzer measurement, 4Hz - 10Hz, 8 averages Figure 7-5: Short pendulum system loop closed loop measurements. 78 Figure 7-6: Step response of the system shown in Figure 7-4. Top trace: measured angle output. Bottom trace: input angle command. 79 7.1.1 Short Pendulum Position Feedback Position feedback is not included when the short pendulum is used as the minor loop of a dual pendulum system. However, for the purposes of lecture demonstrations it makes sense to have a stand-alone single pendulum system as well as the dual pendulum demonstration. Thus a position loop was implemented based on the approach in Section 2.2. In Section 2.2 it was shown that air damping can make additional loop compensation uneccesary when the position is added as an offset to the angle measurement. With this in mind, a first attempt at a position control loop was made without lag compensation. In this experiment, the position feedback constant is chosen as kp = 3.3 degrees/meter. The cart is started in the center of the track and released. Figure 7-7 shows the measurement of cart position over time. Clearly the system is unstable. Figure 7-7: Position measurement output when position feedback is used on the short pendulum system without a lag compensator. This system is unstable. A lag network was added to compensate the position feedback system. The complete schematic of lag, lead, and summing junction is shown in Figure 7-8. The lag network is designed in a noninverting connection so that it can be switched in or out without changing the sign of the loop transmission. Op amp U1 serves two functions: it adds gain to the lag network to bring the highfrequency gain to unity, and it acts as a buffer to the input of the summing junction to avoid adding dynamics to the position measurement input. Resistors R4 and R5 set the amount of position feedback. The position measurement scale is 18.4V/meter, and the angle measurement scale is 1.6V/degree. By adding these two inputs in the ratio Vangle /Vpos = 0.23, the feedback scale factor 80 angle measurement position measurement or major loop command C1 R1 R3 R2 10R3 U1 − + 81 S3 S2 R6 R4 R5 R7 U2 − + Figure 7-8: Complete schematic of compensator implementation for single pendulum loop. C2 R9 R8 + U3 − R10 to motor drive Table 7.2: Component values for single pendulum compensator shown in Figure 7-8. Lag Network Summing Junction Lead Network R1 R2 C1 R3 10R3 R4 R5 R6 R7 R8 R9 C2 R10 2MΩ 511kΩ 2µF 10kΩ 100kΩ 27.4kΩ 91kΩ 10kΩ 50kΩ 160kΩ 14.3kΩ 1µF 160kΩ kp is determined as: kp = [degree] 1.6[Volt] 18.4[Volts] [meter] 1 = 2.66 degrees/meter 2 Thus when the cart is at one end of the track, the angle is offset by 1.33 degrees. The loop gain lost by the attenuation of the angle measurement by R5 /(R4 + R5 ) is made up for in the variable gain block formed by U2, R6 , and R7 . Switches S2 and S3 allow the operator to select whether the position feedback and lag network are used. More details on operation can be found in Appendix C. The position feedback was built and tested. When the pendulum cart is manually brought to one end of the track and released, the system drives the cart back towards the center as expected. The cart will begin to settle to the location where the offset in angle measurement is corrected by the offset from the position command to bring the pendulum to true vertical. Due to the minimum cart speed set by the lower operating limit of the VCO, in addition to the unstable nature of the system, however, the cart never truly settles. Instead, the cart “hunts” around this location. This is a characteristic seen in other single pendulum demonstrations, such as the one currently used as a lecture demonstration in the MIT courses 6.003 and 6.302. One complication with the position feedback arises when the cart settles to a location offset from the center of the track. In this case, the integrator producing the position measurement signal is never reset and will eventually saturate. One solution is to adjust the pendulum offset so that its sign opposes that of the integrator drift direction. Then, as the integrator drifts it will eventually push the cart to reset point at the center of the track. 82 7.2 Stabilizing the Dual Inverted Pendulum Once the single pendulum loop was successfully implemented, the slow pendulum was added for the dual inverted pendulum system. The minor loop used is identical to the single pendulum system described in the previous section with position feedback omitted. As described in Section 2.3, the major loop compensator is a lead network. The zero is placed at the slow pendulum’s natural frequency, and the pole at the fast pendulum’s natural frequency. This allows a loop crossover at the geometric mean of these two frequencies with a maximum theoretical √ Ls /Lf −1 as derived in Section 2.3.2. The single pendulum closed loop phase margin of arcsin √ Ls /Lf +1 p measurements show no measurable phase shift at the ideal crossover frequency fc = fs ff = 584mHz. This bodes well for system stability. The compensator implementation is identical to that of the single pendulum compensator. The topology is shown in Figure 7-2. With the component values R1 = R3 = 144kΩ, R2 = 376kΩ, and C = 1µF, the lead network has transfer function G(s) = 0.52s + 1 0.144s + 1 By comparison, the time constants associated with the slow and fast pendulums are 0.52 and 0.143, respectively. This system was build and tested before position feedback was attempted. By manually adjusting the slow pendulum angle offset it was possible to keep the system running on the track. When a sinusoidal signal was input at the summing junction (in lieu of a position feedback signal), both the slow and fast pendulum could be observed to move sinusoidally. The slow pendulum could additionally be disturbed manually and the system would recover. However, these last two tests are limited by the dynamic range of the fast pendulum. The single pendulum system described in Section 7.1 can stabilize the fast pendulum for deviations up to six degrees from vertical. Since the fast pendulum is driven to have an angle from vertical that is twice that of the slow pendulum, this means that the maximum angle for the slow pendulum is only three degrees from vertical. The short physical length of the slow pendulum combined with its small dynamic range makes it difficult to observe the small-signal response. For a lecture demonstration, the physical length will have to be increased. 7.2.1 Position Feedback Although not explicitly part of the problem statement, position feedback is necessary for any reasonable demonstration as the cart will run off the track if it is omitted. The approach for closing a position feedback loop for the dual system is similar to that used for the single inverted pendulum. 83 Figure 7-9: Position measurement output when position feedback is connected around the dual position system with no additional compensation. Table 7.3: Component values for dual pendulum compensator shown in Figure 7-10. Lag Network Summing Junction Lead Network R1 R2 C1 R3 R4 R5 R6 R7 R8 R9 C2 72kΩ 75kΩ 10µF 294kΩ 22.6kΩ 111.3kΩ 50kΩ 376kΩ 511kΩ 376kΩ 1µF In order to measure the lower crossover frequency of the major loop, the position is first connected with no addition loop compensation. When R5 = 111.3kΩ, the cart oscillates at 96mHz as shown in Figure 7-9. Thus the lag compensator should be centered about this frequency. In order to limit the lower frequency of the pole from the lag network, the separation between the lag pole and zero is chosen to be only a factor of 5 in frequency. This value was chosen to avoid a very slow rise time in response to a step in angle. Otherwise, the process of manually trimming out the pendulum angle as described in Appendix C becomes tedious if the system takes over 30 seconds to settle. A schematic of the dual pendulum loop is shown in Figure 7-10, with component values given in Table 7.3. This circuit was built and tested, and seems to behave as expected with both pendulums held upright, although the system response has not yet been thoroughly measured. 84 Figure 7-10: Circuit implementation of compensator for dual pendulum loop. 85 angle measurement R1 + − R2 R3 C1 R4 R5 + − R6 position measurement C2 R7 R8 + − R9 input to minor loop 7.3 Conclusions This thesis has demonstrated that it is possible to implement a dual inverted pendulum system using a stable minor loop approach. Furthermore, the systems built along the way, such as the motor drive and acceleration loop, provide a strong foundation for possible improvement to the system. One of the major successes of this project was the use of counterbalancing to produce a pendulum with a very slow time constant. This technique allows for a high phase margin in the dual pendulum system, making demonstrations of stability more impressive, while avoiding a physically large structure. Before being presented as a lecture demonstration, however, the upwards-facing pendulum part should be extended so that it is physically longer than the fast pendulum. It seems that this aesthetic modification, although it will not affect the stability of the system, will make the system more immediately understandable. There are some additional adjustments that should be made before the system is robust enough to be used as a lecture demonstration. For instance, one practical improvement would be to reduce the power consumption of the circuits located on the cart to extend its run time, since for this thesis no attempt was made to reduce power consumption. However, such improvements are related to the reliability of the system over repeated demonstrations rather than the system stability. The single inverted pendulum system, which was initially intended to serve only as a minor loop, can be used as a demonstration of the single pendulum feedback system. This system is very robust and has very smooth operation, making it ideal for a lecture demonstration. Because this system is configurable, it can additionally be used to demonstrate the importance of the position feedback compensation. This ability will allow for a more complete discussion of the non-idealities involved, rather than a system that “just works.” This thesis attempts to convey the complexity of compensating what appears to be a straightforward system in the real world. It is interesting to note that the majority of the time spent on this thesis was focused first on the machining of the mechanical system, and then on the design and implementation of all of the necessary circuits that do not appear in the theoretical analysis, such as the motor drive, or the implementation of the pendulum angle and cart position measurements. Only in the final months were the pendulums stabilized, and in fact this process (particularly the single pendulum system), was relatively straightforward. 86 Appendix A Temporary Single Inverted Pendulum The first pendulum stabilized for this thesis was a single pendulum with effective length 90cm. This attempt was made in order to make sure that the mechanical system and supporting electronics such as the motor drive were sufficient to stabilize the faster pendulum that was eventually used as the minor loop pendulum in the dual inverted pendulum system. This experiment is interesting primarily because it demonstrated a need for both a closed-loop motor drive and a linear position measurement. This temporary single pendulum system was built before an acceleration loop was closed around the motor drive. The open-loop motor drive affects the system significantly. First, it introduces a low-frequency pole measured to be around 13 Hz that contributes negative phase shift to the transfer function, limiting the phase margin. Furthermore, since the stator windings are not perfectly sinusoidal, the cart does not in fact move at a constant velocity when the velocity command to the open loop system is constant. Instead, it accelerates at each pole winding, resulting in the sort of behavior shown in Figure 6-6(a). When a feedback loop is used, these spikes in acceleration are diminished as shown in Figure 6-6(b). Finally, it is possible when using the open-loop drive to command the magnetic wave to accelerate at a higher rate than the inertia of the cart allows the rotor to match. When the acceleration is too great, the motor will operate asynchronously. This problem arises because the open-loop drive has a velocity command input, making the slope of this input effectively an acceleration command. By limiting the rate of change of the velocity command, the acceleration is limited to a value that can be met by the cart. The slew rate limiter schematic is shown in Figure A-1. This circuit is based on the four-diode gate, with the charging rate of capacitor C limited by the bias current Ic . The rate of change of the voltage across the capacitor is limited 87 +15V +15V 200Ω 200Ω Ic 34.5kΩ velocity command + 100kΩ C 4.7µF 200Ω -15V − input to VCO 200Ω -15V Figure A-1: An adjustable slew rate limiter was used to limit the acceleration to avoid slip when the motor was driven open loop. to dV/dt = Ic /C. In order to compensate this system, the approach derived in Section 2.2 must be slightly modified to account for the change in the motor transfer function from Km /s2 to Km /s(τm s + 1). Because there is only one integration from the motor, the compensator must include an integration as shown in the block diagram in Figure A-2. The requirement of an additional integration makes it possible to use a compensator without the higher frequency pole included in the analysis in Section 2.2. A pole is included in the original compensator in order to limit its high-frequency gain, effectively avoiding building an analog differentiator. If a pole is included at the origin, the gain will be constant above the lead zero and there is no need for an additional pole. The transfer function of this circuit is vo RCs + 1 = vi 2RCs The circuit topology for this compensator is shown in Figure A-3. To keep the cart on the track, the basic position measurement described in 4.2.1 was used. This position measurement scheme divides the motor track into eight discrete segments, each with an associated value. The values are added as an offset to the angle measurement to drive the cart to the center. As mentioned in Section 4.2.1, a low-pass filter was used to limit the rate of change 88 kp + + G(s) motor K(τ s+1) s Km s(τm s+1) x + θ −s2 /g (τp s+1)(τp s−1) pendulum Figure A-2: When the motor is driven open loop, an additional integration must be added in the single pendulum loop compensator. R1 angle + position R1 R to VCO − C Figure A-3: The single inverted pendulum compensator consists of an integrator and a zero around the natural frequency of the pendulum. 89 of the position offset. Avoiding a step input in this way is beneficial for a system with low phase margin, since any overshoot might bring the pendulum angle outside of the operating range of the system. The temporary pendulum system demonstrated a need for two systems that were ultimately implemented for this system: a linear position measurement and a closed loop motor drive. Both of these additions reduce the disturbances in the pendulum system. The analog approach to position measurement satisfies the need for a position signal that does not have step changes. Similarly, the acceleration loop removes the unwanted accelerations due to motor saliency. The 90cm pendulum system was able to reject both of these disturbance sources, but the dual pendulum system inherently has lower stability margins, so it was necessary to remove these disturbances from the system. 90 Appendix B An Alternative Single Pendulum Loop As desribed in Section 7.1, there are two approaches to stabilizing the single inverted pendulum depending on the placement of the lead network in frequency. Based on the theoretical model of the system, the lead network should be able to be placed at an arbitrarily high frequency, with the loop gain increased accordingly. Thus the initial approach to stabilize the single inverted pendulum was to incrementally increase the loop gain and lead frequency in an attempt to achieve the highest possible crossover frequency. The results below refer to a single inverted pendulum without position feedback. The compensator implementation is reproduced in Figure B-1. This circuit is identical in topology to that used in the final version of the short pendulum system as described in Section 7.1. The circuit was first built and tested with the component values shown in Table B.1(a). This choice of components places the compensator zero at the frequency of the short pendulum pole. By adjusting the variable gain block, the system can be made to keep the pendulum upright, although the cart of course has the tendency to drift off the track. The system can run continuously for some time if the pendulum is tapped by hand toward the center of the track when it approaches the ends. This small interference with the system does not significantly affect its performance. The lead network frequency was incrementally increased with the values shown in Table B.1(b)(e). Note that in this table, the gain value Gvar does not directly correspond to the loop gain due to other scale factors associated with the angle measurement and motor drive. In theory, the gain should increase by k 2 for every k increase in lead frequency. However, Table B.1 shows that this is only true for low frequencies. At higher frequencies there is apparently negative phase shift from the non-idealities in the system, presumably from the 40Hz motor drive, so the loop gain cannot 91 Rpos R3 position + angle Rang R1 − − input to motor loop + Ri Rf C R2 Figure B-1: Implementation of summing junction and lead compensator. be increased without causing instability. Naturally the maximum phase margin is also limited at higher frequencies, as demonstrated by the increasing peak overshoot (Po ) in response to a step input. Of these attempts, system (d) gives the best results since it has a combination of high crossover frequency and damping ratio. The frequency response was tested with the dynamic analyzer for component choice (d). The results of this measurement are shown in Figure B-2. The peaking of 4.3dB at 4.9Hz corroborates the damping ratio derived from the small signal response, shown in Figure B-3. When the lead zero and loop gain were increased further, the system could not be stabilized. Based on these results, it seems that the crossover frequency is limited to such an extent that the frequency domain peaking that results from this approach outweigh any potential benefits of a higher frequency lead. The limit is probably due to phase shift from additional poles that are not included in this analysis. In addition, when the loop gain is large it becomes difficult to stabilize the system due to saturating signals. This approach was therefore discarded in favor of the one described in Section 7.1, since minor loop peaking in the frequency domain cannot be tolerated in the dual pendulum system. Table B.1: Various iterations of component values and gain and peak overshoot measurements for the compensator shown in Figure B-1. The small signal measurements for system (d) are shown in Figure B-2 and Figure B-3. R1 R2 R3 C max Gvar measured Po (a) (b) (c) (d) (e) 28kΩ 2.2kΩ 28kΩ 4.7µF 0.51 28kΩ 2.2kΩ 28kΩ 2µF 3.9 28kΩ 2.2kΩ 28kΩ 660nF 9.79 28kΩ 2.2kΩ 28kΩ 660nF 5.2 1.29 (ζ ≈ 0.4) 28kΩ 2.2kΩ 28kΩ 330nF 5.3 1.55 (ζ ≈ 0.2) 92 Figure B-2: The single short pendulum system: closed loop measurement from dynamic analyzer. 93 (a) Step Response (b) Sinusoidal Response Figure B-3: Small signal response of short pendulum system without position feedback. In both figures, the top trace is the output of the angle sensor (taken after the Sallen-Key filter) and the bottom trace is the command signal. Note the large amplitude of the angle signal in (b), which corresponds to a deviation from vertical of up to 4 degrees. 94 Appendix C Operating Instructions This thesis is set up to perform a variety of demonstrations as well as the dual inverted pendulum system. Each demonstration requires some initial setup as well as offset adjustments. This appendix describes the configuration and operation of the demonstrations. C.1 Configuration The cart can be configured for three types of demonstrations: the dual inverted pendulum system, and the single inverted pendulum with and without position feedback. Three switches control the configuration as summarized in Table C.1. Figure C-1 shows a sketch of the physical layout of the cart circuit board with the approximate locations of the switches. a S3 a b a POT4 S2 S1 b b POT3 POT2 POT1 Figure C-1: Sketch of physical locations of switches on cart board. The angle measurement offsets and pendulum loop gains are adjusted with the four potentiometers sketched in Figure C-1. The fast and slow pendulum angle measurements are offset with 95 Table C.1: Table of switch settings for various demonstrations. S1 S2 S3 Demonstration a a a Single pendulum - no position feedback a b a Single pendulum - uncompensated pos. feedback a b b Single pendulum - compensated pos. feedback b b a Dual pendulum system with position feedback potentiometers POT1 and POT2, respectively. The minor (single) pendulum loop gain is adjusted with POT4, and the major loop gain with POT3. C.2 Startup This thesis is designed for small-signal operation around vertical and ignores the problem of getting the pendulum upright in the first place. A manual approach to startup is described below. The single pendulum system has a double integration because of the acceleration loop, so the signals will saturate if the loop is not closed. To start the system, then, the signals must be coaxed into the operating range for the feedback to kick in. Startup is best achieved by bringing the cart to one side of the track, then leaning the pendulum to the opposite side and allowing the cart to “catch” the pendulum from one side. The pendulum loop is too fast to simply hold the pendulum at small angles by tracking the movement of the cart, a technique that works for the slower (1 meter) pendulum. Another effective technique is to slowly increase the loop gain while holding the pendulum upright until the system can be felt taking control. The angle offset seems to be slightly different each time the system is started up, probably due to the impact from the pendulum falling when the system is shut off. There is a potentiometer on the pendulum cart to adjust this offset (see Section C.1 above). When position feedback is being used this should be adjusted with the cart as close to the center as possible, ideally with the position reset brush contacting the copper foil pad. The angle offset should be corrected before adding an input or the second pendulum. The general approach to the dual pendulum system is to get the fast pendulum upright first by commanding it to an angle of zero, then switching in the slow pendulum. The slow pendulum is held upright while the minor loop input is observed on an oscilloscope. By adjusting the angle offset, the minor loop input is brought approximately to zero, then the system is switched into the dual pendulum mode. The two pendulums should be trimmed as closely as possible. 96 Appendix D List of Symbols A A, B fs , ff g Glag G(s) Gs (s), Gf (s) Gvar kℓ Km km kp kρ ℓ ℓs , ℓf l L L(s) Po x ζ θp θs , θf θz µ τc τg φM ωc ωs , ωf VCO multiplier gain dynamic analyzer inputs, output is B/A(s) slow, fast pendulum natural frequency in Hertz gravitational constant, 9.81m/s2 lag compensator general loop compensator slow, fast pendulum loop compensator gain associated with variable gain block ratio of lengths in slow pendulum assembly motor block gain constant ratio of masses in slow pendulum assembly position feedback constant ratio of linear density of steel cylinder to PETG hollow rod pendulum effective length slow, fast pendulum effective length length integration variable physical length of non-ideal pendulum. system loop transfer function peak overshoot in system step response cart position system damping ratio angle contributed by a zero in the transfer function slow, fast pendulum angle from vertical angle contributed by a pole in the transfer function linear density of short pendulum torque acting on pendulum due to acceleration of the cart torque acting on pendulum due to gravity system phase margin system crossover frequency in radians per second slow, fast pendulum natural frequency in radians per second 97 THIS PAGE INTENTIONALLY LEFT BLANK 98 Bibliography [1] J. K. Roberge, “The mechanical seal,” Bachelor’s thesis, Massachusetts Institute of Technology, 1960. [2] K. H. Lundberg, “Linear dual inverted pendulum control,” Master’s thesis, Massachusetts Institute of Technology, 1997. [3] L. C. Phillips, “Control of a dual inverted pendulum system using linear-quadratic and h-infinity methods,” Master’s thesis, Massachusetts Institute of Technology, 1994. [4] J. Rubı́, A. Rubio, and A. Avello, “Swing-up control problem for a self-erecting double inverted pendulum,” IEE Proc.-Control Theory Appl., vol. 149, no. 2, 2002. [5] C.-M. Lin and Y.-J. Mon, “Decoupling control by hierarchical fuzzy sliding-mode controller,” IEE Transactions on Control Systems Technology, vol. 13, no. 4, 2005. [6] M.-C. Tsai and B.-H. Shen, “Synchronisation control of parallel dual inverted pendulums driven by linear servomotors,” IET Control Theory Appl., vol. 1, no. 1, 2007. [7] J. K. Roberge, Personal correspondance, 2007. [8] E. Oberg, F. D. Jones, H. L. Horton, and H. H. Ryffel, Machinery’s Handbook, 27th ed. In- dustrial Press Inc., 2004. [9] “2SA-10 Integrated 2-Axis Hall Sensor,” Sentron AG, Zug, Switzerland. [10] J. K. Roberge, Operational Amplifiers: Theory and Practice. John Wiley & Sons, Inc., 1975. [11] A. G. Bose, “A two-state modulation system,” Wescon Convention Record, vol. Part 6, Paper 7.1, 1963. [12] S. Bowden and C. Honsberg, “Photovoltaics CDROM,” Solar Hydrogen IGERT. [13] “Low Cost ±1.2g Dual Axis Accelerometer,” Analog Devices, Inc. 99