© Springer International Publishing AG, part of Springer Nature 2019
Victor Manuel Hernández-Guzmán and Ramón Silva-OrtigozaAutomatic Control with ExperimentsAdvanced Textbooks in Control and Signal Processinghttps://doi.org/10.1007/978-3-319-75804-6_16

16. Control of an Inertia Wheel Pendulum

Victor Manuel Hernández-Guzmán1  and Ramón Silva-Ortigoza2
(1)
Universidad Autonoma de Queretaro, Facultad de Ingenieria, Querétaro, Querétaro, Mexico
(2)
Instituto Politécnico Nacional, CIDETEC, Mexico City, Mexico
 

16.1 Inertia Wheel Pendulum Description

In this chapter, a control strategy is designed for a mechanism known as the inertia wheel pendulum (IWP). A picture of the IWP is shown in Fig. 16.1 when operating at the downward position, whereas the variables and the parameters involved are defined in Fig. 16.2. It is a pendulum with a PM brushed DC motor fixed at its free end, which actuates on a wheel. The pendulum hangs up from a point where no external torque is applied. It is said that this point is not actuated but the wheel is actuated because it receives torque generated by the motor. As the pendulum and the wheel define two-degrees-of-freedom [1] but there is only one actuator (at the wheel), the mechanism is said to be underactuated [2].
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig1_HTML.jpg
Fig. 16.1

The inertia wheel pendulum at the noninverted position

/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig2_HTML.png
Fig. 16.2

Inertia wheel pendulum

The IWP was introduced by Spong et al. [2], and aside from its academic applications it is also widely used for research purposes as a workbench for nonlinear controllers [211].

The nomenclature employed is the following:
  • q 1 is the pendulum angular position.

  • q 2 is the wheel angular position.

  • m 1 is the pendulum mass.

  • m 2 is the wheel mass.

  • τ is torque applied at the wheel.

  • l c1 is the location of the pendulum’s center of mass.

  • l 1 is the pendulum’s length.

  • I 1 is the pendulum’ inertia when rotating around its center of mass.

  • I 2 is the wheel inertia (plus the motor rotor inertia).

  • g is the gravity acceleration.

  • R is the motor armature resistance.

  • L is the motor armature inductance.

  • k b and k m are the motor counter electromotive force constant and the motor torque constant.

  • u and i stand respectively, for voltage applied at the motor armature terminals and the electric current through the motor armature.

According to the above description of the IWP, it is clear that it is not easy to take the pendulum directly from q 1 = 0,  $$\dot q_1=0$$ , to q 1 = +π, or q 1 = −π, and  $$\dot q_1=0$$ . Moreover, the latter configuration is unstable and it is known as the inverted unstable configuration. Thus, it is of interest to design a control strategy such that: (i) The pendulum is taken from a vicinity of q 1 = 0,  $$\dot q_1=0$$ , to the inverted unstable configuration, (ii) The pendulum stays at the inverted unstable configuration. The first part of this task is known as the pendulum swing up and the second part is known as the pendulum balancing .

In this chapter it is shown that solution of the swing up problem requires the use of nonlinear control techniques because the IWP has a nonlinear model. Although nonlinear, the model of this mechanism is straightforward enough to design a control strategy using simple ideas. One important objective in including this control problem is to introduce the reader, using a basic example, to nonlinear control systems techniques.

16.2 Mathematical Model

As the inertia wheel pendulum is a mechanism composed of two interacting bodies, its mathematical model is obtained using the Euler–Lagrange equations , i.e.,
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \frac{d}{dt}\frac{\partial L}{\partial \dot{q}_1}-\frac{\partial L}{\partial q_1}&\displaystyle =&\displaystyle 0,{}\\ \frac{d}{dt}\frac{\partial L}{\partial \dot{q}_2}-\frac{\partial L}{\partial q_2}&\displaystyle =&\displaystyle \tau. \end{array} \end{aligned} $$
(16.1)
The zero on the right-hand side in the first expression indicates that no external torque is applied at the point where the pendulum hangs up. The Lagrangian is given as:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} L&\displaystyle =&\displaystyle K-P,{}\\ K&\displaystyle =&\displaystyle K_1+K_2, P=P_1+P_2, \end{array} \end{aligned} $$
(16.2)
where K 1 and K 2 represent the kinetic energies of the pendulum and the wheel respectively, whereas P 1 and P 2 represent the potential energies of the pendulum and the wheel respectively. As the pendulum is a body with a mass distributed along a stick, its kinetic energy is computed by adding the kinetic energy of a particle of mass m 1, which translates on a circumference with radius l c1 and the kinetic energy of a stick that rotates around its center of mass, i.e.,:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} K_1=\frac{1}{2}m_1l_{c1}^2\dot q_1^2+\frac{1}{2}I_1\dot q_1^2. \end{array} \end{aligned} $$
The kinetic energy of the wheel is obtained in a similar manner. However, it must be taken into account that the wheel’s angular velocity, as measured by an observer fixed to the laboratory, is  $$\dot q_1+\dot q_2$$ . Then, the following is found:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} K_2=\frac{1}{2}m_2l_{1}^2\dot q_1^2+\frac{1}{2}I_2(\dot q_1+\dot q_2)^2. \end{array} \end{aligned} $$
To compute the potential energy, the configuration where q 1 = 0 is used as reference, i.e., where P 1 = 0 and P 2 = 0. Recall that the pendulum potential energy is given as the product of force applied to the pendulum, i.e., the pendulum weight, and the component parallel to the pendulum weight of the distance between the pendulum’s center of mass at the actual position q 1 and position of the pendulum’s center of mass where the pendulum’s potential energy is zero, i.e., when q 1 = 0. Then:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} P_1=gm_1l_{c1}(1-\cos{}(q_1)). \end{array} \end{aligned} $$
Proceeding in a similar manner, it is found that the wheel’s potential energy is given as:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} P_2=gm_2l_1(1-\cos{}(q_1)). \end{array} \end{aligned} $$
Hence, according to (16.2):
 $$\displaystyle \begin{aligned} \begin{array}{rcl} L&\displaystyle =&\displaystyle \frac{1}{2}m_1l_{c1}^2\dot q_1^2+\frac{1}{2}I_1\dot q_1^2 +\frac{1}{2}m_2l_{1}^2\dot q_1^2+\frac{1}{2}I_2(\dot q_1+\dot q_2)^2-g\overline{ m}(1-\cos{}(q_1)), \end{array} \end{aligned} $$
