Solution to the Ball & Beam Problem Using PID Control
The open-loop transfer function of the plant for the ball and beam experiment is given below:
- Settling time less than 3 seconds
- Overshoot less than 5%
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:
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)
.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;
.....K = (m*g*d)/(L*(J/R^2+m)); %simplifies input
.....num = [-K];
.....den = [1 0 0];
.....kp = 1;
.....numP = kp*num;
.....[numc, denc] = cloop(numP, den)
You numerator and denominator should be:
.....numc =.....
..... 0 0 0.2100
.....denc =
..... 1.0000 0 0.2100
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:
.....step(0.25*numc,denc)
You should get the following output:
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.
.....m = 0.111;
.....R = 0.015;
.....g = -9.8;
.....L = 1.0;
.....d = 0.03;
.....J = 9.99e-6;
.....K = (m*g*d)/(L*(J/R^2+m)); %simplifies input
.....num = [-K];
.....den = [1 0 0];
.....kp = 10;
.....kd = 10;
.....numPD = [kd kp];
.....numh = conv(num, numPD);
.....[numc, denc] = cloop(numh, den);
.....t=0:0.01:5;
.....step(0.25*numc,denc,t)
Your plot should be similar to the following: