Ball and Beam Dynamics
Introduction
This report does not omit any mathematical steps in order to reflect upon details of the mechanical operation of the process.
1. The Process
The ball and beam model consists of a horizontal beam and a DC motor mechanically attached at the centre of the beam. The angle of the beam is controlled by the motor. The angle in turn influences the position of the ball.
2. Mathematical Model Composition
The process model can be broken down into two separate models
a. Model of the angle process with respect to the motor voltage H φ(s)
b. Model of the ball position with respect to the beam angle Hx(s)
The total transfer function from the input voltage to the voltage that indicates the ball position is then
3. Mathematical Model Derivation
a. Model of beam angle vs. input voltage
The relationship between the input voltage and the angle of the beam is defined by the DC motor transfer function. The DC motor, used for angle control application may be thought of as the ‘dirty integrator’ or the integrator with a filter action as shown in figure 1 on the next page.
Figure 1: General DC motor block diagram for angle control application
The K is the motor constant and the tau is the motor time constant. The actual model of the motor used for the project is shown in figure 2.
Figure 2: Actual block diagram of the DC motor used
The measured constants are summarized below:
Therefore the DC motor transfer function becomes
b. Model of ball position vs. beam angle
Consider the following sketch
Figure 3: Rolling ball free-body diagram
The inclination is considered the x-coordinate.
Let acceleration of the ball be denoted as
The force due to translational motion is then
The torque developed through ball rotation is determined by the force at the edge of the ball multiplied by the radius which can be further expressed as:
where
J = moment of inertia (for solid ball defined by J=2/5*mR2)
Wb=angular velocity of the ball
Vb= speed of the ball along x axis
The equation is arranged such that the final result is expressed solely in terms of position or its derivatives as well as variables associated with the ball.
We now obtain the rotational force by dividing torque of the ball by its radius
substituting the moment of inertia into the equation we get
In order to make the system independent of the mass of the ball we further express the above equations as
rearranging for x’’ gives
we utilize approximation , since the angle of the beam will not exceed 20-30 degree inclination. This means that in radians, sine of the angle is approximately the angle itself, so the equation is further approximated as
taking Laplace transform of position with respect to angle (details omitted) gives
The constant in the numerator was measured manually and closely matches theory. Therefore
Now the overall transfer function of the system becomes
where, 10.5 is an approximated constant.
The block diagram of the overall system is
Figure 4: Entire system block diagram
The MATLAB provides easy conversion of the system into state space.
> num=[0 0 0 0 80.9];
> den=[0.4 1 0 0 0];
> [A, B, C, D]=tf2ss(num, den)
The LQR control can be implemented by choosing Q and R values. The controllability is verified first as follows:
> rank(ctrb(A, B))
ans =
4
This indicates that the ball and beam system is completely state controllable. Next we select Q and R and calculate for controller gains in MATLAB. We get
> Q=[1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1];
> R=1;
> [K,S,E]=lqr(A,B,Q,R)
K =
1.7135 5.2519 3.3917 1.0000
S =
1.7135 5.2519 3.3917 1.0000
5.2519 18.7371 13.2911 4.2135
3.3917 13.2911 13.5993 5.2519
1.0000 4.2135 5.2519 3.3917
E =
-2.6696
-0.6931
-0.4254 + 0.5996i
-0.4254 - 0.5996i
We can see that the gain values are reasonable and therefore the actual system may perform well.
The simulation in simulink is done using the following block diagram:
Figure 5: Simulink state space model
The Scope measures the output while the Scope1 monitors the control effort. The snapshots are as shown in figures 6 and 7.
Figure 6: Output converging from IC
Figure 7: Control effort
The initial condition was set to 10cm from the centre at an angle of 5.7 degrees. It is can be seen that the system converges very slowly.
The state variables are:
- angular acceleration
- angle of the beam
- ball acceleration
- position of the ball
The position and the angle can be measured directly with sensors while the angular acceleration and the ball acceleration will have to be mathematically estimated. The control voltage V is then
NON-LINEAR MODEL simulation
The non-linear model is built directly from the differential equations block by block. The model is not much different from the linear approximation and behaves in much the same way. The model appears in figure 8.
Figure 8: Non-linear ball and beam model
The initial conditions can be entered inside the integrator blocks to observe the performance of the system. This model can now be simulated in place of the state-space block as shown in figure 9.
Figure 9: Simulated nonlinear state-space model
The results with exact same initial conditions (x=10cm, alpha=5.7 degrees) are reflected in figures 10 and 11.
Figure 10: Angle converging from initial condition
Figure 11: Position converging from initial condition
The slight difference between the nonlinear model and the linear one is that the non-linear model exhibits still slower convergence rates.