State-Space Motor Modeling
Please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.mit.edu) to authenticate, and then you will be redirected back to this page.
An Lmotor-Driven Arm
In this problem, we will consider an example that is similar to the propeller-levitated arm, a lego-motor-driven arm (for brevity, an Lmotor-driven arm). The similarities will make it easier for us to understand the structure of this new control problem, but differences will allow us to raise additional issues, while also giving us a chance to practice with the state-space concepts.
In earlier versions of 6.302, we rotated a heavier arm using a geared Lego motor, shown in the figure below. The figure also shows that we used two rubber bands to create an angle dependent torque on the motor (both to assist the motor when holding heavy loads, and to eliminate gear "backlash"). That angle dependent force will have a number of interesting consequences, ones that we hope will help you develop a better understanding of controller design.
The Lmotor is a geared brushed motor, just like the propeller motor. By changing the motor voltage, v, we change the motor current, i_m, which is proportional to the torque generated by the motor. The net arm torque, a sum of motor-, gravity-, and elastic-generated torques, results in an arm rotation characterized by angular acceleration, \alpha, angular velocity, \omega, and rotation angle \theta, as shown in the figure below.
We can sense the Lmotor-driven arm angle using the same kind of angle sensor we use for the propeller arm, by linking the shaft of the angle sensor to the shaft of the motor (using heat-shrink tubing actually). As an example, using our angle sensor, we could easily measure the \theta in the figure below as approximately \frac{-\pi}{6}.
In fact, we can reuse most of our propeller-levitated arm hardware in an Lmotor-driven arm controller, since they both use brushed DC motors. We can use the same angle sensor, and we can drive the Lmotor using the same H-bridge (the Pololu board) with almost the same PWM voltages (though lego motors are designed to work with lower-frequency PWM signals). In fact, we could even use exactly the same PID controller, though we might find that good K_i, K_d, and K_p values for the Lmotor-driven arm will be different from good values for the propeller arm.
The issues in designing state-space controllers are a little different, however, as we shall see.
Generating a State-Space model
We will need a few physical relationships in order to derive a state-space model, but thankfully, the Lmotor-driven arm model does not require linearization.
The physical relationships
As in the propeller-levitated arm, the Lmotor-driven arm angle, \theta(t), is related to its angular velocity, \omega(t), through differentiation,
The product of the arm's moment of inertia, J, and its angular acceleration, \alpha, is equal to the torque on the arm \tau,
As we have seen before, motor torque, \tau_m, is proportional to motor current,
Since the Lmotor is a brushed motor, we can model it in the same way we modeled the propeller motor. That is, we can use a circuit model to relate the voltage across the motor to the current through the motor, and after scaling by K_m, relate the motor voltage to the motor torque. If we model the motor as a series combination of a motor coil resistor, R_m, a motor coil inductor, L_m, and a rotational-velocity dependent voltage source, v_{emf}, the current through the motor, i_m, can be related to the drive voltage, v, by
The motor's inductance and resistance are much larger than in the propeller motor, so the above relation can not be simplified. The v_{emf} is proportional to the motor speed, \omega_m, a fact we made use of, but did not investigate, in the SPINUP sketch used to calibrate our propeller motor.
Values for the physical parameters.
(http://nxt-unroller.blogspot.com/2015/03/mathematical-model-of-lego-ev3-motor.html)
L_m = 0.005 is the motor inductance in Henries.
J = 0.0015 is the arm-plus-motor moment of inertia.
R_m = 7.0 is the motor's series resistance in ohms.
K_e = 0.46 is the back-emf per radian/sec of motor rotational velocity.
K_m = 0.3 is the torque per ampere of current.
K_f = 0.00073 is the torque due to friction per radian/second.
K_b = 0.0 \;or\; -0.1 is the elastic torque per radian (due to the rubber bands) and is negative because the elastic was used to oppose arm motion.
Generating the State-Space Matrices
We can describe our Lmotor-driven arm as a single-input single-output (SISO) state-space system with the motor voltage as the input and the arm angle as the output. The standard state-space form is
The physical equations, rearranged in state-space form, are obtained by solving for each derivative. From the electrical equation,
Choosing the state vector \textbf{x} = \begin{bmatrix}i_m & \omega & \theta\end{bmatrix}^T, input u = v, and output y = \theta, the state-space matrices are completely determined by the above equations:
Please enter the \textbf{A} matrix below. Remember to use Python form — for example, a matrix with numerical values would be entered as
[[-1400.0, -92.0, 0], [200.0, -0.487, 0], [0, 1, 0]]
Poles and Eigenvalues.
In the SISO state-space system, the transfer function from plant input u to plant output y is given by
The key fact is that the poles of H_{plant}(s) are exactly the eigenvalues of \textbf{A}. Recall that if \lambda_i is an eigenvalue of \textbf{A}, and \textbf{V}_i is the associated eigenvector, then
Consider the change of variables \textbf{x}(t) = \textbf{V} \textbf{w}(t) (the spectral decomposition of \textbf{x}). Substituting into the state-space model,
Since \Lambda is diagonal, we can rewrite the transfer function as
Poles, Eigenvalues, and Feedback
Assuming the eigenvalues of \textbf{A} are distinct, answer the following questions in terms of A, B, C, V, and L (for \Lambda), and their inverses (e.g. A**-1).
When using state-feedback control
The poles of the closed-loop transfer function are equal to the eigenvalues of what matrix?
Poles and transfer functions for the Lmotor-driven arm
Now use the above formulas (and/or python) to compute the poles and partial fraction expansion representation of the transfer function for the open-loop Lmotor-driven arm plant,
[4.0,5.0+3.0j,5.0-3.0j].
[4.0,5.0+3.0j,5.0-3.0j].
[4.0,5.0+3.0j,5.0-3.0j].
[4.0,5.0+3.0j,5.0-3.0j]).
Note that one pole is much larger than the other two, and its associated \beta much smaller. That suggests H(s) could be well approximated without that pole, an idea we return to below.
The elastic torque and K_r
Since you completed the above problem, you know that the states for the system are i_m, \omega, and \theta, in that order. If you want to design a state-feedback controller, then you have to determine K_r and \textbf{K} for
Recall that given a vector of state feedback gains, \textbf{K}, we derived a formula for K_r based on matching the steady-state output to the steady-state reference input:
For our specific \textbf{B} and \textbf{C}, this formula depends on only one element of (\textbf{A} - \textbf{B}\textbf{K})^{-1}. To see which one, recall that \textbf{C} = \begin{bmatrix}0 & 0 & 1\end{bmatrix} picks out the third row of any matrix it premultiplies, and that \textbf{B} = \begin{bmatrix}1/L_m & 0 & 0\end{bmatrix}^T picks out a scaled version of the first column. So
For what i,j does K_r depend on (\textbf{A} - \textbf{B}\textbf{K})^{-1}_{i,j}?
Enter your answer in python format. So if your answer is i=2 and j=3, enter [2,3].
[i,j]=
When calculating the inverse of a matrix \textbf{M}, it is sometimes helpful to recall that if the inverse exists, then
This column-at-a-time approach is especially useful when \textbf{M} has a special structure. For example, suppose \textbf{M} has an inverse, and in addition, the only nonzero element of the 5^{th} column of \textbf{M} is M_{1,5} = 25. The first column of \textbf{M}^{-1} will then have only one nonzero (do you see why?). In what row is that nonzero, and what is its value?
The above observation will help you understand when K_r will simplify. In particular, suppose you remove the elastic bands from the motor, so K_b = 0. Then nothing in the open-loop model depends directly on \theta, which gives a special structure to the third column of \textbf{A}. For this K_b = 0 case, show that K_r simplifies to a single state-feedback gain. Denote the three state gains as 'K1', 'K2' and 'K3'.
Suppose the elastic bands are back on the motor, so that K_b = -0.1, and the state-feedback gains are
The model for the propeller-levitated arm we used in lab is like the Lmotor-driven arm without elastic bands. Nothing in the propeller-arm model depended directly on arm angle, and as a result, K_r was always equal to K_{angle}.