Design of a Micro Quadrotor Drone Control System Based on RISC-V Microcontroller

In recent years, the rapid development of unmanned aerial vehicles (UAVs) has transformed various sectors, including agriculture, logistics, surveillance, and research. Among these, quadrotor drones have gained significant popularity due to their versatility, stability, and maneuverability. As a researcher involved in embedded systems and robotics, I embarked on designing a micro quadrotor drone leveraging the emerging RISC-V architecture. This project aims to create a cost-effective, high-performance control system for a micro quadrotor drone, emphasizing stability, precision, and adaptability in both indoor and outdoor environments. The core of this system is the CH32V303 microcontroller, a RISC-V-based chip that offers robust computational capabilities and rich peripherals, making it ideal for real-time control applications in quadrotor drones.

The quadrotor drone design focuses on a compact X-configuration, which enhances agility and simplifies control dynamics. A micro quadrotor drone, as defined by regulations, typically has a weight under 0.25 kg and operates at low altitudes, making it suitable for hobbyist and educational purposes. My approach integrates hardware and software components to achieve stable flight, with key elements including sensor fusion, wireless communication, and advanced control algorithms. The quadrotor drone’s control system relies on a cascade PID structure to manage attitude and altitude, ensuring responsive and smooth maneuvers. Throughout this article, I will detail the design process, from circuit implementation to software development, highlighting the innovations enabled by RISC-V technology for quadrotor drone applications.

The adoption of RISC-V as an open instruction set architecture represents a paradigm shift in microcontroller design, promoting customization and reduced costs. For this quadrotor drone project, I selected the CH32V303 series microcontroller, which features a 32-bit RISC-V core with single-precision floating-point support and a clock speed of 144 MHz. This choice aligns with the growing trend of domestic chip utilization in embedded systems, offering a viable alternative to traditional ARM or x86 platforms. The quadrotor drone’s control system leverages the microcontroller’s peripherals, such as I2C, SPI, and PWM interfaces, to interface with sensors, wireless modules, and motor drivers. By exploring this architecture, I aim to demonstrate the feasibility of RISC-V in demanding real-time applications like quadrotor drone control.

To provide a comprehensive overview, I will structure the discussion into several key areas: the hardware design of the quadrotor drone’s control board, the software architecture for sensor processing and control, the implementation of cascade PID algorithms, and the systematic debugging and tuning process. Each section will include technical details, formulas, and tables to summarize critical parameters. The quadrotor drone’s performance hinges on precise coordination between these elements, and I will share insights from my hands-on experience in building and testing the system. Emphasis will be placed on the quadrotor drone’s stability under various conditions, achieved through iterative design improvements.

Beginning with the hardware design, the quadrotor drone’s main control board serves as the brain of the system. It comprises the microcontroller unit (MCU), power management circuits, motion sensors, motor drivers, and communication modules. The CH32V303CBT6 microcontroller, packaged in LQFP48, forms the core, with its 128 KB Flash and 32 KB SRAM providing ample memory for program storage and data handling. The quadrotor drone operates on a 1S lithium polymer battery, typically outputting 3.7V, which necessitates voltage regulation to power the MCU and other components at 3.3V. To address voltage drops during motor operation, I implemented a boost converter to step up the battery voltage to 5V, followed by a linear regulator to produce a stable 3.3V supply. This design ensures reliable operation of the quadrotor drone even under high load conditions.

The motion sensing for the quadrotor drone is accomplished using the MPU6050, a six-axis inertial measurement unit (IMU) that combines a three-axis gyroscope and a three-axis accelerometer. This sensor is crucial for real-time attitude estimation of the quadrotor drone. The MPU6050 includes a digital motion processor (DMP), which offloads computation from the MCU by directly outputting quaternion data. I configured the sensor via I2C communication, with the SCL and SDA lines connected to the microcontroller’s PB6 and PB7 pins, respectively. The orientation of the MPU6050 on the quadrotor drone defines the pitch, roll, and yaw axes, enabling accurate angle measurements. For instance, the pitch axis corresponds to the Y-direction of the sensor, while the roll axis aligns with the X-direction. The quadrotor drone’s stability depends heavily on the precision of these readings, and the DMP enhances performance by reducing latency.

