BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE...

33
BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE-4962 Control Systems Design Greg Andrews Chris Colasuonno Aaron Herrmann March 24, 2004 Rensselaer Polytechnic Institute

Transcript of BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE...

Page 1: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

BALL ON PLATE BALANCING SYSTEM

Progress Report for ECSE-4962 Control Systems Design

Greg AndrewsChris ColasuonnoAaron Herrmann

March 24, 2004

Rensselaer Polytechnic Institute

Page 2: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Abstract

The goal of the ball-on-plate balancing system is to create a control system that can accurately balance asteel ball on a plate. To date, significant strides have been made towards the completion of said goal. Thephysical system, including a rebuilt yoke, axle and motor bracket, is nearly complete. The basic controllerhas been coded, and is currently capable of gravity compensation, friction compensation, and following asine wave input. The ball coordinate system is also complete, and can generate plate coordinates for use inthe controller. With regard to the originally proposed schedule, tasks are continuing to be completed aheadof schedule.

Page 3: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Contents

1 Introduction 4

2 Preliminary Results 62.1 Model Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.2 Control Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.3 Friction Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.4 Friction & Gravity Cancellation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.5 Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.6 Subsystem Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

3 Summary of Progress 233.1 Plan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.2 Schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.3 Cost . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.4 Unanticipated Challenges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.5 Forecast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

4 Statement of Contribution 27

A MATLAB Code 29

1

Page 4: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

List of Figures

2.1 Simulink Diagram - Complete System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 State Feedback Control (LQR) - Step Response . . . . . . . . . . . . . . . . . . . . . . . . . . 82.3 Simulink diagram for Observer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92.4 State Feedback Control with Observer - Step Response . . . . . . . . . . . . . . . . . . . . . . 102.5 Plate Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.6 Ball Control - Root Locus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.7 Ball Control - Step Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.8 Ball Control - Frequency Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.9 Ball Position with Time - Circular Trajectory . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.10 Absolute Ball Position in Meters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.11 Simulink Virtual Reality Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.12 3D Animation of The Ball on Plate System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.13 Pan Axis Friction Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.14 Tilt Axis Friction Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.15 Gravity Compensation Torque Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.16 Open Loop Response for 2.1 N-m Torque, Actual and Simulated . . . . . . . . . . . . . . . . 182.17 Step Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.18 Tracking Error for 1.5 rad/sec sine wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.19 Tracking Error for 3.0 rad/sec sine wave . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202.20 xPC Target Touchpad Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.21 xPC Target Touchpad Packet Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212.22 Touchpad Ball Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

2

Page 5: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

List of Tables

2.1 Touchpad Controller Packet composition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

3.1 Remaining schedule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.2 List of parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.3 List of raw materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.4 Labor costs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

3

Page 6: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Chapter 1

Introduction

The goal of this project is to develop a ball-on-plate balancing system, capable of controlling the position ofa ball on a plate for both static positions as well as smooth paths. We intend that the initially horizontalplate will be tilted along each of two horizontal axes in order to control the position of the ball. Each tiltingaxis will be operated on by an electric motor. Each motor will be controlled using software, with a minimumof position feedback for control.

After an extensive search, few systems of similar scale were found. The ball-on-beam system, a 1-dimensionalsimilarity to the ball-on-plate, however, is a classic control problem, and has been studied in great detail,and solved a great many ways; PID control, optimal control, fuzzy-logic controllers, etc. The fuzzy-logiccontrollers would seem to be the current state of the art, however classical approaches using discrete approx-imations are certainly adequate, if not preferred for their relative ease of implementation. Two ball-on-platesystems were uncovered during the search: one, developed at Rensselaer Polytechnic Institute by ProfessorKevin Craig [6] using a similar method to that which we intend, and another at the University of Newcastle,Australia, which was developed using image processing techniques in conjunction with a textbook by Pro-fessors Graham Goodwin, Stefan Graebe and Mario Salgado [7]. While this would seem to be a short list,the ball and beam system seems to be a more popular and less structurally complex system to implement.

The aim of this project will be to create a ball-plate system using a resistive touch sensor to allow themovement of a ball by means of automatic control. The system should have accuracy of < 2% in theplacement of the ball on the screen, as well as the ability to move the ball from one end of the plate to theother in less than 2 seconds (long side). Overshoot should be minimal, to reduce the chances of losing theball off of the plate or incurring damage to the touch element due to striking the physical structure of thesystem.

