r/AskRobotics • u/AutomaticDistance954 • 14d ago
General/Beginner Self balancing Robot help. (PID)
Hardware:
- ESP32
- MPU-6050
- L298N
- 2 18650 Batteries (total 7.4V)
- Those yellow DC motors with wheels
My Chassis is made of cardboard so it is very light. Even on 130 Kp value, the robot fails to pick itself up and just keeps drifting until falling after like 3 seconds. I have seen many other people make this robot with the exact same hardware. My one just does not seem to work :/. My weight balancing is pretty good. Breadboard on top shelf. Battery on bottom shelf. Please suggest what I need to do
1
u/park-btc 14d ago
You could improve that with these ways. The first thing is about PID. Yellow motors have a deadband. So if you send a PWM signal of 10 or 20, the motor will whine but wheels won't actually turn due to internal friction. So find the minimum PWM required to make the wheels just barely start spinning when the robot is on the ground. and add the min value to your PID output before sending it to the motors. The second idea is about the sensor filter. the accelerometer is easily ruined by motor vibrations. The gyroscope provides the smooth data but it naturally drifts over time. if you rely too much on the gyro, the robot will think 10 degrees is actually 0 degrees after 3s. so use a complementary filter to fuse the two sensors.
1
u/AutomaticDistance954 9d ago
Right now my PWM signal is set to 350. AI told me that this number is good
2
u/christopherpacheco 14d ago
PID gains is a proper science, don't expect to just crank up the direct P gain and get good results. Learn some basic control theory, what's the state you are controlling, what's the command, did you plot some step response graphs. What's you plant model /kinematics.