where  $$\overline { m}= m_1l_{c1} +m_2l_1$$ . Replacing L in the Euler–Lagrange equations (16.1) and after suitably arranging the resulting terms, the following is found:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} D\left[\begin{array}{cc} \ddot q_1\\ \ddot q_2 \end{array}\right]&+& \left[\begin{array}{cc} \overline{m}g\sin{(q_1)}\\ 0 \end{array}\right]= \left[\begin{array}{cc} 0\\ \tau \end{array}\right],{}\\ D= \left[\begin{array}{cc} d_{11} & d_{12}\\ d_{21} & d_{22} \end{array}\right]&=& \left[\begin{array}{cc} {m_1l_{c1}^2+m_2l_{1}^2+I_{1}+I_{2}} & {\ \ I_{2}}\\ {I_{2}} & {\ \ I_{2}} \end{array}\right]. \end{array} \end{aligned} $$
(16.3)
It is simple to verify that the determinant of matrix D is positive, i.e.,:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \det(D)=d_{11}d_{22}-d_{12}d_{21}>0.{} \end{array} \end{aligned} $$
(16.4)
The model in (16.3) is the most complete one for the IWP and it will be used in the next section to design a control strategy to swing up the pendulum to the inverted unstable configuration.
Voltage applied at the armature terminals of the PM brushed DC motor actuating on the wheel is the actual control signal, i.e., the variable that can be directly manipulated, whereas torque at the wheel is a variable that is a consequence of the application of such a voltage. However, in practice it is possible to assume that torque at the wheel is the control signal if it is supposed that the armature inductance is small. The armature circuit model of a PM brushed DC motor is the following:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} L_a\frac{d i}{dt}+R i+k_b \dot q_2=u.{} \end{array} \end{aligned} $$
(16.5)
If L a and k b are assumed to be zero, then:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \tau=k_m i=\frac{k_m}{R}u.{} \end{array} \end{aligned} $$
(16.6)
This means that the applied voltage has a direct effect on the generated torque; hence, it is reasonable to assume that torque is the control signal. Assuming k b to be zero is justified as follows. It is observed from (16.5) that k b introduces additional viscous friction to the mechanism. As this commonly improves stability in a control system, then assuming k b  = 0 renders the control problem more interesting at hand in the sense that the design is performed by assuming that any stabilizing effect is not present naturally in the mechanism.

16.3 Swing Up Nonlinear Control

A controller is designed in this section to take the pendulum to its inverted unstable configuration, i.e., to any of the points  $$(q_1,\dot q_1)=(+ \pi ,0)$$ or  $$(q_1,\dot q_1)=(- \pi ,0)$$ . It will be explained later why the wheel position and velocity are not taken into account during the time interval when this task is performed.

Solving the first row in (16.3) for  $$\ddot q_2$$ , replacing this value in the second row of (16.3), and using (16.6) in addition to d 12 = d 22, the following is found:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} J\ddot q_1+mgl\sin{}(q_1)&\displaystyle =&\displaystyle \tau_1.{}\\ J=\frac{d_{22}d_{11}-d_{21}d_{12}}{d_{12}}, mgl=\overline{m}g, \tau_1&\displaystyle =&\displaystyle -\frac{k_m}{R}u. \end{array} \end{aligned} $$
(16.7)
Notice that J > 0 because of (16.4). Hence, the model in (16.7) corresponds to a simple pendulum where J, m, l, and g represent the equivalent inertia, mass, length, and gravity acceleration respectively. The total energy of this pendulum is given by adding its kinetic energy and potential energy , i.e.,:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} V(q_1,\dot q_1)=\frac{1}{2}J\dot q_1^2+mgl(1-\cos{}(q_1)).{} \end{array} \end{aligned} $$
(16.8)
The level surfaces of V  are depicted in Fig. 16.3. This means that each curve in this figure represents the set of points  $$(q_1,\dot q_1)$$ where  $$V(q_1,\dot q_1)$$ takes a constant value. The reader should realize that the more external curves correspond to larger values of V > 0 and the internal-most curve corresponds to a single point,  $$(q_1,\dot q)=(0,0)$$ , where V = 0 takes its smallest value.
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig3_HTML.png
Fig. 16.3

Level surfaces of V  in (16.8)

Time derivative of  $$V(q_1,\dot q_1)$$ , given in (16.8), is found to be:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \frac{dV(q_1,\dot q_1)}{dt}=\dot q_1J\ddot q_1+mgl\dot q_1\sin{}(q_1). \end{array} \end{aligned} $$
If  $$J\ddot q_1$$ is replaced from (16.7), the following is found:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \frac{dV(q_1,\dot q_1)}{dt}=\dot q_1\tau_1.{} \end{array} \end{aligned} $$
(16.9)

What has been computed is known as the time derivative of V along the trajectories of (16.7) [12]. This means that (16.9) represents the values that  $$\frac {d}{dt}V$$ takes as the pendulum in (16.7) moves under the effect of the external torque τ 1. For instance, if τ 1 = 0 then  $$\frac {d}{dt}V=0$$ , according to (16.9), which means that the pendulum’s energy V  remains constant as the pendulum moves. This is very important for our purposes. From the knowledge of the pendulum’s initial position and velocity  $$(q_1(0),\dot q_1(0))$$ , it is possible to know the initial value of the pendulum’s energy  $$V(q_1(0),\dot q_1(0))$$ . As  $$\frac {d}{dt}V=0$$ because τ 1 = 0 then, as time grows, the pendulum moves only on points representing the level surface where  $$V(q_1(t),\dot q_1(t))=V(q_1(0),\dot q_1(0))$$ , which are shown in Fig. 16.3. Arrows on the level surfaces represent the sense of the pendulum’s movement. These senses of movement are easy to determine. The state vector of a simple pendulum is defined as  $$y=[q_1,\dot q]^T$$ . The variable  $$\dot y=[\dot q_1,\ddot q]^T$$ is a vector indicating where the state y moves to. Notice that the horizontal component of  $$\dot y$$ , i.e.,  $$\dot q_1$$ , points to the right as long as the pendulum velocity  $$\dot q_1$$ is positive. This suffices to determine the sense of the arrows on the level surfaces of V .

