|
|
Open-loop poles
LQR design
Observer design
The state equations for this problem are:
The design criteria (with the pendulum receiving a 1N impulse force from the cart) are:
This problem can be solved using the control-law for full state feedback. This type of controller has two added elements: the control law and the estimator. The schematic of the state-space design elements is shown below.
In this problem r(t) represents the force applied to the cart; this force will be simulated by an impulse to model the cart receiving a bump. The 4 states represent the position and velocity of the cart and the angle and angular velocity of the pendulum. The output y(t) contains both the position of the cart and the angle of the pendulum; we will assume that we can only measure the angle of the pendulum, and that this is the output we want to regulate. We want to design a controller so that when an impulse input is given to the system, the pendulum should be displaced, but eventually return to zero (i.e. the vertical). Although we will focus our design on balancing the pendulum, the cart will also be moving.
The first step in designing this type of controller is to determine the open-loop poles of the system. Enter the following lines of code into a m-file (or a '.m' file located in the same directory as Matlab):
M = 0.5;
m = 0.2;
b = 0.1;
i = 0.006;
g = 9.8;
l = 0.3;
p = i*(M+m)+M*m*l^2; %denominator
A = [0 1 0 0;
0 -(i+m*l^2)*b/p (m^2*g*l^2)/p 0;
0 0 0 1;
0 -(m*l*b)/p m*g*l*(M+m)/p 0];
B = [0; (i+m*l^2)/p; 0; m*l/p];
C = [1 0 0 0;
0 0 1 0];
D = [0;0];
p = eig(A)
The Matlab command window should output the following text as a result:
The next step in the design process is to assume that we have full-state feedback (i.e. that we can measure all four states), and find the vector K which determines the feedback control law. This can be done in a number of ways. If you know the desired closed-loop poles, you can use the place or acker command. Another option is to use the lqr function; this will give you the optimal controller (under certain assumptions; consult your textbook for more details). The lqr function allows you to choose two parameters, R and Q, which will balance the relative importance of the input and state in the cost function that you are trying to optimize. The simplest case is to assume R=1, and Q=C'*C. You may notice that we are using both outputs (the pendulum's angle and the cart's position). Essentially, the lqr method allows for the control of both outputs. In this case, it is pretty easy to do. The controller can be tuned by changing the nonzero elements in the Q matrix to get a desirable response. To find the structure of Q, enter the following into the Matlab command window:
The curve in purple represents the pendulum's angle, in radians. As you can see, this plot is still not satisfactory. The pendulum moves about 0.25 radians away from the vertical, which is 0.2 radians too far. The settling time is about right at 4 seconds. The yellow curve is the cart's position (in meters). At first it is bumped a little (about 0.1 m), but then it moves a relatively long way in the other direction to stop the pendulum from tipping over. Go back to your m-file and change the x and y variables to see if you can get a better response. You will find that increasing x makes the settling time go down, and lowers the angle the pendulum moves. Using x=50,000 and y=100,000, the following impulse response was reached:
You may have noted that if you increased x and y even higher, you could improve the response even more. The reason this plot was chosen was because it satisfied the design requirements while keeping x and y as small as possible. In this problem, x and y have been used to describe the relative weight of the tracking error in the cart's position and pendulum's angle versus the control effort. The higher x and y are, the more control effort is used, but the smaller the tracking error. The system response has the pendulum's angle moving about 0.05 radians away from the vertical, and a 0.75 second settling time.
This response is good, but was found assuming full-state feedback, which most likely will not be a valid assumption. To compensate for this, we will next design a full-order estimator to estimate those states that are not measured.
To begin, we must first find the controller poles. To do this copy the following code to the end of you m-file:
This response is about the same as before. The settling time is now about 1 second and the pendulum does not ever move more than 0.05 radians away from the vertical. Both of the design requirements have been met with the minimum amount of control effort, so no more iteration is needed. The cart position is stabilized as well. As you can see, it is much easier to control multi-input or multi-output systems with the state space method than with any other of the methods.
Tutorials