Driving relays directly from an Arduino/etc.

GroupDIY Audio Forum

Help Support GroupDIY Audio Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Brian Roth

Well-known member
Joined
Aug 20, 2005
Messages
3,706
Location
Salina Kansas
From another thread on this forum, Sahib suggests that I should be sucking eggs <G!>:

"Brian,

I would not dare to try to teach you how to suck eggs but driving relays directly from the output of a micro is not really a good idea."

So...a new thread......

Backgrounders:

1.  YEARS ago, I ended up as the "PBX guy" for a semi-large company which also owned the studio where I had been hired as Chief Engineer for their 24 track (MCI analog gear...) studio.  Originally, we had a Mitel PBX...then later a Nortel.  I initially knew NOTHING about telephony as used in a business world, but my curiosity caused me to look at all of the various large circuit boards inside of the PBX cabinets.

I saw multiples of very small mechanical relays, driven by uP types of circuitry.  I looked up the specs for the relays, and discovered they were NOT the Big Current Hogs I was familiar with.....low enough coil current to be driven directly via the 1980's/1990's uP chips....but perhaps via a PIA chip??????  shrug...no schemos to look at back then.

2.  Maybe the Arduino card suppliers are liars, but quoting from http://www.arduino.cc/:

quote:

Properties of Pins Configured as OUTPUT

