# 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 Offered Adaptive Fuzzy 2-DOF PID  
In classical control systems, system's mathematical model is created and controller used is built based on this model. In the fuzzy logic controller, the experience and control strategy of an expert opinion on the system are used as a database. While designing a fuzzy logic controller, in order to get the best efficiency from the controller, the expert who creates the control strategy must know the system very well [28]. The general structure of the fuzzy inference system is given in Figure 9[29]. \begin{table}
\begin{tabular}{c c c c} \hline \hline  & **Balance System** & \multicolumn{2}{c}{**BLDCM Speed**} \\  & **Angle Control** & \multicolumn{2}{c}{**Control**} \\ \hline \(K_{p}\) & 83.1974 & \(K_{p}\) & 56.6088 \\ \(K_{i}\) & 0.8507 & \(K_{i}\) & 53.6323 \\ \(K_{d}\) & 2.3771 & \(K_{d}\) & 0.0097 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Classical PID controller parameters determined by PSO. Figure 8: The change of the \(J_{ITAE}\) value during the optimization process. \begin{table}
\begin{tabular}{c c c} \hline \hline  & **Balance System** & \multicolumn{2}{c}{**BLDCM Speed**} \\  & **Angle Control** & \multicolumn{2}{c}{**Control**} \\ \hline \(K_{p}\) & 95.7409 & \(K_{p}\) & 64.4943 \\ \(K_{i}\) & 34.1622 & \(K_{i}\) & 8.8104 \\ \(K_{d}\) & 1.8018 & \(K_{d}\) & 0.0190 \\ \(b\) & 0.9914 & \(b\) & 1.0806 \\ \(c\) & 0.4508 & \(c\) & 0.9884 \\ \hline \hline \end{tabular}
\end{table} 
Table 5: 2-DOF PID controller parameters determined by PSO. Figure 9: General structure of the fuzzy inference system. In Figure 9:  
* Fuzzification: Converts digital inputs into fuzzy data. * Rule Base: Contains rule tables prepared by an expert opinion. * Inference Mechanism: A fuzzy set is created for the output using membership functions and rule base. * Defuzzification: Converts fuzzy data into digital outputs. First, when designing a controller using fuzzy logic, input and output variables must be determined. Afterwards, the digital inputs of the fuzzy logic controller are converted into fuzzy data. A range is defined for specified inputs and outputs, and each is given a linguistic label. A membership function is created for each fuzzy subset given a linguistic label. Then, fuzzy inference is made using the fuzzy rule table created in the rule base. Fuzzy data generated by the application of fuzzy rules is converted into digital output by defuzzification [30]. The AF 2-DOF PID controller proposed in this study is a control method that combines fuzzy logic, an artificial intelligence control method, and a 2-DOF PID controller, one of the advanced control methods. In this fuzzy logic controller, normalized error (\(e\)) and change of error (\(\Delta e\)) are entered into the input of fuzzy logic. At the output of the fuzzy logic controller, \(K_{p}\), \(K_{i}\), \(K_{d}\), \(b\) and \(c\) values are obtained as a result of the rule table determined by the input and output membership functions created. The 2-DOF PID parameters are determined by multiplying these values with the controller parameters previously determined by PSO. Basis of the AF 2-DOF PID controller is given in Figure 10 [18]. The Simulink model of the BLDCM driven 2R-UAV balance system with an AF 2-DOF PID controller is displayed in Figure 11. In this model, an AF 2-DOF PID controller is used for closed-loop control of both balance angle and BLDCM speeds. Figure 11: AF 2-DOF PID controlled Matlab/Simulink model of BLDCM driven 2R-UAV balance system. Figure 10: Basis of the Adaptive Fuzzy 2-DOF PID controller. The normalized error (\(e\)) and change of error (\(\Delta e\)) input variables of the balance angle and BLDCM speed controllers are expressed with seven triangular membership functions, as seen in Figure 13. These membership functions are named with the linguistic labels \(\mathrm{Z}\) (zero), \(\mathrm{MS}\) (middle-small), \(\mathrm{S}\) (small), \(\mathrm{M}\) (middle-small), \(\mathrm{L}\) (large), \(\mathrm{ML}\) (middle-large), \(\mathrm{EL}\) (extra-large).