# Performance Evaluation of a Quadcopter by an Optimized Proportional-Integral-Derivative Controller
## 2 The Statement of Methodologies
### Software Architecture  
At the beginning, the simple expression for the operation of a PID controller is introduced herein. As the basic PID architecture is shown in Figure 1, the PID controller is the most suitable controller circuit for the BLDC motor. It is well known that the PID controller mainly consists of three blocks with their corresponding circuits, and they are proportional, integral, and derivative blocks. As the name suggests, each block of the circuit is used to perform different mathematical operations. The PID diagram shown in Figure 1 clearly shows how the reference source, PID controller, driver circuit, sensors, converter circuit, inverter circuit, display scope, and motor are connected. In the theoretical discussion, the basic frequency transferring performance \(H(s)\) of the PID controller can be expressed as  
\[H(s)=K_{p}+K_{i}s^{-1}+K_{d}s \tag{1}\]  
where \(K_{p}\), \(K_{i}\), and \(K_{d}\) have been defined in the previous section; these are, proportional gain coefficient, the integral gain coefficient, and the derivative gain coefficient, respectively. The \(s\) is the complex frequency. Normally, the time derivative output, \(H(s)\), of the controller for controlling the plant is equal to \(K_{p}\) times the magnitude of the error pulse \(K_{d}\) times the derivative of the time function error signal \(err(t)\) and \(K_{i}\) times the integral, which generates the results that can be represented as  
\[h(t)=K_{p}\cdot err(t)+K_{i}\cdot\int err(t)dt+K_{d}\cdot d[err(t)]/dt \tag{2}\]  
where the \(err(t)\) denotes the error values that occur in each parameter of the proportional, integral and derivative components. Typically, a closed-loop PID controller is used for industrial applications. Its applications are wide due to its simplicity and excellent performance; in many cases, its efficiency is more than 95%. The overall performance of the proposed optimized PID controller could be evaluated by appropriately adjusting the parameter values of \(K_{p}\), \(K_{i}\), and \(K_{d}\). Certainly, the error occurring in Equation (2) can be modified according to the feedback signals from the control center of a UAV on the duty of flight. The so-called optimization of a quadcopter which is able to be obtained by an optimized PID, and the analyzed results will be implemented in a later section. In this study, the \(\text{Stm}^{\text{\textregistered}}\) IDE device of the EC (edge computing) device is used as the main integrated development platform, which has a beginner's learning program and supports C/C++. In addition, the advantage of the MCU is that there are many developers who build libraries embedded in the \(\text{Stm}^{\text{\textregistered}}\) development environment for convenience when compared to other MCU modulars. Moreover, the development time cost for the \(\text{Stm}^{\text{\textregistered}}\) modular is much lower, although the performance is much lower than other MCUs; this article focuses on it because of the advantages mentioned previously. To adjust the PID controller parameters, this paper uses the Matlab/Simulink(r) software platform as the test data platform and determines whether the PID controller matches the objective function according to the waveform diagram shown in Figure 2. Accordingly, the program flowchart for the PID controller program will first be written to the \(\text{Stm}32\text{f}401\text{c}\text{u}6\) development board. Then, the Stm32f401 ccu6 will be issued. The three initial values of yaw (YAW), pitch (PITCH), and roll (ROLL) are given at a setpoint from the operator via the HMI, as shown in Figure 2. The gain constants (P, I, D) mentioned in the flowchart are used for error correction. Error correction can be achieved by performing multiple tunings. Proportional gain helps reduce the rise time; at the same time, there is a sudden increase in the overshoot which leads to the instability of the system. Tracking and correcting the error by using different tuning methods such as P, PI, PD, and PID provide effective results.