# Balance Control of Brushless Direct Current Motor Driven Two-Rotor UAV
## 3 Mathematical Model and Control of the Two-Rotor UAV System
### Control of 2R-UAV Balance System Using Both Classical PID and 2-DOF PID Controllers  
There is only one input (error) and one output (control signal) for a classical PID controller. As in all controllers, the purpose of the classical PID controller is to eliminate disturbing effects affecting the system and tracking the reference. To do this, the difference between the input and output is controlled [23]. Equation (20) provides the mathematical s-domain equation for the classical PID controller. \[u(s)=[K_{p}+K_{l}\,s^{-1}+K_{d}\,s]e(s) \tag{20}\]  
Here, \(e(s)\) is the error signal used as input, \(u(s)\) is the control signal used as output, \(K_{p}\), \(K_{i}\), and \(K_{d}\) respectively stand for the proportional, integral, and derivative terms. There are a few benefits that the two-degree-of-freedom (2-DOF) controller offers over the single-degree-of-freedom (classical) controller. These benefits include lowering the impact of disruptive inputs and offering excellent performance in tracking the reference. The 2-DOF PID controller produces an output signal according to the difference within the actual value and the reference signal. Based on the stated weights of the proportional, integral, and derivative actions, it computes a weighted signal for each. The total of the these actions on the corresponding difference signals, each of which is weighted in accordance with the chosen gain settings, is the controller output [24]. The mathematical s-domain equation of the 2-DOF PID controller is given in Equation (21). \[u(s)=K_{p}(b\,r-y)+K_{l}\,s^{-1}(r-y)+K_{d}\,s(c\,r-y) \tag{21}\]  
In this expression, \(u(s)\) is the controller outcome, \(b\) is the proportional weight coefficient, \(c\) is the derivative weight coefficient, \(r\) is the reference input value and \(y\) is the system output. \(K_{p,j,d}\) values have been employed in the classical PID expression. \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameters** & **Values** \\ \hline Mass of the motor 1 (\(m_{1}\) ) & 20.10\({}^{-3}\) kg \\ Length of the link 1 (\(l_{1}\)) & 0.301 m \\ Mass of the motor 2 (\(m_{2}\)) & 20.10\({}^{-3}\) kg \\ Length of the link 2 (\(l_{2}\)) & 0.301 m \\ Gravity (g) & 9.81 m/s\({}^{2}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Parameters of the 2R-UAV balance system. Figure 5: Model of the 2R-UAV balance system in Matlab/Simulink. Both the speed of the BLDCMs and the balance angle were controlled using classical and 2-DOF PID controllers. The parameters of these controllers were determined by the PSO. Figure 6 illustrates the Simulink model of the 2R-UAV system controlled by both classical and 2-DOF PID controllers. As seen in Figure 6, the balance angle of the system changes with the effect of the \(F_{1}\) and \(F_{2}\) forces on the turning moment of the system, and the difference between this angle and the reference balance angle is entered into the controller. The output of this controller determines the speed difference of the motors. The reference speed of the BLDCM-1 is determined by adding the determined speed difference value to 2000 rpm, determined as the reference balance speed. Similarly, to determine the reference speed of the BLDCM-2, the speed difference value is subtracted from the 2000 rpm balance speed. Thus, closed-loop control of both balance angle and motor speeds is achieved. A pair of propellers called 1045 (10 \(\times\) 4.5 inches), designed to produce thrust in clockwise and counter-clockwise rotations, are mounted to the motors. The \(F_{1}\) and \(F_{2}\) forces were determined by multiplying the square of the BLDCM-1 and BLDCM-2 motor speeds by the propeller thrust constant (\(b=1.46\cdot 10^{-5}\) Ns\({}^{2}\)). By multiplying the \(F_{1}\) and \(F_{2}\) forces with the moment constant (\(k=5.63\cdot 10^{-6}\) Nms\({}^{2}\)), the load moments to be applied to the BLDCM-1 and BLDCM-2 motors were calculated. Determining the Parameters of the Classical PID and 2-DOF PID Controllers Using the PSO  
The controller parameters in this study were determined using PSO.