Current progress to date has shown great strides towards the creation of a fully modelled, fully controlledbalancing system. The modelling of the dynamics of the system have been completed, and the simulatedmodel validated by means of comparison to the physical system. The friction of the system has also beenidentified through successive trials using varying torque inputs on both axes. A controller with full state-feedback and an observer has also been designed, and is currently undergoing testing and incremental tuning.The touchpad sensor interface is also complete, and waiting to be attached to the now completed mechanicalsystem.

4

Page 7: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Comparing the progress with the proposed initial schedule, work is proceeding as planned. This week is theintegration phase, and work is continuing on that front, with the physical system and sensors being marriedtogether. Then the controller can finally be tested on the complete system, aiming for ball balancing sometime in the next week. The interface for the touchpad did have to be changed to using the serial controllerthat came with the touchpad itself, but it all functions as expected. There are concerns that the motordrivers cannot supply enough torque for our system with the current setup, and therefore might requiretweaking.

The prognosis for the remaining 5 weeks of development looks good. If the controller works as the simulationshows, the basic objective of balancing a ball seems plausible. Given all present indications, the further goalof tracing a path also seems possible.

5

Page 8: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Chapter 2

Preliminary Results

2.1 Model Development

In order to design a control system that will accurately control the position of the ball, a highly accuratemodel must be developed. As the accuracy of the model increases, the control effort required will be less.To develop this model, Professor Wen’s pantilt.m MATLAB script was run to find the equations of motionfor our system. This script returns symbolic values for the mass-inertia matrix, velocity coupling matrix,gravity loading vector, and the total system energy. A SolidWorks model was developed, and from this,numeric inertia tensors were found for bodies A and B with respect to our defined coordinate systems.

Unfortunately, using the linear control theory that we have learned thus far, it becomes difficult to developa control system for our fully non-linear model. Because of this, the system must be linearized about anoperating condition, (θ, θ) = (0, θd). By doing this, we are left with the linearized equations of motion:

M(θd)θ +∂G(θd)

∂θ(θ − θd) + Fv θ = Bu− Fcsgn(θ) (2.1)

The state-space realization of this system becomes [5]:

[x1

x2

]=

0 0 1 00 0 0 1

−M−1(θd)∂G

∂θ︸ ︷︷ ︸2x2

M−1Fv︸ ︷︷ ︸2x2

[

x1

x2

]+

0 00 01 00 1

(2.2)

y =[

1 0 0 00 1 0 0

] [x1

x2

]Using this linearized system, a controller can be developed for the plate.

6

Page 9: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

In addition to the plate system, a model for the ball dynamics must be developed as well. If we ignorecoupling between the two modes of motion, as well as the friction between the ball and plate, a linear modeland transfer function can be determined [3].

(J

r2b

+ mb)x = −mbgθ

X(s)Θ(s)

=−mg

s2( Jr2

b

+ m)(2.3)

Substituting numerical values into this equation results in the transfer function 7s2 . This double integrator

can be easily controlled with classical control approaches.

2.2 Control Development

The design approach for this control consists of two feedback loops: an inner loop to control the positionof the plate, and an outer loop to control the position of the ball [6]. A Simulink diagram illustrating thisapproach can be seen in Figure 2.1.

Figure 2.1: Simulink Diagram - Complete System

In order to successfully implement this design, the inner loop must have a much faster response than theouter loop. Since the inner loop can only be designed to be as fast as physical limitations allow (motortorque, etc.), we must intentionally design the outer loop to be slower.

From the linearized system in Equation 2.2, a full state-feedback control can be implemented. For oursystem we decided to use a linear quadratic regulator (LQR) to determine the feedback gain matrix, K,such that the control becomes u = −Kx. The Q matrix must be chosen to optimize the control to achieve

7

Page 10: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

out desired result. Since we are interested in tracking θ1 and θ2, we place a high weighting on those states.In addition, the R function can be adjusted to either promote or penalize the control effort. After severaldesign iterations, the current Q and R matrices are found to be:

Q =

1000 0 0 0

0 1000 0 00 0 0 00 0 0 0

R =[

.5 00 .5

](2.4)

resulting in the feedback gain matrix:

K =[

44.7214 0 9.5625 00 44.7214 0 9.5625

](2.5)

