flight controller

x 0.40 · purpose 0.85 · t 250 µs · scope 0.65

from 2026-05

STM32 · C/C++ · KiCad · DShot · Real-Time Control

I fly FPV drones, but the flight controller inside them used to be a black box. After learning PID control, I designed an STM32 flight controller board in KiCad and wrote bare-metal firmware for it around a host-tested control core, to understand the whole loop well enough to explain every part of it.

gyro sampling
8 kHz
control loop
4 kHz
loop jitter, on the board
< 1%

250 microseconds

1,024 consecutive simulated control-loop periods at 4 kHz, 249.58–250.48 µs around the 250 µs target, all inside the ±1% band. Simulated, not measured: a model of the bare-metal schedule on a 168 MHz STM32F405, the 8 kHz gyro interrupt and the 4 kHz control task chained after every second one, with representative execution times and jitter. In the model, jitter is the period error of each control-task start, as the DWT cycle counter would time it: for every start-to-start interval T_i of 1,024 consecutive loops, J_i = 100 · |T_i - 250 µs| / 250 µs. The simulated worst case, max J_i, is 0.192% (0.48 µs off target); 99% of intervals are within 0.358 µs (0.143%). The modeled control task, DShot frame included, ends at most 71.26 µs after its gyro edge, leaving 53.74 µs before the next one. These periods are the model, not the board’s measurement, which is stated on its own: measured on the board, control-loop jitter stays under 1% at 4 kHz.

