Hi. I just tried to connect two different types of DC motors to my Arduino uno bot. Both have same rpm -100. But their torque differs. :( I am only able to supply it each with a voltage of 3.5V. The bot doesn't go straight. :( What's the solution. Is there any PWM correction or should I raise the Voltage to 12V to get it go straight ? Thanks in advance. :o
OK, let's get started.
(Web) Links to the "bot" you have, please.
Perfectly illuminated and focussed picture of the connections you have made.
Diagram of any circuit you are using, including the "bot" itself.
The solution is to use two identical motors surely?
You might try slowing the faster motor down with the MAP function, how much do the speeds differ at full voltage?
First - I agree with Paul in that you need to give us more information.
That said, I'm going to take a stab at things. First off, it sounds like you are working on a custom robot platform of some kind (either from a kit, or completely homebrewed) - and not likely the official Arduino Robot. Please correct me if I am wrong.
A picture or a link or something to your robot would help matters, though.
That said, it also sounds like the robot is a differentially steered/driven robot (aka - like a tank), which is a common design.
Note that no matter what you do, you will likely never get one of these robots to go perfectly straight, except under certain controlled circumstances. Even on a perfectly level and hard floor, over a given distance your robot will veer. This is due both to slight mis-matches in the motors or motor speeds, as well as variations in the surface, your gearing, tire friction, etc. It all adds up.
You can never eliminate all of this error. The best you can do is realize it is going to occur, and to deal with it as it occurs.
First would be to make sure both motors are turning the wheels at the same rate. This can be done by putting a simple encoder on each wheel. As the wheel turns, the encoder will output a pulse for every so-many degrees of rotation of the wheel. Say your encoder had 8 sectors alternating white and black, and you encoder sensor was optical in nature. So for every 45 degrees of rotation, your sensor would alternate from white-to-black-to-white-to-black...and so forth; your sensor would output a high-low-high-low-...etc pattern as the wheel turned.
You set up things in your code to time these transitions - you want both side (each wheel) to give you the same time value for each transition - which would indicate that both wheels are turning at the same rate. If one or the other doesn't have the same time values as the other, you would need to adjust the speed of the motors by either slowing down one side, or speeding up one side. Which you would need to do would depend on the situation - in most cases, you would slow things down on one side to match the other, until you went under your set speed value, then you would speed things up (you would be basically implementing a PID-like feedback algorithm where you're trying to keep a set speed - and the error factor is the differences in speed between the wheels). Of course, this doesn't work well if both motors are at "max speed" - but at that point you likely have other issues (and maybe you shouldn't command both motors at max speed, just to give yourself room for the algorithm to work).
Once you have that implemented, the other issues will come into play. To overcome those, you need to give your robot other sensors, such as a compass - so you know that if you are veering off-course, you can correct back to the proper course.
Ultimately - to completely fix this problem is not going to happen - and you shouldn't really try; instead, you need to learn to take error into account, and work around it.
And note that using encoders (for which most of the basic play robot chassis do have the mounting - haven't built mine yet though :grinning: ), you would not want to try to match the speed of the two motors, but use an algorithm that matches distance travelled by each side.
If you merely try and correct to make the speeds match, errors can and will accumulate and you will definitely veer off course.