Arduino with L293D weird problem

raschemmel:
do you know how to measure current ?

I think so, from my measurement, the current across the motor terminal is 0.28-0.3A(Motor requires 0.3A) and the voltage is a bit weird. I set the multimeter to 20V DC and sometimes the value varies around 0.2-0.32 and sometimes it goes up to 0.7(And my motor required 3V-6V, so I think this is the problem?). I tried adding an external power source but it's still not running, I'm not sure if it's because the contact of the wire and the battery is loose or the battery isn't supplying enough voltages/current. I didn't have enough hands to press the wire to the battery and measure the current and voltages of the motor so I didn't measure it. I tried with 9V battery, 9V battery + LM7805 5V voltage regulator, 4 x 1.5V AA battery(3 of the battery only have 1.1-1.2V left in it but I measured and the total voltage the battery pack is supplying is 5V). Again I was just holding the wires to the battery pack's terminals

DuaneDegn:
Hey guys, while many h-bridges require two separate power supplies for the logic and the motor, the L293D just needs the motor supply to be equal or greater than the logic voltage. The motor voltage does not have to be higher than the logic voltage.

The chip should work when powered with 5V.

My main concern about his setup is the motor is being powered of the computer's USB.

When you add an external supply, make sure to remember to connect the grounds from the two lines together.

One thing I often suggest when people are using a new h-bridge is to test the h-bridge without a microcontroller to make sure you understand the signal logic.

Here's my "L298N" video. The L298N and the L293D use the same control logic.

One reason the L293D chip could be getting hot is because you're using use PWM to reduce the power. You're running the motors full on. These chips can get hot from normal use so if you have the motor running full blast, it's not too surprising the chip is getting hot.

When you're ready to use PWM you'll likely have a cooler chip if you pulse the enable pin rather than a direction pin. If you use PWM on a direction pin the motor alternates between being powered (during the high part of the pulse) and braking (low part of the pulse). If you pulse the enable pin, rather than pulse/brake you get pulse/coast. Pulse/coast has all sorts of advantages over pulse/brake.

The one advantage pulse/brake offers is the it's a bit easier to control the speed of a motor with pulse/brake than when using pulse/coast.

I'm not sure if you're aware of it of not, but that motor won't be very useful. It really needs a gearbox in order to produce any sort of useful torque. My guess is the motor is just there for learning purposes (which is fine).

The 2 lines you're referring to is the ground that's connected to the L293D pin and the ground from the external power supply? And I'm not using any PWM, if you see my code in the first post, I'm only using digitalWrite

Anyway, guys, would it be better if I just used a TIP120 transistor instead? Would the voltage drop across the transistor be lower than the L293D? The L293D is a bit too complicated for a beginner like me

You obviously do NOT know how to measure current.
If the meter has current mode there will a SECOND RED banana jack labeled "10A" . (yours is directly above where the red lead is now) MOVE the RED lead to that jack , move the selector to "10A" and INSERT the meter IN SERIES with the motor. That is the ONLY way to measure current with a meter when you don't have a current shunt ( 0.01 ohm resistor rated for at least 1A).
I suggest you watch a YOUTUBE video on how to measure current using a DMM. You reply (" I think so.....") ( in view of the photo of your DMM) indicates you are probably about as green as they ( Newbees) get. If a COP pulled you over and asked you if you "knew how to operate a motor vehicle " and you answered "I think so..." , how do you think he would respond to that answer ?

No, a TIP120 also has a voltage drop. You could try it. I still think you miswired your circuit bw
ecause I have used the L 293 countless times eith much larger motors and it always worked without overheating. If you don't even know Ohm's Law then you are literally a "child playing with matches" and we can only hope you don't blow something up or fry something (Like the L293)

Hi
Can you post a picture of your project please, so we can check your layout?

Thanks.. Tom.... :slight_smile:

TomGeorge:
Hi
Can you post a picture of your project please, so we can check your layout?

Thanks.. Tom.... :slight_smile:

I already did, it's up there

Hi,
So I see, it wasn;'t there when I left the message, yet it shows you put it there before my post......
This forum program does weird things.

Thanks.. Tom... :slight_smile:

current ?

TomGeorge:
Hi,
So I see, it wasn;'t there when I left the message, yet it shows you put it there before my post......
This forum program does weird things.

Thanks.. Tom... :slight_smile:

So anything wrong with the wiring?

raschemmel:
current ?

