This is the second part of my B.S. thesis at Seoul National University, Design of Quadrotor UAV Flight Control Computer and Control System (December 2014, advisor: Youdan Kim; mentor: Yongjun Seo). Part 1 covered the flight control computer (FCC) hardware. This part covers the quadrotor dynamics simulation, the controller, and the tests on the real quadrotor.

Quadrotor dynamics modeling and controller simulation

Before designing the quadrotor controller on the flight control computer, it is necessary to see how the quadrotor model responds to motor inputs through dynamics modeling and simulation, and to design the controller from that. This is done by simulating the quadrotor dynamics and giving it virtual control inputs. I used MathWorks Simulink for the quadrotor dynamics simulation, and the dynamics equations followed the references [2, 3]. In the microcontroller simulation in Part 1, I generated the signals that correspond to the quadrotor’s motor outputs. The Simulink dynamics simulation receives them and shows how the quadrotor responds to the motor outputs. The two simulations communicate through a virtual serial port, which exchanges data between them.

The Simulink model has three main parts: serial communication, the motor system model, and the quadrotor six-degree-of-freedom model. The serial communication part receives and processes the serial data sent from Proteus 8. The motor system part calculates the thrust and torque from the motor speed, which it receives from the serial communication part. The six-degree-of-freedom dynamics part takes the thrust and moments calculated in the body frame and calculates the velocity, Euler angles, and other states with respect to the ground frame. Since the quadrotor airframe had not been selected yet, I set the physical properties and parameters at reasonable values to observe the trends. Because the properties were chosen arbitrarily, the motor speed used in the calculation has no exact physical meaning. I only adjusted the properties so that the quadrotor hovers when all four motors are given 50.

Simulink blocks that receive serial port data and split it into four motor signals
Figure 1. Simulink block for serial port communication.
Simulink blocks that compute thrust and torque for each of the four motors
Figure 2. Simulink block for the motor system.
Simulink six-degree-of-freedom rigid body block with Euler angle outputs
Figure 3. Simulink block for the quadrotor dynamics.

Building the quadrotor and mounting the flight control computer

I mounted the flight control computer on a quadrotor. The airframe and its specifications are as follows.

Turnigy H.A.L. quadcopter frame with a clear dome and yellow landing gear
Figure 4. Turnigy H.A.L. (Heavy Aerial Lift) quadcopter frame, 585 mm.
Item Specification
Weight 614 g (without electronics)
Width 585 mm
Motor bolt holes 16/19/25 mm
Layout X or + landing gear setup
Motors 28-XX or 35-XX brushless outrunner × 4
ESCs 18–30 A brushless ESC × 4
Propellers 8×4 to 10×4.7 × 4 (2 standard, 2 reverse rotation)
Battery 2200–3000 mAh 11.1 V LiPo
Radio 4-channel transmitter and receiver

Table 1. Specification of the quadrotor.

The quadrotor with the flight control computer developed in this study is shown below. To prevent accidents while designing the controller, I built a stand that holds the quadrotor on the ground so the controller can be designed there. The bottom of the quadrotor is fixed to the stand with a ball joint, so it has only roll, pitch, and yaw freedom. On the stand, the quadrotor can move between −30° and +30° in roll and pitch, and through the full range of −180° to +180° in yaw.

Two photos of the quadrotor with the flight control computer mounted on the frame
Figure 5. The developed flight control computer mounted on the quadrotor.
Quadrotor fixed on a metal ground test stand through a ball joint
Figure 6. The ground test stand.
Quadrotor with propellers on the ground test stand
Figure 7. The quadrotor on the stand, ready for tuning.

The controller blocks programmed on the flight control computer are shown below. Because the controller was built from blocks in Simulink, it could be loaded onto the flight control computer easily, following the earlier steps.

Simulink model on the flight control computer: radio data request, radio data read, controller, quadrotor plant, and data request blocks
Figure 8. The quadrotor controller loaded on the flight control computer.

I tuned the controller with the quadrotor carrying the developed flight control computer. A PD controller was used, one each for roll, pitch, and yaw, and suitable gains were found by trial and error. First, with the D gain set to 0, I raised the P gain to find a suitable value: the P gain at which the quadrotor oscillates with a constant period. Then I raised the D gain from 0 little by little until the system was damped. The PD gains found this way for roll and pitch are shown below.

Simulink PID controller dialog with the proportional and derivative gains for roll and pitch
Figure 9. PD controller gains found by trial and error (roll, pitch).

I tuned yaw in the same way, after roll and pitch were stable. The PD gains for yaw were set as shown below.

Simulink PID controller dialog with the proportional and derivative gains for yaw
Figure 10. PD controller gains found by trial and error (yaw).

Simulation results

Open-loop response

The following results come from giving the microcontroller transmitter inputs that set two of the four motors to a speed of 60 and the other two to 55, and running the dynamics model on the motor signals received in Simulink. The transmitter inputs were PWM step inputs with duty ratios of 60 and 55, applied to the general-purpose input pins of the microcontroller at the start of the simulation, and they reached the Simulink model through serial communication as step inputs of the same size.

Sketch of the quadrotor body axes with the rear rotors 3 and 4 at speed 60 and the front rotors 1 and 2 at speed 55
Figure 11. Sketch of the quadrotor and the rotor speeds.

