PID Problem

Sep 29, 2006 4 Replies

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.

formatting link
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



Maybe bit more Integral? It could also be that the forward/reverse gains (losses) are not the same. How does it behave on a slope?

Regards,

Boris Mohar

Got Knock? - see: Viatrack Printed Circuit Designs (among other things)

formatting link

void _-void-_ in the obvious place

Posted via a free Usenet account from http://www.teranews.com

Do you have any absolute position measurement? If not then it's going to be hard to keep it in one spot. I don't see a variable that indicates a robot position, not even one that's done by integrating the robot velocity -- this would at least keep your robot down to a crawl, and probably better than that if you're using position encoders to get velocity.

You're probably beyond it, but check out my book, anyway:

formatting link

Tim Wescott Wescott Design Services http://www.wescottdesign.com Posting from Google? See http://cfaj.freeshell.org/google/ "Applied Control Theory for Embedded Systems" came out in April. See details at http://www.wescottdesign.com/actfes/actfes.html

Thanks for the replys, I have no position measurement which is what I need. Thanks for that, It's amazing how much something makes sense after you give it a break for a while.

Your book looks good, ill see if I can get hold of it in Australia otherwise I might get a copy from overseas.

Reagrds, Michael

Tim Wescott wrote:

You need to keep track of how many steps it has taken in trying to balance itself then try to undo those steps by adjusting the setpoint for the center of gravity/angle whatever untill eventualy it should move back to the original position then keep still.

Colin =^.^=

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required