With this gain matrix, the closed loop eigenvalues (A−BK) are placed so that the damping ratio is ζ = .707and natural frequency is ωn = 6.68 rad/sec. The step response of this closed-loop system can be seen inFigure 2.2. However, this response assumes that all states can be measured, when in fact we can only

Figure 2.2: State Feedback Control (LQR) - Step Response

measure position, not velocity. For this reason, we have implemented an observer to estimate the velocitystates of our system [4]. To do this, the plant was first converted to a discrete system using MATLAB’sc2d() command using the zero-order hold method for a sampling frequency of 10KHz. Then, observer polesare placed so that they are roughly five times faster than the closed-loop poles. To do this, we find the timeconstant of the closed-loop poles, and calculate our observer poles accordingly. Using MATLAB’s place()command, the observer gain matrix L is found to place the poles in these desired locations. The observer isof the form:

˙x = Ax(k) + Bu(k) + L(y(k)− y(k)) (2.6)

8

Page 11: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

y(k) = Cx(k)

Poles = 1e− 3 [−.478− .467j − .478 + .467j − .478− .467j − .478 + .467j] (2.7)

L =

2 00 2

10000 00 10000

(2.8)

where x is the observer’s estimate of the velocity states, u is the system input, y is the plant output, andy is the observer output. The L matrix ensures that the observer error, x(k) − x(k) converges to zero [2].This can easily be implemented as a controller of the form [8]:

u(k) = −Kx(k)

x(k + 1) = (A−BK− LC)x(k) + Ly(k) (2.9)

The Simulink diagram and response for this system can be seen in Figures 2.3 and 2.4. The observer

Figure 2.3: Simulink diagram for Observer Control

estimates the velocity fairly accurately, however this may be able to improve my moving the eigenvalues ofthe observer (2.7). The closed-loop frequency response as well as gain and phase margins for this systemcan be seen in Figure 2.5. It can be seen from this response that we should be able to track the plate ata velocity of 6.7 rad/sec, while at the same time suppressing high-frequency sensor noise. This meets ouroriginal specification of 1.36 rad/sec. The gain margin for the closed-loop plate system is 80.6dB at 138rad/sec. At our desired speed, we should be able to position the plate with very little chance of instability.

It should be noted that in Figure 2.1, that the gravity and friction terms are being added back into thecontrol effort. This feedback linearization in effect cancels out the nonlinear terms within the plant, makingthe control effort required less. However, this does not come without cost. The feedback linearizationincreases computation time, as well as the torque requirement, though through both simulation and actualexperimental runs, this does not seem to pose a problem.

For the ball position control, a classical root-locus design methodology was used. Figure 2.6 shows thelocus before and after compensation. It can be seen from the prior that the open-loop system is onlymarginally stable, and a purely proportional controller will not be sufficient to compensate for this. Insteada proportional+integral+derivative (PID) control will be used. A zero is placed at s = − 1

2 , and a pole to thefar right at s = −100 resulting in a derivative gain of Kd = 2. By using MATLAB’s rltool(), a proportionalgain of Kp=1 was found. In addition, a small integral term was added to improve the steady state response.

9

Page 12: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.4: State Feedback Control with Observer - Step Response

Figure 2.5: Plate Frequency Response

10

Page 13: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.6: Ball Control - Root Locus

An integral gain of Kp = 1.05 was used to achieve this. closed-loop response can be seen in Figure 2.7. Withthese relatively low gains, our control is sufficiently slow to allow the plate dynamics to respond.

14s2 + 7.073s + 7.34.01s4 + s3 + 14s2 + 7.073s + 7.35

(2.10)

Equation 2.10 shows the closed-loop transfer function for the ball dynamics. The controller Kp + Kds +fracKis can be converted to a digital controller using MATLAB’s c2d() command. This emulation designapproach can be used since the sampling time is sufficiently faster than the bandwidth of the closed-loopsystem. After the discretization at a rate of 10KHz with a bilinear transform, the digital PID controlbecomes:

199z2 − 398z + 199z2 − 1.99 + .99

(2.11)

The frequency response and gain and phase margins can be seen in Figure 2.8. It can be seen that with thiscontrol, we should be able to track the ball at 12 rad/sec, and high-frequency noise should be suppressed.This meets our original design requirements.