Right so by changing the area contact point of the multimeter lead and the wire, the highest average current I can get is 0.24A, highest average current between the output pins without motor is 0.39A(Not sure if this is useful), highest average voltage between the output pins without motor is 4.45V and highest average voltage between output pins with motor is 0.58V

Any suggestions on a cheap external supply? I tried using Eveready super heavy duty 9V battery but I don't think it's enough

highest average voltage between output pins with motor is 0.58V

I know you are a beginner , but please try to pay attention to what is said in these posts.
NOWHERE do I say put the meter across the output pins. I specifically said put it in series with the motor. You still don't understand. We are not interested in the current between the output pins without the motor. The only thing we care about is the motor current. REREAD my post ! I said INSERT THE METER IN SERIES WITH THE MOTOR ! If you DO NOT UNDERSTAND this say so but so far you have said nothing to indicate that you inserted the meter in series , or even that you understand what "in series" means. Forget about the current between the output pins and focus on the motor current.
The motor current is NOT measured by putting the meter leads accross the output pins. It is measured by disconnecting the motor at one end and putting the meter between one of the output pins and the motor lead. I suggested you watch a YOUTUBE video of how to measure current but apparently you did not do that.

As a result. We STILL do NOT know what the motor current is, due to your lack of understanding what current is or how it is measured. You cannot measure the motor current if you are completely bypassing the motor by putting the meter leads across the output pins. Whe you say "between the output pins, when talking about measuring current with a meter, what you are saying is that you put the meter leads across the output pins. If that is not what you mean then you need to say so because right now that's exactly what you are saying, whether intentionally or not.

raschemmel:
You still don't understand. We are not interested in the current between the output pins without the motor. The only thing we care about is the motor current. REREAD my post ! I said INSERT THE METER IN SERIES WITH THE MOTOR ! If you DO NOT UNDERSTAND this say so but so far you have said nothing to indicate that you inserted the meter in series , or even that you understand what "in series" means. Forget about the current between the output pins and focus on the motor current.
The motor current is NOT measured by putting the meter leads accross the output pins. It is measured by disconnecting the motor at one end and putting the meter between one of the output pins and the motor lead. I suggested you watch a YOUTUBE video of how to measure current but apparently you did not do that.

0.24A it is then. Connection: Output pin -> Multimeter lead, other Multimeter lead -> motor terminal. Is this not in series?

As for your edit, yes I did do that but if you read what you quoted properly, I was measuring voltage, not current. I gave 4 values; 2 for voltage and 2 for current. Voltage: 1 with motor and another without, Current: 1 in series and another across the output pins without motor which I already say it might be useless

Connection: Output pin -> Multimeter lead, other Multimeter lead -> motor terminal. Is this not in series?

Yes it is but that is not what you said. You said the current "between the output pins"

What you should have said is "the motor current with the meter in series is ..."

The mistake was in your wording, not your actions.

Any measurement across an H-bridge output without a load is useless unless you only care about voltage.

So anything wrong with the current the motor's getting? What did you have in mind when you initially asked for the current reading?

FYI, anyone with any electronics experience or experience with H-bridges would never say "between the output pins". That's understood because that's the motor connections. They would simply say:
"The motor current is...."

I asked to determine if it was within spec for the chip, which it is. If the motor is still not turning your USB cable is unable to source enough current and you need to find some other power source to connect to pin-8 (Vcc2) of the chip.
That's it. There's nothing more to say. (yet)

SlonCHL:
the highest average current I can get is 0.24A

Should give you the hint

We still don't know the voltage on the arduino 5V pin when you are running the sketch trying to drive the motor.

And the weird thing is when I connect both wires to A0 to measure the voltage, the serial monitor gives me the values of around 35-50 for both wires

If you have a voltmeter you don't need to use an analog input when you are running an L293. That's only usefull if you have the proper low resistance resistors to use for measuring current. You connect two analog inputs to either side of the resistor and subtract one reading from the other and divide by the resistor value. It's called "Differential Analog measurement".

VR = IR*RR ==>>VR/RR=IR= Imotor

