| This paper takes the actual project as the starting point,refers to the open source APM circuit principle,Ardu Pilot source code,and uses the composite VTOL UAV as the carrier to develop the modular design of hardware and software flight control system.Firstly,the overall design scheme of the hardware circuit of the flight control system is proposed,and the hardware circuit is modularly designed.The single chip STM32F407VET6 is used as the main control chip,the dual IMU module adopts the MPU6500 module with SPI communication protocol,the magnetometer uses the HMC5883 L module with IIC communication protocol,the barometer utilizes the BMP180 module with IIC communication protocol,the GPS adopts the GPS with NEMA module serial communication protocol,the receiver PWM signal reading adopts the way of PPM signal resolution to read PWM signal of each channel,PWM signal output adopts the way of IIC communication protocol PCA9685 module to output PWM signal,wireless data transmission adopts the HC-12 module of serial communication protocol,plus the OLED display of IIC communication protocol to display the relevant status information of the flight control system.Next,the flight control principle of the composite VTOL UAV is firstly introduced,then the principle of each device is introduced,and finally the control flow design scheme of the flight control system is proposed,including: overall flight control flow scheme,attitude solution flow,position solution flow,attitude control flow,position control flow,PID control flow,manual mode control flow,fixed height mode control flow,fixed point mode control process,etc.Finally,the overall design of the software source code structure of the flight control system is proposed.The software source code is written in a modular way and compiled and developed with MDK compiler software under Windows operating system.The project files,using the standard library project files of STM32F407 as the template,create sub-folders: Libraries folder,UAV folder,and USER folder.In the Libraries folder,it creates the subfolders such as “Barometer”,“Magnetic Compass”,“GPS”,etc.,and creates “h” and “.cpp” files,using C++ programming language to write the corresponding module driver source code,the software structure in the form of parent-child class,the parent class for the upper application layer to call the function interface,the child class inheriting the interface of the parent class,for different models of modules to write different source code programs,so as to achieve software modularity;and some function library or algorithm library source code,“PID”,“navigation”,etc.Under the UAV file,there are some “.h” header files source code,which are some macro definitions,related function settings,parameter management,etc.for the application layer source code program of the composite UAV VTOL.The “main.h” under the USER file is the entrance of the whole project program.By calling the relevant function interfaces under the Libraries file and UAV folder,together with the flight control algorithm,the different flight attitudes of the composite VTOL UAV are completed. |