Skip to main content
Back to project

STM32 Quadcopter Flight Controller

Development History

Follow the team’s experiments from the first serial check through four-motor integration and the plan for physical testing.

Stage 01 · Experimentally Verified

Testing the board’s serial connection

We started by checking the board’s inputs, outputs, and serial connection.

Test setup.
We used one STM32F407G-DISC1 board, a jumper, a joystick pushbutton, and two onboard LEDs.
Implementation.
We configured the board clock and GPIO, then wired the USART2 transmit pin back to its receive pin so the board could read its own messages.
Problem and response.
The serial interface for our planned PC-terminal test was unavailable. Wiring the pins together let us check both directions on one board.
What the test showed

Each button state produced the expected message at the receive pin and lit the corresponding LED.

Limits of the evidence
Communication with a separate PC terminal still needed testing.
Next objective.
Check the board’s timed outputs on an oscilloscope.

Stage 02 · Experimentally Verified

Measuring the four motor-control signals

We checked whether four outputs could share the 50 Hz rate needed for the electronic speed controllers (ESCs) while sending different pulse widths.

Test setup.
We connected the four STM32 outputs to the oscilloscope in pairs, before connecting any speed controllers.
Implementation.
We set one period on TIM4 and used a separate compare value to set each channel’s pulse width.
Problem and response.
We configured the timer before we had access to an oscilloscope. Once we had one, we could check the signals at the output pins.
What the test showed

All four traces repeated at about 50 Hz. On one pair of traces, the scope cursors showed about 1.30 ms for a 1.25 ms setting and 1.50 ms for a 1.50 ms setting.

Limits of the evidence
The widths are scope readings. Cursor placement and display resolution affect their precision.
Oscilloscope traces with similar repetition periods and different pulse widths on two TIM4 outputs.
TIM4 channels 1 and 2 show approximately 50 Hz PWM with distinct pulse widths.
Next objective.
Connect one speed controller and see how the motor responds.

Stage 03 · Bench-Tested

Testing the motion sensor and tilt estimate

We wanted to read the MPU-6050 motion sensor and use its measurements to estimate roll and pitch.

Test setup.
We connected the breakout to the STM32 board and tilted it by hand while watching the sensor readings and estimated angles.
Implementation.
We read the sensor over I²C2 and measured the gyroscope’s offset while it was still. After subtracting that offset, we used a complementary filter to combine the gyroscope’s estimate with the tilt from the accelerometer.
Problem and response.
We checked the wiring to restore communication, then worked separately on getting a repeatable zero reading with the sensor still.
What the test showed

Reconnecting the hardware restored sensor detection. Both the raw readings and the filtered angles changed as we moved the sensor.

Limits of the evidence
Hand-applied tilts checked the direction of the angle estimates. Accuracy against an independent angle reference and under motor vibration still needs testing.
MPU-6050 breakout module wired to an STM32 development board on a breadboard.
MPU-6050 breakout connected to the STM32F407 development board during I²C2 validation.
Next objective.
Use the roll estimate in the single-motor test and recheck which direction counts as positive after mounting the sensor on the frame.

Stage 04 · Bench-Tested

Running one motor from board commands

We checked that one brushless motor responded to PWM commands from the STM32, then tested whether a change in roll could change the command.

Test setup.
A bench supply powered the speed controller and motor. We moved the MPU-6050 by hand, with the sensor physically separate from the motor.
Implementation.
We sent PWM commands directly to a DJI E300 speed controller before using the estimated roll to calculate the motor command.
Problem and response.
Some initial pulse widths left the motor stopped. We distinguished the stop command from the first command that made the motor run.
What the test showed

The motor ran at several commanded pulse widths. The board also changed the command when we tilted the sensor.

Limits of the evidence
The motor could not change the sensor’s tilt in this setup. Speed and thrust across the full command range still need measurement.
Bench power supply, STM32 development board, ESC, and a single brushless motor.
Single-motor bench setup for verifying actuation with a DJI E300 ESC and an STM32-generated PWM command.
Next objective.
Add radio control and test what happens when the receiver stops getting commands.

Stage 05 · Experimentally Verified

Checking radio range and the stop command

We tested the radio link between two boards and checked how a motor responded when the receiver stopped getting valid commands.

Test setup.
We watched test packets along an unobstructed path and ran a separate signal-loss check on the single-motor bench.
Implementation.
Each board used a CC1101 radio over SPI2. Valid packets could enable or disable the motor and set its maximum pulse width. The receiver used its own tilt measurement to calculate the motor command.
Problem and response.
The green radio status LED shared a pin with the motor’s PWM output. We reserved that pin for PWM and watched packet reception in the debugger.
What the test showed

