View unanswered posts | View active topics It is currently Wed Apr 23, 2014 4:42 am

Reply to topic  [ 3 posts ] 
Accelerometer/gyro bridge balancing 
Author Message

Joined: Fri Mar 25, 2011 7:54 pm
Posts: 1
Post Accelerometer/gyro bridge balancing
How are other teams balancing on the bridge with an accelerometer?
I know it involves something like waiting until the readings in the x and y direction are 0, and then waiting until the reading in the z
axis is 200,
but i've also heard alot about how it's impossible to balance with only a accelerometer, and that you need a gyro sensor as well

My team tried balancing with the gyro sensor, but its had limited success. For some reason, it always stops a little after when its supposed to so it can balance, and as a result, it doesnt balance.
Below is the function i made to auto balance on the bridge in autonomous..can anyone spot any problem that i'm not seeing that could explain why its not working? I've tryed messing with the number "5.5" and "-5.5" but its still not very consistent..
void BalanceOnBridgeUsingGyro()
       nxtDisplayTextLine(1, "Resetting");
       nxtDisplayTextLine(1, "heading");

       // Start the calibration and display the offset
       nxtDisplayTextLine(2, "Offset: %4d", HTGYROstartCal(HTGYRO));
      // wait10Msec(1000);


      gPwr = -50;
      motor[rightm] = gPwr;
       motor[leftm] = gPwr;
      //while (true)
       gPwr = -25;

           motor[rightm] = gPwr;
            motor[leftm] = gPwr;
            if( (heading < 5.5) && (heading > -5.5))
              motor[rightm] = 0;
              motor[leftm] = 0;



Fri Mar 25, 2011 8:18 pm
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Accelerometer/gyro bridge balancing
There is not enough information in your post. First, how are you using the gyro for balancing? Do you mount the gyro vertically so the tilting of the bridge will change your vertical heading? You did not show the code that calculates the heading. We use the accelerometer and it worked beautifully with our algorithm. At first, we did PID control using the the forward axis of the accelerometer as the PID input. But as soon as the bridge started to move, PID contorl went crazy because it was responding the change too fast so it went back and forth and the bridge would oscillate forever. So we abandoned PID control and use the algorithm such that we move forward slowly until the accelerometer value comes within a small threshold, then we stop and wait for a period of time (2 seconds) for the bridge to settle. If it settles, we are done, if not we check the accelerometer again and will either move forward or backward a little bit depending on if the accelerometer value is positive or negative. Then we wait for the settling period again and repeat the steps until it settles.

Sat Mar 26, 2011 12:52 am

Joined: Fri Apr 15, 2011 12:08 am
Posts: 5
Post Re: Accelerometer/gyro bridge balancing
I don't have access to my code, otherwise I'd paste it here. But you can easily balance with only an accelerometer, the gyro is usually for making it more accurate/reducing noise.

I'm not totally sure how to explain my code without having it here, since I have odd practices. Basically, you go forward until you're tipped forwards, and then you go back until you tip the other way; the trick is then creating a middle area, where you can stop to be balanced. I know a lot of people find inching to be better, but I somehow got oscillation to work, and it balances faster than most inchers I see.

Fri Apr 15, 2011 12:28 am
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.