Pins configured as OUTPUT with pinMode() are said to be in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can source (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don't forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.

un-quote

Yes, they say "...not enough current to run  MOST  relays....."  But, what about small signal relays drawing 28 mA?

Is that a falsehood?  Is the chip unable to source/sink 28 mA? per output?  Or, will the chip overheat if driving multiples of 40 (or 28) mA, all at the same time?

I am asking as one guy who has NEVER played with ANY Arduino board.  I have looked at the specs, the firmware op-codes, but never hooked one up/made blinking LED's.

If the chip can't drive multiples of outputs at 28 mA each, then it's basically a toy component...IMHO.  OK for Science Fairs and toy robots via all sorts of external circuits.

Of course, relays are a tad tougher load to drive than a LED (typical Arduino circuits that I've seen "play" with a "naked" LED + series resistor in order to "make' the Arduino become a Fancy Light Flasher!  <g!>).

Obviously, you need to add a "snubber" diode across the relay coil.  Are the Ardunio's  outputs so weak that they CANNOT drive that 28 mA circuit load?

If so, then I won't waste my time with a toy.

BTW...I don't prefer hard boiled eggs...I  prefer scrambled.  lol 

Just asking about stuff that I never have messed with...

Best,

Bri
 
The ATMega 640/1280/2560 family data sheet:

http://www.atmel.com/Images/doc2549.pdf

On page367, absolute maximum ratings: DC current per IO pin..... 40mA

And then there's an overall maximum current for the chip at 200mA

Haven't tried it though - but will do so sometime soon.

However, I don't think it's too problematic to add a transistor per relay - just to play it safe.

Jakob E.
 
I was hoping to "KISS".....Keep it Simple....

Oh well, then we need to throw a 2n2222 plus at least another resistor per output port.

Forget Arduino.  Been there/done that.  It's not any better than all of the other crap that I've used to make an LED light up, or to make a relay to "click" via an uP.

I had hopes.....shrug.  Keep adding more componemts....siiiiiiigh.

Bri




 
Obviously someone did it, for a toy!
http://dev.squarecows.com/2010/05/07/arduino-nerf-sentry-gun-build-relay-firing-circuit/

Dunno what your application is, but I would feel more confident using some kind of interface before the relay coils.
What is the reason you don't want any? Cost? Real estate? Component count?

What about using an ULN2003 ? 7 set of Darlington+ associated resistors + diode in a cheap an convenient 16 pins package....

Axel
 
Axel, it was NOT my original project.  See:

http://www.groupdiy.com/index.php?topic=49496.0

Sahib said I was full of crap...LOL!  (Love ya, Sahib....)

I was just "thinking out loud"  re. with the questions re. the Arduino microprocessor gizmo....

So NOW what..throw a million other parts into what SHOULD be a simple circuit.....making a relay coil activate, and move some contacts????


Bri
 
Yes, I have read the OP after answering this one...

Then again, 1 Arduino, 1 ULN2003, 7 relays... we're still 999 991 short of a million, ain't we?

Also there's the debate of 'simple' vs 'reliable'... Traditionally, we take a lot af measures when it comes to interface the analog (real) world with highly integrated sandstate...
I.e.: coupling caps or transformers before and after opamps...
One doesn't expect a DAC chip to directly drive a 4 X 12"  ;)

Axel
 
And, an Ardunio is as worthless as any uP when it comes to driving something as simple as a a low current relay?????


Woooo...I wish I was 40 years younger, and still doing Science Fair projects with blinking LEDs.

end of discussion....

ADD a bunch of interface/glue parts in order to make the ardunio work for a living.  Let's add some 40-pin PIA chips and multi supply rails...or at the minimum...some discretes...and make a complex thing.

Did that decades ago with my Timex/Sinclair "computer".

Arduino is NOT a magic solution...AND seems like a piece of junk.  Just throw parts at it  and the I/O is as complex as any other uP.

No reason for me to pay any further attention to it vs. any other uP.  I had hoped it had some useful I/O current.  Just add all sorts of interface "glue" to make it useful.... just like the rest.

BAH

Bri
 
Brian,

I wrote below respectfully;

sahib said:
...................................
Brian,

I would not dare to try to teach you how to suck eggs but driving relays directly from the output of a micro is not really a good idea.

However, Jacob has 24 to 32 channels of relay drive and it would not be practicle to drive them all directly.


and it certainly does not have the meaning;

Brian Roth said:
From another thread on this forum, Sahib suggests that I should be sucking eggs...

A least not here in the UK. But it might have a different meaning in the Us of course.

However, can you show me where I said below;

Brian Roth said:
..........Sahib said I was full of crap...LOL!  (Love ya, Sahib....)
.................................


You may certainly have a different view but that does not warrant you to come up with the above nonsense.









 
Perhaps I should add on.

My view of not driving a relay directly from the output of a micro comes from the headaches I had in the past.

And I would imagine one would definitely not like to have that risk with 24 of them  in a mixing console with wires extending upto a meter or longer. 

 
The small Arduino boards use the Atmega328 chip which is about the size of your little finger nail in surface mount. The I/O pins are multipurpose, programmable for different functions on the fly. The pins easily drive the small relays. As you would expect, active low for heavy loads is a lot easier on the device as it only has the Vds minimum drop per active output. So that would be 5 or 6 relays on at any one time per chip per spec.

There is a much larger chip on the 1280 and 2560 boards which may be able to drive a healthy number of relays directly.

But for decades we've used the 2N2222 for this...
 
Dear Sahib,

Perhaps I should have "peppered" my replies with MORE of <g> and <G!> and <hehe> and that sort of comments.  And, "Go Suck Eggs' and 'Go Pound Salt'  and other yada-yada/etc.  comments perhaps DO have a different meaning from one side of the "Pond"  vs. the other!

Shrug......<g>  LOL !  <G!>  seriously...  ?  <G!!>  Sometimes, one person's comments (especially MINE!...) don't correctly transmit from point "A" to "B"...unless you're sitting across the table from one another.

I merely took your comments as a challenge to back-up my "off the cuff" suggestion re. powering a tiny audio-capable relay (with bifurcated contacts) from any sort of uP and/or any uP powered I/O chip.  I was recalling looking at large circuit boards used in PBX systems....

In other times, I've also seen similar 'schemes' used in audio desks to control the tiny relays for routing applications.

Perhaps we can all agree to use opto-couplers to drive the relay coils?  <G!!!!!>

Seriously now...I am the biggest proponent of "up-time' designs...yet why did the Arduino folks spec 40 mA for the outputs of the chip?  That is one SERIOUSLY large LED!  <G>.

I dunno..I was attempting to create the MOST SIMPLE design answer for the original question.

So...how many 2N2222's does it require to isolate the outputs of an Arduino against every possible failure mode?  lol

I DO see a possible failure mode if every output pin was fully sourciing/sinking the rated current of 40 mA......

asking with a <G!>....

Best Regards,

Bri









 
Brian,

I have only been using the English language in the past 27 years so I might still have got it wrong but  "I would not dare to try to teach you how to suck eggs" has more humble meaning. In other words "I wouldn't be stupid enough to try to teach you how tyo wire a relay" as I know you have credentials goes way far back before mine. The emphasis is on "dare".

But I was more concerned with your second statement and I would certainly not choose the word crap. I normally use sh*t.  ;D

Beside Rochey's explanation in the other thread my view is that it is not a good practice to mix high load currents with the sensitive control system.  But I am sure you are right with PBX systems which I am not familiar with. On board applications I was possibly wrong but I certainly would not think directly dangling relays with long wires on the I/Os of a micro would be a good idea.

 
Most micros will drive a decent current individually to or from their IO pins but as usual the devil is in the detail and as others have pointed out most micros won't sink anything like the full current from all the pins continuously. It's always been that way and there has always been a standard answer in the form of some very well used seven Darlington drivers to a box devices - there's a whole bunch of them from ULN 2003 onwards and now I think there are 8 in a box versions too.

Cheers

Ian
 
First of all, my apologies for being crabby....but I've felt miserable the past few days due to some sort of summer flu.

Rather than cross-posting, I made some useful (???) comments at the end of the original thread, where the OP was seeking a simple solution to controlling relays via an Arduino.

Again...apologies for being a crab....

Best,

Bri
 
Brian Roth said:
First of all, my apologies for being crabby....but I've felt miserable the past few days due to some sort of summer flu.

Rather than cross-posting, I made some useful (???) comments at the end of the original thread, where the OP was seeking a simple solution to controlling relays via an Arduino.

Again...apologies for being a crab....

Working while sick is never fun.

Having said that, I'll throw in with everyone else who recommends using the transistor as the relay coil driver. MMBT2222A is like a nickel a pop and will fit right under (bottom of the PCB) or next to the relay coil pins. It'll be smaller than the kickback-suppresion diode that you also need.

-a
 

Latest posts

Back
Top