The receiver decoded test packets at about 56 m. In the bench test, the configured 500 ms timeout expired after valid packets stopped arriving. The receiver withdrew permission to run and sent the 1000 µs stop command. The motor stopped.

Limits of the evidence
The distance applies to the unobstructed path we tested. Maximum range and the time the motor took to stop were outside these measurements.
Two STM32 development boards with breadboard-mounted CC1101 radio modules.
Separate transmitter and receiver boards used to verify packet reception over the CC1101 link.
Next objective.
Keep the signal-loss protection while adding the four-motor frame and checking the joystick controls.

Stage 06 · Bench-Tested

Sending the same throttle command to four motors

We put the transmitter, receiver, and four motor channels together and tested them with one shared throttle command.

Test setup.
We mounted four brushless motors and speed controllers on the X-frame and used separate computers to watch the two STM32 boards.
Implementation.
After calibrating the joystick, we used a button on the transmitter board to arm and disarm the system. The receiver applied the same throttle to all four channels only when a valid packet authorized it. While disarmed, it kept all four outputs at the 1000 µs stop command.
Problem and response.
We left tilt feedback out of this first four-motor test so we could check the radio, arming, and throttle on their own.
What the test showed

The transmitter, receiver, and four motor channels worked together under a common throttle command.

Limits of the evidence
Sending the same pulse width verified the common throttle path. Motor speeds can still vary at the same command.
Integrated four-motor quadcopter and transmitter on a bench between two laptops and a power supply.
Integrated bench setup with separate computers for observing transmitter and receiver behavior.
Two thumb joysticks connected to an STM32 development board and a CC1101 radio.
Two-joystick transmitter assembly used for the throttle and roll/pitch command interface.
Next objective.
Check which direction gives a positive roll or pitch on the frame, then add separate corrections for each.

Stage 07 · Bench-Tested · Current stage

Checking the four motor commands after a tilt

We checked how the receiver turned the requested and measured angles into four motor commands.

Test setup.
On the bench, we moved the joystick and tilted the frame by hand while watching the received commands, measured angles, and timer compare values.
Implementation.
We mounted and calibrated the MPU-6050, checked the tilt axes, and used only the proportional term of each roll and pitch PID controller for these first tests. TIM6 scheduled the calculations at about 100 Hz. The mixer combined throttle and tilt corrections and sent the resulting commands to TIM4. The firmware supported pulse widths from 1000 to 2000 µs, with a lower maximum for the bench tests.
Problem and response.
When the debugger showed calibration repeatedly restarting, we checked the sensor mounting and calibration criteria. We confirmed the angle signs by tilting the frame and verified the corrected front-to-rear pitch calculation against known inputs. A small tolerance at the joystick’s low end allowed arming when its reading varied slightly. When higher throttle requests stopped changing the outputs, we traced the plateau to the 1400 µs ceiling. We raised it to 1600 µs with the system disarmed. Later runs produced wider pulses and an apparent increase in motor speed.
What the test showed

The roll correction produced the expected 5 µs difference between the two motor pairs. In a separate check, all four STM32 timer compare values agreed with the commands the firmware calculated, verifying the path from calculation to timer output.

Recorded motor commands during a manually applied roll test.
Requested roll
−30°
Measured roll
≈ −32.5°
Calculated roll error
≈ +2.5°
PWM command pulse widths (µs)
M1M2M3M4
1400139513951400
Limits of the evidence
The recorded pulse widths were commands sent to the speed controllers. The frame was tilted by hand, so stable physical attitude regulation, restoring torque, motor speed, and thrust still need separate measurements.
Next objective.
Measure how the motors and frame respond to ESC commands before tuning the controller.

Stage 08 · Planned

Preparing to test physical stabilization

We plan to measure how the motors and frame respond before attempting sustained flight.

Proposed setup.
We need a controlled setup that lets us repeat motor and frame measurements.
Planned work.
We’ll measure the propulsion system and frame before tuning the controller. The hardware requirements we verified will guide the design and testing of a dedicated flight-controller PCB.
Open engineering questions.
We still need to connect ESC commands to measured motor speed and thrust, then see how those outputs move the frame.
Evidence carried forward

Our bench tests verified tilt sensing, radio reception, and the path from firmware commands to the timer.

Limits of the evidence
Stable attitude control, validation of the dedicated board, and autonomous flight are future work.
Next objective.
Define a repeatable way to record ESC commands, motor speed, thrust, and frame motion.
Return to the project timeline