Motor control is another critical aspect of the quadrotor drone design. I employed four 8520 coreless brushed DC motors, each rated at 0.45A nominal current and 1.6A stall current. These motors are driven by NMOS transistors, controlled by PWM signals from the microcontroller. The motor driver circuit includes a current-limiting resistor, a pull-down resistor, and a filtering capacitor to suppress noise. The quadrotor drone’s thrust is generated by varying the PWM duty cycle to adjust motor speeds, allowing for ascent, descent, and directional movements. The table below summarizes key components used in the quadrotor drone’s hardware design:

Component Specification Purpose in Quadrotor Drone
Microcontroller CH32V303CBT6, 144 MHz, 128 KB Flash Core processing and control
IMU Sensor MPU6050 with DMP Attitude and motion data acquisition
Wireless Module NRF24L01, 2.4 GHz Communication with remote controller
Motor 8520 coreless, 0.45A rated Propulsion for quadrotor drone
Power Supply 1S LiPo battery, boost and linear regulators Stable voltage for electronics
Laser/Flow Sensor VL53L1 and optical flow module Altitude hold and position fixing

Wireless communication for the quadrotor drone is facilitated by the NRF24L01 module, which operates at 2.4 GHz with data rates up to 2 Mbps. This module connects to the microcontroller via SPI interface, enabling low-latency transmission of control commands from a remote transmitter. The remote controller itself is built around another CH32V303 microcontroller, equipped with analog joysticks and buttons for user input. The quadrotor drone and remote controller form a closed-loop system, where pilot commands are sent wirelessly, processed by the main controller, and translated into motor adjustments. This setup ensures responsive control of the quadrotor drone, essential for dynamic flight maneuvers.

For enhanced functionality, the quadrotor drone incorporates additional sensors for altitude hold and position stabilization. A laser rangefinder (VL53L1) provides accurate height measurements up to 4 meters, while an optical flow sensor detects ground displacement for positional correction. These sensors communicate with a secondary STM32 microcontroller, which preprocesses data and relays it to the main CH32V303 via I2C. This modular approach allows the quadrotor drone to adapt to indoor environments, where GPS signals are unreliable. The integration of these modules exemplifies the quadrotor drone’s capability for autonomous operations, such as hovering and precise navigation.

Transitioning to software design, the quadrotor drone’s control program is developed using the MounRiver Studio (MRS) IDE, tailored for RISC-V microcontrollers. The software architecture includes initialization routines, sensor data acquisition, attitude estimation, PID control loops, and PWM generation. Upon startup, the system configures interrupts, clocks, and peripherals like I2C, SPI, and timers. The main loop handles LED indicators and USB communication for debugging, while a 3-millisecond timer interrupt triggers critical flight control tasks. In each interrupt cycle, the quadrotor drone reads sensor data, parses remote commands, computes PID outputs, and updates PWM signals to motors. This real-time scheduling ensures the quadrotor drone maintains stability during flight.

Data acquisition and processing are central to the quadrotor drone’s performance. The MPU6050’s DMP outputs quaternions, which are converted to Euler angles (pitch, roll, yaw) using mathematical transformations. The conversion formulas are as follows, where q0, q1, q2, q3 represent the quaternion components:

$$ \text{pitch} = \arcsin(-2q_1 q_3 + 2q_0 q_2) \times 57.3 $$

$$ \text{roll} = \arctan2(2q_2 q_3 + 2q_0 q_1, -2q_1^2 – 2q_2^2 + 1) \times 57.3 $$

$$ \text{yaw} = \arctan2(2(q_1 q_2 + q_0 q_3), q_0^2 + q_1^2 – q_2^2 – q_3^2) \times 57.3 $$

The multiplication by 57.3 converts radians to degrees. These angles provide the quadrotor drone’s orientation, which is fed into the control algorithms. The DMP simplifies this process by handling sensor fusion internally, reducing computational load on the MCU. For the quadrotor drone, accurate angle estimation is vital, as even small errors can lead to instability. I validated these calculations through experimental tests, ensuring the quadrotor drone responds correctly to tilts and rotations.

