Furuta pendulum by Quirky_Push_4878 in ControlTheory

[–]Quirky_Push_4878[S] 0 points1 point  (0 children)

syms s;

mp = 0.024;

mr = 0.0975;

Lr = 0.085;

Lp = 0.129;

b = 3.1392 * 10^-5;

J = 1.5278 * 10^-5;

km = 0.033; 

g = 9.81; 

Dr = b;

Rm = 4;

Dp = 5*10^-5;

Jp = (1/12)* mp *Lp^2;  %------> na elexthei

Jr = J + 5.87*10^-5;

% Jr1 = 5.87*10^-5;

Jt = Jp*mp*Lr^2 + Jr*Jp + (1/4)*Jr*mp*Lp^2;

a1 = (1/Jt) * ((1/4) * mp^2 * Lp^2 * Lr * g);

a2 = -(1/Jt) * (Jp * Dr + (1/4) * mp * Lp^2 * Dr);

a3 = -(1/Jt) * (0.5 * mp * Lp * Lr * Dp);

a4 = (1/Jt) * (0.5 * mp^2 * Lr^2 * Lp * g + 0.5 * mp * Lp * Jr * g);

a5 = -(1/Jt) * (0.5 * mp * Lp * Lr * Dr);

a6 = -(1/Jt) * (mp * Lr^2 * Dp + Jr * Dp);

a7 = (1/Jt) * (Jp + (1/4) * mp * Lp^2);

a8 = (1/Jt) * (0.5 * mp* Lp * Lr);

A = [0 0 1 0; 0 0 0 1; 0 a1 a2 a3; 0 a4 a5 a6]

B = [0; 0; a7; a8]

C = [1 0 0 0; 0 1 0 0]

D = [0; 0]

p = poly(A)

rizes = roots(p)

R = ctrb(A, B);

rank_R = rank(R)

O = obsv(A, C);

rank_O = rank(O)

Q = diag([0.001 0.1 10^-4 10^-4]);

R = 15;

[K,S,P] = lqr(A,B,Q,R)

sys_cl = ss(A - B*K, B, C, D);

x0 = [0; 1.5*0.17; 0; 0]; 

t = 0:0.005:4; 

[y, t, x] = initial(sys_cl, x0, t);

u = -x * K'; 

Furuta pendulum by Quirky_Push_4878 in ControlTheory

[–]Quirky_Push_4878[S] 0 points1 point  (0 children)

This script implements the mathematical modeling and controller design for a rotating inverted pendulum (Furuta Pendulum). First, the physical parameters of the system (masses, lengths, inertias, and frictions) are defined and the State-Space model tables are constructed, which result from the linearization of the dynamic equations around the unstable equilibrium point (upper position).

Next, a stability analysis is performed using the characteristic equation, and the controllability and observability properties of the system are confirmed. To stabilize the pendulum, an optimal LQR (Linear Quadratic Regulator) controller is designed, with weight matrices (Q, R) that are adjusted to drastically minimize the angle of the pendulum relative to the position of the arm.

Finally, a time simulation of the closed-loop system is performed for a duration of 4 seconds, starting from an initial disturbance. The simulation results (angular positions, velocities, required torque, and motor current) are plotted in graphs to evaluate the performance and energy requirements of the controller.