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

 

 

 

More Datasheet

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.

Thanks for the quick reply.
Thanks for the quick reply. What is Vih? And how come the motor voltage needs to be 2.5 volts higher? I tried it temporary with a 9V battery and I get the same result. I know the motor is working because when I connect the battery directly to it, it works fine.

You named the pins pin_10,

You named the pins pin_10, pin_11, pin_12, but they are initialised as pins 2,3,4. Where is the L298 connected: at Pins 10,11,12 or 2,3,4?

 

Datasheet again
From that same Electrical characteristics section of the datasheet, Vih is Voltage input high, when the Arduino send a logical 1 (5 volts) to the input to signal a switch. The Vs probably needs to be higher than that to bias a transistor into it’s on state, so that the collector is actually higher than the base voltage trying to switch it. I’d guess anyway. And if your 9 volt is one of those that clips on, it probably doesn’t have enough current to drive the motor, so no movement occurs. A 9.6 pack of 8 AA rechargables would be able to delvier enough current, but those little rectangular 9 volts only really deliver double digit millimaps adequately, where your motors probably need on the order of Amps to start up.

It appears that pins 2,3,and
It appears that pins 2,3,and 4 of the Arduino are being used to drive pins 10,11,and 12 of the L298.

Yes you’re right, I didn’t
Yes you’re right, I didn’t see that

Still no luck
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

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.

Are you connected to digital
Are you connected to digital pins 2,3,4 or analog 2,3,4?

I’m using the digital pins
I’m using the digital pins on the Arduino. But for testing purposes right now I’m connecting the pins from the motor driver directly to Vss on the breadboard.

So I tested the motor
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)

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.

Vih
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.

Yes the problem was with pin
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
Glad it is working, hope to see your robot running around soon!

hi. i’m having trouble with

hi. i’m having trouble with this. i have the exact same problem as jchang. have connected pin 1,8,and 15 to ground but still no response. hoping you guys can help me. perhaps its a problem with the wiring. would appreciate if anyone could help. im just starting out in these electronic stuff (:

sorry its a bit messy

 

Image000.jpg

 

white wires are connected to 5v and gnd on arduino, brown wires are connected to pin 2,3,and 4 exactly like the program code jchang posted.