I'm about to do it

Hi everybody,

I’m finally able to post a video so you can see problems affecting my robot.

balancing robot
As you can see in the video it responds quickly but then it overshoots in a direction, then falls.

/* PID variables */
double Kp = 20;              //30 seems too high   10is too low  
double Ki = 0.0001;        // >0.1 makes wheels run forever  
double Kd = 100;           //100  
double targetAngle = 0;

I used an arduino mega 2560, 2xpololu https://www.pololu.com/product/144, motor driver Pololu - Dual VNH3SP30 Motor Driver Carrier MD03A.

I’ve read that in noisy reading situations you need to set D to zero and only use PI. It will make the robot respond faster but only if I is big enough. You also need to have a maximal I so you do not overshoot. BUT was very hard to turn an instable balancing system into stable control loop without a D part in your PID controller, so I used also D term.

What I’m expecting is the robot going against my finger when I softly touch with a finger, the motor should start immediately and counteract my finger. THAT IS NOT HAPPENING. maybe this is a deadband problem.

I use position control, 10Khz pwm, direct port reading/writing as you can see in the long .ino file attached.

I really want to balance it.

arnital.ino (12.5 KB)