Thread: Turn 90 Degrees
View Single Post
  #12   Spotlight this post!  
Unread 04-12-2004, 21:52
jgannon's Avatar
jgannon jgannon is offline
I ᐸ3 Robots
AKA: Joey Gannon
no team
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Pittsburgh, PA
Posts: 1,467
jgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond reputejgannon has a reputation beyond repute
Re: Turn 90 Degrees

Quote:
Originally Posted by MikeWasHere05
Somehow measure the amount of time it takes for the wheel to spin one revolution at speed x.
Set it to run at speed x for the needed amount of length/time.
Here's what I would suggest. This is kinda pseudo-code, but you'll get the idea.

Code:
#define COUNT 20 //determine this number experimentally

void turn90(void)
{
   int i=0;
   int last=0;
   while(i<COUNT)
   {
      pwm01=255;
      pwm02=0;
      if(rc_ana_in01<last)
         i++;
      last=rc_ana_in01;
   }
   pwm01=127;
   pwm02=127;
}
COUNT is the number of revolutions it takes for your robot to turn 90 degrees. You have two servos connected to pwm01 and pwm02. You have a multi-turn pot on analog input 01. The value from the pot goes from 0 to 1023, and then starts over at 0 again. (That's just how the processor does it, for some reason. I dunno why they went with 10 bits instead of 8.) If the number is suddenly less than it was last time it checked, then the pot has made a complete revolution. This is more precise than measuring time, because the values needed for other angles are not 1:1, due to inertia and stall friction. If you wanted an angle of 45º, change it to while(i<COUNT/2). If you want 180º, change it to while(i<COUNT*2). I'm not sure if I'm making any sense, so ask me if you don't understand it.
__________________
Team 1743 - The Short Circuits
2010 Pittsburgh Excellence in Design & Team Spirit Awards
2009 Pittsburgh Regional Champions (thanks to 222 and 1218)
2007 Pittsburgh Website Award
2006 Pittsburgh Regional Champions (thanks to 395 and 1038)
2006 Pittsburgh Rookie Inspiration & Highest Rookie Seed

Team 1388 - Eagle Robotics
2005 Sacramento Engineering Inspiration
2004 Curie Division Champions (thanks to 1038 and 175)
2004 Sacramento Rookie All-Star

_

Last edited by jgannon : 04-12-2004 at 22:01.
Reply With Quote