I am currently using two identical motors to drive a robot. The motors are both controlled using relays but one of the motors is spinning faster than the other. How can I slow down the faster motor to turn the same speed as the slow one?
The motors are mechanically different, so you can not get them to move at the same speed at the same voltage. This is a problem if you're driving them with relays since relays tolerate a very slow frequency, so they can not be PWM'ed.
However, if you're willing to change your design and switch to power mosfets you can basically split the problem in three:
- Measure the speed of each of the motors
- Determine which of the two is moving faster
- Adjust their speed accordingly.
For the first part, you will be needing a rotary encoder. There are plenty of types and can be home made.
If you're using an Arduino, reading the information from the rotary encoder and determining which is faster and which is slower should not be a problem.
Lastly, you can adjust the speed of the motors using PWM.
You have not described your needs sufficiently. Wouter's comment makes what seems to be the reasonable assumption that you're driving two wheels, one on each side, each with a different motor. In that case, his comment is correct.
Depending on your physical setup, you may be better served by mechanically linking the two shafts, using gears and a timing belt.
If you must go electronic, you'll need a rather sophisticated setup. You'll need an encoder on each shaft to measure position, then a position-zeroing loop to equalize one to the other. Note that a simple velocity loop will not guarantee that the shafts, and hence the wheels, turn exactly the same amount over time. When you start up, if one wheel starts driving before the other, when the shafts equalize the first one to move will still be ahead of the other.