Session T1A Test Platform to Pitch Angle using Hardware in Loop Sérgio Ronaldo B. Santos and Neusa Maria F. Oliveira. Instituto Tecnológico de Aeronáutica, sronaldo@ita.br, neusa@ita.br. Abstract - The low cost electronic component and sensors makes the development of UAVs more accessible. Consequently, more students are interested in the skills necessary to integrate an UAV developing group. A very important component in a UAV is the automatic pilot. Aiming Education and Research in Digital Automatic Pilot development a flexible system to test flight controllers is proposed. The system uses the structure known as “hardware in the loop” in which the aircraft model is simulated in a PC computer and the designed controller is implemented in a microcontroller. The proposed system is appropriate to be used in laboratory classes in which the students can test the controllers previously designed using control theory and can also practice the use of interfacing devices, necessary to convert the analog signals provided by the sensors to the digital form used by the processors, and communication devices, necessary to the information exchange between the PC and the microcontroller. The laboratory practice is such that the student can compare the results obtained using the conventional simulation approach, in which a control loop consisted of the designed controller and the aircraft model transfer function is simulated in a computer, and the results obtained using the proposed platform. Implementing the designed controller in a microcontroller that can be embedded in an UAV exposes the student to a more real situation, considering also the possible delays between a command given by the controller and the change of a parameter in the aircraft. The results presented here were obtained implementing a PID controller in a microcontroller and doing all the connections necessary to a PC implementing a longitudinal motion model of an aircraft. new version. Index Terms - Pitch displacement autopilot, Pitch angle, PID control, Longitudinal autopilot. NOMENCLATURE θref e δc δe θ Kp Kd Ki = = = = = = = = Pitch angle reference Erro signal Output PID control Elevator deflection angle Airplane pitch attitude angle Proportional control gain Derivative control gain Integral control gain /09/$25.00 ©2009 IEEE v τs = Elevator servo voltage = Servo time constant INTRODUCTION Modern aircraft have many control systems that help pilots during the flight and also the aircraft stability characteristics. An automatic pilot is a device that controls an aircraft in a pre-established flight without human intervention and has the main function stabilizing the dynamic characteristics of the aircraft. These tasks are performed by the control of command surfaces [1]. An automatic pilot is also present in UAV (Unmanned Aircraft Vehicles). Nowadays, UAV’s are in constant study by several research groups in the world. Consequently, the interest in studying automatic pilot has also increased. Aiming the study of automatic pilot in laboratory, a platform has been proposed and developed to test controllers designed by students. The platform uses the structure known as “hardware in the loop” and permits the designed controller to be implemented in a processor that theoretically could be embedded in the aircraft [2]. The proposed and developed test platform of aircraft controllers is introduced herewith. Firstly, the problem that is being addressed - the structure of the loop to be implemented in the “hardware in the loop” - is exposed. Then, we expose how the problem was solved, the tools used and how to connect them to work together in order to implement aircraft control loops. Finally, we show the results obtained using the platform with a PID controller to control the pitch angle of a generic aircraft [3]. PROBLEM STATEMENT The development of a controller involves the knowledge of control theory and simulations in a computer before, if possible, the implementation in a physical systeme. A test platform for controllers is introduced herewith. It shall give an opportunity of implementing the designed controller in a microcontroller that hypothetically should be embedded in an aircraft. The proposed platform has the structure hardware in the loop. This structure is such that the aircraft model to be controlled is implemented in a PC (personal computer) and the designed controller is implemented in another processor [4]. The communication between the two blocks must be done so that the system works properly. The communication is done previously thus letting the student deal exclusively with the controller implementation. October 18 - 21, 2009, San Antonio, TX 39th ASEE/IEEE Frontiers in Education Conference T1A-1 Session T1A In the laboratory, a PC, a microcontroller, and connecting cables are readily available to each student. The longitudinal and lateral models of the aircraft with which it is desired to work should be already available in the PC. With this structure, the task to be developed in the laboratory is the implementation of the designed controller in a microcontroller that should be embedded in an aircraft. The necessary interfacing between the PC and microcontroller should be done by the student if computer interfacing is defined as one goal of the laboratory class. The study of aircraft control in general classifies the movements realized by the vehicle into two instances: lateral and longitudinal. In certain flight conditions it is not possible to study these movements separately; however, in this study it will be assumed flight conditions that permit such consideration [5]. Figure 1 represents a general autopilot control loop and shows the tasks done by PC and the microcontroller in the test platform. The comparator and the digital controller are implemented in the microcontroller. Depending on the aircraft and the movement being studied, a different aircraft transfer function and servo transfer functions are implemented. the PSoC, the modules in the CY8C29466 that were used in the developed system are: UART, comparator, timers, PWM´s, AD, and DA converters, 2Kbytes RAM data memory and 16Kbytes program flash memory [8]. Considering Figure 1, which shows the structure of the proposed platform, we present all the connections that were made. One input signal to the microcontroller is the reference signal yref, which should be followed by the output signal y. yref is an analog DC signal between 0V and 5V and, since it is analog, it is necessary to use an AD converter in order to be handled by the microcontroller. The system output signal is also a signal input in the microcontroller. It compares the reference and output system signals and generates the error signal to be used by the designed controller to calculate the control signal to be sent to the aircraft. In Figure 2 and Figure 3 the block diagrams implemented in MATLAB/SIMULINK. FIGURE 2 DYNAMIC FOR THE GENERIC AIRCRAFT PITCH CONTROL SYSTEM. FIGURE 1 THE CONTROL LOOP TO BE IMPLEMENTED IN THE PROPOSED TEST PLATFORM. To study each one of these movements it is necessary to specify the aircraft model of the aircraft in study. The design of a controller for an aircraft is developed in order to control one or more flight parameters such as altitude, speed, etc [7]. In an aircraft, it is possible to have several control loops. In the development of this test platform, only the lateral and longitudinal loops are taken into consideration, and the controllers are designed for each of them depending on the characteristics to be controlled. The controller should be designed before the laboratory class takes place. The problem resolution and the results presented consider the longitudinal movement of a generic aircraft. FIGURE 3 SERIAL MODULE COMMUNICATION. The S-Function block was used to establish the serial communication between the aircraft model and the PID controller. All the parameters necessary for the communication were configured in a scrip file (m-file) and this file is virtually connected to the S-Function. Another important parameter defined in this file was the sample time of the aircraft output signal. It was adjusted to 500ms. Since the output signal is able to be sent back to the microcontroller, the control loop is closed and the platform is ready to work. IMPLEMENTATION AND RESULTS The control test platform was developed and is ready to be used in laboratory. The example chosen to be presented here PROBLEM RESOLUTION was a control system for the longitudinal movement of an In this section we discuss the development of the proposed aircraft. A pitch control loop for a generic airplane [7] was platform. The microcontroller chosen is the PSoC implemented in the developed platform and the results are (Programmable System on Chip). Several interfacing commented here. As it has already been mentioned, the proposed system devices are integrated within this chip thus minimizing is to be used in laboratory to test designed controllers. the need of external components and the space required in the PCB (Printed Circuit Board). Among others present in Therefore, the student should study control theory, design the controller and test it using computer simulation. Having /09/$25.00 ©2009 IEEE October 18 - 21, 2009, San Antonio, TX 39th ASEE/IEEE Frontiers in Education Conference T1A-2 Session T1A finished the process, it will be implemented in the proposed platform in the laboratory. Consequently, the control theory issues are not the main objective on this paper and they will be presented as briefly as possible. Consider a closed-loop control system as in Figure 1, representing the pitch control loop for a generic airplane [7]. The aircraft transfer function to be used is the transfer function from the elevator deflection to the pitch angle, as in (1). (5) Designing a PID using a continuous transfer function, results in a continuous controller. In order to implement the continuous PID controller on a digital device it is necessary to convert it into a digital PID controller. One approach used to obtain a digital controller with the same behavior as the continuous controller is implementing in the digital processor the equations (6) and (7). (1) (6) The actuator involved in a pitch control loop is the elevator servo. The elevator servo considered has a first order transfer function, as in (2) and (3). (2) (3) The relationship between the control signal, δc(s), generated by the controller and the error signal, e(s), is denominated the control law. The control law is used by a PID controller. It executes three control actions, proportional, integral and derivative actions, and can be written as in (4) and (5). (7) Where T is the sample time used in the system. The control test platform implementing the chosen pitch control loop can be represented, as in Figure 4. The results presented here were obtained applying a step signal in the reference input θref. The behaviors of the system output, θ(t), versus Time (s) are shown in graphs. The maximum value that either, the input signals and output signals, can reach is 5V and in the graphs it is equivalent to 1 (or 100% of the maximum). To this maximum input value the deflection obtained in the elevator servo is 60o. Figure 5 shows the response to an input step of magnitude 1 in θref. The system presents an overshoot and the pitch angle of the aircraft reaches the input value, θref, after 39 sec. (4) FIGURE 4 BLOCK DIAGRAM OF THE PLATFORM IMPLEMENTING THE PITCH CONTROL LOOP /09/$25.00 ©2009 IEEE October 18 - 21, 2009, San Antonio, TX 39th ASEE/IEEE Frontiers in Education Conference T1A-3 Session T1A FIGURA 5 RESPONSE TO A STEP INPUT OF MAGNITUDE 1 FOR THE PITCH AUTOPILOT . Figure 6 shows the response to an input step of magnitude -0.4 in θref. The system presents an overshoot and the pitch angle of the aircraft reaches the input value, θref, after 26 sec, resulting in an elevator deflection angle final of -24o. As it can be seen in Figure 5, Figure 6 and Figure 7, the output signal, θ(t), reaches the reference after some time. Running the system, the observation of the movement of the servo motor can be done and its final position compared with the expected position related to the desired pitch angle. Even though it is not presented here, the comparison of the responses obtained by the control loop being simulated all together in MATLAB and in the platform was done. It was verified that the settling time of the output signal is bigger when the system is implemented in the platform than when it is simulated altogether in the MATLAB. It happens because the discrete time process which takes place when using the platform the PID implemented in the microcontroller uses sampled values obtained in periods preestablished by the AD converter and the communication block in SIMULINK. Due to these facts, the error signal lasts more to reach the desired zero value. However, it is important to notice that the problem which happens as a consequence of the data sampling will be always present if the problem is to control a continuous system with a digital device. Therefore, this is another aspect with which the test platform contributes in the learning process - the observation of data samplings consequences in dynamic systems. CONCLUSION FIGURA 6 RESPONSE TO A STEP INPUT OF MAGNITUDE -0.4 FOR THE PITCH AUTOPILOT . Figure 7 shows the aircraft response to an initial step of magnitude 0.7 in θref, resulting in an elevator deflection angle of 42o. A second step was given in θref, this one with magnitude -0.5, which results in an elevator deflection angle of -30o. The test platform for aircraft controllers was developed and the results obtained from the implementation of a pitch control loop of a generic aircraft were presented. The platform is ready to be used in laboratory classes to improve the study of automatic pilots, providing the experience of implementing a controller in a device that could be the automatic pilot computer. With the test platform it is possible to practice the implementation of a controller in a digital device, to experience the effects of discretizing the signal and also realizes the visual observation of a servo motor positioning movement – which to be performed, it is necessary that the student controls the servo motor by PWM signal. The control loops for the longitudinal movements of an aircraft can be implemented using the platform and the hands on experience shall enhance the learning process. REFERENCES FIGURA 7 RESPONSE TO A INITIAL STEP INPUT OF MAGNITUDE 0.7 AND TO A INPUT STEP OF MAGNITUDE -0.5 AT TIME T=65S. /09/$25.00 ©2009 IEEE [1] Bryson, A E, “Control of Spacecraft and Aircraft”. Princeton Univerty Press, 1994. [2] K.P. Valavanis,“ Introduction in Unmanned Aerial Vehicles: State of the Art and the Road to Autonomy ”, Vol. 33, Intelligent Systems,Control, and Automation: Science and Engineering, K.P. Valavanis, Ed.Springer: 2007, pp. 23-34. [3] P. Fabiani, V. Fuertes, A. Piquereau, R. Mampey and F. Konigsbuch, “Autonomous flight and navigation of VTOL UAVs: from autonomy demonstrations to out-of-sight flights” in Aerospace Science and Technology, Vol. 11, Issues 2-3, p:183-193, March-April 2007. [4] A. Ryan et al., “ An overview of emerging results in cooperative UAV control. Decision and Control”,2004. CDC. 43rd IEEE Conference on, 2004, pp. 602-607 Vol.1. October 18 - 21, 2009, San Antonio, TX 39th ASEE/IEEE Frontiers in Education Conference T1A-4 Session T1A [5] D. Jung e P. Tsiotras, “Modeling and Hardware-in-the-Loop Simulation for a Small Unmanned Aerial Vehicle”, AIAA Infotech at Aerospace,Rohnert Park, CA: 2007. [6] R. Gimenes et al., “Using Flight Simulation Environments with AgentAutonomous Robot Systems and Controlled UAVs”, Competitions:Proceedings of the 8th Conference, Aveiro, Portugal: 2008. [7] Nelson, R. C.,” Flight Stability and Automatic Control.”, McGraw-Hill Second Editions, 1998. [8] Cypress Semiconductor, “Technical Reference Manual (TRM) PSoC CY8C29x66”, Version 1.0, 2006. [9] Ogata, K, “Engenharia de Controle Moderno.” Prentice Hall do Brasil Quarta Edição, 2003 [10] Hermely M.E., “Controle por Computador de Sistemas Dinâmicos”, Edgard Blucher, 1996. [11] Pallet, E. H. J., “ Automatic Flight Control ”, Blackwell Science Ltda, 1993. [12] Roskam, J., “Airplane Flight Dynamics and Automatic Flight Dynamics and Automatic Flight Controls, PART I”., Roskam Aviation and Engineering Corporation, 1982. [13] Rauw, M. “FDC 1..2 A Simulink Toolbox for Flight Dynamics and Control Analysis”, 1999. [14] Lobo, J. F., “ Noções de Física Aplicada a Vôo Simulado.”, Fórum de Simulações Aéreas ( FSA), http:// www.fsa.com.br . [16] Blakelock, J. H., “Automatic Control of Aircrafts and Missiles”, Wiley,1991. /09/$25.00 ©2009 IEEE October 18 - 21, 2009, San Antonio, TX 39th ASEE/IEEE Frontiers in Education Conference T1A-5