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.

Just get a dedicated motor
Just get a dedicated motor controller chip (LM293D, LM298, SN754410) and you will be set.

The ULN2803 has a number of

The ULN2803 has a number of transistors in low side driver configuration, where an h-bridge needs 2 transitors in high side in addition to the 2 on low side. Won’t make an h-bridge.

Check Arrow Electronics for ordering parts, they appear to have offices in Argentina.

Thanks guys…

However if I could JUST get an H-bridge I wouldn’t have posted this topic in the 1st place. It seems I can’t buy them here and the word JUST simply doesn’t apply to getting stuff shipped here. It’s extremely slow, expensive and risky. :frowning:

I checked the Arrow ECS and they do not have offices here in Argentina. However they do in Brazil, which may or may not be of use to me. I’ll check it out further. But for now it seems I’m back to square one, which means the easiest, fastest and cheapest option probably is building my own H-bridge(s) using transistors and stuff.

Anyway thanks a lot for ruling out the ULN2803…

 

Best wishes :slight_smile:

Aniss

 

 

This is the H bridge I

This is the H bridge I use:

PShbridge.gif

 

The transistors are cheaper than dirt, just don't turn both sides high!

Thanks…

I’ll be looking into that…just one question…

This H-bridge seems somewhat more complicated than the ones I’ve seen. Any particalar advantages in using 6 transistor rather than 4? And why the crossing of the wire (above the motor)? I’m quite a noob in electronics so I don’t quite understand this diagram. I was thinking in simpler terms like this

basic-bridge.gif

 

... which I DO understand!! But I suppose this is incomplete and merely meant to explain the principles to noobs like me...

I’ve built several H-Bridges

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.

The H-Bridge you posted
The H-Bridge you posted requires 4 inputs to control, whereas the one above only needs two =D

Allright…

NOW we’re talking :slight_smile: 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 :slight_smile:

Ah! Now I get it :slight_smile:

In that case I think I’ll go for the simpler version and simply use a shift register or (de)multiplexer to make up for the extra use of pins, since I know how to use these and they’re easy to buy here (for around $0.5 each)…

Besides I don’t think I’ll need that either. I’m not really in danger of running out of pins in this project, which is a simple 2 dc motor + 2 servo “start here”-class robot for environment mapping experiments…

Thanks again :slight_smile:

More info

I’d be very grateful for a circuit diagram :slight_smile:

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

motor1.jpg

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

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.

ULN2803_H-Bridge.jpg

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.

Wow! Thanks!

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 :slight_smile:

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 :slight_smile:

Nothing wrong with being

Nothing wrong with being curious, it’s about the only way to become a better noob =)

The resistors on the left of the ULN2803 are there to limit the current coming out of the Arduino. This makes sure that the input current can be ‘disabled’ when the other input is already active. You can leave these out (as well as the diode/wire coming from Output_2 to Input_1 and vice-versa) if you’re certain there won’t be any chance of both inputs turning on at the same time.
The resistors on the right of the ULN2803 are there to limit the current coming out of the PNP transistors. If they weren’t there then a large current could easily surge through the PNP, wasting a lot of power and possibly destroying it.

You can use the other pins for another H-Bridge, or even another three if you needed to. On a recent project I used a single ULN2803A for two H-Bridges and then I used the other half of the channels for driving some LED sets.

If I remember correctly the postfix is just the ‘grade’ of the IC, nothing very important changes from grade A to B to C, etc, etc. Either DitenTec left it off because it’s not a big deal, or maybe because they get in a range of grades and don’t know what stock will be available at what time. Either way it doesn’t matter, the ‘2803’ is the important part as the others in the family (ULN2801 etc) have different properties.

Here’s an updated schematic with some recommended values. I can’t be 100% sure on the PNP base resistors without knowing what actual transistors you plan on using, but the values are probably close enough:

Those D1647s look really nice; Darlington configuration, up to 60V across the collector-emitter at up to 2A, with built in protection diodes too. Definitely usable in an H-Bridge, just make sure you use a resistor in between the control input and the base.

There are a number of ways to control the motor speed other than PWM, but I don't recommend any of them =D
They all involve more parts and more complication, but the end result will probably be worse. If you're really curious I can describe a few, but they're pretty awful. There's a good reason why PWM is so popular!

Thanks again…

…however it seems I was saved by the bell. I had given up on finding an H-bridge IC here since I had allready been to like 25 of the most prominent shops (=all the ones I know). But a classmate told me about a tiny shop hidden away that specializes in ICs, and they DID have an L293D chip :slight_smile: so I think I’ll go for that…atleast for this project. I’m definately gonna build my own bridge for another project later (soon), so the knowledge gained here will be used no matter what. I saved your diagrams and explanations in a document to make sure I have it for later use…

Thanks again…I learned a hell of a lot…

 

PS: No need for any further description of the awful non-pwm control methods. I’m busy enough learning USEFUL stuff right now :wink:

 

I’m glad you managed to find

I’m glad you managed to find a local shop that sells some good parts =D

Even I prefer to use prebuilt driver ICs when I can, but there are a few occasions where a more specialised driver is indeed useful.

Good! Building your own
Good! Building your own Transistor H Bridges take up too much valueable board space!

That’s almost certainly true
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 =)

Well…

…yes it does simplify things somewhat. And this particular robot is meant for range sensor based environment mapping (not electronics experiments) and I wanna be able to put it together FAST as soon as I get the motors (ordered from DAGU a few days ago). A secondary purpose is to use it with OddBot’s compound eye (ordered with the motors). I call this robot Mappy (so far).

I’m planning to build Mappy’s ugly brother Scrappy before long. This will be a robot build entirely from scrap EXCEPT the brain which will be a standalone Atmega168. For that project I’ll definately build my own H-bridge. Probably using the D1647 transistors you seemed to like. So far I’ve also got varios motors, gears, wheels, caps, resistors, transistors, (touchsense) switches, etc…

:slight_smile:

Capacitors?!
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.