Foreword:
Compared to helicopters, multirotor aircraft such as quadcopters offer a simpler mechanical structure, more flexible control, and better stability. They are smaller in size and have greater payload capacity. The complexity of the helicopter's mechanical design is replaced by electronic circuits and algorithms, making quadcopter design more accessible and popular.
The software core of a quadcopter consists of two main parts: attitude fusion algorithms and control algorithms. The hardware core includes the MCU (Microcontroller Unit) and sensors.
First, let's discuss the attitude fusion algorithm. This process combines 3-axis acceleration, 3-axis angular velocity, and 3-axis magnetic field data into a quaternion, which is then converted into Euler angles. These Euler angles—Yaw, Pitch, and Roll—are used to control the aircraft’s orientation. I use the AHRSUpdate and IMUUpdate algorithms developed by Madgwick, which are simple and effective. AHRSUpdate fuses gyroscope, accelerometer, and magnetometer data, while IMUUpdate only fuses the gyroscope and accelerometer. However, IMUUpdate requires additional complementary filtering for the magnetometer to correct Yaw, which can cause issues when the yaw crosses from 360° back to 0°. AHRSUpdate solves this problem but may be affected by strong external magnetic fields, leading to loss of control.
The sensor I used is the Invensense MPU9150, which integrates an accelerometer, gyroscope, and magnetometer. It also has a built-in DMP for attitude fusion, but it's not always easy to use. For the MCU, I chose the Gigadevice GD32F103 series. My goal was to get the quadcopter flying smoothly without adding extra peripherals at first. Future upgrades might include higher-end models like GD32F107 or GD32F4xx, which offer better performance with floating-point units to handle complex algorithms more efficiently.
The quadcopter project is still in its early stages. So far, I've completed the attitude fusion. Next, I need to select the right frame, ESCs, motors, and propellers, write PID control code, and fine-tune everything after system integration. I'm encouraging myself to keep going, one step at a time.
Currently, I’m implementing functions like the AHRSUpdate algorithm, gyroscope zero offset calibration, accelerometer smoothing, and magnetometer plane calibration. In the future, I plan to add more advanced features like accurate accelerometer calibration, magnetometer ellipsoid fitting, and gyroscope temperature compensation.
Part 1: Hardware
1. Sensor: MPU9150 (Invensense) – integrates accelerometer, gyroscope, and magnetometer. It has a built-in DMP for attitude fusion but doesn’t fully fuse the magnetometer data. It’s compact and efficient, though more expensive than the MPU6050.
2. MCU: GD32F103CB – based on ARM Cortex-M3, runs up to 108MHz, cost-effective, and compatible with STM32. It uses an external 8MHz crystal to avoid interference with the magnetometer.
3. Power chip: TLV70233DBVR – a TI LDO that provides 3.3V output with minimal external components.
4. Serial port: MAX3232 – convenient for debugging.
5. USB power supply: 5V output.
6. Frame, ESCs, battery, motors, and propellers have been purchased. Here’s a photo of the current setup:

Part 2: Software
1. Keil uVision 4.1.0, RealView MDK-ARM Version 4.12.
2. Drivers: Official MPU6050 driver files (inv_mpu.c and inv_mpu_dmp_motion_driver.c).
Below are some key figures showing the system initialization and attitude angle outputs.
Figure 1: System initialization steps include initializing the MPU, setting sensor usage, configuring gyroscope and accelerometer ranges, enabling DMP, calibrating the gyroscope and accelerometer, and starting the attitude fusion.

Figure 2: Final attitude angles obtained from the quaternion. Yaw indicates heading, Pitch is elevation, and Roll is roll angle. When the aircraft is level, the nose is about 37 degrees west of north.

Figure 3: Wing level, nose pointing north, and nose tilted down by 25 degrees.

Figure 4: Nose pointing north, level, and right wing tilted down by 23 degrees.

Figure 5: Euler angle singularity issue. When Pitch reaches +90°, the aircraft becomes uncontrollable, and the Roll axis changes direction.

Part 3: How to Determine Your Own Axial Direction
The definition of the axes is crucial for proper attitude calculation. The right-hand rule must be followed for the accelerometer, gyroscope, and magnetometer axes. The rotation order (ZYX or ZXY) affects how the Euler angles are derived. Proper axis alignment ensures accurate attitude estimation.

