# A General Framework for Crankshaft Balancing and Counterweight Design
## 3 Tool Design  
Once the balancing requirements in terms of dynamic equilibrium of the crankshaft are defined, it is possible to proceed with the creation of the code in charge of computing the masses and orientation of the balancing components required by the engine configuration defined by the inputs provided by the user. Unlike other existing codes, the one proposed here can be easily adapted to a wide range of crankshaft configurations. This flexibility is achieved thanks to a modular matrix-based formulation, which will be extensively presented in the following paragraphs. It must be noted that the balancing performed by the code is a \"global\" one, so it does not consider the specific local forces on each individual bearing and the forces that the addition of counterweights could generate on the crankshaft, for which much more extensive analysis should be performed. The first section of the code is designed to create the matrices useful to define the geometry of the crankshaft with its counterweights. The inputs used in the definition of such matrices are the following:  
* Number of cranks, \(N_{cr}\);
* Vector of the firing order, \(F0_{1,N_{cr}}\);
* Crank angle of the first crank, \(\theta\);
* Distance between the mid-points of two consecutive cranks, \(a\);
* Phase between two cranks (based on firing order), \(\phi\);
* Angle between counterweight and crankpin symmetrical opposite, \(\alpha\);
* Vector for definition of counterweight configuration, \(Y_{cw}\). The creation of the crankshaft matrix \(CS\) starts by defining the reference system of the crankshaft: it is positioned at the mid-length of the component, with the \(y\)-axis aligned with the rotational axis of the crankshaft itself. Such reference system and the inputs previously defined are reported in Figure 1.  
Figure 4: Polar plot and relative isometry of the crankshaft for a 2 cylinder in-line engine with a 180° angle between cranks, including the secondary reciprocating forces equilibrium and the additional secondary balancing shafts. The crankshaft is thus defined by obtaining the position and orientation of each crank with respect to the reference system. The reference point taken for each crank corresponds to the mid-length of the crank journal, which also coincides with the centre point of the big eye of the con-rod. If we define \(N_{fo}=FO(i)\) with \(1\leq i\leq N_{cr}\in\mathbb{N}\), the formulation of CS, is as follows:  
\[CS(1,N_{fo})=[\sin(\theta+(i-1)\phi)] \tag{1}\]  
\[CS(2,N_{fo})=\left[(N_{fo}-1)a-\frac{(N_{cr}-1)}{2}a\right] \tag{2}\]  
\[CS(3,N_{fo})=[\cos(\theta+(i-1)\phi)] \tag{3}\]  
From these equations we can see that the geometry matrix for the crankshaft will be a \(3-by-N_{cr}\) matrix, with the first, second and third row, i.e., Equations (1)-(3), the x, y and z components of the crankpin centre position respectively. Meanwhile, each column represents the set of components for each crank of the crankshaft. The following equation is an example of matrix for the crankshaft geometry, shown in Figure 1:  
\[CS=\left( \begin{array}{ccc}0&\sin\left(\frac{4}{3}\pi\right)&\sin\left(\frac {2}{3}\pi\right)\\ -a&0&a\\ 1&\cos\left(\frac{4}{3}\pi\right)&\cos\left(\frac{2}{3}\pi\right)\end{array} \right) \tag{4}\]  
The matrix of the crankshaft counterweights \(CW\) is then created. The reference system and method is the same as those followed for \(CS\): for each counterweight, a column representing the three components of the counterweight position will be defined. Since not all crankswebs will be equipped with a counterweight, a vector of ones and zeros, termed \(Y_{cw}\), is used to signal the presence of a counterweight in a given position. \[Y_{cw}=[110011] \tag{5}\]  
The example in Equation (5) is the vector for the 3 cylinder in-line engine with four counterweight presented in Figure 1. It should be noted that, since we have two crankwebs for each crank, the dimension of \(Y_{cw}\) is twice the number of cranks, with ones that indicate the presence and zeros the absence of a counterweight.