Thread: Motor Speed
View Single Post
  #6   Spotlight this post!  
Unread 25-01-2008, 21:31
Tom Line's Avatar
Tom Line Tom Line is offline
Raptors can't turn doorknobs.
FRC #1718 (The Fighting Pi)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 1999
Location: Armada, Michigan
Posts: 2,521
Tom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond reputeTom Line has a reputation beyond repute
Re: Motor Speed

Use any type of encoder, but use the same one for both wheels.

It should be this simple, though I haven't done it yet (that's for tomorrow if we have a rolling chassis).

right_encoder = Get_Encoder(1);
left_encoder = Get_Encoder(2);

difference = right_encoder - left_encoder;

if (p1_y < (p2_y + 15)) && (p1_y > (p2_y - 15)) //If they're within 15 of eachtoher
{
right_drive = p1_y - difference * constant; //adjust based on difference of encoders
left_drive = p2_y + difference * constant; //adjust based on difference of encoders
}
else
{
right_drive = p1_y;
left_drive = p2_y;
}
Adjust constant until you go straight. This is essentially a PID loop based on the encoder difference. This assumes a tank drive system, but the same concept is applicable to other drive systems.