Control algorithms for the quadrotor drone employ a cascade PID structure, which consists of an outer loop for angle control and an inner loop for angular rate control. This approach improves disturbance rejection and system robustness, crucial for the quadrotor drone’s dynamic environment. The outer PID controller takes the desired attitude angles (from remote commands) and compares them with actual angles from the MPU6050. Its output serves as the desired angular rate for the inner PID controller, which then compares it with gyroscope readings to generate PWM signals. The block diagram below illustrates this cascade configuration for the quadrotor drone:

Desired Angles → Angle PID → Desired Rates → Rate PID → PWM → Motors → Quadrotor Drone Dynamics → Sensors (Feedback)

The PID equation for each controller is given by:

$$ \text{output} = K_p \cdot e + K_i \cdot \int e \, dt + K_d \cdot \frac{de}{dt} $$

where \( e \) is the error between setpoint and measurement, \( K_p \), \( K_i \), and \( K_d \) are tuning parameters. For the quadrotor drone, separate PID instances are used for pitch, roll, and yaw axes, each with customized coefficients. Additionally, for altitude hold, a similar cascade PID is applied, with an outer loop for height and an inner loop for vertical velocity. The optical flow sensor enables position PID control, where displacement errors are minimized through proportional, integral, and derivative terms. The table below lists the optimized PID parameters for the quadrotor drone, obtained through extensive tuning:

Control Axis Outer Loop (Angle) \( K_p \) Inner Loop (Rate) \( K_p \) Inner Loop \( K_d \)
Pitch 8.12 3.10 0.22
Roll 8.10 3.12 0.23
Yaw 6.55 7.92 0.41
Altitude 1.5 (height) 0.8 (velocity) 0.1

System debugging and PID tuning are iterative processes essential for the quadrotor drone’s flight stability. I began with ground tests using a restraint frame to limit the quadrotor drone’s movements, allowing safe parameter adjustment. For the pitch and roll axes, I initially set all PID gains to zero, then incrementally increased the proportional gains until oscillations occurred. The derivative gain was then introduced to dampen oscillations, while integral gain was added to eliminate steady-state errors. The quadrotor drone’s response was monitored visually and via serial logs, with adjustments made until satisfactory performance was achieved. The yaw axis required similar steps, though its dynamics differ due to rotational inertia. Throughout tuning, the quadrotor drone’s battery voltage and environmental conditions were kept consistent to ensure reliable results.

In flight tests, the quadrotor drone demonstrated stable hover, precise attitude control, and responsive maneuverability. The cascade PID controller effectively rejected external disturbances, such as wind gusts, maintaining the quadrotor drone’s orientation. The laser altimeter enabled accurate height holding within ±0.1 meters, while the optical flow sensor provided position locking in indoor settings. The wireless link between the remote and quadrotor drone remained robust up to 100 meters, with no packet loss observed. These outcomes validate the design choices, particularly the use of RISC-V microcontroller for real-time processing in quadrotor drone applications.

To delve deeper into the quadrotor drone’s mathematical model, the dynamics can be described by Newton-Euler equations. For a quadrotor drone with mass \( m \) and inertia matrix \( I \), the translational and rotational motions are governed by:

$$ m \ddot{\mathbf{r}} = \mathbf{R} \mathbf{F} – m g \mathbf{e}_3 $$

$$ I \dot{\boldsymbol{\omega}} + \boldsymbol{\omega} \times I \boldsymbol{\omega} = \boldsymbol{\tau} $$

where \( \mathbf{r} \) is the position vector, \( \mathbf{R} \) is the rotation matrix, \( \mathbf{F} \) is the thrust vector, \( g \) is gravity, \( \boldsymbol{\omega} \) is angular velocity, and \( \boldsymbol{\tau} \) is torque. The quadrotor drone’s thrust is generated by motor speeds \( \omega_i \), related by:

$$ F_i = k_f \omega_i^2, \quad \tau_i = k_\tau \omega_i^2 $$

with \( k_f \) and \( k_\tau \) as thrust and torque coefficients. The control allocation for the quadrotor drone maps desired forces and torques to individual motor commands, often expressed as:

$$ \begin{bmatrix} F \\ \tau_x \\ \tau_y \\ \tau_z \end{bmatrix} = \begin{bmatrix} k_f & k_f & k_f & k_f \\ 0 & -k_f l & 0 & k_f l \\ -k_f l & 0 & k_f l & 0 \\ k_\tau & -k_\tau & k_\tau & -k_\tau \end{bmatrix} \begin{bmatrix} \omega_1^2 \\ \omega_2^2 \\ \omega_3^2 \\ \omega_4^2 \end{bmatrix} $$

where \( l \) is the arm length from center to motor. This model underpins the quadrotor drone’s control system, though practical implementations like mine simplify it through empirical tuning.

Another aspect of the quadrotor drone design is power efficiency. The micro quadrotor drone’s flight time depends on battery capacity and motor consumption. I measured current draw during hover at approximately 2.5A total, yielding around 6 minutes of operation with a 250 mAh battery. To extend endurance, future iterations could incorporate brushless motors and optimized propeller designs. The quadrotor drone’s weight budget is critical; every component was selected to minimize mass while maintaining functionality. The table below summarizes the quadrotor drone’s key performance metrics:

Parameter Value Impact on Quadrotor Drone
Total Weight 0.22 kg Complies with micro drone regulations
Maximum Flight Time 6-8 minutes Limited by battery capacity
Control Frequency 333 Hz (3 ms interrupt) Ensures real-time response
Wireless Range Up to 100 m Adequate for line-of-sight operations
Attitude Accuracy ±0.5 degrees Enables stable hover and maneuvers

In terms of software optimization, I implemented fixed-point arithmetic for PID calculations to reduce computational overhead on the quadrotor drone’s microcontroller. However, the CH32V303’s floating-point unit allowed for ease of development without significant performance penalty. The code structure is modular, with separate functions for sensor reading, quaternion conversion, PID updates, and PWM generation. This modularity facilitates debugging and future enhancements for the quadrotor drone, such as adding autonomous navigation or machine learning-based control.

Challenges encountered during the quadrotor drone project included sensor noise, motor synchronization, and wireless interference. The MPU6050’s raw data exhibited high-frequency noise, which was mitigated using software low-pass filters. The quadrotor drone’s motors required calibration to ensure uniform thrust output; I implemented a startup routine to measure and compensate for variations. The NRF24L01 module occasionally experienced packet collisions in crowded 2.4 GHz environments, addressed by implementing acknowledgment protocols and frequency hopping. These solutions contributed to the quadrotor drone’s reliability in diverse conditions.

Looking ahead, the quadrotor drone platform can be extended with additional features, such as GPS for outdoor navigation, computer vision for object avoidance, or swarm coordination. The RISC-V architecture’s openness allows for custom instruction set extensions, potentially accelerating specific tasks like matrix operations for the quadrotor drone’s control algorithms. Moreover, the quadrotor drone’s design could be scaled for larger payloads or different configurations, such as hexacopters or octocopters. The lessons learned from this micro quadrotor drone project are applicable to broader UAV development, emphasizing the importance of iterative design and thorough testing.

In conclusion, this project successfully demonstrates a micro quadrotor drone control system based on a RISC-V microcontroller. The integration of hardware components like the CH32V303, MPU6050, and NRF24L01, combined with software algorithms for sensor fusion and cascade PID control, results in a stable and maneuverable quadrotor drone. The quadrotor drone achieves precise attitude and altitude control, suitable for both indoor and outdoor applications. The use of RISC-V technology highlights its potential in embedded robotics, offering performance comparable to traditional architectures. Future work will focus on enhancing autonomy and endurance, further advancing the capabilities of quadrotor drones. Through this endeavor, I have gained valuable insights into embedded system design, control theory, and practical UAV implementation, reinforcing the quadrotor drone’s role as a versatile tool in modern technology.

Throughout the article, the term “quadrotor drone” has been emphasized to underscore the focus on this specific UAV type. The design principles discussed here—from circuit layout to algorithm tuning—are foundational for anyone interested in developing quadrotor drones. As the drone industry evolves, open architectures like RISC-V will likely play a pivotal role in fostering innovation, making quadrotor drones more accessible and capable. I encourage further exploration of these concepts, as the quadrotor drone represents a dynamic intersection of hardware, software, and control engineering.

Scroll to Top