In the simulation, the pitch angle decreased from 0 to 3 seconds, and at the same time a displacement in the positive x direction appeared. This matches the empirical fact that when the output of the two motors opposite the nose is increased symmetrically, the quadrotor tilts toward the nose and moves forward. Around 3 seconds, however, the pitch angle reached $-\pi/2$ and the vehicle quickly became unstable. At the same time a large displacement in the positive z direction appeared, which means the quadrotor was moving in the direction of gravity: it could not control its attitude and was falling. A controller is therefore needed for attitude control.

Plot of x, y, and z velocity over 10 seconds in the flat Earth frame
Figure 12. Velocity response of the quadrotor.
Plot of x, y, and z position over 10 seconds in the flat Earth frame
Figure 13. Position response of the quadrotor.
Plot of roll, pitch, and yaw angles over 10 seconds, with pitch dropping and then diverging
Figure 14. Euler angle response of the quadrotor.

PID controller in simulation

To stabilize the attitude of the dynamics model above, I designed a simple PID controller that controls roll and pitch separately [4]. The controller block and the PID gains are shown below.

Simulink model of the PID attitude controller connected to the quadrotor dynamics
Figure 15. The developed controller in Simulink.
Simulink PID controller dialog with P, I, D, and filter coefficient values
Figure 16. Gains of the Simulink PID controller.

In an ideal quadrotor model, roll and pitch have the same transfer function. A step input of $\pi/8$ on the roll angle showed that the controller works well on the developed dynamics model.

Plot of a roll angle step input and the roll angle response settling near 0.4 radians
Figure 17. Result of applying the PID controller to the quadrotor dynamics model.

A flight simulator with a game controller

The simulator above ran the quadrotor dynamics in MATLAB Simulink with step inputs as the control inputs, and I looked at the transient response to them. For more intuitive controller tuning, however, it is necessary to see how the quadrotor responds to arbitrary inputs from a real user.

So instead of step inputs, I set up a way to take user inputs in real time from a game controller, similar to flying a real quadrotor. I also used Simulink Animation Blocks to show the attitude and thrust of the quadrotor visually. The game controller was an InterLink ELITE, connected to the PC as shown below.

Four photos of a laptop showing a 3D quadrotor model that tilts as the game controller sticks move
Figure 18. The simulation method using a game controller.

As shown above, the 3D model of the quadrotor changed with the game controller input. The top images show the change in thrust with the throttle stick, and the bottom images show the change in roll with the aileron input. Once the physical properties of the commercial quadrotor are measured and suitable control parameters are chosen, a more intuitive quadrotor simulation should be possible.

The Simulink model of the simulator is shown below. It has three main parts: a virtual transmitter block that uses the game controller, a controller block that takes the control inputs from the transmitter and the attitude feedback, and a quadrotor plant block that calculates the attitude from the control inputs. I added the virtual transmitter block and the 3D animation block to the simulator I had built before.

Simulink model with transmitter, controller, quadrotor plant, and animation blocks
Figure 19. The Simulink model for the quadrotor simulation.

The transmitter block converts the game controller signals to values between 0 and 1. The signals changed linearly with the joystick input, so I normalized them by their maximum and minimum values.

Simulink transmitter block that reads the joystick axes and normalizes them
Figure 20. The transmitter block.

The 3D animation block takes the attitude and thrust from the quadrotor plant and shows them visually.

Simulink 3D animation block with attitude and thrust inputs
Figure 21. The Simulink block for the 3D animation.

Testing the flight control computer

After mounting the flight control computer on the quadrotor and finishing the controller tuning, I applied a step input to the quadrotor. Before the step input, the propeller thrust control kept the pitch angle of the quadrotor at 0. The step input was applied at about 9 seconds, and the pitch angle changed in response.

Plot of the pitch input step and the measured pitch output on the test stand
Figure 22. Unit step input on the quadrotor pitch angle.

After the step input, the quadrotor did not recover its attitude and stayed at +30°. The derivative term of the PD controller overreacted to the sudden change of the step input and drove the motors too hard, so the quadrotor moved quickly and hit the angle limit of the stand. This needs further work, and a stand with a wider angle range should solve it. The step from +30° back to 0° converged to 0 without steady-state error.

Conclusion and future work

I built a flight control computer and a controller for a quadrotor and mounted them on a quadrotor to check the performance of the flight control computer. The flight control computer and the controller controlled the attitude of the quadrotor stably. The response to the unit step input was somewhat unstable, which can be fixed by modifying the controller blocks. Because the controller on this flight control computer is designed directly in Simulink, various advanced control methods can be applied easily, and future work will study and apply them. I will also take the quadrotor off the stand and look at its response in real flight tests.

In addition, I plan to measure the physical properties and parameters used in the simulation through system identification of the frame, motors, and propellers, and to improve the dynamics model with them. This will make it possible to predict the performance of a controller before designing it on the flight control computer.

References

  • 1. Lee, I. (2010). AVR ATmega128 Microcontroller: From Basics to Device Control (with the WinAVR compiler). Seoul: Hongneung Science. (in Korean)
  • 2. Stevens, B. L., & Lewis, F. L. (2003). Aircraft Control and Simulation (Vol. 2). New York: Wiley.
  • 3. Sanca, A. S., Alsina, P. J., & Cerqueira, J. de J. F. (2008). Dynamic modelling of a quadrotor aerial vehicle with nonlinear inputs. In Robotic Symposium, 2008. LARS'08. IEEE Latin American (pp. 143–148).
  • 4. Junior, J. C. V., De Paula, J. C., Leandro, G. V., & Bonfim, M. C. (2013). Stability control of a quad-rotor using a PID controller. Brazilian Journal of Instrumentation and Control, 1, 15–20.