|
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.
|