ME 405 HW 0x04: Linearization and Simulation of the Balancing Platform Board

Authors: Ryan McLaughlin and Matthew Frost
Originally Created: 04/25/21
Last Modified: 05/03/21

Initial Setup and Variable Definitions

Define fun, eqn, and eqnNames as the "structures." These will now allow for notation for fun.xB to save an equation xB within the functions class.

Define symbolic variables (constants and functions of time)

Compute the moment of inertia of the ball, $\overline{I}_B$

1) Ball Kinematics

X-Direction Kinematic Equations

Z-Direction Kinematic Equations

2) Motor Torque to Platform Moment

Define the effective moment on the platform, $ M_y $ in terms of the input motor torque, $ T_x $

3) Equations of Motion

3.1) System 1: Ball and Platform Together

3.2) System 2: Ball Only

4) Convert EOM's to Matrix Form

Next, the linear_eq_to_matrix function (similar to equationsToMatrix in MATLAB®) is used.

Convert matrices to form of $x=M^{-1}f$

Create $h$ matrix for state space representation

5) Jacobian Linearization

Define the state variable matrix

Compute the Jacobian with respect to the state vector, and define operating point by subsituting zeros for all state variables present

Substitue values for all other constants to determine a numerical form of the $A$ matrix

Compute the Jacobian with respect to the input vector, define operating point, and substitute numerical values to determine $B$ matrix

6) Simulation of State Space Model

After linearizing the system, we are now ready to use the scipy Python library to simulate the time response of the balancing platform system in both open- and closed-loop configurations

Convert earlier defined $A$ and $B$ matrices to numpy arrays

Define a linear, time-invariant state space system based on the $A$, $B$, $C$, and $D$ matrices defined above using the scipy.lti

6.1) Open Loop Simulation 1

Initial conditions: Ball is at rest on a level platform, located in the center of the platfrom, and no input is applied

6.2) Open Loop Simulation 2

Initial conditions: Ball is at rest on a level platform, offset 5 cm horizontally from the center of the platform, and no input is applied

6.3) Closed Loop Simulation

Initial conditions and controller: Ball is at rest on a level platform, offset 5 cm horizontally from the center of the platform, and closed-loop feedback is utilized

Define the controller gain matrix, and find the new $A$, $B$, $C$, and $D$ matrices

New state space system definition

Plot the system response