Maker Pro
Maker Pro

Powering a relay

C

Captain Dondo

Jan 1, 1970
0
OK, I have a real basic question....

I have an embedded computer. It had digital I/O. Per the manufacturer,
"When the DIO pins are configured as outputs, they can source 4 mA or
sink 8 mA and have logic swings between 3.3V and ground."

OK, I prefer to work as source. So... How do I get 4 ma @ 3.3V to
control a 5V relay that needs 100 ma to operate?

ISTR something about transistors, but it's been a few years since my
electronics classes....

Right now I need to be able to power LEDs, but eventually I need to
siwtch 120 VAC and 24-48 VDC at a few amps load, and I thought I could
use relays for that. But this has thrown a wrench into the works....

Any suggestions?

Thanks,

--Yan
 
M

Mark VB

Jan 1, 1970
0
Captain said:
OK, I have a real basic question....

I have an embedded computer. It had digital I/O. Per the manufacturer,
"When the DIO pins are configured as outputs, they can source 4 mA or
sink 8 mA and have logic swings between 3.3V and ground."

OK, I prefer to work as source. So... How do I get 4 ma @ 3.3V to
control a 5V relay that needs 100 ma to operate?

ISTR something about transistors, but it's been a few years since my
electronics classes....

Right now I need to be able to power LEDs, but eventually I need to
siwtch 120 VAC and 24-48 VDC at a few amps load, and I thought I could
use relays for that. But this has thrown a wrench into the works....

Any suggestions?

Thanks,

--Yan

So, you'll have to use an NPN-transistor with Vce>5 V, Ic>100ma, Hfe>25.
Don't forget to put a flyback-diode over the coil.


HTH,
Mark Van Borm
 
P

petrus bitbyter

Jan 1, 1970
0
Captain Dondo said:
OK, I have a real basic question....

I have an embedded computer. It had digital I/O. Per the manufacturer,
"When the DIO pins are configured as outputs, they can source 4 mA or sink
8 mA and have logic swings between 3.3V and ground."

OK, I prefer to work as source. So... How do I get 4 ma @ 3.3V to
control a 5V relay that needs 100 ma to operate?

ISTR something about transistors, but it's been a few years since my
electronics classes....

Right now I need to be able to power LEDs, but eventually I need to siwtch
120 VAC and 24-48 VDC at a few amps load, and I thought I could use relays
for that. But this has thrown a wrench into the works....

Any suggestions?

Thanks,

--Yan

Yan,

A transistor solution shown below. The NPN are general purpose transistors
like BC547. Don't forget the diode otherwise your transistor will be blown.
An 1N4148 or similar will do. A much simpler solution is using a FET.
A BSS295 or similar will do.


+---+----+------+5V -+-----+-
| | | | |
| - _|_ | |
.-. ^ |_/_|- - _|_
| | | | ^ |_/_|-
330| | +----+ | |
'-' | | |
| | +-----+
| |/ |
+------| NPN |
| |> |
| | |-+
___ |/ | ----->| BSS295
-|___|--| NPN | |-+
5k6 |> | |
| | |
| | |
----------+--------+-------- --------+-----
GND
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de


petrus bitbyter
 
E

ehsjr

Jan 1, 1970
0
petrus said:
Yan,

A transistor solution shown below. The NPN are general purpose transistors
like BC547. Don't forget the diode otherwise your transistor will be blown.
An 1N4148 or similar will do. A much simpler solution is using a FET.
A BSS295 or similar will do.


+---+----+------+5V -+-----+-
| | | | |
| - _|_ | |
.-. ^ |_/_|- - _|_
| | | | ^ |_/_|-
330| | +----+ | |
'-' | | |
| | +-----+
| |/ |
+------| NPN |
| |> |
| | |-+
___ |/ | ----->| BSS295
-|___|--| NPN | |-+
5k6 |> | |
| | |
| | |
----------+--------+-------- --------+-----
GND
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de


petrus bitbyter

Nice. Another possibility is a darlington:



+----+------+5V
| |
- _|_
^ |_/_|-
| |
+----+
|
___ |/
--|___|----| TIP120
5k6 |>
|
|
Gnd -----------------+--------

Ed
 
J

Jonathan Kirwan

