DOI: 10.3303/CET24114126 Paper Received: 5 May 2024; Revised: 16 October 2024; Accepted: 8 November 2024 Please cite this article as: Kiss B., Ballagi Á., Kuczmann M., 2024, Investigation of System Stability and the Design of a Controller based on the Transfer Function of a Quadcopter’s BLDC Motor, Chemical Engineering Transactions, 114, 751-756 DOI:10.3303/CET24114126 CHEMICAL ENGINEERING TRANSACTIONS VOL. 114, 2024 A publication of The Italian Association of Chemical Engineering Online at www.cetjournal.it Guest Editors: Petar S. Varbanov, Min Zeng, Yee Van Fan, Xuechao Wang Copyright © 2024, AIDIC Servizi S.r.l. ISBN 979-12-81206-12-0; ISSN 2283-9216 Investigation of System Stability and the Design of a Controller based on the Transfer Function of a Quadcopter’s BLDC Motor Barnabás Kiss*,a, Áron Ballagib, Miklós Kuczmannc aSzéchenyi István University, Zalaegerszeg Innovation Park, 3 Dr. Michelberger Pál Street, Zalaegerszeg, 8900, Hungary bSzéchenyi István University, Department of Automation and Mechatronics, 1 University Square, Győr, 9026, Hungary cSzéchenyi István University, Department of Power Electronics and E-Drives, 1 University Square, Győr, 9026, Hungary kiss.barnabas@ga.sze.hu The objective of this study is the control technology of quadcopters. The aim of this article is to propose further simulation assessment opportunities and other control implementations for investigating the transfer function of a quadrotor BLDC (Brushless Direct Current Electric Motor) motor obtained from experimental results in a previously published paper by separate authors. In this article, an LQ (linear-quadratic) controller is implemented based on the transmission function, during which the response of the controller to a unit step signal is examined. It is proved that LQ control can significantly enhance the autonomy of UAVs (Unmanned Aerial Vehicles) compared to PID (Proportional-Integral-Derivative Controller) control, as a faster and more accurate step response is achieved during system analysis. Additionally, how the LQ controller and the PID controller respond to a randomly generated white noise is examined. The results are compared with those implemented with a PID controller presented in a separate article. 1. Introduction Today, the application areas for UAVs have become extremely diverse. The applicability of unmanned aerial vehicles in areas such as infrastructure inspection, land mapping, and filmmaking is mentioned by Islam et al. (2019). Furthermore, a separate study by Say et al. (2021) indicates that increasing the autonomy of UAVs is essential for the above-mentioned projects, which raises important control engineering questions. According to Tahir et al. (2023), many application fields require the autonomous operation of UAVs in unpredictable, hard-to- reach areas, emphasising the importance of control engineering. The agricultural applications of UAVs are discussed and examined by Sadenova et al. (2023), with a focus on crop monitoring. In that study, the use and performance of two different drone types, the DJI P4M and the senseFly eBee X was compared during barley cultivation. The results show that the senseFly eBee X proved to be the better choice in most indicators, and it also processed plant indices more efficiently than the DJI P4M. Drone technology and its sustainability aspects in pesticide application in oil palm cultivation are studied by Loh et al. (2022). Different spraying methods were compared during the research. It was shown that drones powered by gasoline generators represent the most sustainable option, with the highest sustainability index value of 0.834. Drones in agriculture are also examined in another study by Sarghini and De Vivo (2017), focusing on the topic of sustainability, particularly on the precise distribution of pesticides to reduce the use of chemicals and groundwater contamination. According to the results, optimal design decisions can significantly increase spraying efficiency and reduce environmental damage. UAVs were used for package delivery tasks in the research of Chiang et al. (2019). According to the results, the use of UAVs can lead to significant energy savings and a reduction in carbon dioxide emissions, which is not only cost-effective but also environmentally friendly. As can be seen from the above, the application areas of UAVs are extremely diverse and multidisciplinary, and the research on this topic is relevant in terms of sustainability. 751 To increase the autonomy of UAVs, the control technology of UAVs is discussed in more detail in this paper. The aim of the authors is to examine and demonstrate that LQ control can achieve a more precise and faster step response in controlling the BLDC motors of quadcopters compared to the use of PID controllers. The authors' further goal is to contribute to increasing the autonomy of UAVs with this research. 2. Review of reference works The transfer function of a quadcopter's thrust-providing BLDC motor based on experimental setup and system identification was determined by Ahmed et al. (2015). The transfer function is illustrated by Eq(1): 𝑊𝑝 = 3.3928𝑠2 − 340.09𝑠 + 39,451 𝑠3 + 74.38𝑠2 + 5,589𝑠 + 42,107 . (1) The aim of the research by Ahmed et al. (2015) was to derive the motor transfer function based on input and output data. To achieve this, varying input signals were applied to the motor, and the output thrust was measured using a KG scalar (thrust sensor). After gradually activating the radio control, the thrust was increased at different reference values, and the data were recorded in a table to determine the appropriate PWM (pulse-width modulation) value to ensure the desired load and flight duration. The data were collected via an ATMEL ATMEGA 2560 microcontroller, which monitored the input and output characteristics of the motor. The MATLAB System Identification Toolbox was used to determine the transfer function, which was later used to build the MATLAB/SIMULINK model to provide a simulation and controller design close to the real behaviour of the quadcopter. For control implementation, a PID controller was recommended due to its reliability, simplicity, performance, and favourable tunability. During implementation, a special modified PID control was applied, where the differential component was integrated into the feedback loop of the controlled characteristic. Ahmed et al. (2015) found that with the modified PID controller applied, the system achieved 4 seconds of positional stability, during which the quadcopter ascended to a height of 2.8 m. In another study, the work of Say et al. (2021) was based on the Eq(1) transfer function to examine a tuning technique implemented with a GA (genetic algorithm) for the PID controller. The essence of the GA approach is to determine optimal gain values without the need for empirical trial and error. The effects of different selections on the determination of PID parameters generated by GA were examined by Say et al. (2021). The gain values are illustrated in Table 1. The results obtained with remainder selection in PID5 were considered to be the most suitable by Say et al. (2021) during the examination of the response to a unit step signal. The results on the step response are shown in Table 2, under the PID column. The study of Ahmed et al. (2015) and Say et al. (2021) focused on the application of PID controllers, and it was not extended to the examination of the system with other types of control. The Eq(1) transfer function used by Ahmed et al. (2015) and Say et al. (2021) is utilised in this present article to propose and demonstrate control implementation using optimal LQR (Linear-Quadratic Regulator). In the authors' research, the response of the system to a unit step signal under LQ control is examined. The behaviour of the LQ and PID controllers is also examined when white noise is applied to the system input. Table 1: Summary of PID gain values by Say et al. (2021) PID1 PID2 PID3 PID4 PID5 KP 4.1302 2.9055 2.5865 2.2066 2.9043 KI 89.8994 22.8899 20.9157 18.4527 22.8864 KD 0.0511 0.0208 0.0106 9.5367e-07 0.0212 3. System step response with continuous-time LQ control In this chapter, an LQ, state-space-based, optimal control was implemented on the system with the Eq(1) transfer function. According to Rasheed (2020), LQR is a state-space-based control that achieves optimal control by minimizing the Eq(2) cost function: 𝐽 = ∫ [𝑥𝑇𝑄𝑥 + 𝑢𝑇𝑅𝑢] ∞ 0 𝑑𝑡. (2) Eq(2) is the general cost function to be minimized for LQ control. Due to the single input in the problem discussed in this article, Ru2 should be used for the solution. The design of an LQ controller requires the system to be controllable, which, for an LTI (Linear Time Invariant) system, can be verified using the following equation as mentioned by Sawyer (2015): 752 𝐶𝑟 = [𝑏 𝐴𝑏 𝐴2𝑏 … 𝐴𝑛−1 𝑏 ]. (3) In the next step of designing the LQ controller, the matrices Q, for weighting the states, and R for weighting the control signals were defined. The problem of determining the Q and R weighting matrices is extensively discussed by Kumar and Jerome (2016). According to them, tuning the weighting matrices is a crucial step in controller design, where the weighting of the states and control inputs is determined. Properly setting the weighting matrices can pose a significant challenge as it influences overshoot, settling time, and steady-state error. After determining the initial values of Q and R, the Riccati equation can be solved. According to Katsuhiko (2009), solving the Riccati equation allows for the calculation of the K gain matrix. Subsequently, further fine- tuning of the Q and R matrices may be necessary to achieve the control objectives. For fine-tuning the Q and R matrices, Bryson’s rule was applied in the present study. Regarding Okyere et al. (2019), Bryson's rule provides guidance on determining the order of magnitudes for the weightings, offering a more effective method for optimizing the weighting matrices as opposed to empirical approaches. It is mentioned by Okyere et al. (2019), that according to Bryson's rule, Q and R are diagonal matrices whose diagonal elements are respectively expressed as the reciprocals of the squares of the maximum acceptable values of the state variables and the input variables. Accordingly, the following Eq(4) and Eq(5) relations were used by the authors to determine the Q and R matrices. 𝑄𝑖𝑖 = 1 𝑚𝑎𝑥𝑖𝑚𝑢𝑚 𝑎𝑐𝑐𝑒𝑝𝑡𝑎𝑏𝑙𝑒 𝑣𝑎𝑙𝑢𝑒 𝑜𝑓 𝑋𝑖 2 , (4) and 𝑅𝑗𝑗 = 1 𝑚𝑎𝑥𝑖𝑚𝑢𝑚 𝑎𝑐𝑐𝑒𝑝𝑡𝑎𝑏𝑙𝑒 𝑣𝑎𝑙𝑢𝑒 𝑜𝑓 𝑢𝑡 2 . (5) The fine-tuned values of the Q matrix and R were determined the following way: 𝑄 = [ 111,110 0 0 0 40,000 0 0 0 62,500 ], (6) and 𝑅 = 1. (7) The next step in the LQ controller design to solve the CARE (Control Algebraic Riccati Equation), as mentioned by Rasheed (2020) in Eq(8): 𝑃𝐴 + 𝐴𝑇𝑃 − 𝑃𝑏 1 𝑅 𝑏𝑇𝑃 + 𝑄 = 0. (8) In Eq(8), P is the sought symmetric, positive semi-definite matrix. According to Rasheed (2020), solving Eq(8) provides the P matrix, which enables the calculation of the optimal feedback gain K matrix based on Eq(9): 𝐾 = 𝑅−1𝑏𝑇𝑃. (9) Subsequently, the K feedback gain matrix was determined: 𝐾 = [330.9727 335.6473 244.9128]. (10) In the MATLAB environment, the 'lqr' function was used to calculate the K gain matrix. In the practical application of the LQ controller, minimising the sensitivity of the system to noise and ensuring precise response time are particularly important considerations that are beneficial for controlling quadcopters, where accurate position control and fast settling time are required for various flight manoeuvres. Following this, the state-space model of the closed-loop system can be defined to facilitate the analysis of the closed system. Initially, the matrices of the closed-loop system were determined. The A matrix was modified to incorporate the feedback gain, as mentioned by Sawyer (2015) in Eq(11). The Ac matrix describes the dynamics of the system after the LQ controller intervention has taken effect. The B, C, and D matrices remain unchanged: 𝐴𝑐 = (𝐴 − 𝑏𝐾). (11) The state-space model of the closed-loop system can then be specified using the A, B, C, and D matrices. Based on Åström (2002), the LQ controller was supplemented with feedforward to achieve the desired reference faster and reduce overshoot. The calculation of the feedforward gain in the application of the LQ controller may 753 be a solution for fine-tuning the control loop. The reciprocal of the steady-state gain of the closed-loop system is used in the program code, ensuring the proper scaling of the step response, enabling the system output to quickly and accurately converge to a value of 1 on a step input. According to Åström (2002), feedforward gain allows for the optimisation of the system's dynamics and response without altering the feedback loop, and in this way, system efficiency is improved to achieve the desired control objectives. The value of the feedforward gain was determined to be 51.9235. Using the Q and R weighting matrices fine-tuned with Bryson's rule, along with the K feedback and feedforward gain values, the step response shown in the red graph in Figure 1 was obtained during the simulation. In Figure 1, the results of the most optimal PID controller tuned (Table 1; Column: PID5) by Say et al. (2021) with remainder selection are also shown for comparison, as illustrated in the blue graph. Figure 1: Comparison of step response with LQ control and PID controller application Real systems often contain uncertainties and disturbances that can affect system dynamics and controller performance. In the MATLAB simulation, white noise was added to the input signal to model external disturbances. This allowed the examination of how the LQ and PID controllers respond in uncertain and disturbed environments. By addressing disturbances and uncertainties, the model more closely represents real- world applications, which is significant for the autonomous control of quadcopters. The white noise was added to the system input using MATLAB's 'randn' function. By adding white noise, non- ideal conditions were modelled in reality, such as sensor errors, environmental disturbances, or other factors that could affect the response of the controlled system. This way, the differences in the performance of the LQ and PID controllers could also be observed in a more realistic environment. The result obtained with the addition of white noise is illustrated in Figure 2. In Figure 2, it can be observed that both controllers exhibit a similar response in suppressing the disturbances caused by white noise. The rise times of the two controllers are nearly identical, indicating comparable initial response speeds. However, the LQR controller shows an overshoot in the initial phase of the response while subsequently demonstrating smaller deviations from the desired value of 1 compared to the PID controller. The system, however, continues to struggle with the effects of the noise, and neither controller is able to completely suppress the white noise; smaller deviations are observed throughout the step response. 754 Figure 2: Effect of white noise on the examined system 4. Results and discussion The results of the authors mentioned in Section 2 are illustrated in the PID column of the following Table 2, while the results of this article are presented in the LQ column, based on the graph in Figure 1 above. The results in the PID column report the simulation of the most optimal PID tuning as per the PID5 column in Table 1. According to the results shown in the table, the PID controller brings the system to 90% of the desired level faster, as indicated by the rise time row in the table. However, it is also concluded that the LQR stabilises the system around the steady-state value more quickly, with a settling time of 0.15 seconds, and the overshoot value with the LQR-controlled system is 0, indicating that the LQR reaches and maintains the output value of 1 more accurately, unlike the overshoot observed with the PID. In the case of the PID, the peak value is slightly higher than 1, at 1.0174, reflecting the overshoot. The peak value for the LQR is exactly 1, indicating that the system stabilises precisely at the value of 1 without overshooting. It has been determined in this article that the LQR controller provides a more stable response, with the response remaining precisely at the value of 1 the entire time, while the response with the PID fluctuates around the desired value. It is shown in this study that for controlling the quadcopter's BLDC motor, LQ control is overall more advantageous, and the LQ control is recommended for implementation. Table 2: Comparison of results for PID and LQR PID LQR Rise Time 0.0415 0.0900 Settling Time 0.1642 0.1500 Settling Min 0.9233 1.0000 Settling Max 1.0174 1.0000 Overshoot 1.7383 0.0000 Undershoot 0.0000 0.0000 Peak 1.0174 1.0000 Peak Time 0.0900 0.1500 5. Conclusion The BLDC motor transfer function identified with the Eq(1) equation, used for operating quadcopters, was utilised in this article to examine the system's stability through multiple approaches. Subsequently, the step response of the system was analysed when continuous-time LQR is applied. In this study, it was found that the application of the LQR technique achieves a fast-rising, overshoot-free, and steady-state error-free step response for controlling quadcopters' BLDC motors, which proved to be more advantageous than the PID controller. 755 Further investigation opportunities are suggested for other controllers, and the implementation of the examined transfer function for both PID and LQ controllers in discrete time through simulation is planned for the future. In addition, as a continuation of this present article, it is planned by the authors to compare the LQ controller with an MPC (Model Predictive Control) algorithm in the future, which will provide an opportunity to understand the advantages and applicability of each controller in quadcopter control. Nomenclature A – system matrix describing the dynamics of the system, - Ac – A matrix with feedback gain, - AT – transpose of the A matrix, - b – input vector of the state equation, - B – input matrix describing the effect of the input signal, - BT– transpose of the B matrix, - Cr – controllability matrix, - J – LQR cost function, - K – feedback gain value, - KP – proportional component, - KI – integral component, - KD – differential component, - P – optimal feedback matrix,- Q – state weighting matrix, - R – input weighting matrix, - R-1 – inverse of the R matrix, - s – Laplace transform variable, - u – input vector, - uT – transpose of u, - Wc – controller transfer function, - Wo – open-loop transfer function, - Wp – plant transfer function, - x – state vector, - xT– transpose of x, - References Åström K.J., 2002, Control system design lecture notes for me 155a. Department of Mechanical and Environmental Engineering University of California Santa Barbara, United States of America, 333. Ahmed A.H., Ouda A.N., Kamel A.M., Elhalwagy Y.Z., 2015, Design and analysis of quadcopter classical controller. International Conference on Aerospace Sciences and Aviation Technology, 16, ASAT-16–May 26-28, 1-17, The Military Technical College, DOI: 10.21608/ASAT.2015.23032. Chiang W.C., Li Y., Shang J., Urban T.L., 2019, Impact of drone delivery on sustainability and cost: Realizing the UAV potential through vehicle routing optimisation. Applied Energy, 242, 1164-1175, DOI: 10.106/j.apenergy.2019.03.117. Islam M., Okasha M., Sulaeman E., 2019, A model predictive control (MPC) approach on unit quaternion orientation based quadrotor for trajectory tracking. International Journal of Control, Automation and Systems, 17(11), 2819-2832, DOI: 10.1007/s12555-018-0860-9. Katsuhiko O., 2009, Modern Control Engineering. 5-th ed, Prentice Hall, Upper Saddle River, New Jersey, United States, ISBN 978-0-13-615673-4. Kumar E. V., Jerome J., 2016, Algebraic Riccati equation based Q and R matrices selection algorithm for optimal LQR applied to tracking control of 3rd order magnetic levitation system. Archives of Electrical Engineering, 65(1), 151-168, DOI: 10.1515/aee-2016-0012. Loh Y.W., Lim C.H., Foo D.C., How B.S., Ng W.P.Q., Lam H.L., 2022, Sustainability evaluation for pesticide application in oil palm plantation integrated with industry 4.0 technology. Chemical Engineering Transactions, 94, 751-756, DOI: 10.3303/CET2294125. Okyere E., Bousbaine A., Poyi G.T., Joseph A.K., Andrade J.M., 2019, LQR controller design for quad‐rotor helicopters. The Journal of Engineering, 2019(17), 4003-4007, DOI: 10.1049/joe.2018.8126. Rasheed L.T., 2020, Optimal tuning of linear quadratic regulator controller using ant colony optimization algorithm for position control of a permanent magnet DC motor. Iraqi Journal of Computers, Communications, Control and Systems Engineering, 20(3), 29-41, DOI: 10.33103/uot.ijccce.20.3.3. Sadenova M.A., Beisekenov N.A., Anuarbekov T.B., Kapasov A.K., Kulenova N.A., 2023, Study of Unmanned Aerial Vehicle Sensors for Practical Remote Application of Earth Sensing in Agriculture. Chemical Engineering Transactions, 98, 243-248, DOI: 10.3303/CET2398041. Sarghini F., De Vivo A., 2017, Interference analysis of a heavy lift multirotor drone flow field and transported spraying system. Chemical Engineering Transactions, 58, 631-636, DOI: 10.3303/CET1758106. Sawyer S., 2015, Gain-scheduled control of a quadcopter UAV. Master's thesis, University of Waterloo, Ontario, Canada. Say M.F.Q., Sybingco E., Bandala A.A., Vicerra R.R.P., Chua A.Y., 2021, A genetic algorithm approach to PID tuning of a quadcopter UAV model. The 2021 IEEE/SICE International Symposium on System Integration, 675-678, DOI: 10.1109/IEEECONF49454.2021.9382697. Tahir M.A., Mir I., Islam T.U., 2023, A review of UAV platforms for autonomous applications: comprehensive analysis and future directions. IEEE Access, 52540-52554, DOI: 10.1109/ACCESS.2023.3273780. 756