Now that controllers have been developed separately for both plate position and ball position, it is desirableto to combine the two, resulting in the diagram shown in Figure 2.1. By doing this, the plate control iscommanded by the output of the ball control. A simple test is to command a trajectory for the ball, and seeif the plate dynamics respond in such a way to follow that trajectory. For this test, we used two sine waves,both at 2 rad/sec and amplitude of 0.04, and one inverted and π

2 radians out of phase with the other. Onesine wave commanded the ball’s X position, the other, the ball’s Y position. By doing this, the ball shouldessentially travel in a circle of radius 0.04m. This trajectory was commanded though a Simulink simulation,and the results were promising. Figure 2.9 shows the ball’s response in a position vs. time manner. It can

11

Page 14: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.7: Ball Control - Step Response

Figure 2.8: Ball Control - Frequency Response

12

Page 15: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.9: Ball Position with Time - Circular Trajectory

be seen that initially, the ball has a 0.04m position error since it’s initial position is at (0,0). This does notcause the system to go unstable, however there is some lag and overshoot while the ball tries to catch up tothe commanded position. Once the ball has caught up to the desired position, it tracks it with very littleerror. Figure 2.10 shows the balls spatial position in an X vs. Y position plot. The ball initially overshootsthe desired trajectory as mentioned before, but then settles into a near perfect circular trajectory in roughly3 seconds.

To better visualize this, a 3D animation has been created using MATLAB’s Virtual Reality Toolbox. Themodel created in SolidWorks was exported as a VRML file, and a VR block was created in Simulink to movethe model in accordance with the simulation results. The Simulink block diagram and a sample frame fromthe animation are shown in Figures 2.11 and 2.12. A video file of this animation is available upon request.

2.3 Friction Identification

Identification of the friction in the system was performed as prescribed in the design proposal. A Simulinkmodel capable of measuring the encoder and outputting constant voltages was used in conjunction with aMATLAB script to repeatedly estimate the velocity of each joint. For each of 200 voltage increments fromminus two volts to plus to volts, the motor was allowed to turn for ten seconds so that it would reach steadystate velocity. The last four seconds were then averaged to obtain a single value for steady state velocityfor that particular torque (voltage). In addition, a one second ten volt spike was added in the beginning ofeach run in order to overcome the stiction of the system. By plotting this data and finding a least squaresapproximation for the data, the coulomb and viscous friction were found as the intercept and slope of theregression line, respectively. The plots for each axis are shown in Figures 2.13 and 2.14.

13

Page 16: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.10: Absolute Ball Position in Meters

Figure 2.11: Simulink Virtual Reality Diagram

14

Page 17: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.12: 3D Animation of The Ball on Plate System

15

Page 18: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.13: Pan Axis Friction Data

Figure 2.14: Tilt Axis Friction Data

16

Page 19: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

2.4 Friction & Gravity Cancellation

Following the identification of the friction and gravity, a Simulink diagram was created to cancel out bothwithin the system. When the program was run, the system could be positioned by hand at any positionwithout falling and was very easy to move. A fairly light touch could rotate the system about an axis severaltimes before it settled at a location and remained there.

Through some simple hand calculations, the amount of torque required to cancel gravity in the system wasfound to be about 0.4 N-m. This value matched the torque value in both the model and the value recordedfrom running gravity cancellation on the actual system. The torque plot can be seen in Figure 2.15.

Figure 2.15: Gravity Compensation Torque Data

2.5 Validation

Having completed the identification of the system’s inertia from the SolidWorks model, friction, and gravityloading, the model of the system was completed. In order to verify the validity of this model, severalexperiments were run on the system. These experiments included testing of the open loop response, stepresponse, and position tracking, for both the actual system and a simulation using the developed model.The results were very promising.

The open loop response for both the actual system and simulation for an input of a 2.1 N-m torque areshown in Figure 2.16. The plots for both are nearly identical.

With a preliminary control system running, the system’s pan axis was commanded to a 0.5 radian positionusing a step function input. The actual, desired, and simulated responses are shown in Figure 2.17. While

17

Page 20: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.16: Open Loop Response for 2.1 N-m Torque, Actual and Simulated

there is some variation between the actual and simulated responses including rise time and error, they are afairly close match as well.

