In recent years, micro quadcopters have gained significant attention due to their compact size, versatility, and wide range of applications in fields such as environmental monitoring, search and rescue, and precision agriculture. As a researcher in embedded systems and unmanned aerial vehicles, I have focused on designing a micro quadcopter that achieves high stability and reliable data transmission. The core of this project revolves around using the STM32 microcontroller as the main control unit, integrating sensor modules for attitude estimation, and implementing efficient algorithms for precise control. The quadcopter’s ability to maintain stable flight hinges on accurate attitude data acquisition and processing, which is a critical aspect of this design. In this article, I will detail the entire process, from system overview and hardware design to attitude calculation and experimental testing, emphasizing the use of Kalman filtering and other techniques to enhance performance.
The overall system design of the micro quadcopter is centered on the STM32F103C8T6 microcontroller, which serves as the brain of the operation. This quadcopter employs an X-shaped configuration, known for its agility, rapid acceleration, and robustness in dynamic environments. Key components include the NRF24L01 wireless communication module for remote control, the MPU6050 inertial measurement unit (IMU) for capturing motion data, and a combination of motors and batteries for propulsion. The remote controller communicates with the quadcopter via a 2.4GHz wireless frequency, enabling real-time trajectory adjustments. Attitude data is derived from the MPU6050 gyroscope and accelerometer, complemented by a BMP280 barometer for altitude estimation. The main controller processes this data using a cascade PID control strategy, generating PWM signals to drive the motors. To validate the efficiency of the Kalman filter algorithm, I utilized MATLAB/Simulink for simulation modeling, ensuring the quadcopter’s stability before physical implementation. The system’s modular design allows for seamless integration of components, as illustrated in the block diagram where the motor drivers, power module, and communication interfaces are interconnected through the STM32 controller.

