View Single Post
  #2   Spotlight this post!  
Unread 02-01-2004, 01:18
Anthony Kesich's Avatar
Anthony Kesich Anthony Kesich is offline
Programmer Turned Engineer
AKA: SonKenshin
#1097 (Site 3 Engineernig)
Team Role: Leadership
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Sacramento, CA
Posts: 186
Anthony Kesich has a spectacular aura aboutAnthony Kesich has a spectacular aura about
Send a message via AIM to Anthony Kesich
Re: how can you use a gyro in autonomous mode

I shouldn't even be writing this, but i felt like i needed to. The second topic in this forum asks the exact same thing (found here:http://www.chiefdelphi.com/forums/sh...ad.php?t=23268) and i gave them the following response:

Quote:
Originally Posted by myself in another forum
one piece of advice, before bringing up something that is not completely obscure, search the forums and also just go the the appropriate forum and make sure to change the start date from one week to one year or something along those lines. here's one forum on gyroscopes and C and the like:
http://www.chiefdelphi.com/forums/sh...ad.php?t=23071
I cannot say it enough, search, search, search!

As i just realized though, that doesn't give autonomous code. All a gyro can really do is tell you which way you're pointing, nothing more. So there really is no way to give sample code except for the following which just integrates the gyro output to give you one number which shows how far you've turned.

Code:
int theta=0;  //in global variables

// from here on in autonomous section or what have you

signed char gyro = (GYRO-127)*G_ADJUST; //GYRO being the macro for wherever your gyro is attached
                                          //and G_ADJUST is a constant to adjust to degrees

if (theta+gyro>=360)  //rolling from 359 to 0 and around again
   theta+=gyro-360;
else if (theta+gryo<0)  //rolling from 0 to 359 and around again
   theta+=gyro+360;
else
   theta+=gyro;
__________________
C is screwing up my English--I'm ending all my sentences in semi-colons;

Horray for most things! -George Carlin

"Sure, I'll play rugby. Besides, I have a lot of experience running from really big guys who want to cream me." -Me, Freshman year

Last edited by Anthony Kesich : 02-01-2004 at 01:38.