In recent years, drone applications have been well-liked and used in many fields, such as aerial technology, plant protection, transportation, security, and so on. With the increase of application scenarios, the performance and function requirements of the brain control of drones are strictly requested. I started the Starry Pilot project in 2016. The design concept of flight control is a lightweight, powerful flight control, mainly for scientific research and UAV industry applications, making UAV development technology more popular, but also easier to apply drone technology to various industries.

img

img

img

Outdoor Height Keeping Flying.

img

Gazebo HITL simulating

img

Msh shell system

Integrated Development Environment(IDE)

  • Main Control:STM32F427 + STM32F100
  • IDE: Keil MDK5.23
  • RT-Thread Open-Source Embedded Real-Time Operating System: V2.1.0

Hardware Design

The hardware uses the open source project Pixhawk, as shown in the following image. Pixhawk is also the most widely used and supported open source flight control hardware in the world.

img

Main Features are as follows:

  • 168MHz / 256 MIPS Cortex M4F
  • 14 PWM/Servo output
  • Extended bus interface (I2C, CAN, UART)
  • Redundant power input
  • External safety switch
  • Multi-color LED
  • External microSD card slot

Sensor:

  • ST Micro L3GD20 16-bit gyroscope
  • ST Micro LSM303D 16-bit accelerometer/magnetometer
  • Invensense MPU 6000 three-axis accelerometer/gyroscope
  • MEAS MS5611 air pressure meter

Interface:

  • 5x UART, 2x CAN, I2C, SPI
  • DSM/DSM2/DSM-X satellite compatible input
  • PPWM, S-BUS
  • 3.3 & 6.6V ADC Inputs
  • microUSB

In addition to the Pixhawk, the entire system also has a number of external electronic devices, such as brushless motor, GPS, electronic speed control, radio modem, RC receiver, Lidar-Lite lidar and so on. The overall system framework is shown below:

img

Software Design

The software is designed in a hierarchical structure, as shown as follows, from the bottom to the top are the Driver layer, RTOS (RT-Thread and Fatfs), HAL hardware virtual layer, Framework layer and application layer.

img

1. Driver Layer

The Driver layer enables the driver of all hardware devices on board Pixhawk, such as sensor devices (gyroscopes, accelerometers, magnetometers, air pressure meters, etc.), bus devices (UART, I2C, SPI, etc.), USB, motor driver, SD card driver, GPS driver, LED, and some on-board devices. Each driver registers with RT-Thread in the form of Device and provides its own init(), read(), write, ioctrl() functions for upper-level calls. Here we are taking the driver of the hmc5883 magnetometer to illustrate the general design steps of the driver.

- Device Initialization Function

The following is the initialization function of hmc5883. First, the Functions of the device functionality are assigned a function pointer, init(), read() and ioctrl() are defined. A driver device named hmc5883 is then registered with RT-Thread, and the upper layer can obtain the driver device by looking for the device name. Next is to set up the corresponding bus device for hmc5883. hmc5883 uses i2c communication, so the corresponding i2c device is found in the initialization.

img

- init()

The Init() function does some initialization for chips, including register configuration.img

- read()

The read() function enables the reading of device data, such as raw magnetic field data and reading the magnetic field data after calibration.img

- ioctrl()

The Ioctrl() function mainly implements the configuration functionalities of some devices, such as setting the range of magnetic field measurement, sampling frequency, etc.img

2. RTOS Layer

In this project, I'm using RT-Thread opensource embedded operating system, it is powerful by providing basic thread scheduling, memory management, synchronization and other basic functions, as well as providing msh shell system, device drive system, making the overall architecture of the system more clear and with more complete functions....

Read more »