In the hardware design phase, I selected the STM32F103C8T6 microcontroller for its rich peripheral set, including I2C, SPI, multiple timers, and USART interfaces, which are essential for a micro quadcopter. This controller interfaces with the MPU6050 IMU via I2C on pins PB6 and PB7, while the NRF24L01 wireless module connects through SPI on pins PB12 to PB15. Additional pins, such as PA8 and PB8, manage chip enable and interrupt requests for the communication module. The NRF24L01 module was chosen for its strong anti-interference capabilities, ensuring reliable data transmission over distances without signal loss. In the communication process, the transmitter encodes and modulates data, sending it wirelessly, while the receiver decodes it for the control system. The MPU6050, with its 3-axis MEMS gyroscope and accelerometer, provides raw motion data that is filtered and processed to obtain attitude information. The hardware circuit design incorporates components like crystal oscillators, capacitors, and resistors to stabilize the system, with a focus on minimizing noise and power consumption. For instance, decoupling capacitors are used near the power pins to reduce voltage fluctuations, and the SPI interface ensures high-speed data exchange between the STM32 and NRF24L01. This setup not only supports the quadcopter’s basic functions but also allows for future expansions, such as adding GPS or obstacle avoidance sensors.
| Component | Model | Interface | Key Features |
|---|---|---|---|
| Main Controller | STM32F103C8T6 | I2C, SPI, USART | 32-bit ARM Cortex-M3, 72MHz clock |
| Wireless Module | NRF24L01 | SPI | 2.4GHz frequency, 1Mbps data rate |
| IMU Sensor | MPU6050 | I2C | 3-axis gyroscope, 3-axis accelerometer |
| Barometer | BMP280 | I2C | Pressure and temperature sensing |
| Motors | Brushed DC | PWM | High torque for lift and control |
Attitude calculation is a fundamental aspect of quadcopter control, and I employed quaternion-based methods to convert sensor data into usable Euler angles. The MPU6050 provides angular velocity and acceleration data, but these are prone to noise and drift. To address this, I used quaternions for their computational efficiency and avoidance of gimbal lock. A quaternion is represented as $q = q_0 + q_1 i + q_2 j + q_3 k$, where $q_0$, $q_1$, $q_2$, and $q_3$ are real numbers, and $i$, $j$, $k$ are imaginary units. The Euler angles—roll ($\phi$), pitch ($\theta$), and yaw ($\psi$)—describe the quadcopter’s orientation around the X, Y, and Z axes, respectively. The conversion from quaternions to Euler angles involves the following equations:
$$q_0 = \sin\left(\frac{\phi}{2}\right) \sin\left(\frac{\theta}{2}\right) \sin\left(\frac{\psi}{2}\right) + \cos\left(\frac{\phi}{2}\right) \cos\left(\frac{\theta}{2}\right) \cos\left(\frac{\psi}{2}\right)$$
$$q_1 = \cos\left(\frac{\phi}{2}\right) \sin\left(\frac{\theta}{2}\right) \sin\left(\frac{\psi}{2}\right) – \sin\left(\frac{\phi}{2}\right) \cos\left(\frac{\theta}{2}\right) \cos\left(\frac{\psi}{2}\right)$$
$$q_2 = \sin\left(\frac{\phi}{2}\right) \cos\left(\frac{\theta}{2}\right) \sin\left(\frac{\psi}{2}\right) + \cos\left(\frac{\phi}{2}\right) \sin\left(\frac{\theta}{2}\right) \cos\left(\frac{\psi}{2}\right)$$
$$q_3 = \sin\left(\frac{\phi}{2}\right) \sin\left(\frac{\theta}{2}\right) \cos\left(\frac{\psi}{2}\right) – \cos\left(\frac{\phi}{2}\right) \cos\left(\frac{\theta}{2}\right) \sin\left(\frac{\psi}{2}\right)$$
From these quaternions, the Euler angles are derived as:
$$\theta = \arcsin\left(2(q_0 q_2 – q_1 q_3)\right)$$
$$\phi = \arctan\left(\frac{2(q_0 q_1 + q_2 q_3)}{1 – 2(q_1^2 + q_2^2)}\right)$$
$$\psi = \arctan\left(\frac{2(q_0 q_3 + q_1 q_2)}{1 – 2(q_2^2 + q_3^2)}\right)$$
To enhance the accuracy of the attitude estimation, I implemented a Kalman filter, which is a recursive algorithm that optimally estimates the state of a system in the presence of noise. The Kalman filter process involves five key steps: prediction and update cycles. First, the prior estimate is computed as $\hat{x}_k^- = A \hat{x}_{k-1} + B u_{k-1}$, where $A$ is the state transition matrix, $B$ is the control input matrix, and $u$ is the control vector. Second, the prior error covariance is calculated as $P_k^- = A P_{k-1} A^T + Q$, with $Q$ being the process noise covariance. Third, the Kalman gain is determined by $K_k = \frac{P_k^- H^T}{H P_k^- H^T + R}$, where $H$ is the observation matrix and $R$ is the measurement noise covariance. Fourth, the posterior estimate (optimal value) is updated as $\hat{x}_k = \hat{x}_k^- + K_k (z_k – H \hat{x}_k^-)$, with $z_k$ representing the measurement. Finally, the error covariance is updated as $P_k = (I – K_k H) P_k^-$. In the context of the quadcopter, the state variables include attitude angles and angular velocities, and the filter helps reduce errors from sensor noise. I simulated this using MATLAB/Simulink, where the Kalman filter was applied to the quadcopter’s dynamics. The simulation results showed that the estimated states closely tracked the actual outputs, even with varying input commands, confirming the filter’s effectiveness in maintaining stability.
| Parameter | Symbol | Value | Description |
|---|---|---|---|
| State Matrix | $A$ | Derived from dynamics | Models state transition |
| Control Matrix | $B$ | Based on input effects | Maps control to state |
| Process Noise Covariance | $Q$ | 0.01 × I | Assumes low process noise |
| Measurement Noise Covariance | $R$ | 0.1 × I | Accounts for sensor inaccuracies |
| Observation Matrix | $H$ | Identity for direct measurement | Links state to output |
For the physical testing phase, I conducted both communication and flight tests to evaluate the quadcopter’s performance. The communication test involved transmitting data between the remote controller and the quadcopter in an open area to assess accuracy. I sent 400 sets of data and recorded the number of successful receptions. Out of these, 390 sets were accurately received, resulting in a data accuracy rate of 97.5%. This high reliability is crucial for real-time control of the quadcopter, as any data loss could lead to instability or crashes. The flight tests included dynamic and indoor evaluations. In the dynamic test, the quadcopter was mounted on a debugging stand and connected to a ground station via USB. After configuring the HID mode and device type, I powered on the system and used the remote to control the quadcopter. Over a 30-second flight, the quadcopter maintained stable operation with roll and pitch angle errors within ±0.8 degrees. The indoor flight test further demonstrated stability during takeoff and hover, with minimal抖动 and a vertical offset of only 5.1 cm from the initial position. In hover mode, the roll and pitch angles oscillated around zero within a range of ±1.4 degrees, and the signal remained strong within a 5-meter radius of the controller. These results validate the design’s effectiveness in achieving stable flight and reliable communication for the micro quadcopter.
| Test Type | Duration | Parameter | Value | Performance |
|---|---|---|---|---|
| Dynamic Test | 30 seconds | Roll/Pitch Error | ±0.8° | Stable with minor fluctuations |
| Indoor Flight | Continuous | Vertical Offset | 5.1 cm | Minimal deviation |
| Hover Mode | N/A | Angle Oscillation | ±1.4° | Smooth hovering |
| Communication | N/A | Data Accuracy | 97.5% | High reliability |
In conclusion, the design and implementation of this micro quadcopter based on the STM32 microcontroller have proven successful in achieving high stability and efficient data transmission. The integration of hardware components like the MPU6050 and NRF24L01, combined with software algorithms such as quaternion conversions and Kalman filtering, enables precise attitude control. The tests confirm that the quadcopter can maintain stable flight with minimal errors, making it suitable for various applications. However, there is room for improvement, such as optimizing the control algorithms for better performance in windy conditions or adding features like laser radar for obstacle avoidance and GPS for navigation. Future work will focus on enhancing the quadcopter’s autonomy and robustness, potentially incorporating machine learning techniques for adaptive control. This project underscores the potential of micro quadcopters in advancing unmanned aerial vehicle technology, and I believe that continued research will lead to even more innovative solutions in this field.
Throughout this project, I have gained valuable insights into the challenges of quadcopter design, particularly in balancing computational efficiency with control accuracy. The use of the STM32 platform demonstrates its suitability for embedded systems in UAVs, offering a cost-effective and flexible solution. As quadcopter technology evolves, I anticipate further advancements in sensor fusion and real-time processing, which will enable more complex missions and broader adoption in commercial and industrial sectors. The journey of developing this micro quadcopter has been rewarding, and I look forward to exploring new horizons in aerial robotics.
