## 2 Mechanical Analysis  
### Mass-Matrix of the Four-Bar Linkage Using Fully Cartesian Coordinates  
Figure 1 shows a four-bar linkage consisting of four rigid bodies located in the same plane. A motor is located at point A, so the crank AB rotates with velocity \(\omega[rads/s]\). \(l_{AB},l_{BD}\) and \(l_{CD}\) represent the length of each link. By using Fully Cartesian coordinates [9] to represent the system, it is easy to obtain the equations of the ShF and ShM. This method has been previously used in [22; 25; 26]. To obtain the mass-matrix \(M\) of the whole mechanism, it is necessary to define the mass-matrix \(M_{n}\) of each \(n\) link. Those matrices can be calculated as presented in [9]. As long as the balance is carried out by adding counterweights, it is necessary to include in \(M\) the related parameters. Therefore, each link will be considered as the conjunction of one-bar and one counterweight as shown in Figure 2.  
The mass \(m_{n}\) of each link-counterweight \(n=1,2,3\) is defined as:  
\[m_{n}=m_{bn}+m_{cn} \tag{1}\]  
where \(m_{bn}\) is the mass of the original bar n (\(n=1,2,3\)) and \(m_{cn}\) is the mass of each counterweight (\(n=1,2,3\)). In addition, the counterweight mass in terms of its density and size can be represented as:  
\[m_{cn}=\pi\rho_{cn}t_{cn}\left({y_{cn}}^{2}+{x_{cn}}^{2}\right) \tag{2}\]  
Figure 1: Original Four-bar linkage. Figure 2: Four-bar linkage with counterweights. where \(\rho_{cn}\) is the density of the material used in each counterweight, \(t_{cn}\) is the thickness of each counterweight, and \(x_{cn},y_{cn}\) represents the position of the center of mass of the counterweight measured in relation with the local coordinate system \(O_{n}\). The total inertia of each link-counterweight \(I_{n}\), where \(n=1,2,3\), is defined as:  
\[I_{n}=\frac{3m_{cn}\left(y_{cn}{}^{2}+x_{cn}{}^{2}\right)}{2}+I_{bn} \tag{3}\]  
where \(x_{cn}\) is the \(x\) position of the mass center of the counterweight corresponding to the \(n\) element measured from the origin \(O_{n}\) and \(y_{cn}\) is the \(y\) position of the mass center of the counterweight corresponding to the \(n\) element measured from the origin \(O_{n}\). \(I_{bn}\) corresponds to the inertia of each original bar. The new \(x\) position of the mass center for each \(n\) element is defined as:  
\[X_{Gn}=\frac{m_{cn}x_{cn}+m_{bn}x_{bn}}{m_{cn}+m_{bn}} \tag{4}\]  
And the new \(y\) position of the mass center for each \(n\) element is defined as:  
\[Y_{Gn}=\frac{m_{cn}y_{cn}+m_{bn}y_{bn}}{m_{cn}+m_{bn}} \tag{5}\]  
where \((x_{cn},y_{cn})\) is the position of the center of mass of each counterweight, and \((x_{bn},y_{bn})\) is the position of the center of mass of each original bar, both measured from the origin \(O_{n}\). To avoid the use of extra variables, the mass of each counterweight \(m_{cn}\) is defined as:  
\[m_{cn}=\pi(r_{cn}^{2})(t_{cn})\rho_{cn} \tag{6}\]  
where \(\rho_{cn}\) represents the density of the counterweight, \(t_{cn}\) is the thickness of the counterweight, and \(r_{cn}\) represents the ratio of the counterweight. In addition, if the counterweight is considered to be a cylinder, the radius of the counterweight can be defined as:  
\[r_{cn}=\sqrt{x_{cn}^{2}+y_{cn}^{2}} \tag{7}\]  
By substituting Equation (7) in (6):  
\[m_{n}=m_{bn}+m_{cn} \tag{1}\]0  
and applying the concepts of [9], the mass-matrix representing the whole mechanism can be written as:  
\[\mathbf{M}= \begin{bmatrix}a&0&e&-f&0&0&0\\ 0&a&f&e&0&0&0&0\\ e&f&b&0&0&0&g&-h\\ -f&e&0&b&0&0&h&g\\ 0&0&0&0&c&0&i&-j\\ 0&0&0&0&0&c&j&i\\ 0&0&g&h&i&j&d&0\\ 0&0&-h&g&-j&i&0&d\end{bmatrix}  \tag{9}\]  
With:  
\[ \begin{split} a&=\frac{3\pi\rho_{c_{1}}t_{c_{1}}\left(y_{c_{1}}^{ 2}+x_{c_{1}}^{2}\right)^{2}+2I_{b1}}{2l_{1}^{2}}-\frac{2\left(\pi\rho_{c_{1}}t _{c_{1}}x_{c_{1}}\left(y_{c_{1}}^{2}+x_{c_{1}}^{2}\right)+m_{b1}x_{b1}\right)} {l_{1}}\\ +\pi\rho_{c_{1}}t_{c1}\left(y_{c_{1}}^{2}+x_{c_{1}}^{2}\right)+m_{ b1}\end{split}