According to the ideas discussed above, to swing up the pendulum it suffices to increase the pendulum energy to:
 $$\begin{array}{rcl} V(q_1,\dot q_1)\vert_{\stackrel{q_1=+ \pi \;\text{\'{o}}\; q_1=- \pi}{\dot q_1=0}}=\frac{1}{2}J(0)^2+mgl(1-\cos{}(\pm\pi))=2mgl=V_0, \end{array} $$
and, in the case that such an energy is reached at a point where  $$(q_1,\dot q_1)\neq (+\pi ,0)$$ or  $$(q_1,\dot q_1)\neq (-\pi ,0)$$ , then apply a torque τ 1 that ensures  $$\frac {d}{dt}V=0$$ from that time on. Notice that, according to Fig. 16.3, if V  is kept constant once V = V 0, then the pendulum continues to move until one of the points  $$(q_1,\dot q_1)=(+\pi ,0)$$ or  $$(q_1,\dot q_1)=(-\pi ,0)$$ is reached. It is shown next that the above is ensured if the following torque is used:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \tau_1&=&-k_d\; sat(\dot q_1)\; sign(V-V_0),{} \end{array} \end{aligned} $$
(16.10)
 $$\displaystyle \begin{aligned} \begin{array}{rcl} sat(\dot q_1)&=&\left\{\begin{array}{cc} \varepsilon_0, & \dot q_1 >\varepsilon_0\\ -\varepsilon_0, & \dot q_1 <-\varepsilon_0\\ \dot q_1, &\vert\dot q_1\vert\leq \varepsilon_0 \end{array} \right.,sign(V-V_0)=\left\{\begin{array}{cc} +1, & V>V_0\\ -1, & V<V_0\\ 0, &V=V_0 \end{array} \right., {} \end{array} \end{aligned} $$
(16.11)
where ε 0 and k d are arbitrary positive constants. Replacing (16.10) in (16.9):
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \frac{dV(q_1,\dot q_1)}{dt}=-k_d\dot q_1\; sat(\dot q_1)\; sign(V-V_0). \end{array} \end{aligned} $$
It is easy to realize from (16.11) that the product  $$\dot q_1\; sat(\dot q_1)$$ is always positive and it is zero only when  $$\dot q_1=0$$ . Hence, as long as  $$\dot q_1\neq 0$$ we have:
  • If V < V 0 then  $$\frac {d}{dt}V&gt;0$$ and energy V  increases.

  • If V > V 0 then  $$\frac {d}{dt}V&lt;0$$ and energy V  decreases.

  • If V = V 0, then  $$\frac {d}{dt}V=0$$ and energy V  remains at V 0.

Then, it is ensured that the pendulum energy V  reaches the required value to arrive at one of the points  $$(q_1,\dot q_1)=(+\pi ,0)$$ or  $$(q_1,\dot q_1)=(-\pi ,0)$$ . Furthermore, the energy remains at that value until one of these points is reached. Now, analyze what happens if  $$\dot q_1=0$$ . Notice that the pendulum is at rest under this condition. However, the only way for  $$\dot q_1=0$$ to be true for ever is q 1 = 0, because it is only there that the pendulum may remain at rest. Hence, it is necessary to slightly hit the pendulum at the beginning to force it to abandon the configuration  $$(q_1,\dot q_1)=(0,0)$$ .

The previous analysis ensures that the pendulum reaches the inverted unstable configuration if, from the downward stable configuration, the pendulum is slightly hit to start it moving. It is not difficult to realize that none of the above results change if sat(V − V 0) is used in controller (16.10) instead of sign(V − V 0). The controller in (16.10), (16.11), has its roots in the ideas reported in [13].

On the other hand, it is important to stress that, once the inverted unstable configuration is reached, the controller (16.10) does not ensure that the pendulum stays at such a configuration. This requires another controller to be designed that must be put to work when the pendulum is very close to the inverted unstable configuration. This means that the controller in (16.10) must be disconnected from that time on. In the next section, a controller is designed solving the second part of the control problem: pendulum balancing at the inverted unstable configuration.

Finally, notice that nothing has been said on the wheel position and velocity during the pendulum swing-up stage. As the wheel is symmetrical and homogeneous, then the wheel position does not matter. On the other hand, although the wheel velocity increases in an unknown manner during this time interval, the velocity is finite at the moment when the pendulum reaches the inverted unstable configuration; hence, the balancing controller must just regulate the wheel velocity at the value that this variable has when this controller begins to work.

Example 16.1

Consider the alternative controller:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \tau_1&amp;=&amp;-k_d\; (V-V_0)\; sat(\dot q_1),u=-\frac{R}{k_m}\tau_1,{} \end{array} \end{aligned} $$
(16.12)
 $$\displaystyle \begin{aligned} \begin{array}{rcl} sat(\dot q_1)&amp;=&amp;\left\{\begin{array}{cc} d, &amp; \dot q_1 &gt;d\\ -d, &amp; \dot q_1 &lt;-d\\ \dot q_1, &amp;\vert\dot q_1\vert\leq d \end{array} \right.,d=\frac{u_{max}k_m}{k_dRV_0}, {} \end{array} \end{aligned} $$
(16.13)
where d, u max and k d are positive arbitrary constants. Replacing (16.12) in (16.9):
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \frac{dV(q_1,\dot q_1)}{dt}=-k_d\;(V-V_0)\;\dot q_1\; sat(\dot q_1). \end{array} \end{aligned} $$
It is easy to realize, from (16.13), that the product  $$\dot q_1\; sat(\dot q_1)$$ is always positive and it is zero only when  $$\dot q_1=0$$ . Hence, as long as  $$\dot q_1\neq 0$$ , we have the following:
  • If V < V 0 then  $$\frac {d}{dt}V&gt;0$$ and energy V  increases.

  • If V > V 0 then  $$\frac {d}{dt}V&lt;0$$ and energy V  decreases.

  • If V = V 0 then  $$\frac {d}{dt}V=0$$ and energy V  remains at V 0.

Thus, it is ensured again that the pendulum energy V  reaches the required value to arrive at one of the points  $$(q_1,\dot q_1)=(+\pi ,0)$$ of  $$(q_1,\dot q_1)=(-\pi ,0)$$ .

16.4 Balancing Controller

The strategy for balancing the pendulum is a linear state feedback controller designed on the basis of a linear approximation of (16.3). This linear approximation is obtained in the following. Note that the model in (16.3) does not depend on the wheel position q 2. Hence, the state vector can be defined as:
 $$\displaystyle \begin{aligned} x=\left[\begin{array}{cccc} x_1\\ x_2\\ x_3 \end{array}\right]= \left[\begin{array}{cccc} q_1\\ \dot{q}_1\\ \dot{q}_2 \end{array}\right],{} \end{aligned} $$
(16.14)
From (16.3):
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \left[\begin{array}{cc} \ddot q_1\\ \ddot q_2 \end{array}\right]&amp;=&amp;D^{-1}\left\{ -\left[\begin{array}{cc} \overline{m}g\sin{(q_1)}\\ 0 \end{array}\right]+ \left[\begin{array}{cc} 0\\ \tau \end{array}\right]\right\},{} \end{array} \end{aligned} $$
(16.15)
 $$\displaystyle \begin{aligned} \begin{array}{rcl} D^{-1}&amp;=&amp; \left[\begin{array}{cc} \overline{d}_{11} &amp; \overline{d}_{12}\\ \overline{d}_{21} &amp; \overline{d}_{22} \end{array}\right]= \frac{1}{d_{11}d_{22}-d_{12}d_{21}} \left[\begin{array}{cc} d_{22} &amp; -d_{12}\\ -d_{21} &amp; d_{11} \end{array}\right]. {} \end{array} \end{aligned} $$
(16.16)
Note that  $$\det (D^{-1})\neq 0$$ because it is the inverse matrix of a nonsingular matrix. Using (16.14) and (16.15), the model in (16.3) can be written as:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \dot{x}=f(x,\tau)= \left[\begin{array}{c} x_2\\ -\overline{d}_{11}\overline{m}g\sin{(x_1)}+\overline{d}_{12}\tau \\ -\overline{d}_{21}\overline{m}g\sin{(x_1)}+\overline{d}_{22}\tau \end{array}\right]. {} \end{array} \end{aligned} $$
(16.17)
According to Sect. 7.​3.​2, the operation points (x , τ ) of (16.17) are found from the condition f(x , τ ) = 0, i.e.,:
 $$\displaystyle \begin{aligned} \left[\begin{array}{c} x_2^*\\ -\overline{d}_{11}\overline{m}g\sin{(x_1^*)}+\overline{d}_{12}\tau^* \\ -\overline{d}_{21}\overline{m}g\sin{(x_1^*)}+\overline{d}_{22}\tau^* \end{array}\right]= \left[\begin{array}{c} 0\\ 0\\ 0 \end{array}\right]. {} \end{aligned} $$
(16.18)
It is clear that:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} x_2^*&amp;\displaystyle =&amp;\displaystyle 0.{} \end{array} \end{aligned} $$
(16.19)
On the other hand, from the second and third rows in (16.18), the following is found:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \tau^*&amp;\displaystyle =&amp;\displaystyle \frac{\overline{d}_{11}\overline{m}g\sin{(x_1^*)}}{\overline{d}_{12}},{}\\ \tau^*&amp;\displaystyle =&amp;\displaystyle \frac{\overline{d}_{21}\overline{m}g\sin{(x_1^*)}}{\overline{d}_{22}}. \end{array} \end{aligned} $$
(16.20)
Solving these expressions simultaneously:
 $$\displaystyle \begin{aligned} \frac{\overline{m}g}{\overline{d}_{12}\overline{d}_{22}} \left[\overline{d}_{11}\overline{d}_{22}-\overline{d}_{21}\overline{d}_{12}\right]\sin{(x_1^*)}=0. {} \end{aligned} $$
(16.21)
As  $$\det (D^{-1})=\overline {d}_{11}\overline {d}_{22}-\overline {d}_{21}\overline {d}_{12}\neq 0$$ , then (16.21) is only satisfied if:
 $$\displaystyle \begin{aligned} x_1^*=\pm n\pi,n=0,1,2,3,\dots {} \end{aligned} $$
(16.22)
Replacing this condition in any of the expressions in (16.20), the following is found:
 $$\displaystyle \begin{aligned} \tau^*=0. {} \end{aligned} $$
(16.23)
Finally, as no restriction exists on  $$x_3^*$$ , it is concluded that:
 $$\displaystyle \begin{aligned} x_3^*=c, {} \end{aligned} $$
(16.24)
where c is any real constant. According to Sect. 7.​3.​2, the linear approximation of (16.17) at the operation point (16.19), (16.22), (16.23), (16.24), with n = ±1, is given as:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \dot z&amp;=&amp;Az+Bw,{}\\ {}A&amp;=&amp;\left.\dfrac{\partial f(x,\tau)}{\partial x}\right|{}_{\stackrel{x^*}{\tau^*}}= \left.\left[\begin{array}{ccc} \dfrac{\partial f_1}{\partial x_1} &amp; \dfrac{\partial f_1}{\partial x_2} &amp; \dfrac{\partial f_1}{\partial x_3} \\ {}\dfrac{\partial f_2}{\partial x_1} &amp; \dfrac{\partial f_2}{\partial x_2} &amp; \dfrac{\partial f_2}{\partial x_3} \\ {}\dfrac{\partial f_3}{\partial x_1} &amp; \dfrac{\partial f_3}{\partial x_2} &amp; \dfrac{\partial f_3}{\partial x_3} \\ {}\end{array}\right]\right|{}_{\stackrel{x^*}{\tau^*}}= \left[\begin{array}{ccc} 0 &amp; 1 &amp; 0 \\ {}\overline{d}_{11}\overline{m}g &amp; 0 &amp; 0 \\ {}\overline{d}_{21}\overline{m}g &amp; 0 &amp; 0 \end{array}\right],\\ {}B&amp;=&amp;\left.\dfrac{\partial f(x,\tau)}{\partial \tau}\right|{}_{\stackrel{x^*}{\tau^*}}= \left.\left[\begin{array}{c} \dfrac{\partial f_1}{\partial \tau}\\ {}\dfrac{\partial f_2}{\partial \tau}\\ {}\dfrac{\partial f_3}{\partial \tau} \end{array}\right]\right|{}_{\stackrel{x^*}{\tau^*}}= \left[\begin{array}{c} 0\\ {}\overline{d}_{12}\\ {}\overline{d}_{22}\\ {}\end{array}\right], \end{array} \end{aligned} $$
(16.25)
where:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} z&amp;\displaystyle =&amp;\displaystyle x-x^*,{} \end{array} \end{aligned} $$
(16.26)
 $$\displaystyle \begin{aligned} \begin{array}{rcl} w&amp;\displaystyle =&amp;\displaystyle \tau-\tau^*,{} \end{array} \end{aligned} $$
(16.27)
remain small, i.e., z ≈ 0, w ≈ 0. On the other hand, recall that τ  = 0 and, hence, w = τ. Then, (16.6) can be used to find the following modified version of (16.25):
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \dot z&amp;=&amp;Az+\mathcal{B}u,{} \\ \mathcal{B}&amp;=&amp; \left[\begin{array}{c} 0\\ \overline{d}_{12}\\ \overline{d}_{22}\\ \end{array}\right]\frac{k_m}{R}. \end{array} \end{aligned} $$
(16.28)
This approximate linear model is to be used to design the balancing controller.
First, the pair  $$(A,\mathcal {B})$$ is checked to be controllable. This requires computation of the determinant of the controllability matrix  $$C=[\mathcal {B}|A\mathcal {B}|A^2\mathcal {B}]$$ , which is found to be:
 $$\displaystyle \begin{aligned} \det(C)=\frac{\overline{m}gk_m^3}{R^3}\overline{d}_{12}^2(\overline{d}_{11}\overline{d}_{22}-\overline{d}_{12}\overline{d}_{21})\neq 0.{} \end{aligned} $$
(16.29)
Hence, it is concluded that the pair  $$(A,\mathcal {B})$$ is controllable. This means that it is always possible to find a gain vector K such that all eigenvalues of the closed-loop matrix  $$(A-\mathcal {B}K)$$ are assigned at arbitrary locations. This is achieved using the controller:
 $$\displaystyle \begin{aligned} u=-Kz.{} \end{aligned} $$
(16.30)
The gain vector K is computed once the numerical values of the parameters involved in matrices A and  $$\mathcal {B}$$ are known. The controller (16.30) renders it possible to balance the IWP at the inverted unstable configuration defined by the operation point (16.19), (16.22), (16.23), (16.24), with n = ±1. It is important to stress that this requires the mechanism state vector x to be close enough to such an unstable configuration at the time when the controller (16.30) starts to work.

Finally, it is important to say that the constant c introduced in (16.24) takes the value of the wheel velocity at the time when the controller (16.30) starts to work. As this velocity may take any value, it is instrumental that c can be defined as any real constant.

16.5 Prototype Construction and Parameter Identification

A drawing of the IWP that has been built is shown in Fig. 16.4. There, the main components are shown. Some of these components are included to successfully assemble the mechanical pieces. An incremental encoder and a tachometer are also included, to measure the pendulum position q 1 and the wheel velocity  $$\dot q_2$$ respectively. The dimensions of the pieces employed are presented in Table 16.1.
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig4_HTML.png
Fig. 16.4

Inertia wheel pendulum

Table 16.1

Simple parameters

Symbol

Description

Value

Units

l 1

Metal sheet length

0.117

m

a sol

Metal sheet width

0.0254

m

m sol

Metal sheet mass

0.016

Kg

m car

Actuator stator mass

0.03

Kg

m sop

Tachometer holder mass

0.01375

Kg

m rot

Actuator rotor mass

0.02

Kg

r rot

Actuator rotor radius

0.00915

m

m rue

Wheel mass

0.038

Kg

r rue

Wheel radius

0.0189

m

R

Armature resistance

4.172

Ohm

L

Armature inductance

0.0009

H

k b

Counter electromotive force constant

0.00775

Vs/rad

k m

Torque constant

0.00775

Nm/A

The pendulum equivalent mass m 1 is defined as:
 $$\displaystyle \begin{aligned} m_1=m_{sol}+m_{car}+m_{sop}=0{.}05975\ \mathrm{[Kg]}.{} \end{aligned} $$
(16.31)
To compute the pendulum’s center of mass including all its components, the balance principle is employed, i.e., the sum of all the torques around the support point is zero. Hence, when applying an equivalent weight at a distance l c1 on the opposite end of the metal sheet, the assembly in Fig. 16.5 must be balanced. Using (16.31) and the data in Table 16.1, the following is found:
 $$\displaystyle \begin{aligned} l_{c1}=\frac{m_{sol}\frac{l_{1}}{2}+m_{car}l_{1}+m_{sop}l_{1}}{m_1}=0{.}10133\ \mathrm{[m]}.{} \end{aligned} $$
(16.32)
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig5_HTML.png
Fig. 16.5

The balance principle to compute l c1

The moment of inertia of a rectangular thick sheet with mass m, width b, and length d, with rotation axis x orthogonal to the plane, with edges b and d passing through its geometric center, is given as [14, 15], pp. 271:
 $$\displaystyle \begin{aligned} I_{x}=\frac{1}{12}m(b^2+d^2).{} \end{aligned} $$
(16.33)
Using (16.33) and the data in Table 16.1, the moment of inertia I is obtained as:
 $$\displaystyle \begin{aligned} I^*=\frac{1}{12}m_{sol}(a_{sol}^2+l_1^2)=0{.}0000191122\ \mathrm{[Kg m}^2\mathrm{]}.{} \end{aligned} $$
(16.34)
However, the moment of inertia I 1 is defined around an axis passing through the pendulum center of mass located at a distance l c1 − l 1∕2 from the center of the rectangle with edges b and d. According to the parallel axis theorem or Steiner theorem [14, 15], pp. 272:
 $$\displaystyle \begin{aligned} I_{1}=I^*+m_{sol}\left(l_{c1}-\frac{l_1}{2}\right)^2=0{.}000048463\ \mathrm{[Kg m}^2\mathrm{]}. \end{aligned}$$
On the other hand, the moment of inertia of a disc with a mass m and radius r with rotation axis x orthogonal to the disc and passing through its geometric center is given as [14, 15], pp. 271:
 $$\displaystyle \begin{aligned} I_{x}=\frac{1}{2}mr^2.{} \end{aligned} $$
(16.35)
Using the data in Table 16.1 and the expression in (16.35) it is found that the wheel’s moment of inertia I rue is given as:
 $$\displaystyle \begin{aligned} I_{rue}=\frac{1}{2}m_{rue}r_{rue}^2=0{.}000006787\ \mathrm{[Kg m}^2\mathrm{]}.{} \end{aligned} $$
(16.36)
The moment of inertia of a cylinder with a mass m, radius a, and height l, with a rotation axis x passing through its longitudinal axis is given as [14, 15], pp. 271:
 $$\displaystyle \begin{aligned} I_{x}=\frac{1}{2}ma^2.{} \end{aligned} $$
(16.37)
Using the expression in (16.37) and the data in Table 16.1, the moment of inertia of the actuator rotor I rot is found to be:
 $$\displaystyle \begin{aligned} I_{rot}=\frac{1}{2}m_{rot}r_{rot}^2=0{.}000000837225\ \mathrm{[Kg m}^2\mathrm{]}.{} \end{aligned} $$
(16.38)
The equivalent wheel mass m 2 is defined as:
 $$\displaystyle \begin{aligned} m_2=m_{rot}+m_{rue}=0{.}058\ \mathrm{[Kg]}.{} \end{aligned} $$
(16.39)
Using (16.36) and (16.38), it is found that the equivalent wheel moment of inertia I 2 is given as:
 $$\displaystyle \begin{aligned} I_{2}=I_{rue}+I_{rot}=0{.}0000076242\ \mathrm{[Kg m}^2\mathrm{]}.{} \end{aligned} $$
(16.40)
Finally, using the data in Table 16.1, the parameters in (16.34), (16.31), (16.32), (16.39), (16.40), and g = 9.81[m/s2], the following numerical values for the parameters of model (16.3) are found:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} d_{11}&amp;\displaystyle =&amp;\displaystyle 0{.}0014636, d_{12}= 0{.}0000076,{}\\ d_{21}&amp;\displaystyle =&amp;\displaystyle 0{.}0000076, d_{22}= 0{.}0000076, \\ \overline{m}g&amp;\displaystyle =&amp;\displaystyle 0{.}12597. \end{array} \end{aligned} $$
(16.41)

It is worth saying that the tachometer mass is considered as a part of the tachometer holder mass and the effect of the tachometer rotor is neglected when computing I 2. This is because it has a mass less than 0.0001[Kg] and a radius less than 0.001 [m]. On the other hand, the screws holding the dice, the dice itself, and the incremental encoder shaft are neglected when computing the inertia I 1. This is because the addition of these masses is less than 0.008[kg] and, more importantly, they are placed at the point where the pendulum hangs up, which reduces strongly their inertial effects. Finally, the mass of the electric wires and the plastic pipe used to couple the tachometer to the wheel were also neglected.

Example 16.2

Some simulation results are presented in the following when controlling the IWM (16.3), with numerical parameters in (16.41), using the controller in (16.10) to solve the swing-up task and the controller in (16.30) to balance the pendulum at the inverted configuration. The switching condition between the controllers is:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \mathrm{If:}&amp;\displaystyle &amp;\displaystyle \hspace{1cm} z_1^2+z_2^2\leq0{.}01, \mathrm{controller in~(16.30) is on,}\\ \mathrm{else:}&amp;\displaystyle &amp;\displaystyle \hspace{1cm} \mathrm{controller in~(16.10) is on,} \end{array} \end{aligned} $$
with z 1 and z 2 defined in (16.26). All of the initial conditions were chosen to be zero except for  $$\dot q_1(0)=0{.}00001$$ [rad/s]. The controller in (16.10) was set with k d  = 20. The vector of gains K for controller (16.30) was selected such that the eigenvalues of the closed-loop matrix  $$A-\mathcal {B}K$$ are assigned at − 9.27 ± 20.6j and − 0.719. These simulations were performed using the MATLAB/Simulink diagram in Fig. 16.6 where there are four main blocks that contain the code listed in Appendix G.2. Before running the simulation in Fig. 16.6, the code in Appendix G.2.5 must be executed to assign numerical values to all the parameters.
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig6_HTML.png
Fig. 16.6

MATLAB/Simulink diagram for the inertia wheel pendulum

It is observed in Fig. 16.7 that the pendulum swings up and is finally balanced at its inverted unstable configuration. Moreover, the wheel velocity remains bounded along the complete simulation. Also note that the applied voltage remains within a suitable range, i.e., between − 13[V] and + 13[V] and, finally, the pendulum energy converges to its desired value V 0. Thus, these simulation results corroborate the theoretical results stated above.
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig7_HTML.png
Fig. 16.7

Simulation results when swinging up and stabilizing the IWP with controllers in (16.10) and (16.30). (a) Pendulum position. (b) Pendulum velocity. (c) Wheel velocity. (d) Applied voltage. (e) Pendulum energy. (f) Pendulum energy error

16.6 Controller Implementation

Using the numerical values in Sect. 16.5, k d  = 1 and according to (16.7), (16.10), it is found that the swing-up controller is given as:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} V&amp;\displaystyle =&amp;\displaystyle C_1\;\dot q_1^2+\overline mg(1-\cos{}(q_1)), C_1=\frac{1}{2}J,V_0=2\overline mg, \\ u&amp;\displaystyle =&amp;\displaystyle C_2sat(\dot q_1)\; sign(V-V_0), C_2=\frac{Rk_d}{k_m}, \varepsilon_0=\frac{u_{max}k_m}{k_dR},{} \end{array} \end{aligned} $$
(16.42)
where u max  = 13[V], whereas the constants C 1 and C 2 are computed only once when initializing variables, to reduce the number of multiplications required for implementation.
On the other hand, according to Sects. 7.​14.​1 and 7.​14.​2, in Chap. 7, it is found that the linear controller (16.30), together with the gain vector K = [k 1, k 2, k 3] = [−340, −11, −0.0085] assign the eigenvalues of matrix  $$(A-\mathcal {B}K)$$ at:  $$\bar \lambda _1=-5{.}8535+17{.}7192j$$ ,  $$\bar \lambda _2=-5{.}8535-17{.}7192j$$ ,  $$\bar \lambda _3=-0{.}5268$$ . Hence, the controller (16.30) is expressed as:
 $$\displaystyle \begin{aligned} u=-k_1(q_1-q_{1d})-k_2\dot q_1-k_3(\dot q_2-\dot q_{2d}),{} \end{aligned} $$
(16.43)
where any of q 1d  = +π or q 1d  = −π is used, depending on which one is first reached by q 1. Recall that  $$\dot q_{2d}=c$$ is the wheel velocity at the time when the controller (16.43) starts to work.
Define the condition:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} (q_1-q_{1d})^2+\dot q_1^2&lt;\delta,{} \end{array} \end{aligned} $$
(16.44)
for some constant that is small enough δ > 0 and q 1d  = +π or q 1d  = −π. This condition indicates that the pendulum is close to one of the points  $$(q_{1},\dot q_1)=(+\pi ,0)$$ or  $$(q_{1},\dot q_1)=(-\pi ,0)$$ . In the experiments presented later δ = 0.3 has been used.

The control strategy to swing up and to balance the IWP is to employ (16.42) until (16.44) is satisfied and, from that time on, turn off (16.42) and turn on (16.43). This task is performed using the Microchip PIC18F4431 microcontroller. It is explained next how this is done. This part is not intended to present a detailed explanation on how this microcontroller works, but merely a basic description of how this microcontroller is employed to implement the control strategy (16.42), (16.43), (16.44).

The complete code used to program the microcontroller is presented at the end of this chapter. The microcontroller PIC18F4431 [16] works at 40 MHz as maximal clock frequency. In this chapter, a 11-MHz crystal is used. Five programmable input–output ports, three 16-bit timers, one 8-bit timer (employed to fix the sample period T s  = 0.01[s]), and nine 10-bit analog/digital channels (the tachometer voltage enters through channel 0), are available. There are also eight 14-bit PWM channels among which CCP1 is programmed to work with 8 bit to deliver voltage to be applied to the actuator (PM brushed DC motor).

The position q 1 is measured using an incremental encoder model CP-360-S from Computer Optical Products Inc. [17]. This device, once connected to the microcontroller, has a resolution of 1440 ppr. Pulses of this incremental encoder are read through the microcontroller pins 5 and 6 (see Fig. 16.8). The incremental encoder counts are stored in two 8-bit bytes called POSCNTH, the most significative, and POSCNTL, the less significative. The actual count is computed as:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} pos=256*POSCNTH+POSCNTL, \end{array} \end{aligned} $$
The instruction “q1=(signed long)pos” assigns to q1 the numerical value of the encoder count, which includes the corresponding sign, i.e., positive if movement is as that shown in Fig. 16.2 or negative otherwise. Finally, the position q 1 is given in radians when performing:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} q_1=\frac{2\pi}{1440}\;q1, \frac{2\pi}{1440}=0{.}004363. \end{array} \end{aligned} $$
It is worth stating that the complete control system must be turned on when the pendulum is at rest at q 1 = 0, according to the convention in Fig. 16.2. The pendulum velocity  $$\dot q_1$$ is computed by numerical differentiation of the pendulum position q 1, i.e.,:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} \dot q_1&amp;\displaystyle =&amp;\displaystyle \frac{q_1(k)-q_1(k-1)}{T}, \end{array} \end{aligned} $$
where k stands for the discrete time,  $$\dot q_1$$ represents the estimate of the pendulum velocity in radians/second whereas T s  = 0.01[s] is the sampling period. Hence, q 1(k) represents the value of q 1 measured at the present sample time and q 1(k − 1) represents the value of q 1 measured in the previous sample time.
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig8_HTML.png
Fig. 16.8

