L293 D how it work

Hi,

I am using the L293 D to drive a motor speed and rotation orientation. But I have question: how does it know that when I pass 5V to it's ENABLE PIN it has to pass all the external voltage to the motors?

For example, I have a 12V source battery to power my motor. When I apply 5V to the ENABLE PIN of the L293 D it gives me the full 12 V at the motor. Great, but how does it know it? This chip has no "gain" or "multiplier", so how does it know that a 5V should cause it to pass all the source energy to the motor?

See the block diagram on page 2 and the partial schematic on page 3. A high on thr enable pin allows the output drivers to turn on when the selected A pin (1A, 2A, 3A, 4A) is high.

L293d.pdf (372 KB)

When an output is turned, the output is connected to 12V by the upper transistor - the transistor is turned on fully, or it isn't. When then lower transistor is turned on, the output is connected to Gnd.
Thus the output goes to MotorVcc - Vce of the upper drive transistor, and to Gnd +Vce of the lower transistor.

@CrossRoads thank you. I took a look at what you said but look: what is HIGH? For arduino HIGH is 5V. For raspberry pi HIGH is 3.3V. For this chip HIGH is certainly not 5V.

See, when I connect my digital pin 3 to the ENABLE pin of this chip I can do this:

analogWrite(3,50);
analogWrite(3,100);
analogWrite(3,150);
..

Changing the PWM I can make the motor spin faster and faster. So there is no "absolute HIGH". What I am asking it this: why when I do analogWrite(3,255) the chip outputs the 12 v? Where, in the datasheet of this chip, is written that passing 5V to the ENABLE pin it will output all the source power? Cause if I pass 3V to the ENABLE pin the chip will not output the 12V!

What you are doing with analogWrite of 50, 100, 150, is leaving the HIGH signal on for longer portions of the PWM cycle.
50/255 high and 205/255 low,
100/255 high and 155/255 low.
150/255 high and 55/255 low.
I think PWM on pin 3 is 490 Hz, about 2mS.
so 50/205 is about 1/5 on, 4/5 off, and similar math for 100/155, 150/55.
With VCC1 = 4.5 to 7V for the L293, HIGH is 2.3V and above per the datasheet.
So 5V from Arduino of 3.3V from RPi would both be high.

If you have 3.3V for VCC1, that is below anything in the datasheet, and it may not work.

The value that's treated as "high" is spec'ed in the datasheet.

Per the table on the top of page 5, 2.3v and up on input is treated as "high", 1.5v or less is treated as low.

Nice you are really nice! Now I understood it! Thank you so much!!!!

One final question: do you recommend any other chip that is better than L293 D? I see that L293 D has a significantly loss of voltage across the input/output voltage. Do you recommend any other chip that has protective diodes and work in a similar way?

I would recommend something MOSFET based.
Check at www.pololu.com they have a bunch of modules that should all run significantly better than older BJT technology.

batata004:
This chip has no "gain" or "multiplier", so how does it know that a 5V should cause it to pass all the source energy to the motor?

On the contrary it has voltage gain and a lot of current gain. A 5V 30uA input will drive
upto about 30V at 600mA, I make that 6x voltage and 20,000x current gain.

It is not a linear amplifier though, its a switching device. All logic and switching devices
need gain in this sense.

This chip has no "gain" or "multiplier", so how does it know that a 5V should cause it to pass all the source energy to the motor?

I think the OP is confusing the L293 with an analog motor driver that has feedback gain.
I don't think he is referring to the electrical differences between a TTL logic input and an H-bridge motor output. In fact, I haven't seen anything that remotes suggests he even knows what an H-bridge is or how it works. Clearly it's a case of apples and oranges.

Actually what I would like is this: something like TIP120 but with good resolution. I am trying to drive a motor using the TIP120 and even use a larg base resistor (50k ohm) I dont have good resolution on the motor. I mean: if I set analogWrite(x,10) is the same as analogWrite(x,150). If I go higher than 150 my motor changes the speed but after that it does not change the speed anymore, it doesnt matter if I use analogWrite(x,255).

What would you recommend?

I would recommend figuring out why the heck it's behaving like that, and go from there.

PWM means the signal is switched on and off very fast (so analogWrite(pin,10) is 10/255 duty cycle - the pin is high 10/255ths of the time). The transistor should be turning on and off as well, in time with this. So why is the motor not behaving as expected?

That's what you need to figure out - then you'll be able to determine what the appropriate remedy is.

WHY ARE YIU USING TIP120s with an L293 ???

