Author Topic: Relay circuit design  (Read 4083 times)

0 Members and 1 Guest are viewing this topic.

Offline HandullTopic starter

  • Newbie
  • Posts: 1
  • Country: us
Relay circuit design
« on: July 26, 2016, 08:11:42 pm »
Hi all,
I have a basic 5V relay that I want to control with a 5V digital logic line. I learned that I should put a diode backwards across the coil of the relay and I understand why. I've also seen a lot of people putting a transistor after the relay and controlling the transistor with digital logic, rather than just driving the relay directly. What are the reasons for using a transistor along with the relay? I've attached a drawing of the two circuits I'm asking about. One obvious benefit of using a transistor is that your logic voltage doesn't have to match the relay voltage, so you could use 3.3V logic with a 12V relay. Is using a transistor going to have faster switching or something? Thanks!
-Anthony
 

Offline Signal32

  • Frequent Contributor
  • **
  • Posts: 251
  • Country: us
Re: Relay circuit design
« Reply #1 on: July 26, 2016, 08:15:36 pm »
The biggest reason for doing this is that most micro's/logic pins don't have the capability to supply enough current to turn on the relay.
As for speed, it would actually be slower when using a transistor, but it would be a few nanosecond slower which doesn't really matter when the relay takes 1,000,000 times more to actuate.
 
The following users thanked this post: Handull

Offline boffin

  • Supporter
  • ****
  • Posts: 1027
  • Country: ca
Re: Relay circuit design
« Reply #2 on: July 26, 2016, 08:31:21 pm »
I'd use a FET rather than a regular transistor.  Something like the 2N7000 would work perfectly (still want the reverse diode), and you wont need a currently limiting resistor.
If you do it with a regular transistor, you'll need to limit the base current with a 22k-ish resistor in series with the base for a  2N3904/2N2222/BC107


 
The following users thanked this post: Handull

Offline MosherIV

  • Super Contributor
  • ***
  • Posts: 1530
  • Country: gb
Re: Relay circuit design
« Reply #3 on: July 26, 2016, 09:15:36 pm »
Hi

The drawing of the relay being driven directly by the micro GPIO is likely to fail. As you said, you understand the reason for the diode, well as it has been drawn the back emf will likely blow the GPIO port.

The better way to do it is to put the relay from power rail into the GPIO port and the  the diode will direct the back emf into the supply rail. The logic for driving the relay must be inverted.
The power supply need to have a diode to protect against overvolt
http://www.learnabout-electronics.org/PSU/images/78xx-protection-diode.jpg
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Relay circuit design
« Reply #4 on: July 27, 2016, 12:24:39 am »
Wheather a MOSFET or Bipolar add a R from Gate/Base to ground, calculate its
value so that any leakage when pin is in tristate will not reach threshold of BE
junction of Bipolar or Vth for the MOSFET.

When you pick diode use a fast power diode to limit max emf circuit experiences.
Use a scope to confirm you are getting good results in suppression of transient
for the relay you choose.


Regards, Dana.
« Last Edit: July 27, 2016, 12:32:01 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 1938
  • Country: us
Re: Relay circuit design
« Reply #5 on: July 27, 2016, 01:14:55 am »
Whats wrong with a transistor, but use 1K resistor for the drive.  I've never used a 2N7000 FET.  From what I've seen around here,  I have the same fondness for them as I do the 555.  People seem to have a lot of issues with them, they don't seem robust.  Any common 1A diode will work.  Most diodes turn on fast, just some are slow to turn off.  Plenty fast for any relay circuit. Use a 12V relay if possible.  Driving relays from a 5V supply is always asking for trouble.  When you get a little better, drive the relays with PWM to save current.  It can always be dropped in half.
« Last Edit: July 27, 2016, 01:34:49 am by Seekonk »
 

Online MarkF

  • Super Contributor
  • ***
  • Posts: 2550
  • Country: us
Re: Relay circuit design
« Reply #6 on: July 27, 2016, 01:27:43 am »
If you have a number relays you want to drive, a ULN2003 is designed just for the task and has the diode built-in.
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Relay circuit design
« Reply #7 on: July 27, 2016, 11:18:50 am »
Here is a good discussion and testing of low cost power diodes -


http://www.cliftonlaboratories.com/diode_turn-on_time.htm

As Seekonk pointed out the Turn on time of these cheap power diodes pretty good. But
if the diode is in Trr when you try to turn it on therein lies a potential problem. But most
relay driving has exhausted Trr before its asked to conduct, so issue should be moot.


Regards, Dana.
« Last Edit: July 27, 2016, 12:58:16 pm by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline Jeroen3

  • Super Contributor
  • ***
  • Posts: 4078
  • Country: nl
  • Embedded Engineer
    • jeroen3.nl
Re: Relay circuit design
« Reply #8 on: July 27, 2016, 11:29:12 am »
Circuit 1 is missing two resistors.
R1. gate/base resistor.
R2. gate/base pulldown to not half-enable the relay on tri-state output.
 

Offline madires

  • Super Contributor
  • ***
  • Posts: 7780
  • Country: de
  • A qualified hobbyist ;)
Re: Relay circuit design
« Reply #9 on: July 27, 2016, 11:57:04 am »
When you get a little better, drive the relays with PWM to save current.  It can always be dropped in half.

Is PWMing a relay a good idea? What about EMI? Wouldn't it be better to switch the relay to another power rail with a lower voltage?
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Relay circuit design
« Reply #10 on: July 27, 2016, 04:18:32 pm »
Use a latching relay and pulse it to switch back and forth between open and closed.
No PWM needed, and optimal power consumption ( if switching is basic on off switching),
only draws power during applied pulse.


Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline tatus1969

  • Super Contributor
  • ***
  • Posts: 1273
  • Country: de
  • Resistance is futile - We Are The Watt.
    • keenlab
Re: Relay circuit design
« Reply #11 on: July 27, 2016, 11:46:24 pm »
there is another - yet more subtle - reason to not directly use a GPIO port to drive an inductive load like a relay. When the relay is switched off, the free-wheeling diode conducts. During this situation, you have roughly -0.7V at the GPIO. This negative voltage may cause a latchup in your microcontroller, which at least inhibits normal operation until the next power cycle, and even may thermally destroy it. It largely depends on the type of microcontroller, some have specified latchup immunity and are robust against this failure.
We Are The Watt - Resistance Is Futile!
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: Relay circuit design
« Reply #12 on: July 28, 2016, 02:11:09 am »
tatus1969 brings up a very good point. Across the profession we have been protecting
I/O pins with Si diodes, but that raises the question, which diode has the lower threshold,
the internal diode we are trying to prevent from drawing current, or the external one we
are using to protect the internal one ?

The sure footed solution is to use schottky diodes, or SiC, as their Vth is inherently lower (picking
the correct part of course).

The latchup mechanism, parasitic SCR, is a little more complicated as not only is there a Vth
to trigger but its sensitive to dV/dT effects. Most modern controllers now state latchup conditions
and the resulting current when latchup occurs. In the past latchup generally was destructive,
resulting in blowing open internal power rail bond wires, or melting silicon in hotspot areas.
Recently some vendors state that latchup, once power is removed, can be recovered from.
Even if latchup does not occur charge injection into pins can result in erratic behavior, as the
charge release into the substrate has no predetermined sink for it, so random logic can be affected.
So consult datasheet.


Regards, Dana.

« Last Edit: July 28, 2016, 02:18:29 am by danadak »
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf