Driving a motor shield from external power

Hi,

Sorry for the newbie question (or this is how this might sound like) but I cannot seem to understand the following situation: I cannot power this motor shield from external power: L298n Dual H Bridge DC Stepper Motor Drive Controller Board Module for Arduino for sale online | eBay.

I have both motors hooked to the right place, also the 4 control pins (IN1-IN4) are connected to arduino where I instruct both of them to rotate:
digitalWrite(IN1,HIGH);
digitalWrite(IN2,LOW);
digitalWrite(IN3,HIGH);
digitalWrite(IN4,LOW);

This works fine as long as I power the motor shield from +5V and GND pins of the Arduino. BUT when I connect the +5V and GND (I also tried it first with the 12V input) directly to a 9V battery, the motors don't move at all, but the red light indicating power does light up, only the motors don't move. I tried removing the 5V, also didn't make any difference. And here comes the stranges part (at least to my basic knowledge): if I connect the +5V and GND of the motor shield to the SAME 9V battery that powers Arduino, the motors move! Why is connecting the motor shield to the same battery that Arduino is using different than connecting it to a separate 9V battery? Again, if I connect the shield directly to the +5V and GND pins of Arduino, the motors move (only not that fast) OR if I connect to the +/- terminals of the SAME battery that is connected to arduiono, it works, but using a separate battery it doesn't move, just the red light is lit up.

The motors that I use: www.ebay.com/itm/160964087637

I cannot seem to understand this, so some help would be really welcome. :slight_smile:

Thanks!
Bence

Sounds to me that what's missing is that when you power the board externally, you didn't connect the ground of the board to the ground of the Arduino?- Difficult to tell without you showing a circuit, but that might be the problem.

Without the grounds linked, the Arduino control signals to the board have no meaning, since they are 5v as far as the Arduino is concerned but not to the shield since it has no 0V to measure the supposed 5V against.

Edit: Pic added... something like this is needed, see the 0V between the Arduino and the motor board

Edit: The 298 chip in that board guzzled volts by the way... you need about 2-3 (iirc) more in than you need at the motor.

Power supply.jpg

DOH! :slight_smile:
How could I have missed this?
Indeed, the ground was not connected to Arduino. Somehow I forgot about this.
But now it works like a charm. Thanks!

One more question if you don't mind: for me it's not that clear from the description what are the PWM pin for the motors? Is it IN1 and IN3?

what are the PWM pin for the motors? Is it IN1 and IN3?

If I remember correctly, last time I used an L298 I PWM'd the ENable pins

Thanks, works like a charm (except this issue: http://arduino.cc/forum/index.php/topic,153427.0.html)

Thanks again!
Bence