L293 H-Bridge Problem

I’m using an L293 h-bridge with two Mabuchi toy motors. When I send both motors the forward command it works but when In try and reverse, one reverses the other stops!

I have checked, double, triple, checked my wiring, and code. I have two L293’s both behave the same. I just got two L298’s I’m gonna try as soon as I figure out how to plug them in the breadboard!

I also just ordered a Baby Orangutan to try since it has built in h-bridge.

The motors are the ones that come with Tamiya’s twin motor gear box kit.
The controller is an Arduino.

Here is the code used to test the H-Bridge

  /////////////////// 
  // h bridge test //
  ///////////////////
  
  const int switchPin = 7;    // switch input
  const int enablePin1 = 10;    // Enable for Motor 1
  const int enablePin2 = 11;    // Enable for Motor 2
  const int motor1Pin = 2;    // H-bridge leg 1 (pin 2, 1A)
  const int motor2Pin = 3;    // H-bridge leg 2 (pin 7, 2A)
  const int motor3Pin = 4;    // H-bridge leg 3 (pin 10, 3A)
  const int motor4Pin = 5;    // H-bridge leg 4 (pin 15, 4A)
  const int ledPin = 13;      // LED
  
  
  void setup() {
    // set the switch as an input:
    pinMode(switchPin, INPUT); 

    // set all the other pins you're using as outputs:
    pinMode(enablePin1, OUTPUT);
    pinMode(enablePin2, OUTPUT);
    pinMode(motor1Pin, OUTPUT); 
    pinMode(motor2Pin, OUTPUT);
    pinMode(motor3Pin, OUTPUT); 
    pinMode(motor4Pin, OUTPUT); 
    pinMode(ledPin, OUTPUT);

    // set enablePin high so that motor can turn on:
    // digitalWrite(enablePin1, HIGH); //Uncomment if enable pins are not tied to Vcc
    // digitalWrite(enablePin2, HIGH); //Uncomment if enable pins are not tied to Vcc
    digitalWrite(switchPin, HIGH); // Enable internal pull up restor
    // blink the LED 3 times. This should happen only once.
    // if you see the LED blink three times, it means that the module
    // reset itself,. probably because the motor caused a brownout
    // or a short.
    blink(ledPin, 3, 100);
  }

  void loop() {
     
     
    
    // if the switch is high, motor will turn on one direction:
    
    if (digitalRead(switchPin) == HIGH) {
      digitalWrite(motor1Pin, LOW);   // set leg 1A of the H-bridge low
      digitalWrite(motor2Pin, HIGH);  // set leg 2A of the H-bridge high
      digitalWrite(motor3Pin, LOW);   // set leg 1B of the H-bridge low
      digitalWrite(motor4Pin, HIGH);  // set leg 2B of the H-bridge high
    } 
    // if the switch is low, motor will turn in the other direction:
    else {
      digitalWrite(motor1Pin, HIGH);  // set leg 1A of the H-bridge high
      digitalWrite(motor2Pin, LOW);   // set leg 2A of the H-bridge low
      digitalWrite(motor3Pin, HIGH);   // set leg 1B of the H-bridge low
      digitalWrite(motor4Pin, LOW);  // set leg 2B of the H-bridge high
    }
  }

  /*
    blinks an LED
   */
  void blink(int whatPin, int howManyTimes, int milliSecs) {
    int i = 0;
    for ( i = 0; i < howManyTimes; i++) {
      digitalWrite(whatPin, HIGH);
      delay(milliSecs/2);
      digitalWrite(whatPin, LOW);
      delay(milliSecs/2);
    }
  }

Ok as soon as I figure out how to post pics I’ll post a pic of how it’s wired

TIA

Robert

Hello,

In general, to debug this kind of problem, break it down into individual steps.

  1. Does the L293, with no motor or Arduino attached, output the correct voltages if you apply the correct voltages to the input pins?
  2. Does it continue to output the correct voltages with a motor attached?
  3. Does the motor spin as expected?
  4. Does the Arduino output the correct voltages with no L293 attached?
  5. Does it still output the correct voltages with an L293 attached?

-Paul

Thanx I’ll do that and post results

SubMicro

