Im in the process of building my 1st robot with an arduino mega (coming in soon). My initial plan is build a simple differential drive robot (light or proximity sensing) running on two 12V motors. Would be extremely grateful if someone could guide me, as i am not well versed with electronics.
Two of these geared motors are coming in from ebay and all i know bout them is that they are 300rpm and 5W. So im guessing power is approx 0.5A (stall??). I have also ordered a polulu Dual MC33887 Motor Driver.
I’ve done up a rough diagram on how i ‘think’ it should be connected.
A few questions regarding this.
Are the connections correct?
Does pin EN go to the 5V on the arduino, or do i connect it to an external +5v supply? Or do i need to connect it at all?
The MC33887 datasheet states this about pin EN:
From the product description page:
Does pin D2 need to be connected at all? ie, can the robot run without PWM ? From what i’ve understood, without PWM, the motors will come to a sudden halt instead of gradually decelerating or accelerating, if logic states are reversed.
The two motors are 12V each, hence will it make sense to provide two 12V power sources in parallel?
Pins FS, FB and D1 are not connected, and i presume these are ok for a simple robot.
You should connect the big ground pad (the one on the left) directly to your battery’s ground, not to the Arduino’s ground. If you connect it to the Arduino’s ground, all of the current used by your motors will need to flow through the Arduino to get from your motors to the battery, and the Arduino’s ground traces probably aren’t designed to handle this amount of current. Notice how big the left ground pad is, and how much copper there is around it? This is all to support large amounts of current. If you look at the Arduino’s ground connections, they are probably much smaller holes with thin traces that will burn out if you put a few amps through them continuously.
The statements you quoted should make it clear that you cannot leave this pin disconnected if you actually want the motor drivers to do anything other than sit in low-power sleep mode. You need to put 5V on the enable pins; it doesn’t matter where this 5V comes from as long as it’s got a common ground with the board. The simplest solution is probably to use the Arduino’s 5V, or you can connect both enable lines to one of your digital outputs and drive it high to wake the drivers (if you have a digital output to spare).
You need to make a connection to D2, but it doesn’t have to be a PWM output. You can connect it straight to a 5V source and just use inputs 1 and 2 to control the motors. You should understand that the motor driver just puts the full battery voltage across the motor outputs in the direction you’ve specified to make your motor run forward and reverse. Using a PWM causes the driver to rapidly alternate between full voltage and no voltage so that the motor spins at a speed proportional to the percentage of time the driver has full voltage across the motor outputs. Without using PWM, your motors will only ever move at full speed, which will make your robot jerky and difficult to control.
No. Connecting separate power sources in parallel is rarely a good idea; it is almost always better to use a single battery/battery pack with more capacity. For example, a 12V car battery has much more capacity (and hence can deliver much more current) than eight alkaline AAA’s in series. If eight AAA’s don’t cut it, you should move to eight AA’s (or Cs, or Ds, or NiMHs, etc), not add another 8 AAAs in parallel.
It’s definitely reasonable to leave these pins disconnected for simple applications.
I’ve modified the diagram as per your advice; I hope it got it right this time!
I was pretty sure that i had to power the EN pin, but i thought id ask just to confirm. Regarding batteries, could i ask as to why connecting in parallel isnt the best choice? Not to doubt what you said, but a lot of tutorials/FAQs suggest that increasing current flow for robotic applications can be achieved by parallel connections.
Using a single battery will be more efficient than using two batteries of lesser capacity in parallel, so unless your project has some weird constraints, you’re usually better off getting a higher capacity battery. For example, a AA alkaline has roughly twice the weight and volume of a AAA alkaline, but it typically has three times the capacity (so it can supply roughly three times the current). Additionally, different batteries will probably be at slightly different voltages, and they might discharge at slightly different rates. What this means is that you’re effectively shorting different voltages together when you connect them in parallel, which causes current to flow between the batteries until their voltages are equalized. This can lead to unnecessary power loss, especially if the batteries you have connected in parallel are not well matched.
Regarding the “nube to posting” comment, just try to communicate well. So far, your haphazard punctuation and missing words (I think) make your post look lazy, and if your code is similar, you’ll probably have a tough time with programming. Just look at your last sentence. Are you just missing a period, and is your point that you have some experience with your Arduino? Did you mean “as well”? (In that case, I’m left wondering if you actually have an Arduino Mega or a different Arduino.)
Have you programmed anything yet? If not, you might start with something simpler. If so, you should ask a more specific question.
This is a very broad question so I’m not sure what kind of answer you are expecting. Most generally, you’ll probably want to use Arduino digital outputs to control the direction of the motors via the IN1 and IN2 pins and Arduino PWM outputs to control the motor speed via the !D2 (PWM) pins. Digital I/O with the Arduino is very easy, and you should be able to use AnalogWrite() (or something similar as I’m not entirely sure of the syntax) to generate PWMs. You might also use analog inuts to monitor the motor currents and digital inputs to monitor for motor faults, though this is entirely optional.
Yes, the MC33887 motor drivers each implement a full H-bridge. If all you want is unidirectional speed control, you could get by with a single MOSFET and wouldn’t need anything as advanced as an MC33887.