## 4 Dynamic Model
### State Space Model of 2 DSFL and 2 DSFJ  
The dynamic model and equations of the system have been derived with the help of Euler-Lagrange formulation. The equations were then linearised using the Taylor expansion series to achieve representation in the state-space:  
\[\dot{x}=Ax+Bu, \tag{45}\]  
\[y=Cx+Du.\]  
The schematic diagram and the mechanical model equivalent are shown in Figures 4 and 5, respectively.  
Figure 4: Single Flexible link schematic.  
Figure 3: Bode plot for IO transfer function of controller for Link 1.  
The Lagrangian equation is applied to derive the linear state-space model. As we know, the Lagrangian is the difference between the total kinetic (KE) and potential energies (PE). To derive the equations in the form of (45), the following procedure was carried out. Using mechanics, we define the relations  
\[KE=\frac{1}{2}J_{1}\dot{\theta}^{2}+\frac{1}{2}J_{2}(\dot{\theta}+\dot{\phi})^{ 2},\;\;PE=\frac{1}{2}K_{s}\dot{\phi}^{2}, \tag{46}\]  
where the constants \(J_{1}andK_{s}\) have been explained in Table 1. From Equation (46), the Lagrangian \(L\) is derived as  
\[L=Kinetic\;\;energy-Potential\;\;energy=\frac{1}{2}J_{1}\dot{\theta}^{2}+ \frac{1}{2}J_{2}(\dot{\theta}+\dot{\phi})^{2}-\frac{1}{2}K_{s}\dot{\phi}^{2}. \tag{47}\]  
Using Equation (47) and according to the Euler-Lagrangian formulation, we have (48):  
\[\frac{d}{dt}\frac{\partial L}{\partial\dot{\theta}}-\frac{\partial L}{ \partial\theta}=\tau-B_{2}\dot{\theta},\;\;\frac{d}{dt}\frac{\partial L}{ \partial\dot{\phi}}-\frac{\partial L}{\partial\dot{\phi}}=0. \tag{48}\]  
From (47), we obtain the governing set of EOMs (equations of motion) as  
\[(J_{1}+J_{2})\ddot{\theta}+J_{2}\ddot{\phi}+B_{2}\dot{\theta}=\tau, \tag{49}\]  
\[J_{1}\ddot{\theta}+J_{2}\ddot{\phi}+K_{s}\dot{\phi}=0. \tag{50}\]  
Differentiating the values of \(\ddot{\theta}\) and \(\ddot{\phi}\) in (49) and (50), we obtain (51):  
\[\ddot{\theta}=-\frac{B_{1}}{J_{1}}\dot{\theta}+\frac{K_{s}}{J_{2}}\dot{\phi}+ \frac{1}{J_{1}}\tau,\;\;\ddot{\phi}=\frac{B_{1}}{J_{1}}\dot{\theta}+\frac{K_{ s}(J_{1}+J_{2})}{J_{1}J_{2}}\dot{\phi}-\frac{1}{J_{1}}\tau. \tag{51}\]  
The linear state space model achieved from the above equations for a single flexible link is represented in Equation (52). Similarly, the state matrices and input matrices are found for Link 2. Using the same analogy, we have defined the state-space matrices for joints in Equation (53) as  
\[A_{l}=\begin{bmatrix}0&0&1&0\\ 0&0&0&1\\ 0&\frac{K_{s}}{J_{1}}&-\frac{B_{1}}{J_{1}}&\frac{B_{2}}{J_{1}}\\ 0&-\frac{(J_{1}+J_{2})K_{s}}{J_{1}J_{2}}&\frac{B_{1}}{J_{1}}&-\frac{(J_{1}+J_{ 2})B_{2}}{J_{2}}\end{bmatrix},\;\;\;\;\;\;\;\;B_{l}=\begin{bmatrix}0\\ 0\\ \frac{K_{s}}{J_{1}}\\ -\frac{K_{s}}{J_{1}}\end{bmatrix}. \tag{52}\]  
Figure 5: Single Flexible link mechanical model.  
\[A_{j}=\begin{bmatrix}0&0&1&0\\ 0&0&0&1\\ -\frac{K_{s}}{J_{1}}&\frac{K_{s}}{J_{1}}&-\frac{B_{1}}{J_{1}}&0\\ \frac{K_{s}}{J_{2}}&-\frac{K_{s}}{J_{2}}&0&-\frac{B_{2}}{J_{2}}\end{bmatrix}, \qquad B_{j}=\begin{bmatrix}0\\ 0\\ \frac{K_{s}}{J_{1}}\\ 0\end{bmatrix}. \tag{53}\]  
After the state-space model, various simulink (MATLAB) models have been designed for the following purposes: (i) first, the comparison of integer order and fractional order responses; (ii) second, the application of the Kalman Filter to remove noise and the prediction of state for the feedback purpose. Similar state space models have been formed for the remaining link and flexible joints. The physical parameters are the only difference between the state space model presented here and that of the remaining link and flexible joints [53; 54].