. [ x ] [ 0 0 1 0 ] [ x ] [ 0 ] [ . ] [ ] [ ] [ ] [ a ] [ 0 0 0 1 ] [ a ] [ 0 ] [.. ] = [ ] [ . ] + [ ] V [ x ] [ 0 -4.5 -16.8 0 ] [ x ] [ 3.8 ] [.. ] [ ] [ . ] [ ] [ a ] [ 0 46.9 55.3 0 ] [ a ] [ -12.4 ] [1 0 0 0] y = [ ] X [0 1 0 0]where (we use a to stand for alpha)
. . X = [x,a,x,a]' = [x1,x2,x3,x4]'is the states of the system (a 4 element column vector) u = V is the (single) input, y=[x, a]' is the two outputs. Note that, now you have a single input -- double output system, where the first output is y1 = x1 = x = cart position, and the second output is y2 = x2 = a = pendulum angle
Enter the system matrices under Matlab icon or into a m-file in your matlab directory (call it pendulum.m)
A = [0 0 1 0 0 0 0 1 0 -4.5 -16.8 0 0 46.9 55.3 0]; B = [0 0 3.8 -12.4]; C = [1 0 0 0 0 1 0 0];and run the m-file by typing "pendulum" to the matlab prompt.
To see if the open-loop system is stable, we find the poles of the system (which are the values of s where det(sI - A) = 0 and are exactly the eigenvalues of the A matrix)
poles = eig(A)Matlab returns
poles = 0 5.9987 -5.0683 -17.7304You see, two of them (s1=0 and s2=5.9987) are not asymptotically stable. Therefore, the system is unstable in its open-loop form.
Again, Matlab can also compute the transfer function of this system:NUM(s) -1 H(s) = -------- = C(sI-A) B + D DEN(s)using the command[num,den] = ss2tf(A,B,C,D,1)Note that you have to define D asD = [0 0]such that it has the same rows as C before you use ss2tf command. Matlab returnsnum = 0 -0.0000 3.8000 0.0000 -122.4200 0 -0.0000 -12.4000 1.8200 0 den = 1.0000 16.8000 -46.9000 -539.0700 0The reason you got two rows for the numerator is that now you have a two-output system. You can also find the poles of the system usingroots(den)which returnsans = 0 -17.7304 -5.0683 5.9987Which gives you the same answer as before.
U = [B (A*B) (A^2*B) (A^3*B)]which returns
U = 1.0e+04 * 0 0.0004 -0.0064 0.1128 0 -0.0012 0.0210 -0.4112 0.0004 -0.0064 0.1128 -1.9901 -0.0012 0.0210 -0.4112 7.2251Then check if it has full-rank (non-zero determinant) by
rank(U)that returns
ans = 4Therefore, it is full rank and the system is controllable, which means we can design a full-state feedback controller to place the closed-loop system's poles at arbitrary positions as we wish! To place the closed-loop poles, we can use several methods (see lab9). As a reminder, Matlab provides command acker() whose usage is as follows:
ACKER Pole placement gain selection using Ackermann's formula. K = ACKER(A,B,P) calculates the feedback gain matrix K such that the single input system . x = Ax + Bu with a feedback law of u = -Kx has closed loop poles at the values specified in vector P, i.e., P = eig(A-B*K). Note: This algorithm uses Ackermann's formula. This method is NOT numerically reliable and starts to break down rapidly for problems of order greater than 10, or for weakly controllable systems. A warning message is printed if the nonzero closed-loop poles are greater than 10% from the desired locations specified in P.To use Ackermann's formula, you need to provide the system matrices A and B and the poles P that you want to place.
You should also check the observability of the states of the system
to see if our
system is fully observable or not. (Check for the full rank of the
observability matrix, V = [C' A'*C' A'^2*C' A'^3*C']).
Assignment:
You are given the desired pole locations for the closed-loop system as follows:
p1 = -1+j
p2 = -1-j
p3 = -15
p4 = -100(1) Design a state feedback controller by manually implementing Ackermann's formula, i.e. use K = [0 0 ... 0 1] * inv(U) * G, where U is the controllability matrix and G is defined in terms of the coefficients of the desired characteristic equation (d0 ... d_n-1) and the open-loop A matrix as:
G = [A^n + d_n-1*A^(n-1) + d_n-2*A^(n-2) + ... + d1*A + d0*I].Write down the following information:
U = ? G = ? K = ?Note that G and K depends on the choice of non-dominant pole locations. It is recommended that you check your results using MatLab's "acker" command. (Each student must write up results individually).
(2) Form a group of 4-5 students and proceed to the lab downstairs (Room 0126) to impliment your design. Your grade in this studio will depend on the performance of your controller.
Note:
* your derived K will have units of V/m, V/rad, Vs/m, and Vs/rad
respectively. To impliment the design, convert to units of V/cm, V/deg,
Vs/cm, and Vs/deg.
* To zero the angle measurement you should hold the pendulum vertical
(with the motor turned off) and hit the letter 'z' from the main menu of
the controller. This takes the present measurement as zero. Do this before
you start the controller!
Grading:
* 50% for writeup * 50% for implementation controller works 1st try: -0% controller works with minor redesign: -10% controller works with major redesign: -20% controller doesn't work: -30% group has no idea what they're doing: -40% you don't show up for lab: -50%