Student engineering · 2026-09-02
Building a Self-Balancing Robot Using PID Controller for Your Engineering FYP.
A deep dive into the mathematical modeling, complementary filter sensor fusion, PID loop tuning, and mechanical chassis design of an inverted pendulum robot.
The two-wheeled self balancing robot using pid controller is a classic, universally respected capstone project for Mechatronics, Electrical, and Control Systems engineers looking for standout final year project ideas pakistan to build a demonstrable fyp prototype. Modeling an inverted pendulum tests a team's mastery of dynamic differential equations, digital sensor signal filtering, high-speed PWM motor control, and rigid mechanical chassis fabrication.
1. Inverted Pendulum System Architecture
The self-balancing robot maintains upright stability by driving its wheels in the direction that the upper chassis is falling. The hardware pipeline consists of four interconnected subsystems:
- IMU Angle Sensing: An MPU-6050 sensor mounted near the center of gravity measuring angular rate and gravitational acceleration vectors.
- Sensor Fusion Filter: Combining low-pass filtered accelerometer angles with integrated gyroscope angular rates using a complementary filter to obtain drift-free pitch angles.
- Microcontroller PID Processing: Executing a high-frequency (200Hz) timer interrupt loop calculating required motor compensation torque based on proportional, integral, and derivative terms.
- Motor Driver & Actuators: Dual H-bridge driver (TB6612FNG or L298N) modulating 12V geared motors equipped with quadrature encoders.
2. Practical PID Tuning Procedure
Tuning the PID controller requires a methodical, step-by-step approach:
- Set Ki = 0 and Kd = 0. Gradually increase proportional gain Kp until the robot responds to tilt and begins oscillating slowly around the vertical setpoint.
- Introduce derivative gain Kd to dampen the oscillations and eliminate overshoot. Continue increasing Kd until the robot resists sudden push disturbances without shuddering.
- Introduce a small integral gain Ki to eliminate steady-state tilt error, enabling the robot to maintain a stationary balance point without drifting forward or backward.
Frequently Asked Questions
Why does my self-balancing robot oscillate violently and fall?
Violent oscillations indicate excessive proportional gain (Kp) or insufficient derivative gain (Kd). Inverted pendulum robots also require fast loop execution rates (at least 100-200 Hz) and backlash-free gear motors with optical encoders.
What sensor should I use to calculate the tilt angle?
The MPU-6050 6-axis IMU (gyroscope + accelerometer) is standard. Combine the raw readings using a Complementary Filter or Kalman Filter to eliminate gyro drift and accelerometer vibrational noise.
Which motors are best for a self-balancing robot FYP?
High-speed metal geared DC motors with built-in Hall effect encoders (e.g. JGB37-520 12V 330RPM) or NEMA 17 stepper motors driven by A4988/TMC2209 drivers.
Educational engineering guide published by PakMEC Prototyping Division. Contact our engineers for custom circuit design, machining, and technical prototype fabrication.
Need help with the next step?
Need Help Fabricating or Tuning Your Robotic FYP?
PakMEC provides complete Mechatronics FYP support including high-torque motor selection, custom laser-cut chassis, and control algorithm implementation.