Control system electric diagram

The wheel velocity  $$\dot q_2$$ is measured using a tachometer model 34PC. It is a miniature PM brushed DC motor used in cell phones as a buzzer. Voltage delivered by the tachometer is low-pass filtered using the RC circuit shown in Fig. 16.8. It was found that this tachometer delivers 0.58[V] when the wheel velocity is maximal, i.e., 1634 [rad/s]. It was assumed that this voltage is proportional at any other intermediate velocity. To improve the resolution of this velocity measurement, the tension divider connected to pin 4 (see Fig. 16.8) was employed to fix at 3.8372[V] the minimal value of the analog range of the analog/digital converter channel 0 (the maximal value is fixed at 5[V]). On the other hand, the tachometer is series connected to another tension divider, such that, when the tachometer is at rest, i.e., when  $$\dot q_2=0$$ , voltage at channel 0 is (5-3.8372)/2+3.8372=4.4186[V]. Notice that variations of about 0.58[V], i.e., 1634[rad/s], are allowed upward and downward from the middle point of the converter analog range. Hence, when  $$\dot q_2=1634$$ [rad/s] the analog/digital converter delivers the count 1023 = 210 − 1 (the AD converter is 10-bit) and when  $$\dot q_2=0$$ [rad/s] the analog/digital converter delivers the count 1023∕2 = 511. Counts smaller than 511 represent negative velocities  $$\dot q_2$$ . According to this information, the wheel velocity is computed as follows. The instruction “vel=read-adc()-511” assigns to the variable “vel” the code corresponding to the wheel velocity, whereas the instructions “q2_p=(signed long)vel” and “q2_p=3.2039*q2_p” assign to variable “q2_p” a value that is numerically equal to the wheel velocity  $$\dot q_2$$ in radians/second, the sign included. Notice that the constant 3.2039=1634/510[(rad/s)/count] represents the measurement system gain.

