L298N Help Needed

I am having problems getting my L298N motor controller working.

I'm using this controller: http://www.amazon.com/gp/product/B00E58EA90
I'm using this motor: http://www.amazon.com/gp/product/B00HG8DFC4
My Arduino is a MEGA2560.

I have the controller wired as follows:
VCC => 5V on Arduino
GND => GND on Arduino & GND on external power
+5 => 24V+ positive external power
OUTA => positive motor terminal
OUTB => negative motor terminal
INA => pin 4
INB => pin 5
ENA & 5V jumper is in place

My code is as follows:

#include <Wire.h>
#include <SPI.h>

#define OUT1PIN1 4
#define OUT1PIN2 5

void setup()
{
pinMode(OUT1PIN1, OUTPUT);
pinMode(OUT1PIN2, OUTPUT);
}

void loop()
{
digitalWrite(OUT1PIN1, LOW);
digitalWrite(OUT1PIN2, HIGH);
delay(5000);

digitalWrite(OUT1PIN1, HIGH);
digitalWrite(OUT1PIN2, LOW);
delay(5000);
}

The problem is that there is never any voltage to the OUTA/B pins on the controller. Verified with voltage meter and observing that the motor does not run. I've tried other pins on the Arduino such as 40 & 41, but it makes no difference.

Any assistance would be great.

+5 => 24V+ positive external power

Could you explain what you mean by that?

What I mean is that I have the positive side of my external power supply connected to this connector on the L298N controller board. My external power supply is a 24V DC power supply. It is my understanding that the controller can handle voltages of 5 - 35 volts DC.

Yeah - it can. But from what I remember from other similar L298 h-bridge boards like you have, the +5 volt pin is actually an -output- and not an input. That, or it's an input for the 5 volt section for an external regulated 5 volts. It all depends on an on-board jumper.

There is an on-board voltage regulator that provides the 5 volts for the logic of the L298; VCC is supposed to be for the input voltage on the board; a jumper selects whether the 5 volts comes from the regulator (taking VCC - which is for the motors and regulating it down to 5 volts for the logic of the L298), or whether it is supplied from an outside, regulated 5 volts to the +5 pin.

When it is using the on-board regulator (with the jumper placed properly), then the +5 pin is an output from the regulator; when it is jumpered the other way, the +5 pin is an input directly to the 5 volt logic side of the L298. The VCC pin is the supply for the motors (and the L298 logic via the regulator - again, depending on the jumper setting).

If you were applying 24 volts to the +5 pin - depending on the jumper setting you likely have either fried the L298 or the regulator (maybe both). You will need to either get a schematic for the board, or trace one out yourself from the PCB traces (and a multimeter and the L298 datasheet) to determine what everything is for, how the inputs and outputs and connected, and how the jumpers are supposed to be set (and what is currently set when you applied power).

Posted in the comments on the Amazon page was this forum thread:

http://forum.arduino.cc/index.php?topic=110876.0

Which shows a similar (but not the same) board - along with some discussion on how to hook it up. There's also a link to the ebay supplier of the board in the thread, here:

