Motor Speed

Hey guys, I was just wondering why, when we set the same PWM values to two different motors, why the motors are going two different speeds? Anyone know how to fix this through calibration or something???

It’s because you’ve got one motor mounted backwards, and the motors actually have a preferential direction. If you have encoders on your drive shafts, we have some code we’re working on right now that will make it drive straight.

I’m sure someone else will have some code up before I will, but if you send me an email to remind me I’ll put it up by monday.

P.S. I’m literally working on it RIGHT now … final touches … (which means nothing, of course)

also, manufacturing isn’t perfect. we had this problem last year. what happens is 255 to one motor might only act like 230 (exaggeration) on another. one wyay to fix this is to individually slow down each motor to calibrate them:

pwmXX-=127;
pwmXX*=0.9 //for 90% power
pwmXX+=127;

the other (and preferred) way is to use sensors like (ideally) encoders, but you could use a gyro to make it go straight, or, dare i say it, gear tooth sensors as encoders (it only requires a slight modification to kevin’s encoder code). the only problem is that GTS’s have to be almost touching the gear to get a reading, and thereadings are usually pretty sketchy.

good luck!

Thanks for the help. Just wondering what kind of encoders you use/what kind do you recommend? Thanks again!

as far as what kind of encoders, i’m not too sure. just do a search on these forums for encoders, and you’ll find more than you need :slight_smile:

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.

Calibrating the victors would not hurt. Instructions are here. Either calibrate both Victors or reset them both to Factory default (your choice).

Also, I use US Digital encoders. Other people have mentioned Banebots and Grayhill.