With this information, any of the expressions in (16.42) or (16.43) are computed. The resulting variable u is sent to the microcontroller PWM as described in the following.

An equivalent way of implementing the saturation function in (16.42) with a smaller number of computations is the following. It is known that u only takes values in the range [−13, +13][V]; hence, its value is constrained to this range of values by using instructions such as:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} &amp;\displaystyle &amp;\displaystyle if\;u&gt;13\;then \;u=13,\\ &amp;\displaystyle &amp;\displaystyle if\;u&lt;-13\;then \;u=-13. \end{array} \end{aligned} $$
As the PWM resolution is 28 − 1 = 255 counts, then the following value must be sent to the microcontroller PWM to correctly deliver u to the power amplifier:
 $$\displaystyle \begin{aligned} \begin{array}{rcl} cuenta=\frac{255}{13}\;abs(u), \end{array} \end{aligned} $$
where abs(u) represents the absolute value of u. The sign of u is stored in two control bits. The PWM signal is applied to an H bridge (L293B from SGS-Thomson Microelectronics), which suitably amplifies the power of the PWM signal. This H bridge is fed with a 15.3[V] power supply. However, according to the data sheet of this device [18], the voltage drops constrain to ± 13[V] the voltage signal to be delivered. This device has two bits, which are employed to indicate the sign of the power voltage to deliver. Thus, the sign of u is sent to the H bridge through the bits 0 and 1 of the microcontroller port D. This means that the average power voltage sent to the motor is in the range [−13, +13][V]. Hence, it is ensured that the voltage applied at the motor terminals u has an average value that is numerically equal to u, computed by any of the expressions in (16.42) or (16.43). The electric diagram used to implement the control strategy in (16.42), (16.43), (16.44), is shown in Fig. 16.8.