In addition to a step response, several sine wave inputs were made to the controlled system and severalpromising plots were generated. Sine waves with amplitude of one radian and for 1.5 rad/s and 3.0 rad/secfrequency were used as input. Upon viewing the plots it is easy to see that while some further work is requiredon the controller, the model is highly accurate when compared to the actual system. Some slight ”bumping”occurs on the downward stroke on one portion of the sine wave. By doing such things as increasing the speedof the observer by moving its poles, this bumping effect can be removed. The plots are shown in Figures2.18 and 2.19.

A simple tolerance analysis test to verify the gain and phase margins (qualitatively) is to give the systema disturbance while in operation. While the system was being commanded to follow a sine wave input, weheld the yoke from moving by hand. After letting go, the system sped up to catch up with the desiredtrajectory, and then fell back into sync. No tolerance analysis has yet been done as far as sensor noise,however according to the frequency responses of both controllers, high-frequency noise should be sufficientlyattenuated.

2.6 Subsystem Development

The touchpad interface relies entirely on the capabilities of the 3M Dynapro SC3 serial interface controllerfor its operation. The touchpad is composed of 90◦ offset plates. Voltage is applied across one plate whilereading voltage information from the other plane. When pressure is applied to the surface, an electrical

18

Page 21: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.17: Step Response

Figure 2.18: Tracking Error for 1.5 rad/sec sine wave

19

Page 22: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.19: Tracking Error for 3.0 rad/sec sine wave

connection is made, which results in a change of voltage at the output. This change corresponds to thedistance between the contacts on the plate. One reading is made from each of the two plates to create anX-Y coordinate pair.

The SC3 controller takes these X-Y coordinate pairs it generates and converts them into sets of three 8-bitpackets which can be converted into coordinate pairs. The actual coordinate values are 10-bit values, thatare actually spread across the three separate packets as shown in Table 2.1. Note that in the table, the Pbit refers to the status of the ’pen’, or the object touching the pad: 1 is pen down, 0 is pen up. Also notethat x9 refers to the 10th bit of the 10-bit x coordinate number, and so forth for all xk and yk. [1]

Table 2.1: Touchpad Controller Packet compositionPacket/Bit # 7 6 5 4 3 2 1 0

#1 (sync) 1 P x9 x8 x7 y9 y8 y7

#2 (data) 0 x6 x5 x4 x3 x2 x1 x0

#3 (data) 0 y6 y5 y4 y3 y2 y1 y0

All of these packets are sent asynchronously and without prompting: as soon as the touchpad receivessufficient pressure for the controller to register a touch, the system begins to send data. In order to processthis data, and get the resultant coordinate information into the real-time computer, a serial interface needsto be created in MATLAB Simulink that can be compiled for the xPC Target system.

The basic overall system utilizes the binary receive block in Simulink to retrieve data as sets of three 1-bytepackets as described in the manual. The RS232 Setup block sets the link parameters as 2400 bps, and 8-N-1 -8 bits per packet, no parity, and 1 stop bit. Normally, Simulink is unable to utilize binary numbers, however,

20

Page 23: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

the communications toolbox allows conversion to and from binary. This makes possible the individual bitmanipulation necessary to move the 8-bit packets from the controller into the 10-bit binary words that thecontroller’s A/D converter creates. The Simulink diagrams can be seen in figures 2.20 and 2.21.

Figure 2.20: xPC Target Touchpad Interface

Figure 2.21: xPC Target Touchpad Packet Conversion

Testing of the system in real time using the steel ball as a touch source as well as the rubber membrane onthe surface of the touch screen yields clear coordinate plots such as the one seen in Figure 2.22. Furthertesting will have to wait until the physical system is completed, including approximated error calculationsdue to quantization and signal noise.

21

Page 24: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Figure 2.22: Touchpad Ball Test

22

Page 25: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Chapter 3

Summary of Progress

3.1 Plan

The basic project plan remains unchanged: upon completion, the system should autonomously balance aball on a plate. To that end, the system has been modelled and linearized, and a controller designed aroundthe dynamics of the ball and the two-axis pan-tilt mechanism.

Plans also remain in place to allow the system to put the ball into different planned paths, including forexample a circle or a figure-eight shape. Further development could also involve a graphical user interface.

3.2 Schedule