Jan 1, 1970
0
Yan,

A transistor solution shown below. The NPN are general purpose transistors
like BC547. Don't forget the diode otherwise your transistor will be blown.
An 1N4148 or similar will do. A much simpler solution is using a FET.
A BSS295 or similar will do.


+---+----+------+5V -+-----+-
| | | | |
| - _|_ | |
.-. ^ |_/_|- - _|_
| | | | ^ |_/_|-
330| | +----+ | |
'-' | | |
| | +-----+
| |/ |
+------| NPN |
| |> |
| | |-+
___ |/ | ----->| BSS295
-|___|--| NPN | |-+
5k6 |> | |
| | |
| | |
----------+--------+-------- --------+-----
GND
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de


petrus bitbyter

I think the OP was asking that when the I/O is _sourcing_ 4mA, that
this is when the relay should be turned on. I may have misunderstood,
though.

Jon
 
J

Jonathan Kirwan

Jan 1, 1970
0
Nice. Another possibility is a darlington:



+----+------+5V
| |
- _|_
^ |_/_|-
| |
+----+
|
___ |/
--|___|----| TIP120
5k6 |>
|
|
Gnd -----------------+--------

Ed

That's more like what I imagined for the OP, since that turns on the
relay when the I/O is sourcing. However, assuming that the TIP120 is
a Darlington, this also tosses away some extra of the very few volts
available at +5V for the relay.

So, what about:

: +5 +5
: | |
: | |
: \ |
: / R1 |
: \ 10k |
: / |
: | |<e Q2
: +---------| 2N3906
: | |\c PNP
: | |
:3.3V I/O R3 |/c Q1 |
: CONTROL------/\/\---+----| 2N3904 |
: SIGNAL 10k | |>e NPN +---------,
: \ | | |
: / R4 | )| 5V |
: \ 100k | )| RELAY |
: / \ )| --- D1
: | / R2 )| / \ 1N914
: | \ 1k | ---
: | / | |
: | | | |
: gnd | | |
: gnd gnd gnd


Jon
 
P

petrus bitbyter

Jan 1, 1970
0
Jonathan Kirwan said:
I think the OP was asking that when the I/O is _sourcing_ 4mA, that
this is when the relay should be turned on. I may have misunderstood,
though.

Jon


You're right. The transistor solution shown above inverts the output signal
which might not be wanted. The FET solution does not invert. As you have 4mA
source available, you may use a single transistor as shown below. You - or
the OP - only need to keep an eye on the type of transistor choosen. Its
current amplification should be high enough to drive the transistor fully
into saturation at the 100mA collectorcurrent required. So not every general
pupose transistor will do. In both transistor solutions the transistor that
drives the relay should have not too high a VCEsat, so to keep enough
voltage for the relay.

+5V----+-----+-
| _|_
- |_/_|-
^ |
| |
+-----+
|
|
___ |/
---|___|--|
680 |>
|
|
|
GND---------+--
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

petrus bitbyter
 
P

petrus bitbyter

Jan 1, 1970
0
Jonathan Kirwan said:
That's more like what I imagined for the OP, since that turns on the
relay when the I/O is sourcing. However, assuming that the TIP120 is
a Darlington, this also tosses away some extra of the very few volts
available at +5V for the relay.

So, what about:

: +5 +5
: | |
: | |
: \ |
: / R1 |
: \ 10k |
: / |
: | |<e Q2
: +---------| 2N3906
: | |\c PNP
: | |
:3.3V I/O R3 |/c Q1 |
: CONTROL------/\/\---+----| 2N3904 |
: SIGNAL 10k | |>e NPN +---------,
: \ | | |
: / R4 | )| 5V |
: \ 100k | )| RELAY |
: / \ )| --- D1
: | / R2 )| / \ 1N914
: | \ 1k | ---
: | / | |
: | | | |
: gnd | | |
: gnd gnd gnd


Jon


May work but my main objection is the 2N3904 is used as a lineair amplifier.
The base current though the 2N3906 may not be high enough to drive the
transistor into saturation. Used in another - simpler - circuit, the 2N3904
may do it all on its own. (See my other posting.) I'd remove R4 as it has no
use and lower R3 to let's say 1k so to use the available control current.
Then I'd remove (short) R2 but place a similar or even somewhat lower
resistor between the base of Q2 and the R1/Q1 node to limit the base current
for Q2.

