Pages: [1]   Go Down
Author Topic: Using ULN2003 to drive relays - first time schematic  (Read 19935 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm trying to get the Arduino to control multiple 12V relays - some of which will have 240V AC load, the others 24V DC load.

What I want to do is to use a ULN2003 to drive the relays and, in turn, drive the ULN via the digital IO pins from the arduino. I'd also like to include an LED for each relay to indicate it's status.

This is the first time I've ever done this, so am seeking some feedback on the schematic.


(Apologies for the incorrect image link - forgot my home server was password protected smiley ).
My questions are:

  • Am I correct in assuming I just rinse and repeat the red outlined section for each relay?
  • By my reading, the ULN2003 includes a suppression diode on chip, so I don't need to include one, right?
  • Is that the correct wiring for the LED and resistor?
  • If I'm using a basic LED,  1.8-2.2VDC forward drop, Max current: 20mA (http://www.sparkfun.com/products/9590) I'm assuming that I need to add something else into the LED portion to limit the voltage as well as current?
  • As I need to drive at least 12 relays, can I just replicate this board and combine both of their grounds back to the arduino?

Thanks for your time!

andrew.

« Last Edit: February 06, 2011, 10:43:54 pm by gorbs » Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6132
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I get a password prompt when the browser tries to load the image.  Try using another image service (like imgur).
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops! Fixed.

Thanks for the heads up.
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It all looks fairly correct.

Quote
I'm assuming that I need to add something else into the LED portion to limit the voltage as well as current?

No, the resistor does that for you. Let's say you have 2V drop in the LED, then as a ballpark estimate the resistance should be (12V-2V)/10mA = 1k.  10mA is usually plenty to light an LED...use 4.7k if you really want 20mA.

Should be OK on the replication.

The only thing to watch out for is maximum power dissipation on the ULN2003 devices. You didn't tell us how much current each relay uses, or how many you plan to have on at once. The ULN2003 output dissipates V*I power (where V is its on-voltage...close to 0 but not 0).

--
The Rugged Motor Driver: two H-bridges, more power than an L298, fully protected
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again. I write software for a living and it's been a long time since I've done any sort of electronic work for a living - but that was all calibration, not design - so I feel like a bit of a dunce.

The relays I'm planning on using are these http://australia.rs-online.com/web/search/searchBrowseAction.html?method=getProduct&R=2355548#header

Which end up coming out to ~0.08A per relay.  I shouldn't need to have more than 6 relays on at a time. If needs be, I can stagger the which ones between the two ICs to ensure I've only ever got 3 on per IC at any one time.

Looking at the data sheet for the ULN2003A, it's rated at 0.5A for the collector current, so it shouldn't be a problem.
« Last Edit: February 06, 2011, 11:10:18 pm by gorbs » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
No, the resistor does that for you. Let's say you have 2V drop in the LED, then as a ballpark estimate the resistance should be (12V-2V)/10mA = 1k.  10mA is usually plenty to light an LED...use 4.7k if you really want 20mA.

Not to be a pratt, I just want to make sure I'm not going batty with my calculations smiley

Wouldn't a 4.7k resistor drop the current to 2mA, whereas a 510 ohm resistor would bring it up to 20mA?  (Not that I'm going to do that, a 1k driving 10mA is just fine).

Again, thank you for your time and input.
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Oops! I meant 470 ohms, not 4.7k. You're not going batty smiley

--
The Aussie Shield: breakout all 28 pins to quick-connect terminals
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 524
Posts: 26440
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you may find that the LED will not turn off when expected with 12V of reverse bias - many are only good for 5v.
You may have to move it to the input side of the ULN2003.
« Last Edit: February 07, 2011, 02:24:14 am by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think you may find that the LED will not turn off when expected with 12V of reverse bias - many are only good for 5v.
You may have to move it to the input side of the ULN2003.

I think I'm understanding what you're telling me.  By placing the LED and resistor where it is, it's parallel to the relay and will suffer from the reversed bias voltage spike generated by the relay turning off and collapsing it's magnetic field?

Would it be enough to just throw another diode between the resistor and the led that has a better rating than the led to handle the reverse bias? My thing with moving the LED to the input side is that the arduino will be barely enough to drive 1 LED and input collector and will quickly become more complex.

... and then my thought process went on a bit further ...

I was thinking that I'd have to go more complex and have individual transistors for each LED and drive them off the 12V rail, but what's stopping me from going:
  5V in from arduino -> ULN2003 -> drive LED -> ULN2003 -> drive relay? (I'll draw another attempted schematic tomorrow when I have access). Would certainly make for an easier routed PCB.
Logged

Belgium
Offline Offline
Jr. Member
**
Karma: 1
Posts: 80
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

don't forget to put a freewheeling diode on your relay's coil... Just to avoid ULN2003 frying...

Gozaki

-----------------------------
www.laboelectronique.be
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

don't forget to put a freewheeling diode on your relay's coil... Just to avoid ULN2003 frying...

The ULN2003 has freewheeling diodes built in to each emitter.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33371
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Looking at the data sheet for the ULN2003A, it's rated at 0.5A for the collector current, so it shouldn't be a problem.
But you can't have them all pulling that at the same time. About 650mA is the total you can get away with so with 8 all on at the same time you are just about alright.
For a further explanation of this see:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Examples.html
and
http://www.thebox.myzen.co.uk/Tutorial/Power.html
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 524
Posts: 26440
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here's what I intended to say about your monitoring LED:
Per the ULN2003 datasheet, input current will be around 1.2mA at 5V, the arduino can handle that and driving an LED at the same time.

What I have seen in my experimenting is that with a simple open collector driver as shown, a single LED would look partially turned on with a 12V source even when the base was grounded. 2 LEDs would also look turned. For my design, I had to use 5V to get them turned off.
With the ULN2003, which is an open collector driver also with 2 added reverse bias diodes added for protection, I don't know if that will happen. Just don't be surprised if it is.
(I drew a motor symbol here, was thinking of a different circuit, but its still a coil either way).


* Motor_ULN2003.jpg (34.77 KB, 960x371 - viewed 418 times.)
« Last Edit: February 07, 2011, 11:04:33 am by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Offline Offline
Newbie
*
Karma: 0
Posts: 19
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But you can't have them all pulling that at the same time. About 650mA is the total you can get away with so with 8 all on at the same time you are just about alright.

Yes you're right. What I didn't show in my diagram is that there'll be 2 ULN2003s driving the required amount of relays, giving me a total of 14 outputs. Of these I'll only need a maximum of 6 on at any time. With a little bit of thought, I can stagger the relays so when the required 6 are on, I'll only be running 3 concurrently off each IC.

With the ULN2003, which is an open collector driver also with 2 added reverse bias diodes added for protection, I don't know if that will happen. Just don't be surprised if it is.

I get you. I'll experiment with the bread board before I layout a PCB smiley

Thank you both for your input. I'm genuinely appreciative.
Logged

Pages: [1]   Go Up
Jump to: