Let's Make Robots!

Control DC motors with an ULN2803

I live in argentina and getting thing shipped here is a mess, so I try to use whatever is available here (which is rather limited) whenever I can.

So I was wondering since I haven't found any of the typical H-bridges ...is it possible to control DC motors (speed + direction) with a ULN2803? These I can buy here. 

If so then how would that setup be? Do I need any additional components? If so then which (transistors, resistors, diodes etc)?

I googled it a bit and I only saw examples of STEPPER motors being controlled with these ICs. 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Good! Building your own Transistor H Bridges take up too much valueable board space!
That's almost certainly true if you're running two motors or more, but I can build a discrete single H-Bridge smaller than an L293 IC =)
I noticed that you only used 1 (10u) capacitor in the diagrams above? And seemingly a ceramic one? Did you have any problems with current spikes or the likes? I'm gonna go buy the L293D chip tomorrow and I might as well pick up some caps as well. Just not sure which kind, what capacity or how many? It seems every setup is different. For instance this guy uses 7 caps.

When it comes to noise and spike suppression caps, there aren't really any concrete rules.

The last project I used the above H-Bridge for had quite small motors, and a very solid power supply. That meant that motor noise was very mild, and the current never spiked dramatically. The 10μF cap I used across the motor was a non-polarised electrolytic (I'm lazy with my cap symbols; a cap is either polarised or not - that's all I care about apart from capacitance and voltage tolerance), and its only job was to reduce the 'kick' when the motor was abruptly turned on from a stalled start.
The controller was also quite immune to noise, so there was no need for noise suppression on the input lines or anything else. I put a large (1000μF) polarised electrolytic across the power supply lines just in case, but as the power supply was so solid compared to the light current draw of the circuit this probably wasn't necessary.

I recommend you pick up a few electrolytic caps of varying sizes, maybe a few each of 1μF, 10μF, 100μF and 1000μF, plus a few small ceramics in the pF and nF range. Often you can buy bags of an assortment of small ceramics which is quite handy. Except for in very precise analog filters or in capacitive timers you don't normally need great precision in your capacitors so it's good to have a nice range of basic units. Ceramics are usually pretty robust anyway, but make sure your electrolytics can handle 16V or more, even for a 5V circuit, since the motor back EMF can spike quite a lot higher than the supply.

Forgot to reply to your comment..bad style...

Thanks for the explanation and advice :)

NOW we're talking :) Seems we were writing simultaniously BTW...

And I never actually thought the ULN-thingy could replace the H-bridge entirely but rather simplify things when trying to build my own. It would seem I wasn't completely wrong after all (not bad for a noob). I'll read your comment more thoroughly and perhaps get back to you afterwards...

Thanks :)

I've built several H-Bridges using the ULN2803A, it's an extremely convenient IC.
You'll need, at minimum, two PNP transistors and two resistors in addition to the ULN2803 to complete the circuit. I suggest finding some PNP transistors with 500mA or higher emitter-collector current.

You can use two of the ULN2803's channels + two 500mA+ PNPs for a 500mA max current H-Bridges, or you can stack up to 4 ULN2803 channel together and use two 2A+ PNPs for a max current drive of up to 2A. Depending on what class of ULN2803 (A, B, etc) you usually won't need an input resistor, but you'll need a resistor for each of the PNPs.

Although that's the minimum configuration it's also nice to add a few filter capacitors to smooth things out. You don't really need protection diodes (normally a definite must) since the UNL2803 already has two per output, which can be used to protect the circuit provided you wire it up correctly.

If you give us some more info on what the voltages and currents you need are, plus whatever PNPs you can find, then I can sketch you up a circuit diagram.

EDIT: You could also use the ULN2803 to control the speed of the motor, and use a DPDT relay to select the direction. If you dedicate one of the ULN2803's channels to driving the relay, you'll still have enough left to pull up to 3.5A through the motor. In this case all you really need to the ULN2803 and a nice DPDT relay.

I'd be very grateful for a circuit diagram :)

All I wanna do is use an Arduino to drive 2 x DG02S motors from DAGU...Item 12 in the LMR pricelist.


Here are the specs:

Suggested Voltage:3V DC
No Load Speed:65±10rpm
No Load Current:125mA(max.170mA)
Torque:800gf.cm min
43*45*15(more below)

About the transistors...I suppose they're available EVEN here in Argentina. But off course the more common the better. I'm reading up on that part as we speak.

About the simple circuit posted above (no ULN2803): If I decide to go for that I suppose I need to add a diode at the top (?) and find some way to lower the voltage to 3V. Arduino outputs a 5V PWM signal. Could a resistor do that? Or something more complicated like an inverted op amp or something? I'm also not sure if the Arduino can pull that kind of load or I should use an external power source. I do that with my servos, BUT I have no experience with DC motors....

Well, here's the basic circuit for the ULN2803A H-Bridge. The resistor values depends on what PNP transistors you plan on using - previously I've used BC327s, BD140's, and a few other less common types, but just about anything with good current drive will do.


You can build the same circuit using NPN transistors in place of the ULN2803 and get the same effect.
One nice feature that I've added is self-inhibiting of the two halves of the bridge - this means that if INPUT_1 is active, turning INPUT_2 on will have no effect. Likewise, INPUT_1 is ignored if INPUT_2 is already active. This stops the bridge from short circuiting and destroying itself, which is what happens on some other H-Bridges when both inputs are active on a two-input design, or both inputs on the same side are active in a four-input design (like those above). You can avoid getting a short circuit by being careful with your controller, but it's good to have the extra protection in case of a glitch or mistake.

The two H-Bridges above definitely could do with additional diodes to protect the transistors, although some transistors actually have them built in already, which is the case with the ULN2803 ICs. In fact, the protection diodes in the ULN2803 will also protect the PNP transistors, so no extra diodes are needed at all.

Your Arduino won't be powering the H-Bridge directly, just controlling the inputs, so you can use whatever appropriate power supply you want to feed the motor. The current load on the Arduino will be very small, so you don't have to worry about that. Although the motors are rated at 3V they'll probably tolerate 5V, but if you're using PWM you could just limit the duty cycle to a maximum of 60%, which would only feed the motor the same amount of power as if it was being run on a 3V source (even though it's really 5V). Other configurations are of course possible, depending on what you want to acheive.

You seem to know a lot about it so I'll ask a few more questions:

1) I understand what the transistors, diodes and caps do, but I still can't figure out the purpose of the resistors in this context?

2) I noticed that there are several pins free..just wondering if I could use one ULN2903 for BOTH motors/H-bridges?

3) I also noticed that the IC you used has an A postfix. The ones I was thinking of getting are these. No A..

4) What size of resistors (and cap) would you recommend for my setup?

5) I recently scrapped a bunch of D1647 transistors. According to the info I found it's an EPITAXIAL PLANAR NPN SILICON DARLINGTON TRANSISTOR. Could these be used in an H-bridge? Not that transistors are expensive..I just like the idea of scrapping :)

6) You said: "...but if you're using PWM you could just limit the duty cycle to a maximum of 60%..". Hmm...how else could I control the speed of the motors (with an Arduino) apart from PWM?

Sorry to bombard you with question..but I'm a curious noob :)