so you you mean you have it attached without a transistor? I’m surprised the current sourced from the Arduino pin is good enough to energise a relay coil at all - but I don’t think it will be doing your Arduino any good, both from the “on” current draw and the high voltage flyback pulse when you turn the coil off
Without knowing any more about your setup, I think you should get both a diode and a transistor in there (like the diagram you linked)
Go for the highest current NPN switch transistor you can get. Even with a wimpy transistor like a 3904 you will at least be protecting the Arduino (the transistor will blow first)
Ideally get a darlington switch (uln280... tip120) or at worst something like a 2n2222
Cheers
Jason
From: Seb Lee-Delisle Sent: Saturday, November 17, 2012 10:28 PM
To: brightonhackerspace Subject: [brighton-hacker-space] Protection diodes for relays
Hi everyone!
We've attached a relay directly to an arduino pin and gnd, and I now gather that that's not a great thing to do :)
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
The best/easiest way to switch relays is through something like a ULN2003A darlington array.
They include flyback diodes and a transistor in a common package
If you haven't any of these, you can use an NPN transistor and a diode on every relay you need to switch.
I'll try to describe it in words:
Your relay coil is connected to +5V (or whatever power source you're using)
The ground pin on the relay coil goes into the collector pin of a transistor
The output from your Arduino goes to the base (gate) pin on the transistor
The emitter pin on the transistor goes to ground
Now, when your Arduino output goes high, it allows current to flow from the collector through to the emitter (and away to ground) thus activating the relay.
When the relay goes off, you might get some back emf, so you put a flyback or free-wheeling diode from the emitter pin (the one connected to ground) and allow the current to flow (counter-intuitively) from the emitter/ground pin "past" the transistor, and into the positive connection on the relay coil. Any back emf created when the coil goes off is safely handled.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> The best/easiest way to switch relays is through something like a ULN2003A
> darlington array.
> They include flyback diodes and a transistor in a common package
> If you haven't any of these, you can use an NPN transistor and a diode on
> every relay you need to switch.
> I'll try to describe it in words:
> Your relay coil is connected to +5V (or whatever power source you're using)
> The ground pin on the relay coil goes into the collector pin of a
> transistor
> The output from your Arduino goes to the base (gate) pin on the transistor
> The emitter pin on the transistor goes to ground
> Now, when your Arduino output goes high, it allows current to flow from
> the collector through to the emitter (and away to ground) thus activating
> the relay.
> When the relay goes off, you might get some back emf, so you put a flyback
> or free-wheeling diode from the emitter pin (the one connected to ground)
> and allow the current to flow (counter-intuitively) from the emitter/ground
> pin "past" the transistor, and into the positive connection on the relay
> coil. Any back emf created when the coil goes off is safely handled.
> I'll post a diagram and link to it in a min......
> On 17/11/2012 22:28, Seb Lee-Delisle wrote:
>> Hi everyone!
>> We've attached a relay directly to an arduino pin and gnd, and I now
>> gather that that's not a great thing to do :)
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to brightonhackerspace@**
>> googlegroups.com <brightonhackerspace@googlegroups.com>.
>> To unsubscribe from this group, send email to brightonhackerspace+**
>> unsubscribe@googlegroups.com<brightonhackerspace%2Bunsubscribe@googlegroups .com>
>> .
>> For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>> .
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@**
> googlegroups.com <brightonhackerspace@googlegroups.com>.
> To unsubscribe from this group, send email to brightonhackerspace+**
> unsubscribe@googlegroups.com<brightonhackerspace%2Bunsubscribe@googlegroups .com>
> .
> For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
It will be wired per the diagram you linked, with the diode facing the reverse direction to the driving current. Basically the flyback pulse you get when you turn the coil off is going in the opposite direction to the normal coil current.
The diode acts as a short across the coil to kill the high voltage flyback pulse
From: Seb Lee-Delisle Sent: Saturday, November 17, 2012 10:35 PM
To: brightonhackerspace Subject: [brighton-hacker-space] Re: Protection diodes for relays
I'm pretty sure I just put a diode across the relay, with the cathode on the arduino pin side (+ve) but I just wanted a second opinion :)
Seb
On Sat, Nov 17, 2012 at 10:28 PM, Seb Lee-Delisle <s...@leedelisle.com> wrote:
Hi everyone!
We've attached a relay directly to an arduino pin and gnd, and I now gather that that's not a great thing to do :)
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
> Thanks so much for the advice! Yep I'll def do the proper circuit > including a transistor when I get home.
> But in the meantime I just need to make an ad hoc fix, and I was > hoping that a diode across the relay might be at least enough to stop > the flyback?
> Seb
> On Sat, Nov 17, 2012 at 10:39 PM, Chris > <chris.hol...@multiedge-net.co.uk > <mailto:chris.hol...@multiedge-net.co.uk>> wrote:
> The best/easiest way to switch relays is through something like a
> ULN2003A darlington array.
> They include flyback diodes and a transistor in a common package
> If you haven't any of these, you can use an NPN transistor and a
> diode on every relay you need to switch.
> I'll try to describe it in words:
> Your relay coil is connected to +5V (or whatever power source
> you're using)
> The ground pin on the relay coil goes into the collector pin of a
> transistor
> The output from your Arduino goes to the base (gate) pin on the
> transistor
> The emitter pin on the transistor goes to ground
> Now, when your Arduino output goes high, it allows current to flow
> from the collector through to the emitter (and away to ground)
> thus activating the relay.
> When the relay goes off, you might get some back emf, so you put a
> flyback or free-wheeling diode from the emitter pin (the one
> connected to ground) and allow the current to flow
> (counter-intuitively) from the emitter/ground pin "past" the
> transistor, and into the positive connection on the relay coil.
> Any back emf created when the coil goes off is safely handled.
> I'll post a diagram and link to it in a min......
> On 17/11/2012 22:28, Seb Lee-Delisle wrote:
> Hi everyone!
> We've attached a relay directly to an arduino pin and gnd, and
> I now gather that that's not a great thing to do :)
> -- > You received this message because you are subscribed to the
> Google Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to
> brightonhackerspace@googlegroups.com
> <mailto:brightonhackerspace@googlegroups.com>.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com
> <mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com>.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google
> Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to
> brightonhackerspace@googlegroups.com
> <mailto:brightonhackerspace@googlegroups.com>.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com
> <mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com>.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> Thanks so much for the advice! Yep I'll def do the proper circuit
> including a transistor when I get home.
> But in the meantime I just need to make an ad hoc fix, and I was hoping
> that a diode across the relay might be at least enough to stop the flyback?
> Seb
> On Sat, Nov 17, 2012 at 10:39 PM, Chris <chris.hol...@multiedge-net.co.uk>wrote:
>> The best/easiest way to switch relays is through something like a
>> ULN2003A darlington array.
>> They include flyback diodes and a transistor in a common package
>> If you haven't any of these, you can use an NPN transistor and a diode on
>> every relay you need to switch.
>> I'll try to describe it in words:
>> Your relay coil is connected to +5V (or whatever power source you're
>> using)
>> The ground pin on the relay coil goes into the collector pin of a
>> transistor
>> The output from your Arduino goes to the base (gate) pin on the transistor
>> The emitter pin on the transistor goes to ground
>> Now, when your Arduino output goes high, it allows current to flow from
>> the collector through to the emitter (and away to ground) thus activating
>> the relay.
>> When the relay goes off, you might get some back emf, so you put a
>> flyback or free-wheeling diode from the emitter pin (the one connected to
>> ground) and allow the current to flow (counter-intuitively) from the
>> emitter/ground pin "past" the transistor, and into the positive connection
>> on the relay coil. Any back emf created when the coil goes off is safely
>> handled.
>> I'll post a diagram and link to it in a min......
>> On 17/11/2012 22:28, Seb Lee-Delisle wrote:
>>> Hi everyone!
>>> We've attached a relay directly to an arduino pin and gnd, and I now
>>> gather that that's not a great thing to do :)
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "BuildBrighton - the Brighton Hacker Space" group.
>>> To post to this group, send email to
>>> brightonhackerspace@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> brightonhackerspace+unsubscribe@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to brightonhackerspace@googlegroups.com
>> .
>> To unsubscribe from this group, send email to
>> brightonhackerspace+unsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> so you you mean you have it attached without a transistor? I’m surprised
> the current sourced from the Arduino pin is good enough to energise a relay
> coil at all - but I don’t think it will be doing your Arduino any good,
> both from the “on” current draw and the high voltage flyback pulse when you
> turn the coil off
> Without knowing any more about your setup, I think you should get both a
> diode and a transistor in there (like the diagram you linked)
> Go for the highest current NPN switch transistor you can get. Even with a
> wimpy transistor like a 3904 you will at least be protecting the Arduino
> (the transistor will blow first)
> Ideally get a darlington switch (uln280... tip120) or at worst something
> like a 2n2222
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Too much current can burn out the drive transistors on the Atmega output, so that a digital pin stops working as an output (possibly as input either)
Depending on how the Atmega is internally wired you might possibly damage other output drivers on the same output port (in other words up to 7 other output pins could be affected)
from a Google search it looks like you should be good for 40mA. What type of relay do you have?
From: Seb Lee-Delisle Sent: Saturday, November 17, 2012 10:56 PM
To: brightonhackerspace Subject: Re: [brighton-hacker-space] Protection diodes for relays
BTW what will happen if I draw too much current out of an arduino pin?
On Sat, Nov 17, 2012 at 10:36 PM, Jason Hotchkiss <jason_hotchk...@hotmail.com> wrote:
Hi Seb
so you you mean you have it attached without a transistor? I’m surprised the current sourced from the Arduino pin is good enough to energise a relay coil at all - but I don’t think it will be doing your Arduino any good, both from the “on” current draw and the high voltage flyback pulse when you turn the coil off
Without knowing any more about your setup, I think you should get both a diode and a transistor in there (like the diagram you linked)
Go for the highest current NPN switch transistor you can get. Even with a wimpy transistor like a 3904 you will at least be protecting the Arduino (the transistor will blow first)
Ideally get a darlington switch (uln280... tip120) or at worst something like a 2n2222
Cheers
Jason
From: Seb Lee-Delisle Sent: Saturday, November 17, 2012 10:28 PM
To: brightonhackerspace Subject: [brighton-hacker-space] Protection diodes for relays
Hi everyone!
We've attached a relay directly to an arduino pin and gnd, and I now gather that that's not a great thing to do :)
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
I dug out the Atmega328 data sheet which gives
DC Current per I/O Pin ............................................... 40.0 mA
And it also says
Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
ATmega48PA/88PA/168PA/328P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150 mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150 mA.
If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.
This means that there are some maximums for sets of pins, as well as the individual 40mA for a single pin
One thought however - maybe you could increase current drive by using multiple pins on the same port together. You’d need to make darn sure all the outputs on the port go high or low together so you don’t short circuit them (since they can sink current when they are LOW). You could use direct port access instead of digitalWrite. For exampe I think you could get a 150mA drive by connecting all the PORTC pins together (analog output pins 0-5) and using PORTC=0 to switch them off and PORTC=255 to turn them on. I’ve never tried this though and I really recommend going for the transistor option any way you can
From: Jason Hotchkiss Sent: Saturday, November 17, 2012 11:05 PM
To: brightonhackerspace Subject: Re: [brighton-hacker-space] Protection diodes for relays
Too much current can burn out the drive transistors on the Atmega output, so that a digital pin stops working as an output (possibly as input either)
Depending on how the Atmega is internally wired you might possibly damage other output drivers on the same output port (in other words up to 7 other output pins could be affected)
from a Google search it looks like you should be good for 40mA. What type of relay do you have?
From: Seb Lee-Delisle Sent: Saturday, November 17, 2012 10:56 PM
To: brightonhackerspace Subject: Re: [brighton-hacker-space] Protection diodes for relays
BTW what will happen if I draw too much current out of an arduino pin?
On Sat, Nov 17, 2012 at 10:36 PM, Jason Hotchkiss <jason_hotchk...@hotmail.com> wrote:
Hi Seb
so you you mean you have it attached without a transistor? I’m surprised the current sourced from the Arduino pin is good enough to energise a relay coil at all - but I don’t think it will be doing your Arduino any good, both from the “on” current draw and the high voltage flyback pulse when you turn the coil off
Without knowing any more about your setup, I think you should get both a diode and a transistor in there (like the diagram you linked)
Go for the highest current NPN switch transistor you can get. Even with a wimpy transistor like a 3904 you will at least be protecting the Arduino (the transistor will blow first)
Ideally get a darlington switch (uln280... tip120) or at worst something like a 2n2222
Cheers
Jason
From: Seb Lee-Delisle Sent: Saturday, November 17, 2012 10:28 PM
To: brightonhackerspace Subject: [brighton-hacker-space] Protection diodes for relays
Hi everyone!
We've attached a relay directly to an arduino pin and gnd, and I now gather that that's not a great thing to do :)
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
jason_hotchk...@hotmail.com> wrote:
> I dug out the Atmega328 data sheet which gives
> *DC Current per I/O Pin ...............................................40.0 mA
> *
> And it also says
> *Although each I/O port can source more than the test conditions (20 mA
> at VCC = 5V, 10 mA at VCC = 3V) under steady state*
> *conditions (non-transient), the following must be observed:*
> *ATmega48PA/88PA/168PA/328P:*
> *1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not
> exceed 150 mA.*
> *2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2
> should not exceed 150 mA.*
> *If IIOH exceeds the test condition, VOH may exceed the related
> specification. Pins are not guaranteed to source current*
> *greater than the listed test condition.*
> This means that there are some maximums for sets of pins, as well as the
> individual 40mA for a single pin
> One thought however - maybe you could increase current drive by using
> multiple pins on the same port together. You’d need to make darn sure all
> the outputs on the port go high or low together so you don’t short circuit
> them (since they can sink current when they are LOW). You could use direct
> port access instead of digitalWrite. For exampe I think you could get a
> 150mA drive by connecting all the PORTC pins together (analog output pins
> 0-5) and using PORTC=0 to switch them off and PORTC=255 to turn them on.
> I’ve never tried this though and I really recommend going for the
> transistor option any way you can
> *From:* Jason Hotchkiss <jason_hotchk...@hotmail.com>
> *Sent:* Saturday, November 17, 2012 11:05 PM
> *To:* brightonhackerspace <brightonhackerspace@googlegroups.com>
> *Subject:* Re: [brighton-hacker-space] Protection diodes for relays
> Too much current can burn out the drive transistors on the Atmega
> output, so that a digital pin stops working as an output (possibly as input
> either)
> Depending on how the Atmega is internally wired you might possibly damage
> other output drivers on the same output port (in other words up to 7 other
> output pins could be affected)
> from a Google search it looks like you should be good for 40mA. What type
> of relay do you have?
> BTW what will happen if I draw too much current out of an arduino pin?
> On Sat, Nov 17, 2012 at 10:36 PM, Jason Hotchkiss <
> jason_hotchk...@hotmail.com> wrote:
>> Hi Seb
>> so you you mean you have it attached without a transistor? I’m surprised
>> the current sourced from the Arduino pin is good enough to energise a relay
>> coil at all - but I don’t think it will be doing your Arduino any good,
>> both from the “on” current draw and the high voltage flyback pulse when you
>> turn the coil off
>> Without knowing any more about your setup, I think you should get both a
>> diode and a transistor in there (like the diagram you linked)
>> Go for the highest current NPN switch transistor you can get. Even with a
>> wimpy transistor like a 3904 you will at least be protecting the Arduino
>> (the transistor will blow first)
>> Ideally get a darlington switch (uln280... tip120) or at worst something
>> like a 2n2222
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to brightonhackerspace@googlegroups.com
>> .
>> To unsubscribe from this group, send email to
>> mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com<brightonhackerspa ce%2Bunsubscribe@googlegroups.com>
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>> --
>> You received this message because you are subscribed to the Google Groups
>> "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to brightonhackerspace@googlegroups.com
>> .
>> To unsubscribe from this group, send email to
>> mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com<brightonhackerspa ce%2Bunsubscribe@googlegroups.com>
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
As I'm only using 3 relays I'm hoping I don't exceed the 150mA limit.
Oh and I'm using an Arduino Mega too, which may help a bit.
Seb
On Sat, Nov 17, 2012 at 11:19 PM, Jason Hotchkiss <jason_hotchk...@hotmail.com> wrote:
I dug out the Atmega328 data sheet which gives
DC Current per I/O Pin ............................................... 40.0 mA
And it also says
Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:
ATmega48PA/88PA/168PA/328P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150 mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150 mA.
If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.
This means that there are some maximums for sets of pins, as well as the individual 40mA for a single pin
One thought however - maybe you could increase current drive by using multiple pins on the same port together. You’d need to make darn sure all the outputs on the port go high or low together so you don’t short circuit them (since they can sink current when they are LOW). You could use direct port access instead of digitalWrite. For exampe I think you could get a 150mA drive by connecting all the PORTC pins together (analog output pins 0-5) and using PORTC=0 to switch them off and PORTC=255 to turn them on. I’ve never tried this though and I really recommend going for the transistor option any way you can
From: Jason Hotchkiss Sent: Saturday, November 17, 2012 11:05 PM
To: brightonhackerspace Subject: Re: [brighton-hacker-space] Protection diodes for relays
Too much current can burn out the drive transistors on the Atmega output, so that a digital pin stops working as an output (possibly as input either)
Depending on how the Atmega is internally wired you might possibly damage other output drivers on the same output port (in other words up to 7 other output pins could be affected)
from a Google search it looks like you should be good for 40mA. What type of relay do you have?
From: Seb Lee-Delisle Sent: Saturday, November 17, 2012 10:56 PM
To: brightonhackerspace Subject: Re: [brighton-hacker-space] Protection diodes for relays
BTW what will happen if I draw too much current out of an arduino pin?
On Sat, Nov 17, 2012 at 10:36 PM, Jason Hotchkiss <jason_hotchk...@hotmail.com> wrote:
Hi Seb
so you you mean you have it attached without a transistor? I’m surprised the current sourced from the Arduino pin is good enough to energise a relay coil at all - but I don’t think it will be doing your Arduino any good, both from the “on” current draw and the high voltage flyback pulse when you turn the coil off
Without knowing any more about your setup, I think you should get both a diode and a transistor in there (like the diagram you linked)
Go for the highest current NPN switch transistor you can get. Even with a wimpy transistor like a 3904 you will at least be protecting the Arduino (the transistor will blow first)
Ideally get a darlington switch (uln280... tip120) or at worst something like a 2n2222
Cheers
Jason
From: Seb Lee-Delisle Sent: Saturday, November 17, 2012 10:28 PM
To: brightonhackerspace Subject: [brighton-hacker-space] Protection diodes for relays
Hi everyone!
We've attached a relay directly to an arduino pin and gnd, and I now gather that that's not a great thing to do :)
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
> As I'm only using 3 relays I'm hoping I don't exceed the 150mA limit.
> Oh and I'm using an Arduino Mega too, which may help a bit.
> Seb
> On Sat, Nov 17, 2012 at 11:19 PM, Jason Hotchkiss <jason_hotchk...@hotmail.com> wrote:
>> I dug out the Atmega328 data sheet which gives
>> DC Current per I/O Pin ............................................... 40.0 mA
>> And it also says
>> Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state
>> conditions (non-transient), the following must be observed:
>> ATmega48PA/88PA/168PA/328P:
>> 1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150 mA.
>> 2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150 mA.
>> If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
>> greater than the listed test condition.
>> This means that there are some maximums for sets of pins, as well as the individual 40mA for a single pin
>> One thought however - maybe you could increase current drive by using multiple pins on the same port together. You’d need to make darn sure all the outputs on the port go high or low together so you don’t short circuit them (since they can sink current when they are LOW). You could use direct port access instead of digitalWrite. For exampe I think you could get a 150mA drive by connecting all the PORTC pins together (analog output pins 0-5) and using PORTC=0 to switch them off and PORTC=255 to turn them on. I’ve never tried this though and I really recommend going for the transistor option any way you can
>> From: Jason Hotchkiss
>> Sent: Saturday, November 17, 2012 11:05 PM
>> To: brightonhackerspace
>> Subject: Re: [brighton-hacker-space] Protection diodes for relays
>> Too much current can burn out the drive transistors on the Atmega output, so that a digital pin stops working as an output (possibly as input either)
>> Depending on how the Atmega is internally wired you might possibly damage other output drivers on the same output port (in other words up to 7 other output pins could be affected)
>> from a Google search it looks like you should be good for 40mA. What type of relay do you have?
>> From: Seb Lee-Delisle
>> Sent: Saturday, November 17, 2012 10:56 PM
>> To: brightonhackerspace
>> Subject: Re: [brighton-hacker-space] Protection diodes for relays
>> BTW what will happen if I draw too much current out of an arduino pin?
>> On Sat, Nov 17, 2012 at 10:36 PM, Jason Hotchkiss <jason_hotchk...@hotmail.com> wrote:
>>> Hi Seb
>>> so you you mean you have it attached without a transistor? I’m surprised the current sourced from the Arduino pin is good enough to energise a relay coil at all - but I don’t think it will be doing your Arduino any good, both from the “on” current draw and the high voltage flyback pulse when you turn the coil off
>>> Without knowing any more about your setup, I think you should get both a diode and a transistor in there (like the diagram you linked)
>>> Go for the highest current NPN switch transistor you can get. Even with a wimpy transistor like a 3904 you will at least be protecting the Arduino (the transistor will blow first)
>>> Ideally get a darlington switch (uln280... tip120) or at worst something like a 2n2222
>>> Cheers
>>> Jason
>>> From: Seb Lee-Delisle
>>> Sent: Saturday, November 17, 2012 10:28 PM
>>> To: brightonhackerspace
>>> Subject: [brighton-hacker-space] Protection diodes for relays
>>> Hi everyone!
>>> We've attached a relay directly to an arduino pin and gnd, and I now gather that that's not a great thing to do :)
>>> -- >>> You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
>>> To post to this group, send email to brightonhackerspace@googlegroups.com.
>>> To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>> -- >>> You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
>>> To post to this group, send email to brightonhackerspace@googlegroups.com.
>>> To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>> -- >> You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to brightonhackerspace@googlegroups.com.
>> To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>> -- >> You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to brightonhackerspace@googlegroups.com.
>> To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>> -- >> You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to brightonhackerspace@googlegroups.com.
>> To unsubscribe from this group, send email to mailto:brightonhackerspace%2Bunsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
At best, it just won't be able to provide the current and your relay won't switch
(or might switch, but intermittently). A lot of microcontrollers have limiters on the output pins.
In theory you could blow the mcu, but I suspect you'll just not drive whatever load you're trying to if the current draw is too great.
> At best, it just won't be able to provide the current and your relay won't switch
> (or might switch, but intermittently). A lot of microcontrollers have limiters on the output pins.
> In theory you could blow the mcu, but I suspect you'll just not drive whatever load you're trying to if the current draw is too great.
> On 17/11/2012 22:56, Seb Lee-Delisle wrote:
>> BTW what will happen if I draw too much current out of an arduino pin?
> -- > You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
-----Original Message----- From: Seb Lee-Delisle
Sent: Sunday, November 18, 2012 10:01 AM
To: brightonhackerspace@googlegroups.com
Subject: Re: [brighton-hacker-space] Protection diodes for relays
Here's my circuit diagram, I'm getting really confused about which way round the diode should go. Can you guys please check that this is right?
Thanks!
Sent from my iPhone
On 18 Nov 2012, at 00:17, Chris <chris.hol...@multiedge-net.co.uk> wrote:
> At best, it just won't be able to provide the current and your relay won't > switch
> (or might switch, but intermittently). A lot of microcontrollers have > limiters on the output pins.
> In theory you could blow the mcu, but I suspect you'll just not drive > whatever load you're trying to if the current draw is too great.
> On 17/11/2012 22:56, Seb Lee-Delisle wrote:
>> BTW what will happen if I draw too much current out of an arduino pin?
> -- > You received this message because you are subscribed to the Google Groups > "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
> -----Original Message----- From: Seb Lee-Delisle
> Sent: Sunday, November 18, 2012 10:01 AM
> To: brightonhackerspace@googlegroups.com
> Subject: Re: [brighton-hacker-space] Protection diodes for relays
> Here's my circuit diagram, I'm getting really confused about which way round the diode should go. Can you guys please check that this is right?
> Thanks!
> Sent from my iPhone
> On 18 Nov 2012, at 00:17, Chris <chris.hol...@multiedge-net.co.uk> wrote:
>> At best, it just won't be able to provide the current and your relay won't switch
>> (or might switch, but intermittently). A lot of microcontrollers have limiters on the output pins.
>> In theory you could blow the mcu, but I suspect you'll just not drive whatever load you're trying to if the current draw is too great.
>> On 17/11/2012 22:56, Seb Lee-Delisle wrote:
>>> BTW what will happen if I draw too much current out of an arduino pin?
>> -- >> You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to brightonhackerspace@googlegroups.com.
>> To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.