In that ebay listing is a schematic (presumably) of the board being sold (again - not the same as your board, but it will serve as an illustration). If you look at the schematic (which is difficult to see because it isn't very large, and it is blurry), note the sub-schematic in the upper left corner. That shows the LM7805 5 volt regulator circuit for the on-board 5 volts to power the L298 logic side. On the left side is the three pin power connector - one pin for 12 volts one pin for ground, and one for 5 volts. Next in series comes the enable jumper; when this jumper is connected, it sends 12 volts to the LM7805 regulator (next in line), which then shows the +5 pin as an output (pin 1 on the three pin connector).

Now the other schematic is the L298 diagram. Notice how the +12V is connected to the L298 motor input - but the +5V is connected to the VSS (logic voltage) section of the L298. Also note how (in this diagram) there isn't a jumper from the 3 pin voltage input for the +5 volt pin, nor between the output of the LM7805 and the +5V pin.

So - if your board is similar (and I am not saying it is - again, only you will be able to determine this by reverse engineering your own schematic) - then by applying 24 volts to that +5 pin - you applied 24 volts to the output of the LM7805 as well as to the 5 volt logic side of the L298 (and I don't know if you had connected the 24 volts to the other pin on the 3 pin connector; you didn't say).

You are probably going to have to do some reverse engineering yourself if you want a schematic for the board (I doubt the supplier has one, and there have been so many manufacturers of these boards in china that there are tons of revisions and versions of the same basic module - so reverse engineering your own schematic is likely preferable).

You might also try this (but even if it works, I would still suspect the board for damage and not use it):

  1. Hook your 24 volt supply to the VCC and ground pins on that 3 pin connector - leave the +5 pin empty.

...UGH - see my next reply.

Ok - forget most of what I wrote before - I just looked at that amazon listing page again, and noticed the schematic for (presumably) your board here:

Again - it is very similar to the other board's schematic I referenced in my first post. And yes, you did apply 24 volts to the logic side of the L298 (VSS), as well as to the enable pins of the L298, and to (probably) the output of the LM7805.

So - try this:

  1. Put your 24 volt DC supply on the VCC and ground pins of the board - leave the +5 pin open.

  2. I am not sure what the 4 pin jumper block is for; without having one of these boards in hand along with the schematic, it is impossible to tell, but I think it's to allow jumping the IN1-4 pins to possibly 5 volts (?) or to the white connector (?). You will have to determine this.

  3. The switch may have protected things (maybe - if you didn't press it while supplying power to the +5 pin with 24 volts; again, things aren't very clear without the board in-hand). I can't tell if that switch is a toggle switch, or simply a momentary switch of some sort - I think it may be a toggle. It has an LED indicator for some reason, run off the +5 volt output of the LM7805 and/or the input from the 3-pin connector on the board.

Your board may well be truly hosed, given the way you described hooking it up. This is why it is important to read and understand all documentation (datasheet for the L298) and schematics. In this case, the schematic is very important - it at least gives some idea of what is hooked up and where. Unfortunately, it doesn't look entirely complete, and/or it is somewhat confusing in nature. Still, it seems to clearly show that you don't hook up anything more the +5 volts to the +5 terminal, and that VCC is the hookup for the motor supply voltage of the L298 (while +5 is either for the L298 logic, or an output from the on-board LM7805 regulator). Furthermore, while this schematic seems a little sketchy - there's enough there that, with a proper multimeter, and a good set of eyes and understanding of how the L298 is supposed to work, along with tracing the PCB - one with some knowledge and a bit of experience could reverse engineer the parts which seem poorly defined, and validate a proper schematic to understand how the board works - prior to actually using it.

This is, again, why it is so important to know how to read a datasheet, as well as draw and understand schematics - when it comes to electronics. They are the documentation and the "roadmap" to how everything is supposed to work. This doesn't mean that they are perfect - like any map, imperfections and errors can and will be found. But if you don't consult them - or you can't understand them, nor be able to reproduce them - you will be as lost as you would without a map in an unknown city.

It is for these reasons why most of the "old-timers" here and those others with experience always make it a point to stress how necessary and useful those skills are, and why they have a certain level of disdain for the "plug-n-play-lego" attitude that many of these modules and other kits seem to stress. It isn't because we think that electronics should be difficult or hard for others; it isn't because we have an attitude of "Well, I had to do it the 'hard way' - so should you!" - it's because these skills and the understanding of electronics is the only way to know for certain how and why a circuit works. Without that understanding, you can quickly and easily throw good money after bad - while becoming very frustrated along the way. Also, depending on what you are working on (such as mains-powered circuits) - it can be very dangerous not to have that understanding. Unfortunately, electronics is not a "plug-n-play-lego" environment, and there is a lot of math involved in understanding certain concepts and such, and it isn't easy to understand, and it can take many years to fully understand it (and honestly, not everyone fully understands it - I certainly don't! - but there are some wizards out there, many of whom have passed - who came up with such designs like the LM741 and the venerable 555 timer - who really, honestly knew what the hell they were doing - even when their workbenches looked like an electronics factory exploded on them - I'm looking at you, Bob - may you rest in peace).

Thanks so much for taking the time to respond in such detail. I really appreciate it.

I just tested your solution and it works. I simply had the input voltages wired backwards as you said. Fortunately nothing was damaged in the process.

So for anyone who is reading this thread in the future the pin labeled VCC is the source current from the external power supply for the motor. The pin labeled 5V is the 5V current from the Arduino.

Thanks a lot.