To date, progress has been as scheduled with only minor glitches or setbacks during the construction anddevelopment. Of note is the construction of the physical system in the RPI Student Machine Shop, which tooksignificantly longer than originally thought. The end result is acceptable for our system, though it remainsto be tested as a complete system. Other steps, however, proceeded as planned: model development, frictionid, validation and control system development all on schedule, as evidenced by the results detailed previouslyin this report.

The remainder of the schedule remains as originally planned, shown in Table 3.1. This week is devotedto sensor integration and control system testing and development. The real work now is focused on thecompletion of the physical system with sensors, and the testing of the simulated control system against afully working real system. If things proceed as desired, ball balancing should occur within the next week ortwo, proceeding thus to planned ball trajectories.

23

Page 26: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Table 3.1: Remaining scheduleWeek Task Member

Week 10 Integration of sensors AaronControl system testing Greg

Sensor testing ChrisWeek 11 Static ball balancing TeamWeek 12 Complex path following TeamWeek 13 Work on final report Team

Final demonstration TeamWeek 14 Work on final report Team

Final presentation TeamWeek 15 Final report Team

3.3 Cost

Costs have remained as originally planned, mostly due to a large allowance for aluminum usage duringconstruction of the yoke and axis. This previously conceived overestimate turned out to be quite accurate,due to errors made during machining. In fact, several pieces of the yoke and axle had to be completelyremade due to errors.

One item of mention not previously introduced in the project proposal is a Lexan panel. The touch padsensor is constructed with a glass substrate, and while stiff, glass is not shatterproof. It was the consensusof the team members that during testing, a Lexan panel stand in as the sensor plate, so that the expensiveand difficult to source touch sensor was not damaged. This plate will also serve as protection for the touchsensor during operation, and perhaps as a stiffener, providing structural support to the sensor.

A new tilt axis belt was also purchased because of the changes made to the dimensions of the yoke. Due tothe uncertainty of the outcome of the machining process, the belt purchase was put off until recently, to becertain of choosing the correct size. The new belt ties directly into the new tilt drive system, made possibleby using a remanufactured tilt motor bracket from last year’s project. This also saved significant machiningtime.

3.4 Unanticipated Challenges

Several unanticipated challenges have come up during system development. Of particular concern involvesthe required torque for normal system operation. During testing, it was realized that the magnitude of torquerequired by the system was larger than expected, approaching or exceeding the saturation point of the motordrivers. Further testing is planned to ascertain if the system is feasible with the drivers configured as theyare currently, or if the D/A+Motor driver system might have to be tweaked to generate more amperage.

A further controller-related challenge is related to the observer design. Several initial implementations failedto work as well as the basic finite difference. This is obviously a problem related to the placement of thepoles or the implementation in Simulink, and should be corrected upon further discussion on the topic withProfessor John Wen.

24

Page 27: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Table 3.2: List of partsItem Qty Cost Total Source

1 1/4” diam. 440C stainless ball 1 $9.17 $9.17 McMaster-CarrDynapro 95640 10.4” 8-wire resistive touch pad 1 $39 $39 Ebay

Pittman motor GM9234S017 (pan) 1 $97.59 $97.59 SuppliedPittman motor GM9234S017 (tilt) 1 $97.59 $97.59 Supplied

Pan gear A 1 $9.97 $9.97 SuppliedPan gear B 1 $22.02 $22.02 SuppliedTilt gear A 1 $7.95 $7.95 SuppliedTilt gear B 1 $22.02 $22.02 SuppliedPan belt 1 $3.92 $3.92 SuppliedTilt belt 1 $3.55 $3.55 www.sdp-si.com

Misc screws $5.00 $5.00 Home DepotTotal $269.61

Table 3.3: List of raw materialsItem Qty Cost Total Source

1/2” aluminum stock 5 lb $4/lb $20 RPI Machine Shop1/16” latex rubber membrane 1 $9.38 - 12”x12” $9.38 McMaster-Carr

.093” Lexan panel 1 $5.00 - 8”x10” $5.00 Home DepotTotal $34.38

Table 3.4: Labor costsDescription Hours Cost Total

Andrews, Greg (engineer) 300 $35/hr $10,500Colasuonno, Chris (engineer) 300 $35/hr $10,500Herrmann, Aaron (engineer) 300 $35/hr $10,500Caskey, Ryan (machinist) 30 $35/hr $1,050

Total 930 $32,550

25

Page 28: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