If you are going to use the L293 , DON'T use the TIP120 !
Use one or the other not both. Post your schematic that shows how you have the TIP120 connected.
You should NOT need transistors if you are using the L293 because it has internal transistors..
Your circuit design is flawed. Remove the TIP120 transistors .

POST YOUR SCHEMATIC

ALSO, post your code.

See, when I connect my digital pin 3 to the ENABLE pin of this chip I can do this:

analogWrite(3,50);
analogWrite(3,100);
analogWrite(3,150);
..

Changing the PWM I can make the motor spin faster and faster. So there is no "absolute HIGH". What I am asking it this: why when I do analogWrite(3,255) the chip outputs the 12 v? Where, in the datasheet of this chip, is written that passing 5V to the ENABLE pin it will output all the source power? Cause if I pass 3V to the ENABLE pin the chip will not output the 12V!

This question seems to indicate that you do not understand how PWM works. The motor voltage will always be the full source voltage . The motor speed changes due to the duty cycle changes, not due to any change in the motor voltage. If you output a dutycycle of 3% (analogwrite(pin,1):wink: , the motor voltage will still be 12V, but for a period of 1/255 of the 490 hz switching speed . (2 mS period)
analogWrite()

If this is your code :

analogWrite(3,50);
analogWrite(3,100);
analogWrite(3,150);

Then no wonder you have a problem. Is it really possible you don't realize that a motor cannot change speed instantaneously ? It has mass. It requires time to accelerate to the commanded rpm.

Post your entire code so we can see what you actually doing. The above code makes no sense because you don't have any delays in between the speed changes. You would be better off using a potentiometer
and using the MAP function to set the speed based on the pot position.
Look at this example.
or this one.

When I apply 5V to the ENABLE PIN of the L293 D it gives me the full 12 V at the motor.

Really ?
Is there any thing else ?
Is there any other possibility between NO voltage and FULL voltage ?

What's odd about this question is that it indicates a complete lack of understanding of both TTL logic parameters and this chip in particular. Input voltage level ranges are specified for the various logic families. An arduino or L293 using 5V TTL level , is going to consistent with 5V logic input voltage level parameters. A 3.3V logic circuit is going to have different input levels. Before attempting to use an arduino or L293, it would be prudent to start with the basics:
LOGIC LEVELS

Where, in the datasheet of this chip, is written that passing 5V to the ENABLE pin it will output all the source power?

See Function Table at the bottom of Page-2 of the datasheet

What does that say ? (OUTPUT Y H (or L)

When you look at the schematic above the Function Table, is there any doubt what "H" could mean ?

IMO, this post should have started with the introduction:

"I have no electronics ,motor control , uController or logic circuitry experience and would like to use the L293 with an arduino. What do I need to know to do this ?

This would have saved us some time.

I am really sorry I didnt say I was not smart about this subject, really sorry :frowning:

I dont know much about TIP120 and transistor in general. I already played with it a lot but no good knowledge.

I actually mixed 2 questions I have and maybe you got the impression that I am using L293 and TIP120 together, which I dont! :slight_smile:

My question is this: the L293 is terrible, there is a great voltage drop on it and it hurts a lot my motor. The TIP120 is also really bad, it wastes lots of energy and calculating the base resistor is not an easy task.

So I ask you: I have a motor that uses probably 1A. What commercial available MOSFET would you recommend? I also want to turn on and dim a LED strip with about 2A, can I use the same MOSFET?

I will use a diode to protect the arduino when I am using the motor but I want you to help me to find a good "general" MOSFET so I dont need to mess with it's datasheet.

My motor and LED strip will be using 12V, so it would be nice if you could point me to a high availabity and easy to buy/find MOSFET that can supply up to 2A and 12V and can be controlled with an arduino PIN using PWM?

Google: "SPARKFUN LOGIC LEVEL MOSFETS"

I believe AOI514 will handle both of those nicely, as long as the motor is turning 1 direction only.

In Brazil it's not that easy to find eletronic components, it's actually very frustrating.

@raschemmel and I cant go to Google and buy from sparkfun cause the shipment will be freaky expensive.

@CrossRoads I didnt find the model of MOSFET you said (AOI514) in any online eletronic store here in Brazil. Here we use "old stuff" so do you have any idea of other MOSFET that is not as recent so it could exist in poor countries?

mosfets in Brazil

Mosfets in brazil

Do the parts you have access to have datasheets to go with them?
If not, you'll have to look them up one by one to find a part.
You're looking for Logic Level, Low Rds at Vgs = 4.5V.

Post the links to your stores, we can help you pick out a part.