data
loopstart (ms)period (µs)error (%)
00.000250.130.052
10.250250.030.012
20.500249.700.120
30.750250.080.032
41.000250.240.096
51.250249.980.008
61.500249.880.048
71.750249.970.012
82.000249.850.060
92.250250.280.112
102.500249.840.064
112.750250.100.040
123.000249.970.012
133.250249.910.036
143.500250.010.004
153.750249.950.020
164.000250.090.036
174.250249.890.044
184.500250.090.036
194.750250.190.076
205.000249.650.140
215.250250.170.068
225.500250.140.056
235.750249.800.080
246.000250.270.108
256.250249.860.056
266.500249.940.024
276.750249.860.056
287.000250.270.108
297.250249.900.040
307.500249.870.052
317.750250.110.044
328.000250.060.024
338.250249.920.032
348.500250.080.032
358.750249.900.040
369.000249.960.016
379.250250.170.068
389.500249.800.080
399.750250.160.064
4010.000249.920.032
4110.250250.060.024
4210.500249.990.004
4310.750249.980.008
4411.000249.960.016
4511.250249.890.044
4611.500250.150.060
4711.750250.210.084
4812.000249.880.048
4912.250249.790.084
5012.500250.330.132
5112.750249.950.020
5213.000249.930.028
5313.250249.940.024
5413.500250.170.068
5513.750249.640.144
5614.000250.020.008
5714.250250.150.060
5814.500249.770.092
5914.750250.240.096
6015.000249.900.040
6115.250250.010.004
6215.500250.100.040
6315.750250.100.040
6416.000249.830.068
6516.250250.040.016
6616.500250.110.044
6716.750250.010.004
6817.000249.930.028
6917.250249.960.016
7017.500249.890.044
7117.750250.130.052
7218.000249.970.012
7318.250250.150.060
7418.500249.850.060
7518.750249.860.056
7619.000249.950.020
7719.250250.020.008
7819.500250.120.048
7919.750250.170.068
8020.000249.830.068
8120.250249.870.052
8220.500250.080.032
8320.750249.920.032
8421.000250.060.024
8521.250250.190.076
8621.500250.100.040
8721.750249.850.060
8822.000249.920.032
8922.250250.080.032
9022.500249.950.020
9122.750250.140.056
9223.000250.010.004
9323.250249.900.040
9423.500249.970.012
9523.750249.940.024
9624.000250.220.088
9724.250249.800.080
9824.500250.170.068
9924.750249.720.112
10025.000250.290.116
10125.250250.020.008
10225.500249.910.036
10325.750249.860.056
10426.000249.980.008
10526.250250.010.004
10626.500250.340.136
10726.750249.840.064
10827.000249.840.064
10927.250249.900.040
11027.500250.040.016
11127.750250.130.052
11228.000250.090.036
11328.250249.910.036
11428.500250.080.032
11528.750249.980.008
11629.000249.680.128
11729.250250.260.104
11829.500250.010.004
11929.750250.010.004
12030.000250.120.048
12130.250249.760.096
12230.500250.100.040
12330.750250.050.020
12431.000250.020.008
12531.250249.980.008
12631.500250.220.088
12731.750249.790.084
12832.000249.860.056
12932.250250.040.016
13032.500249.930.028
13132.750250.260.104
13233.000249.780.088
13333.250250.070.028
13433.500249.980.008
13533.750250.080.032
13634.000249.820.072
13734.250250.010.004
13834.500250.180.072
13934.750250.090.036
14035.000249.890.044
14135.250249.830.068
14235.500250.140.056
14335.750249.960.016
14436.000249.980.008
14536.250250.050.020
14636.500249.930.028
14736.750250.010.004
14837.000250.110.044
14937.250250.070.028
15037.500250.040.016
15137.750249.830.068
15238.000249.980.008
15338.250249.960.016
15438.500249.910.036
15538.750249.960.016
15639.000250.210.084
15739.250249.850.060
15839.500250.250.100
15939.750250.050.020
16040.000249.790.084
16140.250250.060.024
16240.500250.080.032
16340.750249.940.024
16441.000250.050.020
16541.250250.070.028
16641.500249.860.056
16741.750250.010.004
16842.000249.720.112
16942.250250.420.168
17042.500249.990.004
17142.750250.010.004
17243.000250.010.004
17343.250249.830.068
17443.500250.110.044
17543.750249.960.016
17644.000249.890.044
17744.250250.170.068
17844.500250.080.032
17944.750249.740.104
18045.000249.850.060
18145.250250.110.044
18245.500249.960.016
18345.750250.180.072
18446.000249.820.072
18546.250250.190.076
18646.500250.030.012
18746.750249.790.084
18847.000250.270.108
18947.250249.930.028
19047.500249.810.076
19147.750250.080.032
19248.000249.850.060
19348.250250.100.040
19448.500250.200.080
19548.750249.880.048
19649.000249.950.020
19749.250250.020.008
19849.500250.010.004
19949.750249.970.012
20050.000249.960.016
20150.250250.110.044
20250.500249.840.064
20350.750250.180.072
20451.000249.940.024
20551.250249.980.008
20651.500250.190.076
20751.750249.920.032
20852.000249.860.056
20952.250250.070.028
21052.500250.140.056
21152.750249.880.048
21253.000249.800.080
21353.250250.100.040
21453.500249.920.032
21553.750250.360.144
21654.000249.990.004
21754.250249.840.064
21854.500250.120.048
21954.750249.860.056
22055.000249.900.040
22155.250250.160.064
22255.500249.850.060
22355.750250.120.048
22456.000250.170.068
22556.250249.830.068
22656.500249.950.020
22756.750250.180.072
22857.000249.930.028
22957.250249.750.100
23057.500250.010.004
23157.750250.110.044
23258.000250.160.064
23358.250249.760.096
23458.500249.940.024
23558.750250.290.116
23659.000249.950.020
23759.250249.870.052
23859.500250.080.032
23959.750250.010.004
24060.000250.060.024
24160.250250.050.020
24260.500249.960.016
24360.750250.020.008
24461.000249.610.156
24561.250250.360.144
24661.500249.960.016
24761.750249.960.016
24862.000250.100.040
24962.250249.760.096
25062.500250.270.108
25162.750249.740.104
25263.000250.170.068
25363.250250.110.044
25463.500249.890.044
25563.750249.930.028
25664.000250.050.020
25764.250250.040.016
25864.500249.770.092
25964.750250.190.076
26065.000249.900.040
26165.250250.150.060
26265.500249.990.004
26365.750249.890.044
26466.000250.110.044
26566.250249.970.012
26666.500249.830.068
26766.750250.130.052
26867.000250.010.004
26967.250249.740.104
27067.500250.150.060
27167.750250.210.084
27268.000249.690.124
27368.250250.100.040
27468.500250.000.000
27568.750250.020.008
27669.000249.910.036
27769.250250.110.044
27869.500250.040.016
27969.750249.860.056
28070.000250.190.076
28170.250249.880.048
28270.500250.040.016
28370.750250.090.036
28471.000249.850.060
28571.250249.970.012
28671.500249.860.056
28771.750250.170.068
28872.000250.060.024
28972.250249.890.044
29072.500250.270.108
29172.750250.010.004
29273.000249.830.068
29373.250250.100.040
29473.500249.910.036
29573.750250.110.044
29674.000249.920.032
29774.250249.920.032
29874.500249.860.056
29974.750250.150.060
30075.000250.140.056
30175.250249.740.104
30275.500250.340.136
30375.750249.630.148
30476.000250.240.096
30576.250250.020.008
30676.500249.990.004
30776.750249.840.064
30877.000250.230.092
30977.250249.890.044
31077.500249.990.004
31177.750249.870.052
31278.000250.020.008
31378.250250.170.068
31478.500249.850.060
31578.750250.130.052
31679.000249.940.024
31779.250249.840.064
31879.500250.260.104
31979.750249.760.096
32080.000249.890.044
32180.250250.260.104
32280.500250.030.012
32380.750249.870.052
32481.000250.100.040
32581.250250.050.020
32681.500250.080.032
32781.750249.770.092
32882.000250.200.080
32982.250249.980.008
33082.500249.900.040
33182.750250.170.068
33283.000250.020.008
33383.250249.880.048
33483.500249.920.032
33583.750250.140.056
33684.000249.880.048
33784.250250.040.016
33884.500250.020.008
33984.750249.850.060
34085.000250.200.080
34185.250249.930.028
34285.500250.050.020
34385.750249.880.048
34486.000250.080.032
34586.250250.200.080
34686.500249.680.128
34786.750250.080.032
34887.000250.070.028
34987.250249.840.064
35087.500250.130.052
35187.750250.040.016
35288.000249.970.012
35388.250250.020.008
35488.500249.920.032
35588.750250.060.024
35689.000250.050.020
35789.250249.800.080
35889.500250.130.052
35989.750250.080.032
36090.000249.850.060
36190.250250.060.024
36290.500250.070.028
36390.750250.030.012
36491.000249.900.040
36591.250250.130.052
36691.500249.960.016
36791.750249.790.084
36892.000250.230.092
36992.250249.990.004
37092.500249.880.048
37192.750249.860.056
37293.000250.030.012
37393.250250.230.092
37493.500249.950.020
37593.750249.830.068
37694.000250.040.016
37794.250250.010.004
37894.500250.080.032
37994.750250.070.028
38095.000250.070.028
38195.250249.970.012
38295.500249.980.008
38395.750249.900.040
38496.000249.960.016
38596.250249.870.052
38696.500250.150.060
38796.750250.010.004
38897.000249.960.016
38997.250250.050.020
39097.500249.990.004
39197.750250.150.060
39298.000249.920.032
39398.250250.080.032
39498.500249.680.128
39598.750249.980.008
39699.000250.260.104
39799.250249.990.004
39899.500250.130.052
39999.750249.780.088
400100.000250.100.040
401100.250249.980.008
402100.500250.020.008
403100.750249.820.072
404101.000250.100.040
405101.250250.070.028
406101.500249.990.004
407101.750250.000.000
408102.000250.030.012
409102.250249.890.044
410102.500250.110.044
411102.750250.120.048
412103.000249.740.104
413103.250250.100.040
414103.500249.880.048
415103.750250.200.080
416104.000249.960.016
417104.250249.890.044
418104.500249.930.028
419104.750250.280.112
420105.000249.830.068
421105.250250.080.032
422105.500249.980.008
423105.750249.880.048
424106.000250.190.076
425106.250249.790.084
426106.500250.160.064
427106.750249.930.028
428107.000250.080.032
429107.250249.940.024
430107.500249.860.056
431107.750250.110.044
432108.000250.080.032
433108.250250.120.048
434108.500249.670.132
435108.750250.270.108
436109.000249.980.008
437109.250249.750.100
438109.500250.060.024
439109.750250.170.068
440110.000249.730.108
441110.250250.140.056
442110.500250.130.052
443110.750250.020.008
444111.000249.990.004
445111.250250.020.008
446111.500249.840.064
447111.750250.140.056
448112.000249.880.048
449112.250250.080.032
450112.500249.860.056
451112.750250.020.008
452113.000249.890.044
453113.250250.280.112
454113.500249.860.056
455113.750250.100.040
456114.000250.070.028
457114.250249.680.128
458114.500250.260.104
459114.750250.100.040
460115.000249.860.056
461115.250250.040.016
462115.500249.920.032
463115.750249.970.012
464116.000250.180.072
465116.250250.050.020
466116.500249.760.096
467116.750249.970.012
468117.000250.140.056
469117.250249.750.100
470117.500250.300.120
471117.750250.080.032
472118.000249.750.100
473118.250249.980.008
474118.500250.180.072
475118.750249.910.036
476119.000250.000.000
477119.250250.000.000
478119.500249.980.008
479119.750250.080.032
480120.000250.110.044
481120.250249.840.064
482120.500249.940.024
483120.750250.180.072
484121.000249.730.108
485121.250249.980.008
486121.500250.240.096
487121.750249.790.084
488122.000250.040.016
489122.250250.080.032
490122.500249.780.088
491122.750249.980.008
492123.000250.120.048
493123.250250.050.020
494123.500250.020.008
495123.750250.040.016
496124.000249.980.008
497124.250250.110.044
498124.500250.050.020
499124.750249.860.056
500125.000249.980.008
501125.250250.170.068
502125.500249.780.088
503125.750250.140.056
504126.000249.930.028
505126.250250.100.040
506126.500249.740.104
507126.750250.050.020
508127.000250.130.052
509127.250249.960.016
510127.500249.930.028
511127.750250.070.028
512128.000250.070.028
513128.250250.130.052
514128.500249.830.068
515128.750250.070.028
516129.000249.900.040
517129.250250.080.032
518129.500249.900.040
519129.750249.980.008
520130.000250.080.032
521130.250250.220.088
522130.500249.740.104
523130.750249.990.004
524131.000249.950.020
525131.250250.060.024
526131.500249.990.004
527131.750250.010.004
528132.000249.940.024
529132.250250.150.060
530132.500250.080.032
531132.750249.890.044
532133.000249.840.064
533133.250250.330.132
534133.500249.850.060
535133.750249.840.064
536134.000250.040.016
537134.250250.030.012
538134.500250.070.028
539134.750250.110.044
540135.000249.950.020
541135.250250.010.004
542135.500249.850.060
543135.750249.930.028
544136.000250.040.016
545136.250250.020.008
546136.500250.220.088
547136.750249.830.068
548137.000250.090.036
549137.250249.950.020
550137.500249.950.020
551137.750250.130.052
552138.000249.870.052
553138.250250.070.028
554138.500249.980.008
555138.750250.040.016
556139.000250.050.020
557139.250249.990.004
558139.500249.790.084
559139.750250.180.072
560140.000249.950.020
561140.250249.990.004
562140.500249.950.020
563140.750250.120.048
564141.000249.990.004
565141.250249.910.036
566141.500250.000.000
567141.750249.920.032
568142.000250.010.004
569142.250250.180.072
570142.500250.020.008
571142.750250.050.020
572143.000249.900.040
573143.250249.900.040
574143.500250.240.096
575143.750249.740.104
576144.000250.110.044
577144.250250.010.004
578144.500249.990.004
579144.750250.150.060
580145.000249.860.056
581145.250250.170.068
582145.500249.670.132
583145.750250.150.060
584146.000249.900.040
585146.250249.930.028
586146.500250.210.084
587146.750249.860.056
588147.000250.100.040
589147.250250.040.016
590147.500250.080.032
591147.750249.920.032
592148.000250.050.020
593148.250249.870.052
594148.500249.930.028
595148.750250.150.060
596149.000249.900.040
597149.250249.990.004
598149.500250.170.068
599149.750249.740.104
600150.000250.210.084
601150.250249.840.064
602150.500249.970.012
603150.750250.180.072
604151.000250.080.032
605151.250249.780.088
606151.500249.880.048
607151.750250.150.060
608152.000249.920.032
609152.250250.010.004
610152.500250.000.000
611152.750250.190.076
612153.000249.860.056
613153.250250.110.044
614153.500249.740.104
615153.750250.120.048
616154.000250.040.016
617154.250250.050.020
618154.500250.070.028
619154.750249.840.064
620155.000250.200.080
621155.250249.860.056
622155.500249.960.016
623155.750249.860.056
624156.000250.130.052
625156.250250.110.044
626156.500250.110.044
627156.750249.880.048
628157.000250.030.012
629157.250249.800.080
630157.500250.210.084
631157.750249.980.008
632158.000250.040.016
633158.250249.730.108
634158.500250.160.064
635158.750250.150.060
636159.000249.680.128
637159.250250.110.044
638159.500250.150.060
639159.750249.880.048
640160.000250.020.008
641160.250249.960.016
642160.500250.200.080
643160.750249.880.048
644161.000250.100.040
645161.250249.790.084
646161.500250.010.004
647161.750250.190.076
648162.000250.140.056
649162.250249.820.072
650162.500249.890.044
651162.750250.050.020
652163.000250.190.076
653163.250249.830.068
654163.500250.030.012
655163.750249.820.072
656164.000250.260.104
657164.250249.790.084
658164.500249.990.004
659164.750250.110.044
660165.000250.050.020
661165.250249.790.084
662165.500249.980.008
663165.750250.200.080
664166.000249.860.056
665166.250250.020.008
666166.500250.170.068
667166.750249.880.048
668167.000250.110.044
669167.250249.950.020
670167.500249.830.068
671167.750250.210.084
672168.000250.080.032
673168.250249.900.040
674168.500249.990.004
675168.750249.960.016
676169.000250.010.004
677169.250250.070.028
678169.500249.880.048
679169.750249.920.032
680170.000250.150.060
681170.250250.030.012
682170.500249.880.048
683170.750249.940.024
684171.000250.150.060
685171.250250.020.008
686171.500249.890.044
687171.750249.980.008
688172.000249.970.012
689172.250250.240.096
690172.500249.920.032
691172.750249.800.080
692173.000250.360.144
693173.250249.650.140
694173.500250.220.088
695173.750249.830.068
696174.000250.250.100
697174.250249.760.096
698174.500250.200.080
699174.750249.770.092
700175.000250.100.040
701175.250250.050.020
702175.500249.770.092
703175.750250.180.072
704176.000249.800.080
705176.250250.110.044
706176.500250.230.092
707176.750249.850.060
708177.000249.770.092
709177.250250.040.016
710177.500250.480.192
711177.750249.680.128
712178.000249.930.028
713178.250250.300.120
714178.500249.760.096
715178.750250.050.020
716179.000250.010.004
717179.250250.070.028
718179.500249.860.056
719179.750250.180.072
720180.000249.900.040
721180.250249.950.020
722180.500250.110.044
723180.750249.800.080
724181.000250.060.024
725181.250249.840.064
726181.500250.280.112
727181.750249.850.060
728182.000250.160.064
729182.250249.860.056
730182.500250.090.036
731182.750250.210.084
732183.000249.730.108
733183.250250.260.104
734183.500249.790.084
735183.750249.830.068
736184.000250.140.056
737184.250250.210.084
738184.500249.820.072
739184.750250.050.020
740185.000249.950.020
741185.250250.020.008
742185.500250.030.012
743185.750249.730.108
744186.000250.200.080
745186.250250.100.040
746186.500249.980.008
747186.750249.800.080
748187.000250.090.036
749187.250250.260.104
750187.500249.670.132
751187.750250.200.080
752188.000249.900.040
753188.250249.990.004
754188.500250.140.056
755188.750249.910.036
756189.000249.800.080
757189.250250.320.128
758189.500250.100.040
759189.750249.660.136
760190.000250.220.088
761190.250249.900.040
762190.500250.050.020
763190.750250.080.032
764191.000249.700.120
765191.250250.070.028
766191.500250.020.008
767191.750250.160.064
768192.000249.850.060
769192.250249.950.020
770192.500250.050.020
771192.750250.150.060
772193.000249.860.056
773193.250250.040.016
774193.500250.260.104
775193.750249.580.168
776194.000250.030.012
777194.250250.070.028
778194.500249.960.016
779194.750250.220.088
780195.000250.040.016
781195.250249.990.004
782195.500249.760.096
783195.750249.970.012
784196.000250.000.000
785196.250249.960.016
786196.500250.200.080
787196.750250.000.000
788197.000249.980.008
789197.250250.170.068
790197.500249.790.084
791197.750249.980.008
792198.000250.190.076
793198.250249.660.136
794198.500250.270.108
795198.750250.130.052
796199.000249.790.084
797199.250250.060.024
798199.500250.010.004
799199.750249.760.096
800200.000250.290.116
801200.250250.040.016
802200.500249.580.168
803200.750250.300.120
804201.000250.020.008
805201.250249.990.004
806201.500249.930.028
807201.750249.790.084
808202.000250.320.128
809202.250250.150.060
810202.500249.750.100
811202.750249.890.044
812203.000249.930.028
813203.250250.140.056
814203.500250.050.020
815203.750249.970.012
816204.000249.990.004
817204.250249.840.064
818204.500250.290.116
819204.750249.850.060
820205.000250.180.072
821205.250249.660.136
822205.500250.100.040
823205.750250.010.004
824206.000250.130.052
825206.250250.020.008
826206.500249.830.068
827206.750250.110.044
828207.000249.830.068
829207.250250.270.108
830207.500249.900.040
831207.750249.850.060
832208.000250.240.096
833208.250249.900.040
834208.500249.990.004
835208.750249.950.020
836209.000250.160.064
837209.250250.020.008
838209.500249.910.036
839209.750250.050.020
840210.000249.880.048
841210.250250.140.056
842210.500249.860.056
843210.750250.010.004
844211.000249.920.032
845211.250250.290.116
846211.500249.700.120
847211.750250.150.060
848212.000250.050.020
849212.250249.920.032
850212.500249.790.084
851212.750250.070.028
852213.000250.010.004
853213.250250.090.036
854213.500250.130.052
855213.750249.860.056
856214.000250.050.020
857214.250250.070.028
858214.500249.880.048
859214.750249.950.020
860215.000250.230.092
861215.250249.840.064
862215.500249.990.004
863215.750250.120.048
864216.000249.960.016
865216.250250.030.012
866216.500249.800.080
867216.750250.200.080
868217.000249.740.104
869217.250250.180.072
870217.500249.950.020
871217.750250.080.032
872218.000249.870.052
873218.250250.230.092
874218.500249.880.048
875218.750250.020.008
876219.000249.930.028
877219.250250.020.008
878219.500250.170.068
879219.750249.900.040
880220.000249.950.020
881220.250249.950.020
882220.500250.200.080
883220.750249.850.060
884221.000249.920.032
885221.250250.110.044
886221.500250.040.016
887221.750250.000.000
888222.000250.160.064
889222.250249.760.096
890222.500249.960.016
891222.750250.370.148
892223.000249.730.108
893223.250250.080.032
894223.500249.770.092
895223.750250.010.004
896224.000250.100.040
897224.250250.110.044
898224.500249.870.052
899224.750250.010.004
900225.000250.050.020
901225.250249.900.040
902225.500250.110.044
903225.750250.030.012
904226.000249.850.060
905226.250249.920.032
906226.500250.330.132
907226.750249.870.052
908227.000250.080.032
909227.250249.860.056
910227.500250.000.000
911227.750249.990.004
912228.000249.940.024
913228.250250.060.024
914228.500249.970.012
915228.750250.100.040
916229.000250.060.024
917229.250249.950.020
918229.500249.830.068
919229.750250.310.124
920230.000249.890.044
921230.250250.060.024
922230.500249.920.032
923230.750249.990.004
924231.000249.880.048
925231.250250.140.056
926231.500249.830.068
927231.750250.150.060
928232.000249.950.020
929232.250250.080.032
930232.500249.950.020
931232.750250.020.008
932233.000249.890.044
933233.250250.110.044
934233.500250.020.008
935233.750250.020.008
936234.000250.070.028
937234.250249.920.032
938234.500250.040.016
939234.750249.700.120
940235.000250.200.080
941235.250250.110.044
942235.500249.790.084
943235.750250.080.032
944236.000250.090.036
945236.250249.790.084
946236.500250.110.044
947236.750249.980.008
948237.000250.130.052
949237.250249.940.024
950237.500250.040.016
951237.750250.170.068
952238.000249.820.072
953238.250249.890.044
954238.500250.200.080
955238.750249.830.068
956239.000250.240.096
957239.250249.860.056
958239.500249.880.048
959239.750250.010.004
960240.000250.270.108
961240.250249.830.068
962240.500250.000.000
963240.750250.060.024
964241.000249.840.064
965241.250249.960.016
966241.500250.270.108
967241.750249.890.044
968242.000249.900.040
969242.250249.920.032
970242.500250.200.080
971242.750249.840.064
972243.000250.080.032
973243.250250.010.004
974243.500249.770.092
975243.750250.240.096
976244.000250.210.084
977244.250249.830.068
978244.500249.850.060
979244.750250.250.100
980245.000249.870.052
981245.250249.960.016
982245.500249.920.032
983245.750250.200.080
984246.000249.830.068
985246.250250.040.016
986246.500250.170.068
987246.750249.790.084
988247.000249.860.056
989247.250250.080.032
990247.500250.150.060
991247.750249.970.012
992248.000250.130.052
993248.250249.940.024
994248.500250.040.016
995248.750249.890.044
996249.000250.100.040
997249.250249.920.032
998249.500249.980.008
999249.750250.010.004
1000250.000249.940.024
1001250.250250.100.040
1002250.500250.020.008
1003250.750249.860.056
1004251.000250.130.052
1005251.250249.910.036
1006251.500250.020.008
1007251.750250.060.024
1008252.000249.960.016
1009252.250249.950.020
1010252.500249.930.028
1011252.750250.160.064
1012253.000249.960.016
1013253.250249.880.048
1014253.500250.110.044
1015253.750249.920.032
1016254.000249.900.040
1017254.250250.260.104
1018254.500249.770.092
1019254.750250.120.048
1020255.000250.080.032
1021255.250249.890.044
1022255.500249.980.008
1023255.750249.930.028
250 µs between control updates. these periods are simulated; measured on the board, jitter stays under 1%.

