Let's Make Robots!

Are You Wondering How to Hook Up a Motor Driver IC chip (such as an L293D) ?


  **Click the picture to show it bigger, and then click that picture again to make it big enough to read the fine print**

ADDED (06MAY2012) This is the motor drive circuit exactly as I built it for my newest lttle SHR-like robot.

The above configuration using the L293D is a good way to prevent shorting out the power supply as can happen in the circuit below if you make inputs A and B high at the same time. The Integrated circuit can supply 600 mA current per channel (and twice that in a non-repetitive peak).  It also contains internal protection against reverse spikes such as are generated when driving an inductive load. 

With this configuration, in adding the extra transistors I have changed the function of the inputs. Power to the motor is turned on or off with one lead and You set forward or reverse with the second one. While this feature is not essential, some people may like this better. It is still the same 2 wires per motor (as below), but their functions have changed. Some of my older drawings using the L293D just tied the Enable leads to +V (always enabled), but by using the enable leads you can switch the output to a high-impedance state when the on/off lead is low.

 

Below is a common driver circuit I pulled )almost at random) off the internet. (If anyone is upset that I posted something I did not draw myself, I will remove it; there are many more examples.) I have even seen a video for that particular 6-transistor circuit showing how to put it together, but I do not remember them saying, "Oh by the way, don't turn both inputs on at the same time or you could burn down your house." (Ok, it may not be THAT bad, but the transistors *will* burn up if the battery does not go dead first.)

This does work but there is always the danger of accidentally turning both inputs on at the same time, and *P*O*O*F*.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
What do I need to add to the circuit in order to control the motors with a receiver (not a microcontroller). I bought a 3-channel transmitter & receiver and I want to control the dc motors with this radio controller.

That is the reason for the red line in the schematic. I show it hooked to a microcontroller, but it can be hooked to anything that will switch the leads on or off.  Those four leads are just looking for 0 to 5 volt  (on/off) logic signals.

Thank you for your fast response, now I have 4 wires where do I connect these wires to? There are 2 that go the the motors and 2 enables wires.which of those wires go to the receiver?and how about the other two?
Hi Rodavinci, You can not use this motor controller directly with your reciver. The pins on your reciver produces a signal called a PPM signal, that tells a servor or RC speed controler, which position you are holding the pins and wheel on your transmitter. In order to control your motor, you will need an RC speed controler, they can connect directly to your reciver. You can also use a processor to read the PPM signal and then use this H-bridge motor controler to drive your motors. /vendorf

You said you have a three channel receiver.  Without modification or multiplexing or encoding, that is enough to control 3 things, not 4. If I presume those have off and on states, that lets you control off and on for only 3 of those leads.

There are 4 wires with 2 states each, or 8 states total.  One way might be to use a 3 to 8 decoder but you might run into trouble with timing of when to apply the decoding. This may not be a problem if it is supposed to turn on or off any time the code changes.

Probably the easiest way (for me anyway) would be to send a single coded signal over one channel of the radio and then use a counter & gates or a microcontroller to decode that to tell the robot which leads to switch on or off. It would be sinilar to :one wire" communications.

The other alternative would be to use a small microcontroller. The smallest ones are only in the neighbourhood of $2 each, but the 8-pin ones would not have enough inputs and outputs, so you would need to go to the next step up, like a 14-pin version. Looking at Solarbotics web page I see the 14M2 selling for $3.95, but I see the 18M2+ for $3.87 so may as well get the 18M2+ for more pins and a more advanced chip design (shown by the '+' plus sign). I think they also charge for shipping. Then AtMega chips are available pretty cheaply as well.

I'm trying to figure out.. It does not fit for bipolar movements.. It can go only to forward..right?

And how about capicators?

I was looking around more schematics, but everyone are using capicators..

Few examples:

http://www.instructables.com/id/Control-your-motors-with-L293D-and-Arduino/?ALLSTEPS

http://luckylarry.co.uk/arduino-projects/control-a-dc-motor-with-arduino-and-l293d-chip/

http://itp.nyu.edu/physcomp/Labs/DCMotorControl

http://scuola.arduino.cc/it/content/controlla-motore-dc-ponte-h-l293d

 

Anyway, 2N3904 was surprisingly simple and cool decision. I like it.

Please forgive me, but I am trying to figure out what you are talking about.