16.7 Experimental Results

The experimental results obtained with the proposed control scheme are shown in Figs. 16.9, 16.10, 16.11, 16.12, and 16.13. It is important to recall that it is necessary to apply a slight hit on the pendulum at the beginning to abandon the configuration  $$(q_1,\dot q_1)=(0,0)$$ . Although this can be replaced by sending a small voltage pulse to the actuator at the beginning, this was not programmed.
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig9_HTML.png
Fig. 16.9

Pendulum position as the inverted unstable configuration is reached

/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig10_HTML.png
Fig. 16.10

Wheel velocity

/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig11_HTML.png
Fig. 16.11

Voltage applied to the motor

/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig12_HTML.png
Fig. 16.12

Pendulum evolution on the plane  $$\dot q_1-q_1$$ (phase plane)

/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig13_HTML.png
Fig. 16.13

Energy evolution as the inverted unstable configuration is reached

In Fig. 16.9, it is observed how the pendulum oscillates with ever-growing amplitude until the position q 1 = −π is reached with zero velocity at t ≈ 14[s] and the pendulum stays there from that time on. In Fig. 16.10, it is observed that the wheel velocity remains constant at 380[rad/s] from t ≈ 17[s] on. It is interesting to point out that the wheel velocity is commanded to be regulated at c ≈ 150[rad/s], which is the wheel velocity at t ≈ 14[s], i.e., when the controller (16.43) starts to work. The difference between c and the final wheel velocity 380[rad/s] is due to friction present at the wheel shaft, which has not been taken into account during the design stage.