A 4 kHz loop has just 250 microseconds between iterations. The firmware reads the gyroscope over SPI at 8 kHz, filters every sample, and on every second one estimates attitude and computes motor commands, on a fixed-rate schedule. I characterized the loop’s timing on the board: control-loop jitter stays under 1% at 4 kHz, a deterministic real-time base for closed-loop flight and future GPS and state estimation. The view here is not that measurement but a scheduler simulation that models it: the gyro interrupt and the control task with modeled execution times, stamped the way the firmware’s cycle counter would stamp them. The histogram is narrow and centered on the target, with the trace of simulated intervals beside it.

command and response

Open-loop injections into the control core, simulated on the host; nothing is fed back. Step: the roll-rate setpoint goes from 0 to 200 °/s at 20 ms with the gyro still. P jumps to 0.20, I ramps to its 0.15 clamp by 113.75 ms, D on measurement stays within 0.007, where D on the error would kick to 1.09; the mixer's DShot commands split and the low pair saturates at 48. Noise: a synthetic gyro with a 400 Hz tone; the disturbance's rms falls from 10.382 °/s raw to 3.978 after the pt2 low-pass at 250 Hz and 1.535 with the notch. Sweep: 50 frequencies from 10 to 1600 Hz; the notch at 400 Hz (Q 2.5) reaches -60 dB, and the filter chain is at -26.22 dB by 1600 Hz.

