Rotary Inverted Pendulum State Space Model PID Cascade Control
Show older comments
Hello, i'm currently working on a rotary inverted pendulum, main objective being stabilizing it in its upright position and possibly following a reference on the pendulum arm. For reference : α will be the pendulum angle, θ the arm position. I'm trying to set up a cascade controller, exploiting the transfer functions
and therefore finding
.
I'll put an image of the simulink scheme below, i'm not sure if the problem is the tuning or the overall idea.
The model is linearized around the unstable equilibrium, and it should be precise enough since with Pole Placement and LQR it works, here's the code to have State Space.
% Motor
Rm = 8.4; % Resistance
kt = 0.042; % Current-torque (N-m/A)
km = 0.042; % Back-emf constant (V-s/rad)
% Rotary Arm
mr = 0.095; % Mass (kg)
r = 0.085; % Total length (m)
Jr = mr*r^2/3; % Moment of inertia about pivot (kg-m^2)
% Pendulum Link
mp = 0.024; % Mass (kg)
Lp = 0.129; % Total length (m)
l = Lp/2; % Pendulum center of mass (m)
Jp = mp*Lp^2/3; % Moment of inertia about pivot (kg-m^2)
Jt = 1.314528060e-08;
br = 4.7078e-05; % From identification
bp = 4e-4;
g = 9.81; % Gravity constant
K = 0.0061; % Stiffness coefficient as for least squares
a_31 = -Jp*K/Jt;
a_32 = mp^2*l^2*r*g/Jt;
a_33 = -(Jp*(km^2/Rm + br))/Jt;
a_34 = -(mp*l*r*bp)/Jt;
a_41 = -K*l*mp*r/Jt;
a_42 = (mp*g*l*Jr)/Jt;
a_43 = -(mp*l*r*(km^2/Rm +br))/Jt;
a_44 = -Jr*bp/Jt;
% State space description
A = [0 0 1 0;
0 0 0 1;
a_31 a_32 a_33 a_34;
a_41 a_42 a_43 a_44];
B = [0; 0; Jp*km/Rm; mp*r*l*km/Rm]/Jt;
C = [1 0 0 0;
0 1 0 0];
D = [0; 0];
sys = ss(A,B,C,D);
G = tf(sys); % G(1) for theta G(2) for alpha
G_alpha_theta = G(2)/G(1);
G_alpha_theta_simpl = minreal(G_alpha_theta,1e-3); % needed to close the cascaded loop
I'm aware I could use the gains found through pole placement to then set-up a PD like control, but i'd like to do it directly by shaping the PIDs on the transfer functions. For the tuning I've tuned C_theta on
and C_alpha on
.
The order of the outputs is
but i'm not using velocities for the PID control since on the real system they're not measurable directly.

Accepted Answer
More Answers (0)
Categories
Find more on Tuning, Analysis, and Validation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

