My Journey with the Reaction Wheel Inverted Pendulum
Balancing an inverted pendulum with a reaction wheel is a classic control challenge. My goal was to build a compact and efficient system that could maintain balance using precise motor control, sensor fusion, and real-time tuning.
Picture of my setup!
SIMULINK Model using UDP protocol to update the PID gain’s in real-time.
Struggles & Challenges
- I started with a DC motor but quickly realized its response time and torque were insufficient for precise control. Switching to a BLDC motor with CAN bus communication significantly improved performance.
- For IMU filtering, I initially used a Butterworth filter, but it caused phase lag, affecting stability. I later switched to a complementary filter, which offered a better balance between noise reduction and responsiveness.
- The frame structure is 3D-printed using PLA Tough filament, Ensuring the right balance was crucial to prevent instability. Powering the system with 24V via PSU provided the necessary torque and speed, enabling smoother and more responsive control.
Lessons Learned
- Motor Selection Matters: BLDC motors offer better speed and control compared to DC motors.
- Filtering is Critical: A complementary filter provides a good trade-off between accuracy and real-time performance.
- The flywheel weighs 97g and is semi-solid, while the stem comes in at 235g. Getting the right weight balance was tricky since the flywheel’s inertia plays a big role in keeping the system stable. Too light, and it wouldn’t generate enough reaction force; too heavy, and it would slow down the response time. To improve traction and reduce unwanted slipping, I added a rubber mat for friction control. This helped keep vibrations in check and made the system more stable overall.
- To keep my system responsive and avoid blocking execution, I used the
TaskScheduler
library (#include <TaskScheduler.h>
). This allowed me to run key functions every 10ms without usingdelay()
. The scheduler ensures IMU updates, PID calculations, and motor commands are executed consistently. I also use it to handle UDP communication with MATLAB for real-time tuning, making the system more efficient and stable.
Conclusion
This project reinforced the importance of iterative improvements. Switching to a BLDC motor, refining IMU filtering, and using real-time PID tuning were crucial steps in achieving better control. With Arduino MKR WiFi 1010 handling the computation and CAN bus ensuring reliable communication, the system is now more stable and responsive.
Here my code.
feel free to check out!