An STM32 HAL example of PID control for a 1-DOF copter. The demo features an ESC (electronic speed controller) that supports DShot (Digital Shot) protocol, and an AHRS from Bosch Sensortec.
Video: 1-DOF copter in action
When you have an ESC and an AHRS up your sleeve you should definitely combine them into a 1-DOF copter! Such a copter poses an excellent plant1 to elevate your control system design skills. Let's then play with practical PID controllers. Integrator anti-windup and band-limited differentiator will be your best companions for that journey.
Don't worry 🙂 Just hit Alt-K to generate /Drivers/CMCIS/ and /Drivers/STM32L4xx_HAL_Driver/ based on the .ioc file. After a couple of seconds your project will be ready for building.
- Talon32 Slim 40A AM322 128K 3-6S (Skystars)
- V2306/V2207 V3.0 VELOX 2550KV (T-MOTOR)
- HQProp S4 Lemon Lime (Ethix)
- 2200mAh 11.1V 30C 3S1P LiPo battery (Gens ace)
- AM32-MultiRotor-ESC-firmware (AlkaMotors)
- What Is PID Control? | Understanding PID Control, Part 1 (Brian Douglas, MathWorks)
- Anti-windup for PID control | Understanding PID Control, Part 2 (Brian Douglas, MathWorks)
- Noise Filtering in PID Control | Understanding PID Control, Part 3 (Brian Douglas, MathWorks)
- A PID Tuning Guide | Understanding PID Control, Part 4) (Brian Douglas, MathWorks)
- Important PID Concepts | Understanding PID Control, Part 7 (Brian Douglas, MathWorks)
- PID Controller Implementation in Software - Phil's Lab #6 (Phil’s Lab)
- Bilinear transform (Wikipedia)
- Proportional-integral-derivative controller (Wikipedia)
- Integral windup (Wikipedia)
- The Map of Control Theory (Brian Douglas, Engineering Media)
Note
My favorite anti-windup technic is the one discussed by Brian Douglas. You can switch between the two by commenting or uncommenting #define PHIL_S_LAB.
- AM32 MultiRotor ESC Firmware
- AlkaMotors electronics inc.
- AM32 ESC Unlocker
- Creating a PC Link to AM32 using an Arduino
- AM32's NEW configurator settings 100% Explained (Chris Rosser)
- Tuning AM32 ESCs for Ultimate Performance (Chris Rosser)
Warning
Propellers that spin at tens of thousands rpm are not toys ❗ Safety first: LEGO 43038.
Warning
LiPo batteries are not toys either - learn to handle them before you use one in your project ❗
- BNO055 STM32 library (Ivy Knob) (MIT license)
- PID controller (Philip Salmony) (MIT license)
- stm32-ssd1306 (Aleksander Alekseev) (MIT license)
Create your own home laboratory/workshop/garage! Get inspired by ControllersTech, DroneBot Workshop, Andreas Spiess, GreatScott!, ElectroBOOM, Phil's Lab, atomic14, That Project, Paul McWhorter, and many other professional hobbyists sharing their awesome projects and tutorials! Shout-out/kudos to all of them!
Warning
Feedback control systems - do try them at home ❗
200+ challenges to start from: Control Engineering for Hobbyists at the Warsaw University of Technology.
Stay tuned ❗
Footnotes
-
They used to be shipped with the BLHeli_32 firmware. Recently the manufacturer switched to the AM32 firmware. Both of them support DShot300 and can be used interchangeably in this mini-project if DShot300 is selected. Similar exchangeability is not possible if DShot150 is opt for - the AM32 firmware does not support DShot150, which is totally understandable within the context of modern drones. ↩