In Fig. 16.11, the control signal u is shown. Note that this variable saturates most of the time during the swing-up stage (t < 14[s]). This is the reason why saturation and sign functions are used in the controller (16.42). In fact, ε 0 = 0.024 is chosen so that with this value and the factor  $$\frac {4{.}172}{0{.}00775}$$ , u saturates at ± 13[V].

In Fig. 16.12, it is shown how the pendulum evolves on the plane defined in Fig. 16.3, Sect. 16.3. It is clear that, comparing both figures, the pendulum moves such that its energy V  increases (see also Fig. 16.13) until V = V 0 = 0.2519. Note that V  reaches such a value as t ≈ 11[s], but the pendulum is balanced until t ≈ 14[s]. This demonstrates that energy is regulated at V = V 0 until the point  $$(q_1,\dot q_1)=(-\pi ,0)$$ is reached. It is clear that the pendulum also passes close to the point  $$(q_1,\dot q_1)=(+\pi ,0)$$ at t ≈ 13[s] but it is not balanced, perhaps the condition in (16.44) was not satisfied at that time, i.e., the pendulum did not pass close enough to such a point.

Finally, in Fig. 16.14, a picture is shown where the IWP is observed balancing at the inverted unstable configuration.
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig14_HTML.jpg
Fig. 16.14

The inertia wheel pendulum balancing at the inverted unstable configuration

16.8 PIC18F4431 Microcontroller Programming

The reader is referred to [19] for detailed explanations on each one of the instructions appearing in the following program. The corresponding flow diagram is presented in Fig. 16.15.
/epubstore/G/V-M-Guzman/Automatic-Control-With-Experiments/OEBPS/images/454499_1_En_16_Chapter/454499_1_En_16_Fig15_HTML.png
Fig. 16.15

Flow diagram for PIC18F4431 microcontroller programming when used to control an inertia wheel pendulum