An unanticipated challenge presented itself during the machining of the yoke and axle. Despite a strictattention to detail for all of the dimensions of the parts, a simple detail was misunderstood with regardto the axle bearings. Upon discussion with TA Benjamin Potsaid, it became apparent that the holes forthe axle bearings needed to be slightly smaller than needed, so as to press fit the bearings. However, theholes made are in fact exactly to size, yielding a loose fit. This isn’t expected to impact the performance ofthe system simply because the system is not meant to spin, merely to rotate back and forth through smallangular displacements.

In the area of subsystem development, the expectation was that A/D conversion for the generation of touchpad coordinates would be done by the analog inputs of the xPC Target computer. However, comprehendingthe outputs from the touch pad itself proved difficult at best. Since the controller included with the purchasedtouch pad worked, an xPC Target based serial port interface system was created to interface with thecontroller and generate ball coordinates for the control system.

Another challenge related to the touchpad is the configuration of the serial controller. Several attempts havebeen made to change the averaging, settling time and baud rate settings of the controller with zero success.Though the timing and format of the messages are known, the controller seems to ignore the settings. Itis not yet known whether this is merely an error in the controller, or merely a failure to understand themessage formats. However, successfully configuring the controller could yield a significant improvement inthe sampling period of the ball coordinate generation system.

A challenge that has recently come to light is the zeroing of the axes upon system startup. Simplicitydictates that development forego the usage of inclinometers, simply to make the work easier. However, ithas proven difficult to get the axes initially perfectly zeroed for just a test of the pan axis. Once the systemis physically completed and testing of the balancing system commence, finding a zero point could prove tobe difficult. And if that measurement isn’t correct, the error trickles through all of the systems: gravitycompensation is wrong, encoder angles are wrong. Ultimately, the answer might very well be to create a jigfor the inclinometers that allows a quick startup configuration and then the subsequent removal of the jigduring a test.

3.5 Forecast

A reasonable forecast for the remainder of the project suggests that at the very least, we will complete thebalancing problem. Whether or not the system can be made to overcome the present challenges and trackout a ball path is still unknown, though the group is willing to put in the time to make certain it can. Allthat remains to be seen is what the controller is capable of, and what it can be made to do with propertesting and tuning.

26

Page 29: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Chapter 4

Statement of Contribution

For the progress report document:

Greg completed the following sections:

• Model development

• Controller development

Chris completed the following sections:

• Validation

• Friction Identification

• Friction & Gravity Cancellation

Aaron completed the following sections:

• Abstract

• Introduction

• Subsystem Development

• Summary of Progress

Greg Andrews Chris Colasuonno Aaron Herrmann

x x x

27

Page 30: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Bibliography

[1] 3M Touch Systems. SC3 Touch Screen Controller: User’s Guide, 2nd edition, 2003.

[2] Dr. Murat Arcak. Discrete time systems - lecture notes. 2003.

[3] No Author Available. Control tutorials for matlab: Modeling the ball and beam experiment. AvailableWWW: http://wolfman.eos.uoguelph.ca/∼jzelek/matlab/ctms/examples/ball/ball.htm.

[4] No Author Available. Control tutorials for matlab: State space tutorial. Available WWW: http://www.engin.umich.edu/group/ctm/state/state.html.

[5] No Author Available. Digital control example: Inverted pendulum using state space method. AvailableWWW: http://wolfman.eos.uoguelph.ca/∼jzelek/matlab/ctms/examples/pend/diginvss.htm.

[6] S. Awtar, C. Bernard, N. Boklund, A. Master, D. Ueda, and K. Craig. Mechatronic design of a ball-on-plate balancing system. Technical report, Rensselaer Polytechnic Institute, 2002.

[7] Graham Goodwin, Stefan Graebe, and Mario Salgado. Control system design - ball-on-plate tutorial.Available WWW: http://csd.newcastle.edu.au/control/simulations/ball sim.html, 2001.

[8] C. Phillips and H. Nagle. Digital control system analysis and design, third edition. Technical report,Prentice Hall, Inc., 1995.

28

Page 31: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

Appendix A

MATLAB Code

% Greg Andrews% System Linearization and Control System setup% March 15, 2004% Control System Design

