Let's Make Robots!

Using Arduino and L298N to control Tamiya Twin Motor Gearbox

I've connected the L298N to one of the motors of the Tamiya Twin Gearbox as per the circuit diagram in the L298N data sheet. But when I set pin 10 and pin 12 to go forward or reverse, nothing happens. The voltage at pin 13 and pin 14 seems to be equal to each other regardless of what I set for pin 10 and pin 12 (with the enable pin on high). This is the Arduino code I have. The diodes I am using are IN4007. I've also tried it with the other H-Bridge and I get the same result. I'm powering the L298N (Vss) through the Arduino 5V output and the motor (Vs) through 4 Ni-MH 1.2V batteries in series. Does anyone know what I am doing wrong?

 

int pin_11 = 2;
int pin_12 = 3;
int pin_10 = 4;

void setup()
{
  pinMode(pin_11, OUTPUT);
  pinMode(pin_12, OUTPUT);
  pinMode(pin_10, OUTPUT);
}

void loop()
{
  digitalWrite(pin_11, HIGH);
  digitalWrite(pin_10, HIGH);
  digitalWrite(pin_12, LOW);
}

 

L298N.png

 

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Vih must be atleast 2.3V. Would it be possible to give the driver +5V logic input current, +5V supply current and use resistors in inputs. So Vih would be small(~2.5V) and supply current could be smaller too.
Thanks for the explanation of the Vih. Although I'm an electrical engineering student, these abbreviations in datasheets always confuse me. I tried it with 8*1.2V AA batteries and I still have no luck. Initially I thought the problem was because my two output pins(10& 12) both had the same voltage and therefore the potential across the motor is 0V, hence no movement. That doesn't seem to change regardless of what power supply I'm using. I'm assuming this is correct since there's no potential difference across the motor, it wouldn't be drawing any current regardless of how much power I supply it. Which leads to me thinking either my circuit is wrong or the H-Bridge is defective? Is there a way I can test whether the H-Bridge is working properly?

Uh, your output pins are pins 13 and 14, but I think you just mis-typed. Inputs are 10 and 12, with 11 as an Enable. One thing I'm curious about is pin 15. In the datasheet, they have it attached to a resistor to sense current. This can actually be attached directly to ground, if you don't want to mess with current sensing. Alternatively, if using too large of a sense resistor, it could move the logic levels for the device, and not allow switching.

Testing would involve having just the device in its own circuit, powered, Vss to 5 volts and Vs to your 9.6 volt pack, and physically change the inputs, to see if the outputs change. Wire pin 11 to a 5 volt source, and alternately wire pin 10 to 5 volts with pin 12 to ground, and then reverse pin 10 and 12 connections, measuring the outputs 13 and 14 with respect to ground. Try it for the other side too if you want, pin 5 and 7 with pin 6 enabled, output on pins 2 and 3.

 

edit : scratch the sense resistor moving logic levels,  pin 8 apppears to be a logic ground to maintain levels.

So I tested the motor driver with various voltage for Vs, for some reason the output pin that supposed to be set to low doesn't actually have 0V. I tried it on both H-Bridge and high is always around the same as Vs but low is always between 2-3V. The motor will move if I ground the output that is suppose to be set to low. Is this behaviour caused by my circuit or could it be a defect with the motor driver?

What is pin 15 (and pin 1) of the L298 connected to? In the datasheet it is connected to a sense resistor, but it can be attached directly to ground. Note that in the Electrical Charecteristics of the driver Vce-sat(L) (page 3), The sink aaturation voltage is typically 1.2 with pushing 1 A, and can be higher. That is at least 1.2 volts of the 2 to 3 volts you are seeing, in reference to ground.

Sounds sort of like the h-bridge is operating normally. A motor attached to a BJT h-bridge like the L298 will not see the full Vs voltage, as about 1.2 volts is lost on the upper source transistor(s) and another 1.2 is lost in the lower sink transistor(s). 

It sounds as if your motor needs a greater voltage source, so enough of it gets through to run it.  You could test how much is needed to run the motor with a variable power supply attached directly to it. Just crank it up until the motor turns under some form of load. Then to that number, add about 2.5 volts for the L298, and that is the minimum voltage needed to run your robot.

Yes the problem was with pin 15 and pin 1. I thought I did not need to connect those pins since I was not using current sensing. But as soon as I connected them to ground to motor started working. I can't believe the solution was something so trivial. Thank you very much for the help!
Glad it is working, hope to see your robot running around soon!

In this datasheet, on page 3 in the Electrical Characteristics, it says Vs (motor supply) should be Vih + 2.5 volts minimum, on up to 46 volt max. Your Vih from the Arduino is probably 4.8 to 5 volts, so minimum motor supply voltage should probably be 7.5 or so.  Try it with a higher battery or power supply voltage and see if it starts working.

I'd suggest switching out the standard motors on the Tamiya Twin gearbox, since Pololu has shown they can be a bit easy to trash at higher voltages. They also carry a low voltage dual serial controller to help use the original Tamiya motors at their standard voltage, but I prefer driving the h-bridge directly rather than through a serial connection.