May I presume you are talking about the L293D drivers with 2 transistors I drew at the top of the page? I want to be sure since there are more than one motor driver showing on this page.

If so, it certainly DOES have a reverse. Notice there are 2 wires controlling each motor. One wire goes to the enable lead for that side of the L293D, which is the same as an OFF - ON switch.  The other wire sets the direction the motor turns: FORWARD - REVERSE. So you can have Motor OFF (in which case the direction of the motor does not matter), or you can have Motor ON with motor turning FORWARD or you could also have Motor ON with motor turning in REVERSE with different high or low conditions on those leads.

-----------------------------------------------------------------------------------------------------------

Now about capacitors. What do you need a capacitor for?

I will answer that. Capacitor are used either to (1) set a timer function in an RC (resistor-capacitor) circuit, (2) for coupling an AC, audio or radio frequency signal, or (3) they may be used to remove the ripple (AC component) from a power supply that feeds from the Mains power.

All needed timing for turning the motors on or off is coming from our PICAXE microcontroller chip, so occasion (1) does not apply.

In this circuit there are neither audio, RF nor AC components in the circuit to be passed from one place to another so occasion (2) does not apply either.  Finally, if I am using a battery pack there is no Mains supply, thus there will be no AC ripple in the power.

That said, you could put a cap across the power leads if you like, but in general it will not be necessary.

 

As to the four examples, I see no capacitor in the first one, unless I missed it. The second one has a single capacitor on the 5 volt line, and the last two have a single capacitor on the motor voltage lead.

The L293D chip has reverse voltage spike protection diodes built into it. That is why you do not need to add reverse diodes across the motor leads, however it would not be out of the question that a slight amount of ripple could appear across the motors, so you could put capacitor(s) on the + motor supply lead to ground, but I feel it will generally not be needed.

Hope this clears up any questions. -Dan

Wow, thank You very much for an answer. Now I can understand everything more clear. Thank You a lot.

I was thinking about it.. And now I can understand how it works.. But maybe it will be more simple transistor to take between Input1 & Input2 & Enable motor and in result You will Enable motor too by any input of high.. And both of high will not destroy your circuit.. By the way.. You can use transistor between EN1 & EN2 & Vcc too.. So it will be more effective too.. Because now there is wasting energy of battery.. And the code becomes more difficult to use.. :)

What do You think about it?

I like code from http://lab.guilhermemartins.net/2009/01/29/l293d-custom-motor-driver/     at most..

So when You will enable/high Input1 or Input2, then You can enable motor and chip too..

My apologies once again. I am trying to follow what you mean.

Where you say: "But maybe it will be more simple transistor to take between Input1 & Input2 & Enable motor and in result You will Enable motor too by any input of high.."  I believe what you are saying (?) is to combine the motors so you only use one enable for both. If that is what you mean, no, it is better to have separate control of the two motors. There are times you will only want one motor to run and not both. For instance if you are against something pressing only one bumper switch and want to turn while backing away. You leave the opposite motor not turning and put the motor on the side of contact into reverse for just a moment. If you look closely at my video of the robot's motors being tested there are a couple times that this is happening. Only one motor comes on, but in reverse as though backing away from something he has hit on one side.

When you say, ""By the way.. You can use transistor between EN1 & EN2 & Vcc too." I believe you mean instead of the transistors I did use?  If so, Yes, you could use PNP transistors to the Vcc (+) side of the supply instead of the NPNs and it will work exactly the same.

I do not understand what you mean when you say it would be more effective. I also disagree that there is any unnecessary waste of current from the battery. Please explain this. Perhaps you could draw what you mean if I did not follow your word description(?).

In reference to the code for using the L293D, I plan to post my code I am using for the little robot I am building which uses this circuit, but I have not yet as I am not finished with his construction. I will post the code on the robot page, not here. This page was only to show one possible construction of drivers.

That page you included from the Instructables is the more simplified method (common method) of driving a motor from an L293D. It will work just fine. My point was to show another method which allows the enable leads to be used. They are tying the enable leads permanently to Vcc, so you cannot switch them. It will work, as I said, but without using the enable leads you cannot put the output to the motors into a high-impedance state which may be useful in some circumstances.

Mine above is not the only way the drivers may be built, just what (to me) is a useful method.