Motor Calibration

I made a differential drive bot. When i give the same rpm for both the wheels using an arduino, my bot does not move in a straight line. I have tried changing the motors, the wheels and also tried to manually calibrate it by keeping one slower wheel (left) at 255 and the faster one at a lesser speed but that also did not work as for the combination of (255,231), the bot moved right and for (255,230) it moves left.

How do i fix this?

Put encoders on the drive shafts, but even these can't compensate for wheel-slip.

magnetometer? (but well away from motors - perhaps up on a little stick). Then you can sense orientation in an absolute sense and provide feedback.

I also tried minimizing the error using PID control but it does not solve the problem. How do i counter wheel slip?

How do i counter wheel slip?

Slow your acceleration and deceleration, and/or get grippier wheels.

Tried that also sir, did not work :(.

Optical mouse.

Sorry sir, I dont understand.. Can you explain a bit more?

Use the principle, or indeed the guts, of an optical mouse to give a better estimate of motion over ground.

That won't work because you want to measure movement relative to the ground frame, whereas an optical mouse measures movement relative the robot frame.

phani_krishna: I have tried changing the motors, the wheels and also tried to manually calibrate it by keeping one slower wheel (left) at 255 and the faster one at a lesser speed but that also did not work as for the combination of (255,231), the bot moved right and for (255,230) it moves left.

How do i fix this?

For a finer control you can dither between the two combinations (255,231) and (255,230).

If you were to switch between the two combinations, say every 100ms, that would be equivalent to using (255.230.5).

And if that is not good enough, you can get even finer resolution, by staying on one combination for say 60% of the time, and the other for 40%, etc.

I think you are expecting too much from your hardware - a feedback loop will finesse such issues if you have a sensor that gives correct orientation to the requisite precision.