Part 4: Algorithm
The first step is calibration: accelerometer, gyroscope, and magnetometer. The MPU9150 has internal self-calibration, while the magnetometer requires manual calibration.
The second step is to initialize the quaternion using the Euler angles calculated from the accelerometer and magnetometer data. The rotation order (ZXY) determines the formula used for the initial quaternion.
The third step is to apply the AHRSUpdate algorithm to continuously update the attitude. Finally, the Euler angles are extracted and used for flight control.
Conclusion:
When running at 108MHz, the delay and serial port functions need adjustment to prevent communication issues. Refer to forums for specific modifications. Thanks to everyone who helped along the way.
At OREMA, we are more than just a battery company; we are pioneers in the field of energy solutions. Our commitment to advancing battery technology has led us to develop the OREMA range of tubular batteries, a testament to our dedication to quality, innovation, and sustainability. Designed for a world that demands reliable and efficient power, our lead acid tubular batteries are crafted to meet the diverse needs of our global clientele.
OPzV Series: Tubular GEL Batteries Technology
Our OPzV series stands at the forefront of tubular GEL Battery innovation. Merging traditional lead-acid battery principles with advanced gas-phase nano silica electrolyte technology, these OPzV batteries redefine expectations for power storage solutions.
Key Features of OREMA OPzV series Tubular GEL Batteries:
Robust Longevity: Engineered for over 20 years of service life at 25°C, perfect for long-term applications.Exceptional Temperature Resilience: Optimal performance in extreme temperatures, ranging from -40ºC to 60ºC.
State-of-the-Art Corrosion Resistance: Enhanced durability with Lead Calcium die-cast grids.
Revolutionary Cycle Life: Tubular positive plates designed for prolonged and efficient cycling.
Unparalleled Discharge Recovery: Expertly crafted for deep discharge applications with exceptional recovery capabilities.
Innovative Gel Electrolyte: Fumed Silica gel technology, eliminating leakage and maximizing conductivity.
Applications of OREMA OPzV series Solar GEL Batteries:
High-stakes telecom and electric utility sectors.Cutting-edge control and security systems.
Critical medical equipment and robust UPS systems.
Solar power and renewable energy systems.
And numerous other high-demand applications.
Specifications of OREMA OPzV series Lead-acid Tubular Batteries:

OPzS Series: Ultimate Tubular Flooded Batteries
The OREMA OPzS series encapsulates our commitment to reliability and performance. Utilizing tubular plate technology, these flooded lead acid batteries are a powerhouse of efficiency and endurance.
Key Features of OREMA OPzS Series Tubular Batteries:
Cycling Mastery: Exceptional over 2000 cycles at 80% Depth of Discharge (DOD).Versatile Cycling Compatibility: Ideal for both deep and shallow cycle applications.
Sustained Performance: Low maintenance and long-lasting, even in demanding conditions.
Acid Mist Filtration: Specialized filtration for safer and cleaner operation.
Thermal Tolerance: Designed to perform in a wide range of temperatures.
User-Friendly Design: Transparent containers for effortless maintenance checks.
Extended Service Life: Over 20 years of reliability at 25°C/77°F.
Applications of OREMA OPzS Batteries:
Telecommunication infrastructures.Essential electric utilities and control systems.
Vital medical and emergency power supplies.
Renewable energy installations, including solar and wind power.
OREMA: A Global Vision with Local Impact
Specifications of OREMA OPzS Series Tubular Batteries:

At OREMA, we're not just selling batteries; we're creating partnerships and powering progress. Our OREMA tubular batteries are more than products; they're a promise of quality, durability, and reliability. We are dedicated to providing high-capacity, long-life power solutions without compromising on environmental sustainability. Our global reach and local impact reflect our commitment to delivering power solutions that are not only effective but also responsible.
Join us in our journey towards a more efficient and sustainable future. Choose OREMA for power solutions that you can rely on, today, tomorrow, and beyond.
OpzV Batteries,OpzS Batteries,Tubular Batteries,Tubular GEL Batteries,Tubular Flooded Batteries
OREMA POWER CO., LTD. , https://www.oremapower.com