Skip to content

Test: PID on a Microcontroller

Embedded Control

PID on a Microcontroller: From Maths to Zephyr

The inner loop

Real flight controllers run in layers. A slow outer loop decides what height or angle the drone should have; a fast inner loop keeps it level, hundreds of times a second. That inner loop is what runs on the microcontroller. Here the drone starts tilted by 20°, carries an off-centre parcel that tries to tip it over, and meets a gust at 6 seconds. First, choose how often the loop runs and how precisely its timer fires.

Challenge: Find settings that keep the wobble under 0.5° after the gust.

level20.0°

Tilt now

20°

Loop period

5.0 ms

Worst loop latency

1 ms

Missed periods

0

Control loop rate

gust-30°-15°0°15°30°0 s12 s