data
t (ms)setpoint (°/s)pidd on errorm1m2m3m4
0.0000-0.00010.00010.0001648648648648
0.2500.0001-0.00010.00090.0009646646650650
0.5000-0.00010.00040.0004647647648648
0.7500-0.0001-0.0001-0.0001648648647647
1.000-0.0002-0.0001-0.0012-0.0012651651645645
1.250-0.0002-0.0001-0.0008-0.0008650650646646
1.5000.0001-0.00010.00080.0008646646649649
1.7500.0006-0.00010.00340.0034640640656656
2.0000.0006-0.00010.00310.0031640640655655
2.2500.0002-0.00010.00070.0007646646649649
2.5000.000200.00040.0004647647649649
2.7500.000200.00030.0003647647649649
3.00000-0.0007-0.0007649649646646
3.2500.000200.00020.0002647647648648
3.5000.0001000648648648648
3.7500.000200.00020.0002647647648648
4.0000.000200.00040.0004647647649649
4.2500.00010-0.0001-0.0001648648648648
4.500-0.00010-0.0011-0.0011650650645645
4.750-0.00010-0.0012-0.0012650650645645
5.0000.000100.00030.0003647647648648
5.2500.00010-0.0002-0.0002648648647647
5.5000.000400.00190.0019643643652652
5.7500.000800.00330.0033640640656656
6.0000.000800.0030.003640640655655
6.2500.0003000647647648648
6.500-0.00020-0.0025-0.0025653653642642
6.750-0.00040-0.0036-0.0036656656640640
7.000-0.00040-0.0028-0.0028654654641641
7.250-0.00030-0.0022-0.0022653653643643
7.500-0.00050-0.0028-0.0028654654641641
7.750-0.00040-0.0019-0.0019652652643643
8.000-0.00050-0.0021-0.0021653653642642
8.250-0.0008-0.0001-0.0036-0.0036657657639639
8.500-0.0008-0.0001-0.0033-0.0033656656639639
8.750-0.0006-0.0001-0.0017-0.0017652652643643
9.000-0.0003-0.00010.00020.0002648648647647
9.250-0.0001-0.00010.00130.0013646646650650
9.5000-0.00010.0020.002644644652652
9.750-0.0001-0.00010.00080.0008646646649649
10.000-0.0002-0.00010.00030.0003648648648648
10.250-0.0001-0.00010.00110.0011646646650650
10.5000.0001-0.00010.00180.0018644644652652
10.7500.0003-0.00010.00280.0028641641654654
11.0000.0002-0.00010.00180.0018644644652652
11.250-0.0002-0.0001-0.0007-0.0007650650646646
11.500-0.0004-0.0001-0.0019-0.0019652652643643
11.750-0.0006-0.0001-0.0025-0.0025654654641641
12.000-0.0003-0.0001-0.0006-0.0006650650646646
12.2500-0.00010.00090.0009646646649649
12.500-0.0002-0.0001-0.0002-0.0002649649647647
12.750-0.0006-0.0001-0.002-0.002653653642642
13.000-0.0009-0.0001-0.0033-0.0033656656639639
13.250-0.0007-0.0001-0.0023-0.0023654654641641
13.500-0.0003-0.00010.00040.0004648648648648
13.7500-0.00010.00220.0022643643652652
14.0000.0002-0.00010.00280.0028642642654654
14.2500.0002-0.00010.00230.0023643643653653
14.5000.0001-0.00010.00180.0018644644651651
14.7500.0001-0.00010.00140.0014645645651651
15.0000.0003-0.00010.0020.002643643652652
15.2500.0001-0.00010.00060.0006646646649649
15.500-0.0004-0.0001-0.0021-0.0021653653643643
15.750-0.0004-0.0001-0.0019-0.0019652652643643
16.000-0.0005-0.0001-0.0019-0.0019653653643643
16.250-0.0004-0.0001-0.0013-0.0013651651644644
16.500-0.0005-0.0001-0.0014-0.0014652652644644
16.750-0.0004-0.0001-0.0009-0.0009651651645645
17.000-0.0004-0.0001-0.0005-0.0005650650646646
17.250-0.0004-0.0001-0.0007-0.0007650650645645
17.500-0.0003-0.00010.00010.0001648648647647
17.750-0.0002-0.00010.00080.0008647647649649
18.000-0.0002-0.00010.00060.0006647647648648
18.2500.0003-0.00010.0030.003641641654654
18.5000.0002-0.00010.00230.0023643643653653
18.750-0.0002-0.0001-0.0005-0.0005649649646646
19.000-0.0003-0.0001-0.0009-0.0009650650645645
19.2500.0001-0.00010.00140.0014645645650650
19.5000.0005-0.00010.00350.0035640640656656
19.7500.0005-0.00010.00330.0033640640655655
20.002000.20040.00030.00221.088224224210531053
20.252000.20040.00070.00180.940424224210531053
20.502000.20040.00110.00160.812724224210541054
20.752000.20060.00150.00210.703223923910561056
21.002000.20070.00190.00260.608523723710581058
21.252000.20050.00230.00110.524824024010551055
21.502000.20020.0027-0.00080.451824424410521052
21.752000.19990.0031-0.00240.388724724710491049
22.002000.19980.0035-0.00220.335824624610501050
22.252000.19990.0039-0.00140.290824324310531053
22.502000.19990.0043-0.00110.251324224210541054
22.752000.20.0047-0.00080.217424024010551055
23.002000.19950.0051-0.0030.185524524510511051
23.252000.19990.0055-0.00080.162223923910571057
23.502000.20030.00590.00180.142723223210641064
23.752000.20020.00630.00080.122623323310621062
24.002000.20020.00670.00080.10623223210631063
24.252000.20030.00710.00120.092123123110651065
24.502000.20020.00750.00020.078823223210631063
24.752000.20030.00790.0010.068922922910661066
25.002000.20040.00830.00110.059822822810671067
25.252000.20040.00870.00110.051822722710681068
25.502000.20040.00910.00130.045222622610691069
25.752000.20070.00950.00230.040222322310721072
26.002000.20050.00990.00120.033922522510711071
26.252000.20020.0103-0.00070.027622822810671067
26.502000.20010.0107-0.00130.023222922910671067
26.752000.19990.0111-0.0020.019123023010661066
27.002000.20030.01150.00060.018922322310721072
27.252000.20010.0119-0.00060.015222522510701070
27.502000.20020.0123-0.00040.013322422410721072
27.752000.19990.0127-0.0020.009822722710691069
28.002000.19970.0131-0.00250.007722722710681068
28.252000.20010.013500.008822122110751075
28.502000.20030.01390.00110.008821721710781078
28.752000.20060.01430.00240.00921321310821082
29.002000.20080.01480.00320.008921121110851085
29.252000.20070.01520.00230.007221221210841084
29.502000.20020.0156-0.00070.003621821810781078
29.752000.20040.0160.00070.004421421410821082
30.002000.20090.01640.0030.006220720710881088
30.252000.20120.01680.00430.00720320310921092
30.502000.20090.01720.00240.004820720710881088
30.752000.20060.01760.00020.002221121110841084
31.002000.20080.0180.0010.002820820810871087
31.252000.20090.01840.00140.002920720710891089
31.502000.20090.01880.00130.002620620610891089
31.752000.20080.01920.00070.001820720710891089
32.002000.20090.01960.0010.00220520510901090
32.252000.20090.020.00110.001920420410911091
32.502000.2010.02040.00130.00220320310931093
32.752000.2010.02080.00110.001820220210931093
33.002000.20070.0212-0.00050.000120520510901090
33.252000.20020.0216-0.0031-0.002621021010851085
33.502000.20040.022-0.0015-0.00120620610891089
33.752000.20080.02240.00060.00120020010951095
34.002000.20060.0228-0.00020.000120220210941094
34.252000.20030.0232-0.0018-0.001620520510911091
34.502000.20030.0236-0.0017-0.001520420410921092
34.752000.20030.024-0.0017-0.001520320310931093
35.002000.20050.0244-0.0005-0.000319919910961096
35.252000.20040.0248-0.0008-0.000719919910961096
35.502000.20.0252-0.0029-0.002720320310921092
35.752000.19980.0256-0.0037-0.003620520510911091
36.002000.19970.026-0.0033-0.003220320310921092
36.252000.19980.0264-0.0028-0.002720120110941094
36.502000.20.0268-0.0013-0.001319719710981098
36.752000.20.0272-0.0011-0.00119619611001100
37.002000.19940.0276-0.0042-0.004120220210931093
37.252000.19930.028-0.0037-0.003720120110951095
37.502000.19960.0284-0.0021-0.002119619610991099
37.752000.19980.0288-0.0003-0.000319119111041104
38.002000.20.02920.00070.000818818811071107
38.252000.20010.02960.0010.00118718711091109
38.502000.19980.03-0.0004-0.000418918911061106
38.752000.19960.0304-0.0017-0.001719119111041104
39.002000.19930.0308-0.0033-0.003219419411011101
39.252000.19940.0312-0.0021-0.00219119111051105
39.502000.19950.0316-0.0012-0.001218818811071107
39.752000.19940.032-0.0015-0.001518818811071107
40.002000.19910.0324-0.0031-0.003119119111041104
40.252000.19940.0328-0.0013-0.001318618611091109
40.502000.19960.03320018318311131113
40.752000.19960.03360.00040.000418118111151115
41.002000.19980.0340.00110.001117817811171117
41.252000.20.03440.00230.002317517511211121
41.502000.20020.03480.0030.00317217211231123
41.752000.20030.03520.00320.003217117111251125
42.002000.20010.03560.00180.001817317311231123
42.252000.20.0360.00090.000917417411211121
42.502000.19980.0364-0.0004-0.000417617611191119
42.752000.19990.03680.00010.000117417411211121
43.002000.20030.03720.00250.002516816811271127
43.252000.20040.03760.00250.002516716711281128
43.502000.20.038-0.0001-0.000117217211231123
43.752000.19960.0384-0.0021-0.002117617611191119
44.002000.20.03880.00040.000417017011261126
44.252000.20010.03920.00080.000816816811281128
44.502000.20030.03960.00160.001616516511301130
44.752000.20020.040.00130.001316516511301130
45.002000.20020.04040.00060.000616616611301130
45.252000.20020.04080.00060.000616516511301130
45.502000.20010.04120016516511301130
45.752000.19970.0416-0.002-0.00216916911261126
46.002000.19990.042-0.0007-0.000716616611301130
46.252000.19970.0424-0.0018-0.001816816811281128
46.502000.19960.0428-0.0019-0.001916716711281128
46.752000.19930.0432-0.0031-0.003116916911261126
47.002000.19950.0436-0.0021-0.002116616611291129
47.252000.19960.044-0.001-0.00116316311331133
47.502000.19990.04440.00080.000815815811381138
47.752000.19990.04480.00050.000515815811381138
48.002000.19950.0452-0.0018-0.001816216211331133
48.252000.19940.0456-0.0018-0.001816216211341134
48.502000.19950.046-0.0012-0.001216016011361136
48.752000.19980.04640.0010.00115415411421142
49.002000.19990.04680.0010.00115315311431143
49.252000.19980.04720.00040.000415315311421142
49.502000.19970.0476-0.0003-0.000315415411411141
49.752000.20.0480.00170.001714914911471147
50.002000.20050.04840.00430.004314214211541154
50.252000.20060.04880.00390.003914114111541154
50.502000.20040.04920.00220.002214414411511151
50.752000.20030.04960.00150.001514514511501150
51.002000.20050.050.00220.002214314311531153
51.252000.20030.05040.00120.001214414411511151
51.502000.19990.0508-0.0014-0.001414914911461146
51.752000.19970.0512-0.0024-0.002415115111441144
52.002000.19960.0516-0.0023-0.002315015011451145
52.252000.19950.052-0.0025-0.002515015011451145
52.502000.19940.0524-0.0029-0.002915015011451145
52.752000.19940.0528-0.0026-0.002614914911471147
53.002000.19940.0532-0.0022-0.002214714711481148
53.252000.1990.0536-0.0039-0.003915115111451145
53.502000.19930.054-0.0019-0.001914514511501150
53.752000.19950.0544-0.0005-0.000514114111541154
54.002000.19960.05480013913911561156
54.252000.19950.0552-0.0004-0.000414014011561156
54.502000.19940.0556-0.0008-0.000814014011561156
54.752000.19930.0559-0.0012-0.001214014011561156
55.002000.19930.0563-0.0014-0.001413913911561156
55.252000.1990.0567-0.0025-0.002514114111541154
55.502000.19920.0571-0.0011-0.001113813811581158
55.752000.19970.05750.00140.001413113111651165
56.002000.19990.05790.00270.002712712711691169
56.252000.19980.05830.00170.001712812811671167
56.502000.19960.05870.00050.000513013011651165
56.752000.19950.0591-0.0002-0.000213113111641164
57.002000.19940.0595-0.0008-0.000813213211641164
57.252000.19940.0599-0.0009-0.000913113111641164
57.502000.19950.06030.00010.000112812811671167
57.752000.19950.06070.00020.000212712711681168
58.002000.19930.0611-0.0009-0.000912912911671167
58.252000.19940.0615-0.0007-0.000712812811681168
58.502000.19950.06190.00020.000212512511711171
58.752000.19940.0623-0.0004-0.000412512511701170
59.002000.19940.0627-0.0002-0.000212412411711171
59.252000.19990.06310.00230.002311711711781178
59.502000.20030.06350.00440.004411211211841184
59.752000.20030.06390.00380.003811211211841184
60.002000.20060.06430.00450.004510910911861186
60.252000.20040.06470.00310.003111111111841184
60.502000.20010.06510.00120.001211511511801180
60.752000.19970.0655-0.0014-0.001412012011751175
61.002000.19990.0659-0.0002-0.000211711711791179
61.252000.19980.0663-0.0005-0.000511711711791179
61.502000.19980.0667-0.0008-0.000811711711791179
61.752000.19970.0671-0.001-0.00111611611791179
62.002000.19940.0675-0.0026-0.002611911911761176
62.252000.19970.0679-0.0004-0.000411311311821182
62.502000.19950.0683-0.0013-0.001311511511801180
62.752000.19960.0687-0.0009-0.000911311311821182
63.002000.19930.0691-0.0021-0.002111511511801180
63.252000.19970.06950011011011861186
63.502000.20010.06990.00230.002310310311921192
63.752000.20020.07030.00240.002410210211931193
64.002000.20020.07070.00230.002310110111941194
64.252000.20010.07110.00160.001610210211931193
64.502000.20020.07150.00170.001710110111941194
64.752000.20030.07190.00230.0023999911961196
65.002000.20010.07230.00070.000710210211941194
65.252000.20010.07270.00050.000510110111941194
65.502000.20.0731-0.0002-0.000210210211931193
65.752000.20030.07350.00160.0016979711981198
66.002000.20040.07390.0020.002959512001200
66.252000.20020.07430.00060.0006989811981198
66.502000.20010.0747-0.0001-0.0001999911971197
66.752000.19970.0751-0.0022-0.002210310311931193
67.002000.19990.0755-0.001-0.001999911961196
67.252000.19990.0759-0.0009-0.0009989811971197
67.502000.20.0763-0.0002-0.0002969612001200
67.752000.20.07670.00010.0001949412011201
68.002000.20020.07710.0010.001919112041204
68.252000.20020.07750.0010.001919112051205
68.502000.20050.07790.00250.0025868612091209
68.752000.20030.07830.00110.0011898912071207
69.002000.20020.07870.00030.0003909012061206
69.252000.20030.07910.00070.0007888812081208
69.502000.20040.07950.00120.0012868612101210
69.752000.20070.07990.00250.0025828212141214
70.002000.20020.0803-0.0004-0.0004888812081208
70.252000.19990.0807-0.0019-0.0019909012051205
70.502000.19950.0811-0.0037-0.0037949412011201
70.752000.19940.0815-0.004-0.004949412011201
71.002000.19910.0819-0.0051-0.0051969611991199
71.252000.1990.0823-0.0046-0.0046949412011201
71.502000.19910.0827-0.0035-0.0035919112041204
71.752000.19920.0831-0.0027-0.0027898912071207
72.002000.19920.0835-0.002-0.002868612091209
72.252000.19940.0839-0.0007-0.0007838312131213
72.502000.19960.084300808012151215
72.752000.19970.08470.00090.0009777712181218
73.002000.19970.08510.00060.0006777712181218
73.252000.19980.08550.00110.0011757512201220
73.502000.20010.08590.00290.0029707012251225
73.752000.20020.08630.00290.0029696912261226
74.002000.20.08670.00120.0012727212231223
74.252000.19970.0871-0.0005-0.0005757512201220
74.502000.19950.0875-0.0012-0.0012767612191219
74.752000.19940.0879-0.0019-0.0019777712181218
75.002000.19950.0883-0.001-0.001747412211221
75.252000.19980.08870.00050.0005707012251225
75.502000.20020.08910.00280.0028646412321232
75.752000.20020.08950.00250.0025636312321232
76.002000.20030.08990.00240.0024636312331233
76.252000.20040.09030.00270.0027616112341234
76.502000.20020.09070.00140.0014636312321232
76.752000.20040.09110.00230.0023606012351235
77.002000.20080.09150.00420.0042555512401240
77.252000.20080.09190.00360.0036555512401240
77.502000.20060.09230.0020.002585812371237
77.752000.20030.09270.00020.0002616112341234
78.002000.19990.0931-0.0021-0.0021666612291229
78.252000.19950.0935-0.0042-0.0042707012251225
78.502000.19960.0939-0.0027-0.0027666612291229
78.752000.19980.0943-0.0015-0.0015636312331233
79.002000.19980.0947-0.0013-0.0013626212341234
79.252000.19940.0951-0.003-0.003656512311231
79.502000.1990.0955-0.0049-0.0049696912271227
79.752000.19920.0959-0.0034-0.0034656512311231
80.002000.19940.0963-0.0018-0.0018606012351235
80.252000.19990.09670.00110.0011535312431243
80.502000.19960.0971-0.0004-0.0004555512401240
80.752000.19970.0975-0.0001-0.0001545412421242
81.002000.19990.09790.0010.001505012451245
81.252000.20020.09830.00260.0026484812501250
81.502000.20010.09870.00180.0018484812491249
81.752000.20010.09910.00180.0018484812501250
82.002000.20040.09950.00320.0032484812541254
82.252000.20030.09990.00210.0021484812521252
82.502000.20040.10030.00210.0021484812531253
82.752000.20020.10070.00090.0009484812511251
83.002000.20020.10110.00050.0005484812511251
83.252000.20030.10150.00110.0011484812531253
83.502000.20.1019-0.0005-0.0005484812501250
83.752000.19970.1023-0.0021-0.0021484812471247
84.002000.19990.1027-0.001-0.001484812511251
84.252000.19990.1031-0.0008-0.0008484812521252
84.502000.19980.1035-0.001-0.001484812521252
84.752000.19970.1039-0.0016-0.0016484812511251
85.002000.19980.1043-0.0008-0.0008484812541254
85.252000.19980.1047-0.0009-0.0009484812551255
85.502000.19990.10510.00020.0002484812581258
85.752000.19990.10550.00010.0001484812581258
86.002000.20.10590.00050.0005484812601260
86.252000.19960.1063-0.0017-0.0017484812561256
86.502000.19950.1067-0.0022-0.0022484812551255
86.752000.19950.1071-0.0016-0.0016484812581258
87.002000.19970.1075-0.0003-0.0003484812611261
87.252000.19960.1079-0.0008-0.0008484812611261
87.502000.19960.1083-0.001-0.001484812611261
87.752000.19960.1087-0.0005-0.0005484812631263
88.002000.19940.1091-0.0015-0.0015484812621262
88.252000.19930.1095-0.002-0.002484812611261
88.502000.19930.1099-0.0018-0.0018484812621262
88.752000.19950.1103-0.0003-0.0003484812661266
89.002000.20.11070.00240.0024484812741274
89.252000.20010.11110.00260.0026484812751275
89.502000.20010.11150.00220.0022484812751275
89.752000.20020.11190.00230.0023484812761276
90.002000.19990.11230.00060.0006484812731273
90.252000.19980.112700484812721272
90.502000.20.11310.00070.0007484812751275
90.752000.20010.11350.00150.0015484812781278
91.002000.20020.11390.00190.0019484812791279
91.252000.20050.11430.00310.0031484812831283
91.502000.20060.11470.0030.003484812841284
91.752000.20040.11510.00150.0015484812811281
92.002000.20030.11550.00130.0013484812821282
92.252000.20050.11590.00220.0022484812851285
92.502000.20080.11630.00350.0035484812891289
92.752000.20090.11670.00320.0032484812891289
93.002000.20110.11710.00390.0039484812921292
93.252000.20140.11750.00520.0052484812961296
93.502000.2010.11790.00210.0021484812891289
93.752000.20070.118300484812851285
94.002000.20050.1187-0.001-0.001484812841284
94.252000.20070.11910.00050.0005484812881288
94.502000.20050.1195-0.001-0.001484812851285
94.752000.20020.1199-0.0022-0.0022484812831283
95.002000.19990.1203-0.0034-0.0034484812811281
95.252000.19990.1207-0.0029-0.0029484812831283
95.502000.20.1211-0.002-0.002484812861286
95.752000.20010.1215-0.0012-0.0012484812881288
96.002000.20.1219-0.0017-0.0017484812881288
96.252000.20010.1223-0.001-0.001484812901290
96.502000.20.1227-0.0013-0.0013484812901290
96.752000.20.1231-0.0014-0.0014484812911291
97.002000.20030.12350.00080.0008484812971297
97.252000.20040.12390.00110.0011484812981298
97.502000.20020.124300484812971297
97.752000.20020.1247-0.0004-0.0004484812961296
98.002000.19980.1251-0.0023-0.0023484812931293
98.252000.19980.1255-0.0017-0.0017484812951295
98.502000.20020.12590.00040.0004484813001300
98.752000.20030.12630.00110.0011484813031303
99.002000.20020.12670.00030.0003484813021302
99.252000.20010.1271-0.0003-0.0003484813011301
99.502000.20020.127500484813031303
99.752000.20.1279-0.0007-0.0007484813021302
100.002000.20010.1283-0.0002-0.0002484813041304
100.252000.20030.12870.00080.0008484813071307
100.502000.20020.12910.00030.0003484813071307
100.752000.20010.1295-0.0002-0.0002484813061306
101.002000.20.1299-0.001-0.001484813051305
101.252000.20020.13030.00020.0002484813091309
101.502000.20030.13070.0010.001484813121312
101.752000.20050.13110.00160.0016484813141314
102.002000.20030.13150.00020.0002484813111311
102.252000.20010.1319-0.0005-0.0005484813111311
102.502000.20060.13230.00210.0021484813171317
102.752000.20060.13270.00190.0019484813181318
103.002000.20050.13310.0010.001484813171317
103.252000.20030.1335-0.0002-0.0002484813151315
103.502000.20020.1339-0.0009-0.0009484813141314
103.752000.20050.13430.00090.0009484813191319
104.002000.20040.13470.00060.0006484813191319
104.252000.20040.13510.00060.0006484813201320
104.502000.20040.13550.00010.0001484813191319
104.752000.20030.1359-0.0003-0.0003484813191319
105.002000.20030.1363-0.0005-0.0005484813201320
105.252000.20050.13670.0010.001484813241324
105.502000.20060.13710.00130.0013484813251325
105.752000.20020.1375-0.0008-0.0008484813211321
106.002000.20020.1379-0.0011-0.0011484813221322
106.252000.20.1383-0.0017-0.0017484813211321
106.502000.20020.1387-0.0006-0.0006484813241324
106.752000.20040.13910.00030.0003484813271327
107.002000.20020.1395-0.0007-0.0007484813251325
107.252000.19980.1399-0.0025-0.0025484813221322
107.502000.20020.140300484813281328
107.752000.20020.140700484813291329
108.002000.20020.141100484813301330
108.252000.20020.1416-0.0002-0.0002484813301330
108.502000.19990.142-0.0015-0.0015484813281328
108.752000.19990.1423-0.0015-0.0015484813291329
109.002000.19970.1427-0.0021-0.0021484813281328
109.252000.19960.1431-0.0025-0.0025484813281328
109.502000.19980.1435-0.001-0.001484813321332
109.752000.19980.1439-0.001-0.001484813331333
110.002000.20010.14430.00080.0008484813381338
110.252000.20030.14470.00170.0017484813411341
110.502000.20040.14510.0020.002484813421342
110.752000.20050.14560.0020.002484813431343
111.002000.20.146-0.0007-0.0007484813381338
111.252000.19990.1464-0.001-0.001484813381338
111.502000.20020.14680.00040.0004484813421342
111.752000.20040.14720.00170.0017484813461346
112.002000.20010.1476-0.0002-0.0002484813421342
112.252000.19980.148-0.0019-0.0019484813391339
112.502000.19960.1484-0.0028-0.0028484813381338
112.752000.19960.1487-0.0021-0.0021484813401340
113.002000.19960.1491-0.0017-0.0017484813421342
113.252000.19970.1495-0.0011-0.0011484813441344
113.502000.20.14990.00070.0007484813491349
113.752000.20020.150.00150.0015484813511351
114.002000.20.150.00050.0005484813481348
114.252000.19980.15-0.0008-0.0008484813451345
114.502000.20030.150.00190.0019484813521352
114.752000.20030.150.00170.0017484813511351
115.002000.20010.150.00050.0005484813491349
115.252000.20010.150.00010.0001484813481348
115.502000.20.15-0.0001-0.0001484813471347
115.752000.19990.15-0.001-0.001484813451345
116.002000.19970.15-0.0016-0.0016484813441344
116.252000.19960.15-0.0019-0.0019484813431343
116.502000.20020.150.00140.0014484813511351
116.752000.20020.150.00120.0012484813501350
117.002000.20020.150.00130.0013484813511351
117.252000.20.15-0.0003-0.0003484813471347
117.502000.19980.15-0.0011-0.0011484813451345
117.752000.20.1500484813471347
118.002000.20.150.00020.0002484813481348
118.252000.20040.150.00210.0021484813521352
118.502000.20060.150.00280.0028484813541354
118.752000.20050.150.00190.0019484813521352
119.002000.20050.150.0020.002484813531353
119.252000.20040.150.00120.0012484813511351
119.502000.20060.150.00170.0017484813521352
119.752000.20060.150.00190.0019484813521352
120.002000.20050.150.00070.0007484813501350
120.252000.20030.15-0.0002-0.0002484813481348
120.502000.20050.150.00060.0006484813501350
120.752000.20030.15-0.0003-0.0003484813471347
121.002000.20030.15-0.0005-0.0005484813471347
121.252000.19990.15-0.0023-0.0023484813431343
121.502000.19960.15-0.0035-0.0035484813401340
121.752000.19950.15-0.0036-0.0036484813391339
122.002000.19950.15-0.0033-0.0033484813401340
122.252000.19940.15-0.0033-0.0033484813401340
122.502000.19980.15-0.0006-0.0006484813461346
122.752000.20020.150.00140.0014484813511351
123.002000.20030.150.00180.0018484813521352
123.252000.20040.150.00210.0021484813521352
123.502000.20040.150.00190.0019484813521352
123.752000.20020.150.00070.0007484813491349
124.002000.20060.150.00270.0027484813541354
124.252000.20090.150.00380.0038484813571357
124.502000.20070.150.00240.0024484813531353
124.752000.20080.150.00240.0024484813541354
125.002000.20070.150.00170.0017484813521352
125.252000.20040.15-0.0002-0.0002484813481348
125.502000.20030.15-0.0008-0.0008484813461346
125.752000.20010.15-0.0017-0.0017484813441344
126.002000.20010.15-0.0015-0.0015484813441344
126.252000.20010.15-0.0012-0.0012484813451345
126.502000.19990.15-0.0021-0.0021484813431343
126.752000.19980.15-0.0024-0.0024484813421342
127.002000.19990.15-0.0017-0.0017484813441344
127.252000.20010.15-0.0006-0.0006484813461346
127.502000.19990.15-0.0015-0.0015484813441344
127.752000.19970.15-0.0024-0.0024484813421342
128.002000.19990.15-0.0006-0.0006484813461346
128.252000.19990.15-0.0005-0.0005484813461346
128.502000.19990.15-0.0007-0.0007484813461346
128.752000.19970.15-0.0017-0.0017484813431343
129.002000.19960.15-0.0021-0.0021484813421342
129.252000.19940.15-0.0029-0.0029484813401340
129.502000.19970.15-0.0009-0.0009484813451345
129.752000.19980.15-0.0002-0.0002484813461346
130.002000.19980.1500484813471347
130.252000.19970.15-0.0007-0.0007484813451345
130.502000.19980.15-0.0001-0.0001484813471347
130.752000.19970.15-0.0004-0.0004484813461346
131.002000.19990.150.00090.0009484813491349
131.252000.20030.150.0030.003484813541354
131.502000.20050.150.00330.0033484813551355
131.752000.20040.150.00250.0025484813531353
132.002000.19990.15-0.0007-0.0007484813461346
132.252000.19970.15-0.0017-0.0017484813431343
132.502000.20010.150.00090.0009484813491349
132.752000.20050.150.00280.0028484813541354
133.002000.20030.150.00160.0016484813511351
133.252000.20010.150.00030.0003484813481348
133.502000.20010.1500484813481348
133.752000.19990.15-0.0012-0.0012484813451345
134.002000.20020.150.00050.0005484813491349
134.252000.20050.150.00210.0021484813521352
134.502000.20080.150.00380.0038484813571357
134.752000.20080.150.0030.003484813551355
135.002000.20090.150.0030.003484813551355
135.252000.20070.150.00180.0018484813521352
135.502000.20090.150.00240.0024484813541354
135.752000.20080.150.0020.002484813531353
136.002000.2010.150.00270.0027484813551355
136.252000.2010.150.00210.0021484813541354
136.502000.2010.150.0020.002484813531353
136.752000.20110.150.0020.002484813541354
137.002000.2010.150.00150.0015484813521352
137.252000.20070.15-0.0003-0.0003484813481348
137.502000.20060.15-0.0011-0.0011484813461346
137.752000.20040.15-0.0021-0.0021484813441344
138.002000.20010.15-0.003-0.003484813421342
138.252000.19990.15-0.004-0.004484813391339
138.502000.19990.15-0.0033-0.0033484813411341
138.752000.19980.15-0.0033-0.0033484813401340
139.002000.19960.15-0.0042-0.0042484813381338
139.252000.1990.15-0.0066-0.0066484813321332
139.502000.19910.15-0.0053-0.0053484813351335
139.752000.19930.15-0.0035-0.0035484813391339
140.002000.19970.15-0.0012-0.0012484813441344
140.252000.19970.15-0.001-0.001484813451345
140.502000.19980.15-0.0003-0.0003484813461346
140.752000.19990.150.00040.0004484813481348
141.002000.20010.150.00150.0015484813511351
141.252000.20050.150.00360.0036484813561356
141.502000.20080.150.00470.0047484813581358
141.752000.20070.150.00360.0036484813561356
142.002000.20030.150.00060.0006484813491349
142.252000.20040.150.00120.0012484813501350
142.502000.20050.150.00160.0016484813521352
142.752000.20080.150.00280.0028484813541354
143.002000.20080.150.00260.0026484813541354
143.252000.20060.150.0010.001484813511351
143.502000.20050.150.00030.0003484813491349
143.752000.20060.150.00090.0009484813501350
144.002000.20070.150.00150.0015484813521352
144.252000.20070.150.00150.0015484813521352
144.502000.20050.15-0.0001-0.0001484813481348
144.752000.20020.15-0.0016-0.0016484813441344
145.002000.20020.15-0.0014-0.0014484813451345
145.252000.20.15-0.0024-0.0024484813431343
145.502000.19980.15-0.0032-0.0032484813401340
145.752000.19990.15-0.0019-0.0019484813431343
146.002000.19980.15-0.0026-0.0026484813421342
146.252000.19960.15-0.0029-0.0029484813411341
146.502000.19990.15-0.0014-0.0014484813441344
146.752000.20010.150.00010.0001484813481348
147.002000.20020.150.00070.0007484813491349
147.252000.20030.150.00080.0008484813501350
147.502000.20010.150.00010.0001484813481348
147.752000.20020.150.00020.0002484813481348
148.002000.20010.15-0.0004-0.0004484813471347
148.252000.20020.150.00040.0004484813491349
148.502000.20.15-0.0006-0.0006484813461346
148.752000.19980.15-0.0017-0.0017484813431343
149.002000.19970.15-0.0022-0.0022484813421342
149.252000.19920.15-0.0043-0.0043484813371337
149.502000.1990.15-0.0048-0.0048484813361336
149.752000.1990.15-0.0042-0.0042484813371337
a setpoint step, gyro noise and a sine sweep, injected into the control core, open loop.

