Term Project Gain Calculations

Authors: Damond Li, Christopher Or
Date Created: 12/4/2021
Date Modified: 12/6/2021
Found here are the steps used, based on lecture, to determine the gains for the Full State Feedback (FSFB) controller used for the ball balancing project.
Establish gain variables
syms s K1 K2 K3 K4;
A matrix from HW 0x03
A = [0 0 1 0
0 0 0 1
-84.6 2.6 0 0
1518.6 78.4 0 0];
B matrix from HW 0x03
B = [0
0
35.1365
-630.6554];
Identity matrix
I = [1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1];
K matrix of gain values
K = [K1
K2
K3
K4]';
Closed-loop system
A_cl = A - (B * K);
Characteristic polynomial matching
Z = s*I - A_cl;
detZ = det(Z);
C = coeffs(detZ, s);
C = C'
C = 
Gain calculation using chosen parameters
w_n = 8.2; % Natural frequency
zeta = 0.8; % Damping ratio
lamda3 = -16; % Pole
lamda4 = -17; % Pole
Closed-loop polynomial
P = expand((s - lamda3) * (s - lamda4) * (s^2 + 2 * zeta * w_n * s + w_n^2))
P = 
a_coeff = coeffs(P, s)';
T1 = C(1) == a_coeff(1);
T2 = C(2) == a_coeff(2);
T3 = C(3) == a_coeff(3);
T4 = C(4) == a_coeff(4);
[M, f] = equationsToMatrix([T1; T2; T3; T4], [K1; K2; K3; K4]);
Solve for values for gain matrix
K_matrix = vpa(inv(M) * f, 5)
K_matrix =