Ball & Beam Control System By Stephen Salvatore Ernest Esposito Joseph Miller Instructors: Dr. Raul Ordonez Dr. Ravi P. Ramachandran Dr. Stephanie Farrell Table of Contents Section I. II. III. IV. V. VI. Page 3 4 5 6-9 10 11 Title Introduction Problem Description Requirements Ball & Beam Control Theory System Design Team Organization Page 2 Section I – Introduction The ultimate goal of this experiment is to develop a control system and create the supporting software for the CE106 ball and beam apparatus. In this experiment, a ball is free to roll along the track of a beam that is pivoted at the center. Transducers on the ball and beam continuously detect the ball position and the beam angle of the track. The control problem involves moving the ball from one position on the track to another by controlling the track angle. The control system is to be implemented using a computer interfaced to the ball and beam system via a data acquisition card. Computer inputs are obtained from the voltage signals proportional to the ball position and beam angle of the ball and beam. The computers output voltage controls the motor that changes the beam angle. The block diagram below illustrates the flow of data for the ball and beam experiment. Inputs Motor Signal D to A Computer & Control Software Outputs Beam Angle Ball Position A to D Keithley DAQ Card Page 3 Ball & Beam Experiment Section II – Problem Description The ball and beam apparatus is a simple system where a beam is tilted back and forth to control the position of a ball at a desired position or reference, as shown in the figure below. For instance, for a fixed beam angle the ball will accelerate along the beam at a rate that is proportional to the beam angle. A system such as the ball and beam is an unstable system because for a constant beam angle the ball does not stabilize at any fixed position. At constant beam angle the ball moves at a constant acceleration until it reaches the end of the beam. The beam angle transducer on the ball and beam apparatus consists of a servo potentiometer mounted at the rear of the beam shaft. The signal is internally conditioned and brought out to the Beam Angle socket mounted on the front panel. The range is between 10 V. A voltage signal in the range 0 to 10 V applied to the Motor Drive Signal Input varies the speed of the motor. A profiled cam attached to the motor shaft links the main beam via a secondary beam. Finally, two parallel wires are stretched along the top of the beam. The wires support a steel ball and one of the wires is connected to a voltage source. When the ball rests between the wires it allows a fraction of the source voltage to be measured at the other wire. This voltage fraction provides a voltage that is proportional to the ball position along the length of the wires. With conditioning, an output signal is then generated which is proportional to the ball position on the beam. This particular signal is available at the appropriate socket mounted on the front panel in the range of 10 V. Ball Position Ball Motor Beam Angle Beam The major control objective is to position the ball anywhere along the beam. This is a difficult problem because the only actuator available is the beam itself and its rotation. Moreover, this is a nonlinear, and unstable system. Page 4 Section III - Requirements 1. The C++ software must have a controller module that is easy to edit so students can design and test new controllers for each experiment. 2. All other software implementation (besides controller module) must be low maintenance. 3. Data must be acquired in at least 10 ms intervals because the ball and beam system's dynamics have a time constant in the order of 1 ms. Page 5 Section IV - Ball & Beam Control Theory This section will present an overview of the control strategy to be used, describe the ball and beam model, and discuss controller design. Control Strategy: Cascade Control: The ball and beam system consists of a motor driven beam with a ball free to roll on the beam. Manipulating the beam angle controls the ball position. Since the beam angle is measured using a potentiometer and the motor drive input controls the rate of change (velocity) of the beam angle, it is sensible to place the beam angle control loop around the motor and drive amplifier. In other words, it is necessary to first construct a motor angle controller that can position the motor shaft and beam at any angle required by the ball position controller. If the beam angle control loop is designed to respond rapidly and accurately to the reference beam angle, then the control loop of the ball position can be designed be considering the actual beam angle to be the control input. Now the ball position controller forms an outer control loop. The inner loop is called the slave loop and the outer loop is called the master loop because the master loop determines the reference input for the slave loop. Ball and Beam Model: The ball and beam system can be modeled using the following block diagram: rp yp Page 6 where: rp is the reference or desired value for the ball position on the beam. yp is the actual ball position on the beam at a given instant in time. ex is the calculated ball position error signal (ex = rp - yp). is the actual angle of the beam at a given instant in time. ref is the reference angle generated by the ball position controller. e is the calculated beam angle error signal (e = ref - ). And u is the voltage signal that controls the unstable ball and beam system. Motor Model: The drive motor tilts the beam through the action of a profiled cam attached to the motor shaft. A retaining spring is attached to the beam to ensure that the cam follower is kept in contact with the cam. We can model this motor with the following equation: 1 2 Au Where A, 1, and 2 are all constants that can be determined by conducting experiments with the ball and beam apparatus. These experiments include collecting input versus output data for the ball and beam motor. This data is used to construct a bode plot and derive the appropriate constants for the ball and beam motor model. Also, u represents the control variable or function for the control system. Ball Model: The main co-ordinates for the ball and beam system are the ball position on the beam and the beam angle . We can now write the Lagrangian (L) for the system: L=U*-T where U* is the kinetic energy and T is the potential energy in the system. The potential energy is zero, since there are no springs in this system. Hence, the Lagrangian is given by the kenetic energy which consists of the translational and rotational kinetic energy of the ball as it moves on the beam. Now we can write the following formula: L U* 1 2 1 2 mv I 2 2 where m is the mass of the ball and I is the ball's moment of inertia. Page 7 Now the translational velocity of the ball (v) and the angular velocity of the ball as it rolls () must be re-written in terms of x and . First, consider the angular velocity. The angular distance rolled by the ball with respect to the vertical is given by the following formula: x r Hence, d x dt r where r is the rolling radius of the ball. Also, the velocity (v) of the ball can be obtained by making a velocity diagram of the ball and beam. This formula is given by: 2 v 2 x 2 x Now, by substituting the previous two equations in the Lagrangian equation yields: m 2 I x L x ( x) 2 2 2 r 2 At this point we can write the expression for the moment of inertia of the ball: I 2 mR2 5 where R is the ball radius. The model of the system dynamics is obtained from the Lagrange equation: d l L mg sin dt x x and substituting L in this equation gives us the ball model for the ball and beam apparatus: 2R2 2 R 2 1 2 x 2 x()2 g sin 5r 5r where both R and r are characteristics of the ball. State-space model: For this unstable ball and beam system it is useful simulate controllers using numerical techniques. The state-space model is a method of producing mathematical descriptions of control systems that do not rely on the Laplace transform, which we cannot write Page 8 since this is a nonlinear system. This model defines the model using a system of first order differential equations. In this particular case, we will be solving the nonlinear system of differential equations using the Runge-Kutta method for simulation control design purposes. To begin the state-space model we assign new variable names to the beam angle, beam velocity, ball position, and ball velocity: x1 x 2 x3 x x4 x Now we can begin to fill in the right side of each equation with the appropriate value in the ball and beam system: x1 x 2 x 2 1 x1 2 x 2 Au x 3 x 4 g sin( x1 ) x3 ( x 2 ) 2 B( 1 x1 2 x 2 u ) x 4 C 2 B where 2R 2r 2 and C 1 B. where R and r refer to different dimension of the ball. Finally, we can write the expression for the control variable u: u C1 (C2 (e x ) x1 ), where C2 is the outer loop (master) or ball position controller and C1 is the inner loop (slave) or motor angle controller. Page 9 Section V - System Design A general system block diagram of the computer control is given below: D to A Control Experiment CPU A to D The computer will retrieve actual readings from the control experiment via the analog to digital converter on the data acquisition card. The C++ software will process these readings and a control voltage will be generated and sent to the digital to analog converter. This generated voltage will in turn be sent to the ball and beam apparatus. Software: All of the software developed for this project will be coded in C++. Initialize D/A and A/D converters Set Reference Ball Position rp(k) Measure Ball Position yp(k) Calculate Position Error ex(k) = rp(k) - yp(k) Generate Reference Angle ref(k) = C2(ex(k)) Measure Beam Angle (k) Calculate Angle Error e(k) = ref(k) - (k) Generate Control Signal u(k) = C1(e(k)) Page 10 Write control voltage u(k) to the motor Algorithms: In the initial C++ software design a PID controller algorithm will be used. The following flow chart outlines the algorithm of how the closed loop control would be implemented on a computer. Data Acquisition: In order to retrieve information from the various experiments, a Keithley KPCL-3102 card will be utilized. Also, in order to plug into the various channels on the computer interface a STP-68 screw terminal panel will be used connected by a CAB-305 cable. Page 11 Section VI - Team Organization Engine Speed Control Apparatus Ernest Esposito - Electrical and Computer Engineering - Junior Ball and Beam Control Stephen Salvatore - Electrical and Computer Engineering - Senior Motor Speed Control (Feedback) Joseph Miller - Electrical and Computer Engineering - Junior Page 12