Ball and Beam Workbook (Student)
Ball and Beam Workbook (Student)
Course material
complies with:
where mb is the mass of the ball, x is the ball displacement, Fx,r is the force from the ball’s inertia, and Fx,t is the
translational force generated by gravity. Friction and viscous damping are neglected.
Modeling Conventions:
• Applying a positive voltage causes the servo load gear to move in the positive, counter-clockwise (CCW)
direction. This moves the beam upwards and causes the ball to roll in the positive direction (i.e. away from
the servo towards the left). Thus Vm > 0 → θ̇l > 0 → ẋ > 0.
• Ball position is zero, x = 0, when located in the center of the beam.
• Servo angle is zero, θl = 0, when the beam is parallel to the ground, α = 0.
For the ball to be stationary at a certain moment, i.e. be in equilibrium, the force from the ball’s momentum must be
equal to the force produced by gravity. The force caused by the rotation of the ball is
τb
Fx,r = (1.2)
rb
Applying the sector formula we can convert between linear and angular displacement and get x(t) = γb (t) rb . The
force acting on the ball in the x direction from its momentum in (Equation 1.2) becomes
Jb ẍ(t)
Fx,r = . (1.3)
rb2
The gravitational force acting on the ball in the x direction can be found from Figure 1.1.
2. Obtain the nonlinear equation of motion. This equation should be in the form: ẍ = f (α).
3. Find the moment of inertia of the ball based on its mass, mb , and radius, rb . Apply it to the equation of motion
found and simplify the expression. If the ball doubled in size and mass, how would it affect the equation?
6. Find the transfer function, P (s), of the complete Ball and Beam system that represents the position of the ball
with respect to the input motor voltage of the servo. Assume all initial conditions are zero.
1. Build and run the QUARC controller. Make sure 0 V is applied to the servo.
2. The potentiometer outputs a ±5 V signal proportional to the position of the ball. To confirm this, move the ball
along the beam and examine the voltage. Record what voltage is being measured at the left and right limits
as well as in the center.
3. Determine the sensor gain required to measure the position of the ball in meters and according to the model
convention shown in Figure 1.1. The beam is 16.75 inches long.
4. Enter the sensor gain you found in the BB01 Sensor Gain. Move the ball from end-to-end. Make sure the ball
position measurement is as expected (i.e. follows the modeling conventions). Attach a response of the ball
moving along the beam from right to left, i.e. away from the servo.
5. Make sure the servo voltage and angle measurement follow the model conventions. Modify the Simulink
diagram if necessary. For the test, slowly increase the Slider Gain until enough voltage is supplied to rotate
the servo. Initially, it is recommended to disconnect the Ball and Beam module prior to doing this to make
sure the servo rotates in the expected direction. Attach responses showing the voltage, servo angle, and ball
position when a positive voltage is applied. Record any actuator and sensor gains used and give briefly explain
why the gains had to be set to those value.
6. Stop the QUARC controller.
7. Shut off the power amplifier is no more experiments are to be performed in this session.
1.4 Results
Fill out Table Table 1.1 below with your answers to the Pre-Lab questions and your results from the lab experiments.
Table 1.1: Summary of results for the Ball and Beam modeling laboratory.
The Rotary Servo transfer function models the servo load gear position, θl (t), with respect to the servo input voltage,
Vm (t). This transfer function was found to be:
Θl (s) K
Ps (s) = = (2.2)
Vm (s) s (τ s + 1)
where K = 1.5 rad/s/V is the model steady-state gain and τ = 0.025 s is the model time constant. If desired, you
can conduct an experiment to find more precise model parameters, K and τ , for your particular servo. See Rotary
Servo Modeling laboratory experiment laboratory for more information.
2.1.2 Specifications
The steady-state error, 4% settling time, and percentage overshoot specifications for controlling the position of the
ball are:
|ess | ≤ 0.5 cm (2.3)
ts ≤ 3.0 s (2.4)
P O ≤ 5.0 % (2.5)
Thus, given a step reference, the peak position of the ball (i.e. percentage overshoot) should not exceed 5%. After
3.0 seconds, the ball should settle within 4% of its steady-state value (i.e. not the reference) and the steady-state
should be within 5 mm of the desired position.
For a second-order under damped system, the settling time and percent overshoot equations are
√
ln (cts 1 − ζ 2 )
ts = − (2.6)
ζ ωn
and
√−πζ
P O = 100e 1−ζ 2 (2.7)
where ωn is the natural frequency ζ is the damping ratio.
To design the ball position control, assume that the inner servo loop is ideal and therefore
Given the assumption that Θl (t) = Θd (t), substitute the control Equation 2.9 into the Ball and Beam plant transfer
function Equation 2.1 and solve for X(s)/Xd (s) to obtain the closed-loop transfer function
X(s) Kbb Kc (s + z)
= 2 (2.10)
Xd (s) s + Kbb Kc s + Kbb Kc z
In Figure 2.1, z and Kc are the zero location and the gain for the controller, respectively. We can compute the value
for z to meet the settling time and overshoot specifications. Also, we can find the value of Kc to satisfy a given
natural frequency and damping ratio.
Y (s) ωn2
= 2 (2.11)
R(s) s + 2ζωn s + ωn2
By matching the coefficients of the denominator of this equation to those in Equation 2.10, we can find the
expressions for z and Kc to meet a certain ωn and ζ:
ωn2
z= (2.12)
Kbb Kc
and the gain must be
2ζωn
Kc = (2.13)
Kbb
Note: The closed-loop transfer function of the Ball and Beam given in Equation 2.10 does not strictly match the
prototype second-order system because it has a zero in the numerator. This will cause a slight difference in the
expected behaviour. However, this is permissible given that the control design will be tested in simulation to ensure
the specifications are met prior to implementing the control on the actual system.
Adding Filtering
The position of the ball is measured using an analog sensor and it has some inherent noise. Taking the derivative
of this type of signal would output results in an amplified high-frequency signal that is eventually fed back into the
motor and causes a grinding noise. As illustrated by H(s) in Figure 2.2, this is prevented by using a high-pass filter.
The first-order filter replaces the derivative in Figure 2.1 and has the form
ωf s
H(s) = (2.14)
s + ωf
2. Using Figure 2.3, find the closed-loop transfer function of the Ball and Beam system with proportional control
Cbb (s) = Kc .
3. Plot the root locus of the Ball and Beam forward loop plant transfer function Pbb (s). Describe how the poles
behave as Kc goes to infinity.
4. Find the natural frequency and damping ratio required to achieve the time-domain specifications of the Ball
and Beam plant given in Section 2.1.2.
5. After you plot the root locus of the Ball and Beam plant Pbb (s), describe where the poles should be to satisfy
the desired response specifications.
6. Discuss the response if the poles lie beyond the radius circle along the diagonal lines, i.e. away from the
imaginary axis. Also, comment on what happens if the poles of the system lie inside the diagonal lines along
the radius circle, i.e. moving towards the real axis. Make references to its effects on the settling time and
overshoot of the response.
7. Based on the root locus obtained, can the specifications of the Ball and Beam system be satisfied using a
proportional controller? Discuss.
8. Applying the PD controller Cbb (s) = Kc (s + z) to the system as shown in Figure 2.1. Find the Ball and Beam
error transfer function.
9. Find the steady-state error of the Ball and Beam closed-loop system with the traditional PD controller. Can the
steady-state error requirement in Equation 2.3 be satisfied?
10. Based on the expressions found in Equation 2.12 and Equation 2.13, evaluate numerically the zero location
and gain needed to satisfy the specifications.
Figure 2.4: Simulink diagram used to simulate Ball and Beam system
The nonlinear model of the Ball and Beam was described in Section 1. This is implemented in the Ball and Beam
Model subsystem shown in Figure 2.5. Notice that we are using both the Rotary Servo model and the Ball and Beam
model here (i.e. not only the Ball and Beam system).
Simulation procedure:
r
1. Enter the Ball and Beam model gain found in Pre-Lab question 5 in the M Command Window as variable
K_bb (e.g. type K_bb = 1 in the Matlab prompt).
r
2. Create the open-loop transfer function of the Ball and Beam plant in M as P_bb. Then enter command
sisotool(P_bb) to load the SISO Control Design software tool. The interface should looking similar as shown
in Figure 2.6.
3. As shown in the Step Response window, the response is very oscillatory. Select the Root Locus Editor window
and go to the Root Locus Editor in the toolbar. Add a zero along the real-axis in the left-hand plane. The
response should change similarly as shown in Figure 2.7.
4. You can now add the control requirements by right-clicking on the Root Locus Editor Window and selecting
Design Requirements | New. Add the Percent Overshoot and Settling Time given in Section 2.1.2. The Root
Locus Editor with these addded requirements is shown in Figure 2.8.
5. Move the zero location and the adjust the gain by moving the poles, i.e. the red squares, until the poles are
at the intersection of the settling time and percent overshoot requirements. The zero location and gain where
the poles go through the desired locations should be close to what was computed in Pre-Lab question 10.
6. Run the simulation with the zero location and compensator gain found. The scope response yielded should
r
look similar as shown in Figure 2.9. Generate a M figure showing the ball position, servo angle, and
input voltage responses.
7. Measure the steady-state error, settling time, and percent overshoot. Do they satisfy the specifications without
saturating the motor, i.e. going beyond ± 10 V, or going beyond ± 56 degrees?
r
Hint: Use the Cursor Measurement Tool in S Scope to take measurements.
8. Give a reason why the designed control gains could fail to give a successful closed-loop response on the actual
system.
2.4 Results
Fill out Table Table 2.1 below with your answers to the Pre-Lab questions and your results from the lab experiments.
Table 2.1: Summary of results for the Ball and Beam Control Designa and Simulation laboratory.
Compared to the original PD control proposed in Figure 2.2, this includes an offset adjustment for the servo angle
to help eliminate the steady-state error from imprecise mechanical calibration.
Note: Adding an integral control to the outer-loop ball position feedback can also address this, but this often leads
to undesirable overshoot and settling time.
Important: Follow the setup and wiring procedure in the Ball and Beam User Manualand make sure the Ball and
Beam system is calibrated. The ball should be remain in the center of the beam when the servo is at angle zero.
Figure 3.2: Simulink/QUARC model that implements the ball position control on Ball and Beam system
3. Run the controller with the PD gains found in Section 2 (i.e. make sure you use the final, tuned parameters).
The ball should stabilize to the middle of the beam and read close to 0 cm. If not, adjust the Theta Cmd Offset
block such that the ball is centered and reading 0 cm. See the sample response in Figure 3.3
r
4. Generate a M figure showing the the ball position, servo angle, and input voltage responses.
5. Measure the steady-state error, settling time, and percent overshoot. Do they satisfy the specifications without
saturating the motor, i.e. going beyond ± 10 V, or going beyond ± 56 degrees?
6. If the response did not match, tune your control gains to obtain one that matches the specifications and/or try
to recalibrate the system - both mechanically and by adjusting the Theta Cmd Offset (deg). Record your new
gains and briefly described the procedure used to find them. Attach the response.
9. Shut off the power amplifier is no more experiments are to be performed in this session.
3.3 Results
Fill out Table Table 3.1 below with your answers to the Pre-Lab questions and your results from the lab experiments.
Table 3.1: Summary of results for the Ball and Beam laboratory.
Table 4.1: Files supplied with the Ball and Beam laboratory.
r
1. Load the M software.
2. Browse through the Current Directory window in Matlab and find the folder that contains the Ball and Beam
controller files.
3. Double-click on the s_ball_beam_control file to open the Simulink diagram shown in Figure 2.4.
4. Double-click on the setup_ball_beam.m file to open the setup script for the Ball and Beam Simulink models.
5. Configure setup script: When used with the shortprod, the Rotary Servo must be in the high-gear config-
uration and no load is to be specified. Make sure the script is setup to match this configuration, i.e. the
r
6. Run the script. The following output should be see in the M prompt:
Follow these steps to get the system ready for this lab:
1. Setup the Rotary Servo with the Ball and Beam module as detailed in Ball and Beam User Manual.
r
2. Load the M software.
r
3. Browse through the Current Directory window in M and find the folder that contains the QUARC Ball
and Beam control file q_ball_beam_control.
4. Double-click on the q_ball_beam_control file to open the Ball and Beam Control Simulink diagram shown in
Figure 3.2.
5. Configure DAQ: Ensure the HIL Initialize block in the Ball and Beam Hardware Interface subsystem is configured
for the DAQ device that is installed in your system. By default, the block is setup for the Quanser Q2-USB
data-acquisition (DAQ) device. .
6. Configure setup script: Set the parameters in the setup_ball_beam.m script according to your system setup.
See Section 4.2 for more details.
7. Run the script.
For each experiment, follow the outline corresponding to that experiment to build the content of your report. Also,
in Section 5.4 you can find some basic tips for the format of your report.
1. Implementation
• Briefly describe the main goal of lab portion of modeling the system.
• Briefly describe the hardware interfacing procedure (Section 1.3)
II. RESULTS
Do not interpret or analyze the data in this section. Just provide the results.
III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:
IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions for the following:
1. Whether the hardware follows the modeling conventions in step 5 in Section 1.3.
1. Simulation
• Briefly describe the main goal of the control design and simulation.
• Briefly describe the control design and simulation procedure (Section 2.3)
II. RESULTS
Do not interpret or analyze the data in this section. Just provide the results.
1. Response plot from step 6 in Section 2.3, Simulation of PD ball position control
III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:
3. Steady state error, the settling time and percent overshoot in step 7 in Section 2.3, Simulation of PD ball
position control
4. Reasons why the control specifications are not met in step 8 in Section 2.3
IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions for the following:
1. Whether the controller meets the specifications in step 7 in Section 2.3, Simulation of PD ball position control
1. Implementation
• Briefly describe the main goal of this experiment.
• Briefly describe the experimental procedure (Section 3.2).
II. RESULTS
Do not interpret or analyze the data in this section. Just provide the results.
1. Response plot from step 4 in Section 3.2, for Implementation of PD ball position control.
2. Response plot from step 6 in Section 3.2, for Implementation of tuned PD ball position control.
3. Provide applicable data collected in this laboratory (from Table 3.1).
III. ANALYSIS
Provide details of your calculations (methods used) for analysis for each of the following:
1. Steady state error, the settling time and percent overshoot in step 5 in Section 3.2, Implementation of PD ball
position control.
2. Control tuning method in step 6 in Section 3.2.
3. Steady state error, the settling time and percent overshoot in step 7 in Section 3.2, Implementation of tuned
PD ball position control.
IV. CONCLUSIONS
Interpret your results to arrive at logical conclusions for the following:
1. Whether the controller meets the specifications in step 5 in Section 3.2, Implementation of PD ball position
controller.
• Has cover page with all necessary details (title, course, student name(s), etc.)
• Each of the required sections is completed (Procedure, Results, Analysis and Conclusions).
• Typed.
• Tables are numbered, they include labels, each table has a descriptive caption.
• Data are presented in a useful format (graphs, numerical, table, charts, diagrams).
• No hand drawn sketches/diagrams.
Quanser Inc.
119 Spy Court
Markham, Ontario
L3R 5H6
Canada
[email protected]
Phone: 1-905-940-3575
Fax: 1-905-940-3576
For more information on the solutions Quanser Inc. offers, please visit the web site at:
http://www.quanser.com
This document and the software described in it are provided subject to a license agreement. Neither the software nor this document may be
used or copied except as specified under the terms of that license agreement. All rights are reserved and no part may be reproduced, stored in
a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior
written permission of Quanser Inc.
This product meets the essential requirements of applicable European Directives as follows:
• 2006/95/EC; Low-Voltage Directive (safety)
• 2004/108/EC; Electromagnetic Compatibility Directive (EMC)
Quanser’s rotary collection allows you to create experiments of varying complexity – from basic to advanced. Your lab
starts with the Rotary Servo Base Unit and is designed to help engineering educators reach a new level of efficiency
and effectiveness in teaching controls in virtually every engineering discipline including electrical, computer, mechanical,
aerospace, civil, robotics and mechatronics. For more information please contact [email protected].
©2015 Quanser Inc. All rights reserved.