(Ohm's Law. Ring any bells ?)

Should give you the hint

You told us you are beginner. How do we know if you know where to put the meter ?
Using the phrase "between the output pins" is misleading because nobody else would say that. (because it's the motor connections). They would just say "the motor current is....."
The voltage doesn't tell me anything. It should be turning if it had enough current. The current measurement doesn't necessarily tell me you put the meter in series. Once you say you are beginner, we can assume nothing. I can't see what you are doing. I have to ask to confirm it.

SlonCHL:
So the problem is, my motor isn't running when I connect both outputs to the motor but when I replace the wire which is connected to the Input1 pin on the L293D(or pin3 on the Arduino. I.e. the one which I'm sending the low digital voltage on) with a wire connected to ground, it works!

Now that you've tested the current I can think of three possible problems. (In increasing likelihood.)

  1. A damaged I/O pin. One of more of the I/O pins have been damaged and the h-bridge isn't being set correctly.

  2. There's a bad connection somewhere. Breadboards are not completely reliable. Sometimes it helps to pull a circuit off the breadboard and move it to a different area on the breadboard.

  3. There's a power supply issue. The USB isn't able to provide enough current for the motor which causes the voltage to drop, causing the Arduino to reset. You should add a serial statement to the setup function so can tell if the program is resetting. Even if resetting isn't occurring, with the voltage to the L293D chip so close to its lower limit, I think you could have a power supply problem even if the Arduino isn't resetting.

In most cases, adding a decoupling capacitor to an external IC's is a good idea. I think you should add a 0.1uF cap across the logic supply Vcc1. A larger cap between Vcc2 and ground is also a good idea. This larger cap could be 1000uF or so.

At the moment I think the problem is that Vcc1=Vcc2 (USB 5V)

The OP said he tried a 9V battery with an LM7805 and that didn't work either. He says the motor works when connected directly to 5V (bypassing the chip).

My guess is that with the voltage drop inside the chip, the motor needs more than 5V on Vcc2. This is one of the reasons I bought an adjustable current, variable voltage LAB power supply.

raschemmel:
At the moment I think the problem is that Vcc1=Vcc2 (USB 5V)

That alone shouldn't be a problem. The datasheet for the L293D lists the motor voltage (Vcc2) as being from Vcc1 to 36V. I know other h-bridge chips require a higher voltage for the motor supply but the L293D doesn't have this requirement.

That said, I think there's a good chance an external power supply would solve the problem.

We still don't know what the voltage is on the arduino 5V while running the motor sketch.

highest average current between the output pins without motor is 0.39A(Not sure if this is useful),

Has it occurred to you that removing the motor and putting a current meter across the output pins is essentially SHORTING the output ? (0.6 A isy the maximum that chip can tolerate. The reason you didn't completely blow the chip is that the USB 5V cannot source more than that and it probably pulled the 5V pin down. If you were using an LM7805 it could have done the same thing.

highest average voltage between the output pins without motor is 4.45V and highest average voltage between output pins with motor is 0.58V

If this really is a voltage measurement and not current then what would that tell you if the voltage across a 5V motor is 0.58 V ?

Just for the heck of it I looked through my toy box and found a 1.5V motor and ran it with an L293 with Vcc2 = 3.6V. (pin-8 of L293)

The circuit worked perfectly: (It monitors a direction push button and reverses direction when you push the button. )
I was able to reduce both the voltage and current of the Vcc2 P.S. and motor continued to turn, which means there is something wrong with your circuit, ( most likely you blew the output transistors when you shorted the output wth the DMM in current mode)

  int switchPin = 2; // switch input
int motor1Pin1 = 3; // pin 2 on L293D
int motor1Pin2 = 4; // pin 7 on L293D
int enablePin = 9; // pin 1 on L293D

void setup() {
    // set the switch as an input:
    pinMode(switchPin, INPUT);

    // set all the other pins you're using as outputs:
    pinMode(motor1Pin1, OUTPUT);
    pinMode(motor1Pin2, OUTPUT);
    pinMode(enablePin, OUTPUT);

    // set enablePin high so that motor can turn on:
    digitalWrite(enablePin, HIGH);
}

void loop() {
    // if the switch is high, motor will turn on one direction:
    if (digitalRead(switchPin) == HIGH) {
        digitalWrite(motor1Pin1, LOW); // set pin 2 on L293D low
        digitalWrite(motor1Pin2, HIGH); // set pin 7 on L293D high
    }
    // if the switch is low, motor will turn in the opposite direction:
    else {
        digitalWrite(motor1Pin1, HIGH); // set pin 2 on L293D high
        digitalWrite(motor1Pin2, LOW); // set pin 7 on L293D low
    }
}

You can see the voltage and current in one of the photos. There is a piece of scotch tape on the motor shaft which is the blur you see .



FYI, in case you didn't know , each L293 should have two 1N4001 diodes for flyback (back EMF) protection (anode of one to output pin , cathode to Vcc2. cathode of second diode to output pin, anode of that diode to GND)
(these can be seen in photo)