The purpose of the project is to design a balancing robot based on the STM32 MCU.
On the web, you can find many guidelines on designing the balancing robots. Nevertheless, I always had a hard time finding clear and complete instructions. For example, some resources cover theory without diving into hardware while others do vice versa. Considering these issues, I decided to provide complete guidance on the balancing robot design which includes PCB design, firmware development, and balancing algorithm based on Linear Quadratic Regulator (LQR).
The Balancing Robot is a great project for diving into robotics and embedded firmware development. Designing it requires decent knowledge both in control systems and microcontroller programming.
Hardware:
The PCB design is fully open-access It can be found using this link: https://oshwlab.com/contact63/stm32-balancing-robot
The PCB contains an STM32l476 Microcontroller, an ICM-20948 IMU sensor to estimate angles, a STSPIN240 Motor driver, a pair of gearbox DC motors, and other passive components.
Firmware:
Within the Microcontroller, I read the ICM-20948 IMU sensor at a rate of 1 kHz and estimate the Euler angles. The guidance on attitude estimation can be found using the link: Attitude estimation course
Another great deal is to compute the velocity of the robot. For that purpose, I used a magnetic encoder along with the Encoder Mode of STM32 Timers. To understand how this mode works, you can follow the link: STM32 Timer Encoder Mode
Once I have all these readings, I apply a Linear Quadratic Regulator (LQR) to generate a PWM Signal with the corresponding PWM Signal. Last but not least, I use an RC Joystick to control the motor wirelessly: STM32 RC Joystick
The full source code can be accessed by joining my Patreon community: Steppeschool Patreon Page
Please comment and follow, I will add more details soon