The control core is plain C99 that compiles for the host as well as the STM32, so it can run and be tested without hardware. A host-side simulation drives it open loop with synthetic signals. A step on the rate setpoint: P jumps, I winds up to its clamp, and D, taken on the measurement rather than the error, shows no derivative kick. Gyro noise, through the low-pass and notch filters. A sine sweep, tracing each filter’s gain and the notch’s dip. This simulation feeds nothing back: it has no plant model and no motor.

following the signal

imu (mpu-6000 · spi) → gyro filters (pt2 + notch) → attitude (mahony, six-axis) → rate pid (d on measurement) → mixer (quad-x, 48–2047) → dshot frame (throttle · telemetry · crc). imu: 8 kHz; gyro filters: 8 kHz; rate pid: 4 kHz; dshot frame: DShot300, bit-banged.

data
stepblockwhat it doesrate
1imumpu-6000 · spi8 kHz
2gyro filterspt2 + notch8 kHz
3attitudemahony, six-axis
4rate pidd on measurement4 kHz
5mixerquad-x, 48–2047
6dshot framethrottle · telemetry · crcDShot300, bit-banged
sensor readings become corrections, then motor commands.

A gyroscope measurement enters through SPI, passes through configurable low-pass and notch filtering and six-axis attitude estimation, then reaches the rate controller. A Quad-X mixer turns its output into four throttle values, and the firmware bit-bangs them as DShot300 frames, timed by the cycle counter. With no magnetometer, the attitude estimate’s yaw drifts; that is a known limit of the design.