petrus bitbyter
 
J

Jonathan Kirwan

Jan 1, 1970
0
You're right. The transistor solution shown above inverts the output signal
which might not be wanted. The FET solution does not invert. As you have 4mA
source available, you may use a single transistor as shown below. You - or
the OP - only need to keep an eye on the type of transistor choosen. Its
current amplification should be high enough to drive the transistor fully
into saturation at the 100mA collectorcurrent required. So not every general
pupose transistor will do. In both transistor solutions the transistor that
drives the relay should have not too high a VCEsat, so to keep enough
voltage for the relay.

+5V----+-----+-
| _|_
- |_/_|-
^ |
| |
+-----+
|
|
___ |/
---|___|--|
680 |>
|
|
|
GND---------+--
created by Andy´s ASCII-Circuit v1.24.140803 Beta www.tech-chat.de

petrus bitbyter

I agree. For a really low Vcesat at pretty high currents, the TIP42A
is decent. But in this case at 100mA, I think the common 2n3904 won't
be too bad.

What bugs me and what drove me to offer two BJTs as a solution is that
the OP probably has no real idea what the output voltage is at when
sourcing 4mA. The OP sees the specification, but I wouldn't be
surprised to see a drop of almost a volt at that current (200 ohms in
the FET, or even more, isn't unusual.) So I'd generally rather add
another BJT just to keep it as "no problem, at all" and just not worry
about the question. Plus, it does put that nasty relay inductor just
a little bit further away from the I/O. :) Well, that's how I was
thinking, anyway.

Jon
 
J

Jonathan Kirwan

Jan 1, 1970
0
May work but my main objection is the 2N3904 is used as a lineair amplifier.
The base current though the 2N3906 may not be high enough to drive the
transistor into saturation.

Okay. I think that's a valid criticism to consider. I happen to like
keeping Q1 out of saturation, myself. But let's look at the details
and see where that goes.

