Hi,
I have been building a 2 wheel balancing robot and have it pretty much balancing. I say "Pretty much" because it tends to run away on me and not balance in a single spot. Please see link to video.
Below is the code:
//robotvelocity is cm/sec //angle and q_bias(Gyro rate) are converted to deg and deg/sec
kalman_update(asin(AccZ), asin(AccY)); state_update(GyroY * PI / 180);
torque = (((angle * 180 / PI) + Offset) * K1) + ((q_bias * 180 / PI) * K2) + (robotvelocity * K3);
if(torque >= 500) { torque = 500; } if(torque =< -500) { torque = -500; }
OCR1A = 1500 + (torque); OCR1B = 1500 + (torque);
Any help would be very much appreciated.
Kind Regards, Michael