the boundary

sim/ open-loop step, noise and sine-sweep injection; scheduler timing model; host only; csv logs; jitter simulated. core/ rate pid, mahony, filters, quad-x mixer, dshot encoding (c99); host + arm, unmodified; unit-tested. firmware/ stm32f4 registers: mpu-6000 spi, dshot300 bit-bang, dwt timing; on a kicad board; hil rig, pil sims; jitter < 1%, measured. a base for: closed-loop flight, gps/state estimation.

data
tierwhat it holdshow it runshow it is checked
sim/open-loop step, noise and sine-sweep injection; scheduler timing modelhost onlycsv logs; jitter simulated
core/rate pid, mahony, filters, quad-x mixer, dshot encoding (c99)host + arm, unmodifiedunit-tested
firmware/stm32f4 registers: mpu-6000 spi, dshot300 bit-bang, dwt timingon a kicad boardhil rig, pil sims; jitter < 1%, measured
a base forclosed-loop flight, gps/state estimation
what runs where, how each part is checked, and what it is a base for.

The firmware is real STM32F405/F411 code, written against a small hand-made register header. It builds with the ARM toolchain and runs on the KiCad board, where its loop jitter was measured under 1% at 4 kHz. I designed and built a hardware-in-the-loop rig to check the controller on that board for determinism and field reliability: a Raspberry Pi Pico 2 whose harness and plant model are written in C++. Numerous processor-in-the-loop simulations run the control code on the STM32 itself. The control core is compiled twice, unmodified: once for the host, where its unit tests and the simulation run, and once into the firmware. The timing and response figures here come from the host simulation; the board’s result is stated, not plotted.