CMU
UM


Example: Solution to the Ball & Beam Problem Using PID Control

Closed-loop Representation
Proportional Control
Proportional-Derivative Control

The open-loop transfer function of the plant for the ball and beam experiment is given below:

The design criteria for this problem are:

To see the derivation of the equations for this problem refer to the ball and beam modeling page.

Closed-loop Representation

The block diagram for this example with a controller and unity feedback of the ball's position is shown below:

First, we will study the response of the system shown above when a proportional controller is used. Then, derivative and/or integral control will be added if necessary.

Recall, that the transfer function for a PID controller is:

Proportional Control

The closed-loop transfer function for proportional control with a proportional gain (kp) equal to 100, can be modeled by copying the following lines of Matlab code into an m-file (or a '.m' file located in the same directory as Matlab)


NOTE: Matlab commands from the control system toolbox are highlighted in red.

You numerator and denominator should be:

Now, we can model the system's response to a step input of 0.25 m. Add the following line of code to your m-file and run it:

You should get the following output:

As, you can see the addition of proportional gain does not make the system stable. Try changing the value of kp and note that the system remains unstable.

Proportional-Derivative Control

Now, we will add a derivative term to the controller. Copy the following lines of code to an m-file and run it to view the system's response to this control method.

Your plot should be similar to the following:

Now the system is stable but the overshoot is much too high and the settling time needs to go down a bit. From the PID tutorial page in the section on characteristics of P, I, and D controllers, we see that by increasing kd we can lower overshoot and decrease the settling time slightly. Therefore, make kd = 20 in your m-file and run it again. Your output should be:

The overshoot criterion is met but the settling time needs to come down a bit. To decrease the settling time we may try increasing the kp slightly to increase the rise time. The derivative gain (kd) can also be increased to take off some of the overshoot that increasing kp will cause. After playing with the gains a bit, the following step response plot can be achieved with kp = 15 and kd = 40:

As you can see from the above plot all the control objectives have been met without the use of an integral controller (settling time for this example is considered achieved when the response is less than 2% of it's final value). Remember, that for a control problem there is more than one solution for the problem.

For other methods of controlling the ball and beam example, see the root locus, frequency response, and state-space links below.


User Feedback

We would like to hear about suggestions you have for improvement, difficulties you had with the tutorials, errors that you found, or any other comments that you have. This feedback is anonymous.


PID Examples
Cruise Control | Motor Speed | Motor Position | Bus Suspension | Inverted Pendulum | Pitch Controller | Ball & Beam

Ball & Beam Examples
Modeling | PID | Root Locus | Frequency Response | State Space | Digital Control

Tutorials

Basics | Modeling | PID | Root Locus | Frequency Response | State Space | Digital Control | Examples

8/12/97 CJC