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.

- 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.

- 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.

- 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.

- 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.


- 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) M1 M2 M3 M4 1400 1395 1395 1400 - 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.