#include<18f4431.h>
#device adc=10 //adc, 10 bits
#include<stdlib.h>
#include<math.h>
#fuses HS,NOWDT,NOPROTECT,PUT,NOLVP,NOBROWNOUT,NOWRTC,
MCLR,SSP_RC
#define pi_ 3.14159
//nonlinear controller gain
#define kd 1.0
//linear controller gains
#define k1 340
#define k2 11
#define k3 0.0085
//parameters
#define mbg 0.12597
#define R 4.172
#define L 0.0009
#define Kb 0.00775
#define Km 0.00775
#define d11 0.0014636
#define d12 0.0000076
#define d21 0.0000076
#define d22 0.0000076
#define delta 0.3
#define ts 0.01
//with timer=108, each count= (4/FXtal)∗256 sec
/∗Register addresses∗/
#use delay(clock=11000000)
//time basis (11 MHz)
#byte porta = 0xf80
//ports addresses
#byte portb = 0xf81
#byte portc = 0xf82
#byte portd = 0xf83
#byte portd = 0xf84
#byte TMR0H = 0xfd7
#byte TMR0L = 0xfd6
#byte T0CON = 0xfd5
#byte INTCON= 0xff2
#byte TMR5H=0xf88
//high encoder count
#byte TMR5L=0xf87 //low encoder count
#byte QEICON=0xfB6 //config. quadrature module
#byte T5CON=0xfB7 //Config. TIMER 5
#byte POSCNTL=0xF66 //CAP2BUFL (reg. low count)
#byte POSCNTH=0xF67 //CAP2BUFH (reg. high count)
#byte CAP1CON=0xF63 //reg. config. reset time basis
#byte PIE3=0xFA3
/∗bits addresses ∗/
#bit VCFG1=0xfc1.7 //Bit config. ADC
#bit PD0=0x0f83.0 //control CCW H bridge
#bit PD1=0x0f83.1
//control CW H bridge
#bit PD2=0x0f83.2
//led at board
#bit PD3=0x0f83.3 //led a board
/∗variables declaration∗/
float u,q1,q1_p,q1_1,q2_p,q1_d,q2_pd,gr,V,S,nf,i_ts,
    Je2,V0,RKdeKm;
long pos,vel,inter;
int pwm;
signed int n,mod;
/∗main program∗/
void main(void)
{
set_tris_a(0b11111111);
//Config. I/O ports
set_tris_b(0b00000000);
set_tris_c(0b10000000);
set_tris_d(0b00000000);
portb=0X00;
portc=0X00;
portd=0X00;
//CONFIG. PWM
setup_ccp1(CCP_PWM);
setup_ccp2(CCP_PWM);
setup_timer_2(T2_DIV_BY_16,255,1);
// Config. encoder reading
QEICON=QEICON | (0b00010101);
QEICON=QEICON & (0b01110101);
T5CON=T5CON | (0b00011001);
T5CON=T5CON & (0b10011101);
CAP1CON=CAP1CON | (0b01001111);
setup_timer_1(T1_INTERNAL | T1_DIV_BY_8);
TMR5L=0;
TMR5H=0;
POSCNTL=0;
POSCNTH=0;
//Config. ADC
setup_port_a(sAN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
delay_us(50);
VCFG1=1; //-Vref=AN2
INTCON=0;//turn off interrupt
//Config. timer 0
TMR0L=0;
T0CON=0xC7;
//initializing variables
i_ts=1/ts;
Je2=(d11∗d22-d12∗d21)/(2∗d12);
V0=2∗mbg;
RKdeKm=R∗Kd/Km;
q1=0.0;
q1_1=0.0;
q2_pd=0.0;
while (TRUE)
{
PD3=1;
q1_1=q1; // q1(k-1)
pos=POSCNTH;
pos=pos<<8;
pos=pos+POSCNTL;
q1=(signed long)pos;
q1=0.004363∗q1; //arm position in rad
q1_p=(q1-q1_1)∗i_ts; //arm velocity
vel=read_adc()-511; //wheel velocity
q2_p=(signed long)vel;
q2_p=3.2039∗q2_p; //wheel velocity in rad/seg
//desired q1
n=q1/pi_;
nf=(float)n;
mod=n%2;
if(nf==0)
if(q1>=0) // desired value
q1_d=pi_;
else
q1_d=-pi_;
if((nf!=0)&&!PD2)
{
if(q1>=0) // desired value
{
if(mod==0)
q1_d=pi_∗(nf+1.0);
else
q1_d=pi_∗nf;
}
else
{
if(mod==0)
q1_d=pi_∗(nf-1.0);
else
q1_d=pi_∗nf;
}
}
//defining the operation region for each controller
if((q1-q1_d)∗(q1-q1_d) + q1_p∗q1_p < delta)
{
PD2=1; //linear controller
u= k1∗(q1-q1_d) + k2∗q1_p + k3∗(q2_p-q2_pd);
}
else
{
PD2=0; //nonlinear controller
V=Je2∗q1_p∗q1_p+mbg∗(1-cos(q1));
V=V-V0;
S=0; //sign function
if(V>0)
S=1.0;
if(V<0)
S=-1.0;
u=RKdeKm∗q1_p∗S; //nonlinear controller ends
q2_pd=q2_p; //wheel desired velocity
}
//saturation 13V(15.3 V - 2.3 V drop at H bridge= 13 V)
if(u>13)
u=13;
if(u<-13)
u=-13;
//scaling output, pwm 8 bits, 13 V
u=19.6∗u;
//sense of rotation
if(u>=0)
{
PD0=1;
PD1=0;
}
else
{
PD0=0;
PD1=1;
}
//sending pwm
pwm=(unsigned int)abs(u);
set_pwm1_duty(pwm); //pwm
PD3=0; //control computation ends
while(TMR0L<108); //each count = (4/FXtal)∗256 sec
TMR0L=0;
T0CON=0xC7;
} //closing infinite while
} //closing main

16.9 Summary

In this chapter, another underactuated nonlinear system has been presented: the inertia wheel pendulum. The mathematical model has been obtained and two controllers have been used to solve two different control problems: swing-up and balancing. The balancing control problem has been solved using a linear state feedback controller, whereas the swing-up control problem has been solved using a nonlinear controller. This has been done to introduce the reader to the study of nonlinear control systems. All parameters of the mechanism have been identified and the complete control system has been tested in experiments. A detailed description of the mechanism construction has also been presented.

16.10 Review Questions

  1. 1.

    Why is the inertia wheel pendulum an underactuated mechanism?

     
  2. 2.

    Why must the IWP oscillate several times before reaching the inverted configuration?

     
  3. 3.

    What is the corner frequency in [rad/s] and [Hz] of the tachometer resistor–capacitor filter shown in Fig. 16.8?

     
  4. 4.

    Why does the amplitude of voltage in Fig. 16.11 remain between 13[V] and -13[V] when the swing-up task is performed?