// FILE: myLegoDcpPoles1_0.sce - Works
// DATE: 1.0 10/31/18
// AUTH: P.Oh
// DESC: LEGO Damped compound pendulum: pole calculations
// REFS: MEM 351 myPoles1_0.m

// Pendulum properties
J   = 0.00033;          // Moment of Inertia [kg m^2]
c   = 0.00016;          // Viscous damping coefficient [Nms/rad]
d   = 0.1325;           // Distance from pivot to center-of-mass [m]
L   = 0.265;            // Length of bar [m]
z   = 0.033;            // Damping ratio
w   = 7.32;             // Natural frequency [rad/s]
mL  = 0.0137;           // Mass of system [kg]
g   = 9.81;             // Gravitational constant [m/s^2]
PI  = 3.1416;           // Pi constant

Km  = 0.00018;          // Motor constant [Nm/%]

// Open Loop system: xDot = Fol*x + Gol*u  where u scalar
//                      y = Hol*x + Jol*u

Fol = [ 0  1; -(mL*g*d/J) -(c/J) ];
Gol = [ 0;  Km/J ];
Hol = [ 1 0];
Jol = 0;

desiredPole1 = complex(-0.799, +0.799);
desiredPole2 = complex(-0.799, -0.799);
desiredPole = [desiredPole1; desiredPole2];
gainK = ppol(Fol, Gol, desiredPole)