The arrangement of R3 and R4 yields about 90% of the 3.3V (current
required is minimal and won't pull down the I/O pin) or say 3V at the
base of Q1. This means that about .6V or .65V less than this will
appear at the emitter of Q1. That alone suggests about (3 - .65)/1k
or 2.35mA collector current for Q1. With the collector voltage no
more than the harder-driven Q2 Vbe below 5V, or let's say about 4.15V,
this means about 0.85V/10k or 85uA through R1. This leaves most of
the 2.35mA or let's say at least 2.2mA for base drive on Q2.

With 100mA drive for the coil, even if 200mA for a short time, the
2.2mA will probably be okay as base drive for it. It's a relay though
with inductance, so it probably will be a ramp up on the current until
the DC ohms takes over.

It seems okay.
Used in another - simpler - circuit, the 2N3904
may do it all on its own. (See my other posting.)

I think I agree. I just don't like pulling the mA out of the I/O, I
guess.
I'd remove R4 as it has no use

I added it for the specific scenario that the circuit might be tested
without an I/O actually connected. I just wanted to make sure there
was a little bit of pull-down to keep Q1 off in such a case.
and lower R3 to let's say 1k so to use the available control current.

Well, not unless you also kill R2.
Then I'd remove (short) R2

Ah, there you killed it. But then you are sucking that current out of
the I/O. I suppose that's okay. I just prefer overkill. For a
one-off (which is all I ever try and make), anyway.
but place a similar or even somewhat lower
resistor between the base of Q2 and the R1/Q1 node to limit the base current
for Q2.

A problem you created by deleting R2, which I had in the circuit in
the first place and yielded a nice, poor-man's controlled current sink
for the base drive.

Jon
 
E

ehsjr

Jan 1, 1970
0
Jonathan said:
I agree. For a really low Vcesat at pretty high currents, the TIP42A
is decent. But in this case at 100mA, I think the common 2n3904 won't
be too bad.

What bugs me and what drove me to offer two BJTs as a solution is that
the OP probably has no real idea what the output voltage is at when
sourcing 4mA. The OP sees the specification, but I wouldn't be
surprised to see a drop of almost a volt at that current (200 ohms in
the FET, or even more, isn't unusual.) So I'd generally rather add
another BJT just to keep it as "no problem, at all" and just not worry
about the question. Plus, it does put that nasty relay inductor just
a little bit further away from the I/O. :) Well, that's how I was
thinking, anyway.

Jon

I got to thinking some more about this. Why are we restricting
Vcc to 5 volts? It may be an artifical restriction. Later on he
will have 120VAC and 28-48 DC that he wants to switch with a
relay. Nothing says he can't use those (or any other) sources to
power the relay. He can use a single bjt/fet/darlington as
a driver stage. If there's no common ground, or if the 5V is
all that's available, he could drive an opto with the driver stage.
Opens up the choice of relays, too.

Ed
 
K

Kitchen Man

Jan 1, 1970
0
OK, I have a real basic question....

I have an embedded computer. It had digital I/O. Per the manufacturer,
"When the DIO pins are configured as outputs, they can source 4 mA or
sink 8 mA and have logic swings between 3.3V and ground."

OK, I prefer to work as source. So... How do I get 4 ma @ 3.3V to
control a 5V relay that needs 100 ma to operate?

ISTR something about transistors, but it's been a few years since my
electronics classes....

Right now I need to be able to power LEDs, but eventually I need to
siwtch 120 VAC and 24-48 VDC at a few amps load, and I thought I could
use relays for that. But this has thrown a wrench into the works....

Any suggestions?

Check out this paper:

http://www1.jaycar.com.au/images_uploaded/relaydrv.pdf

and realize there are integrated circuit relay drivers that will
vastly simplify your design requirements, for instance:

http://www.ee.washington.edu/stores/DataSheets/cd4000/74c908.pdf
 
J

Jasen Betts

Jan 1, 1970
0
OK, I have a real basic question....

I have an embedded computer. It had digital I/O. Per the manufacturer,
"When the DIO pins are configured as outputs, they can source 4 mA or
sink 8 mA and have logic swings between 3.3V and ground."

OK, I prefer to work as source. So... How do I get 4 ma @ 3.3V to
control a 5V relay that needs 100 ma to operate?


NPN transistor (eg BC337) emitter to ground colector to relay coil
other end of relay coil to +5V supply, diode (eg 1N4001) with the
cathode (banded end) to +5V and the other end to the collector,
base of the transistor goes to a 1K resistor and the other end of the
resistor goes to the chip's output pin.
Right now I need to be able to power LEDs, but eventually I need to
siwtch 120 VAC and 24-48 VDC at a few amps load, and I thought I could
use relays for that. But this has thrown a wrench into the works....

for switching the 120AC it may be easier to use a triac and a MOC3010
opto-isolator.

for the DC 48V is kind of high for a commonly available relay to switch
(most 240VAC relays are only good to 30VDC) a power MOSFET may be better
suited.

Bye.
Jasen
 
J

Jasen Betts

Jan 1, 1970
0
I got to thinking some more about this. Why are we restricting
Vcc to 5 volts? It may be an artifical restriction. Later on he
will have 120VAC and 28-48 DC that he wants to switch with a
relay. Nothing says he can't use those (or any other) sources to
power the relay. He can use a single bjt/fet/darlington as
a driver stage. If there's no common ground, or if the 5V is
all that's available, he could drive an opto with the driver stage.
Opens up the choice of relays, too.

at 4ma source and 8ma sink capacity he can drive pretty much any opto
coupler directly.
 
E

ehsjr

Jan 1, 1970
0
Jasen said:
at 4ma source and 8ma sink capacity he can drive pretty much any opto
coupler directly.

Perhaps - but connecting an opto directly? What protects
his embedded computer? Use a driver! The 4K7 (or whatever)
base resistor protects the computer from shorted LED or
bjt, and keeps the current minimal during normal operation.

Ed
 
R

Richard

Jan 1, 1970
0
How many outputs would you have total? You can use a darlington ULN2804?
has 8 of these in a single chip which will drive loads of 500 ma per output,
with freewheeling diodes available internally, and very easy to interface
to. You can drive the LED's off this, or the relays, or both.

I use these all the time for TTL to Relay Drivers. My control board Outputs
are rated at 6ma.

Richard
 
Top