## 3 Sliding Mode Control of the Flexible Bar Using Penalization Method
### Sliding Mode Controller Design and Lyapunov-Like Stability Analysis  
In order to stabilize the flexible bar system for the current system, a new method based on sliding mode techniques via a penalty approach is proposed. The main reason for the election of this control strategy is the insensitivity of this algorithm to the shape memory alloy parameter variations during the heating and cooling stages. The equation of motion of the system Equation (6) can be rewritten as  
\[\ddot{x}=-A^{-1}B\dot{x}-A^{-1}C+A^{-1}D\tau, \tag{7}\]  
where  
\[x_{1}=\alpha_{1},\ x_{2}=\alpha_{2},\...\ \,x_{n}=\alpha_{n}\]  
and \(D\tau=Q_{no-pot}=[1,1,\cdots,1]^{\top}\ \tau\). Note that when the flexible bar reaches its desired state, it will be in an equilibrium position as \(\ddot{x}=\dot{x}=0\). Therefore, the following relation holds for the system in the equilibrium position  
\[C=\left[ \begin{array}{c}((n-1)+\frac{1}{2})mgl\sin(x_{1})\\ \\ ((n-2)+\frac{1}{2})mgl\sin(x_{2})\\ \\ ((n-3)+\frac{1}{2})mgl\sin(x_{3})\\ \vdots\\ \frac{1}{2}mgl\sin(x_{n})\end{array} \right]=D\tau \tag{8}\]  
Figure 4: The angular position of flexible bar without control. which makes a constraint between the angular position of segments and the control input. Dividing the first component of Equation (8) by its following components gives the relation between the angles at equilibrium point as follows:  
\[ \begin{array}{l}\frac{C_{1}}{C_{2}}\rightarrow\ \frac{\left((n-1)+\frac{1}{2} \right)\ mgl\sin(x_{1})}{\left((n-2)+\frac{1}{2}\right)\ mgl\sin(x_{2})}=1 \implies\ \frac{\left((n-1)+\frac{1}{2}\right)}{\left((n-2)+\frac{1}{2} \right)}\sin(x_{1})-\sin(x_{2})=0\\ \\ \frac{C_{1}}{C_{3}}\rightarrow\ \frac{\left((n-1)+\frac{1}{2}\right)\ mgl\sin(x_{1})}{ \left((n-3)+\frac{1}{2}\right)\ mgl\sin(x_{3})}=1\implies\ \frac{\left((n-1)+\frac{1}{2}\right)}{ \left((n-3)+\frac{1}{2}\right)}\sin(x_{1})-\sin(x_{3})=0\\ \vdots\\ \frac{C_{1}}{C_{n}}\rightarrow\ \frac{\left((n-1)+\frac{1}{2}\right)\ mgl\sin(x_{1})}{ \frac{1}{2}mgl\sin(x_{n})}=1\implies 2((n-1)+\frac{1}{2})\sin(x_{1})-\sin(x_{n})=0\end{array} \]  
thus, the vector of constraints can be defined by  
\[g=\left[ \begin{array}{c}g_{1}\\ g_{2}\\ \vdots\\ g_{n-1}\end{array} \right]=\left[ \begin{array}{c}\frac{((n-1)+\frac{1}{2})}{ ((n-2)+\frac{1}{2})}\sin(x_{1})-\sin(x_{2})\\ \\ \frac{((n-1)+\frac{1}{2})}{((n-3)+\frac{1}{2})}\sin(x_{1})-\sin(x_{3})\\ \vdots\\ 2((n-1)+\frac{1}{2})\sin(x_{1})-\sin(x_{n})\end{array} \right] \tag{9}\]  
in which \(g=0\). The obtained constraints will be used later on in the design of the SMC. On the other hand, the tracking error for the desired constant angular position \(x_{i}^{*}(t)\) is described as  
\[e_{i}(t)=x_{i}(t)-x_{i}^{*}(t), \tag{10}\]  
by using the equation of tracking error and its derivative, a first order sliding variable can be designed as  
\[S=\left[ \begin{array}{c}\dot{e}_{1}+c_{1}e_{1}\\ \dot{e}_{2}+c_{2}e_{2}\\ \vdots\\ \dot{e}_{n}+c_{n}e_{n}\end{array} \right], \tag{11}\]  
where \(e_{i}=x_{i}-x_{i}^{*}\), \(i=1,2,\cdots,n\) and \(c_{1},c_{2},...,c_{n}\) are positive constants. The derivative of the sliding surface can be taken as follows  
\[\dot{S}=\left[ \begin{array}{c}\dot{e}_{1}+c_{1}\dot{e}_{1}\\ \dot{e}_{2}+c_{2}\dot{e}_{2}\\ \vdots\\ \dot{e}_{n}+c_{n}\dot{e}_{n}\end{array} \right]=\left[ \begin{array}{c}\dot{x }_{1}+c_{1}\dot{x}_{1}\\ \dot{x}_{2}+c_{2}\dot{x}_{2}\\ \vdots\\ \dot{x}_{n}+c_{n}\dot{x}_{n}\end{array} \right]=\ddot{x}+C_{0}\dot{x} \tag{12}\]  
where  
\[C_{0}=\left[ \begin{array}{cccc}c_{1}&0&\cdots&0\\ 0&c_{2}&\cdots&0\\ \vdots&\vdots&\ddots&\vdots\\ 0&0&\cdots&c_{n}\end{array} \right]>0.\]In the next step, a switching control law will be obtained according to the Lyapunov stability theorem. First, the Lyapunov function \(V\) is introduced as  
\[V:=S^{\intercal}S+\frac{\mu}{2}\left\|g\right\|^{2}\quad,\quad\mu>0, \tag{13}\]  
where \(g\) is the penalty function due to the mentioned constraints of the system.