%Symbolic Variablessyms mA mB g t1 t2 lcA1 lcA2 lcA3 lcB1 lcB2 lcB3 Im1 Im2 N1 N2syms IA11 IA12 IA13 IA21 IA22 IA23 IA31 IA32 IA33 syms IB11 IB12IB13 IB21 IB22 IB23 IB31 IB32 IB33

%Gravity VectorG1=-mA*g*sin(t1)*lcA1-mA*g*cos(t1)*lcA2-mB*g*sin(t1)*cos(t2)*lcB1-mB*g*cos(t1)*lcB2-mB*g*sin(t1)*sin(t2)*lcB3;G2= -mB*g*cos(t1)*sin(t2)*lcB1+mB*g*cos(t1)*cos(t2)*lcB3;

%Gradient of the Gravity Vectorpartial_G=[diff(G1,’t1’) diff(G1,’t2’); diff(G2,’t1’)diff(G2,’t2’)];

%Mass-Inertia MatrixM11=IA33+mA*lcA1^2+mA*lcA2^2+Im1*N1^2+IB11-IB11*cos(t2)^2+mB*lcB2^2+mB*lcB3^2-mB*lcB3^2*cos(t2)^2-2*sin(t2)*cos(t2)*IB13+2*sin(t2)*cos(t2)*mB*lcB1*lcB3+cos(t2)^2*IB33+cos(t2)^2*mB*lcB1^2;M12=-sin(t2)*IB12+sin(t2)*mB*lcB1*lcB2+cos(t2)*IB23-cos(t2)*mB*lcB2*lcB3;M21=-sin(t2)*IB12+sin(t2)*mB*lcB1*lcB2+cos(t2)*IB23-cos(t2)*mB*lcB2*lcB3;M22= IB22+mB*lcB1^2+mB*lcB3^2+Im2*N2^2;

29

Page 32: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

M=[M11 M12; M21 M22];

%---------------------------------------------------% Numerical Parametersg=9.81; Im1=11.5; Im2=11.5;

mA = 0.9690; % mass of link A in KglcA1 = .0016; % distance to COMlcA2 = -.0401; lcA3 = -.1367;

mB = 0.3872; lcB1 = -.0028; lcB2 = -.0406; lcB3 = .0003;

N1=2*11.5; % total gear ratioN2=4*11.5;

IA11 = .027716; % inertiaIA12 = -.000122; IA13 = -.000253; IA21 = -.000122; IA22 = .020929;IA23 = .006546; IA31 = -.000253; IA32 = .006546; IA33 = .007022;

IB11 = .004464; IB12 = 0; IB13 = -.000001; IB21 = 0; IB22 =0.001030; IB23 = 0; IB31 = -0.000001; IB32 = 0; IB33 = .003540;

fc1 = .097; % frictionfv1 = .0019; fv2 = 0.00784; fc2 = 0.00784;

t1=0; t2=0;

G_lin=vpa(subs(partial_G)); M_lin=vpa(subs(M)); Fv=[fv1 0; 0 fv2];

Astuff1=-inv(M_lin)*G_lin; Astuff2=-inv(M_lin)*Fv;

% State space representationA=[0 0 1 0; 0 0 0 1; Astuff1(1,1) Astuff1(1,2) Astuff2(1,1)Astuff2(1,2); Astuff1(2,1) Astuff1(2,2) Astuff2(2,1)Astuff2(2,2)]; A=subs(A); B=[0 0; 0 0; 1 0; 0 1]; C=[1 0 0 0; 0 10 0]; D=[0 0; 0 0]; sys_c=ss(A,B,C,D); sys_d=c2d(sys_c,.0001);

% LQRw1=1000; w2=1000; w3=1; w4=1; Q=[w1 0 0 0;

0 w2 0 0;0 0 w3 0;0 0 0 w4];

R=.5*eye(2);

30

Page 33: BALL ON PLATE BALANCING SYSTEM Progress Report for ECSE ...cats-fs.rpi.edu/~wenj/ECSE4962S04/progress/progressreportgroup2.pdf · the ball and beam system seems to be a more popular

K=lqr(A,B,Q,R);

% ObserverPL=[-1000 -1001 -1002 -1003]; L=place(A’,C’,PL)’;Aobs=(A-B*K-L*C); Bobs=L; Cobs=K; Dobs=D;Obs=ss(Aobs,Bobs,Cobs,Dobs); Ts=.0001; Obs=c2d(Obs,Ts);

31