Well I found some strange things!
With no motors or Arduino proper voltages
with motor proper voltages
with Arduino and motors
with outputs on pin5 motor logic HIGH 4.55vdc
pin4 motor logic LOW 1.69vdc
pin3 motor logic HIGH 3.91vdc
pin2 motor logic LOW .02vdc
Oh and now it doesn’t work at all, except when reset is pressed one motor runs for 3 seconds. ARRRGGGG I know it’s a simple mistake but i’m getting frustrated as h&$$.

Another thing I noticed was that with 5vdc hooked up to Vcc1 all motor logic and motor pins registered between 1.2 and 1.5vdc

I’m giving up for tonight I’ll try again tomorrow!

Hello.

How are you powering everything?

- Ben

Hello,

There is not much point in measuring the voltage on input pins when they are unpowered, if that is what you are doing. But it is hard to tell what you are doing from that post!

-Paul

Arduino is powered by wallwart, motors by 4 AA batteries common ground point.

I’m sorry about the last post it was late and I was frustrated.

What I meant was that with everything hooked up and the Arduino sending High or Low signals to the motor logic pins while taking measurements. If that makes sense? :mrgreen:

Hello,

Your explanation of power is not sufficient - the voltage and type of wall-wart as well as the measured voltage of the batteries are important details that you are leaving out.

I gave you a specific series five of questions and experiments to do. If you have done them and you want more help, you should post details of your tests and answers to the questions rather than just a series of incomplete sentences. Even your sentence “What I meant was that with everything hooked up and the Arduino sending High or Low signals to the motor logic pins while taking measurements.” seems to be incomplete. Did you forget to say what happened while you were taking measurements? Did you send only one high or low signal at a time, or was it sending both?

-Paul

hi i have same problem. I did what paul said and when i attach motor to the l293b, voltage decreases 4 volts. used 1n4007 diodes. all connections are ok (%99 sure) can you help me please.
thanks in advance

When you say you have the “same problem”, are you saying that you also have two L293s that both have trouble controlling one out of two Mabuchi motors when you try driving them in reverse with an Arduino?? That seems so unlikely that you should provide some more details. If the problem is not exactly the same, please just start a new thread.

-Paul

i have same mabuchi motors but the only differance is using pic. This matter? and do i need 2 driver more to solvethe problem? you dont have to answer

Hello,

Please do not say that your problem is the same when you are doing something different. At this point, I have no way of knowing what your problem is without guessing, so you should start a new thread, and describe exactly what you are trying to do and what the problem is.

-Paul

You really come off like an AzzHoll Paul. Is that complete enough info or would you like more ? I think I’ll go some place else with my questions, and money!

That certainly is your choice, but I think you will get the same response pretty much anywhere else you go if you continue to act the way you do. I wish you the best of luck where ever you go, but I think you should really take a moment to understand why Paul’s responses were completely appropriate and consider how you can adjust your behavior to interact with others in a meaningful way so that you can actually get the help you need. When you ask someone for help, you need to work with that person. Can’t you see how responding with incomplete sentence fragments that are barely decipherable is just wasting everyone else’s time? Paul’s taking time to try to help you is something you should be grateful for (these aren’t even Pololu products you’re using), and your calling him an “azzholl” for telling you that your troubleshooting steps don’t give him anything to work with reflects incredibly poorly on you.

Just for some feedback, I have some suspicions as to what your problem is, but I cannot understand your situation at all from your description. I feel like I could possibly figure it out if I work really hard and re-read what you’ve written a number of times, but it’s just not worth that level of effort, especially when you won’t put any effort into explaining what’s going on.

- Ben

I don’t mind explaining things better, I just don’t like the attitude.

Hello,

I doubt that anyone is going to give you more help somewhere else, but if they do, feel free to come back and post a link to the discussion here so we can see how it worked out.

Good luck, and just in case it helps, my best guess right now is that your power supply is too weak.

-Paul

I’d like to apologize for my unacceptable behavior. I know Paul was only trying to help.
I’m sorry Paul.

Well, I meant it when I said “good luck”, and I can still help if you answer my questions!

-Paul

Thanks Paul but I figured it out while performing your tests, go figure :wink: .
The problem was that for some reason pin 7 on my Arduino reads 3.3 to 3.8 vdc regardless of what the program tells it! If I avoid using pin 7 then everything works as it should.
I guess I fried pin 7 at some point, I’m not sure. Any ideas what could cause this or how to fix it?

Robert