M
mglazer
- Jan 1, 1970
- 0
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.
http://www.glazer.id.au/robot.WMV
Maybe I just need a break to figure it out but thought I would post a
message here as someone here may have solved this problem before.
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
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.
http://www.glazer.id.au/robot.WMV
Maybe I just need a break to figure it out but thought I would post a
message here as someone here may have solved this problem before.
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