Maker Pro
Maker Pro

Driving relay with transistor question

What I think I understand:

Picture trying to drive a relay with a Basic Stamp microcontroller.

The output pin on the Stamp won't sink or source enough current to
power the coil on the relay. So we add an NPN transistor.

We wire a diode parallel to one of the relay coil terminals, to
truncate the analog junk that the coils will generate. We wire the
other coil terminal to the collector of the NPN transistor. The
emitter of the transistor is wired to ground, and the output pin of the
Stamp is wired to the base. When the output pin goes high, it
saturates the transistor, current flows through the relay coils, and
the relay throws.

But what if I want to add an LED indicating that the relay is thrown?

Driving an LED from an output pin is easy - LED + current-limiting
resistor in series between the pin and ground.

But driving an LED and a relay from the same pin?

Where do I put the LED?

In series between the output pin and the base of the transistor?

In series with the relay coil?

In series between the emitter of the transistor and ground?

Between the output pin and ground, parallel with the transistor?

Seems to me that any of these would work.

What's the most usual practice?

And why?
 
J

John Fields

Jan 1, 1970
0
What I think I understand:

Picture trying to drive a relay with a Basic Stamp microcontroller.

The output pin on the Stamp won't sink or source enough current to
power the coil on the relay. So we add an NPN transistor.

We wire a diode parallel to one of the relay coil terminals, to
truncate the analog junk that the coils will generate. We wire the
other coil terminal to the collector of the NPN transistor. The
emitter of the transistor is wired to ground, and the output pin of the
Stamp is wired to the base. When the output pin goes high, it
saturates the transistor, current flows through the relay coils, and
the relay throws.

But what if I want to add an LED indicating that the relay is thrown?

Driving an LED from an output pin is easy - LED + current-limiting
resistor in series between the pin and ground.

But driving an LED and a relay from the same pin?

Where do I put the LED?

In series between the output pin and the base of the transistor?

---
No, since that would force you to push the current to operate the
LED into the base of the transistor from the output pin of the BS
---
In series with the relay coil?

---
No, since that would require the LED to carry the relay's coil
current.
---
In series between the emitter of the transistor and ground?

---
No, since that would require the LED to carry the relay's coil
current as well as the transistor's base current.
---
Between the output pin and ground, parallel with the transistor?

---
No, since if it was wired in on the stamp side of the base resistor
the transistor would never turn on, and if it was wired in on the
transistor side of the base resistor the LED would never turn on.
---
Seems to me that any of these would work.

---
Oh well...
---
What's the most usual practice?

---

+V
|
+-------+-------+
| | |
|K | [R]
[DIODE] [COIL] |
| | [LED]
| | |K
+-------+-------+
|
C
DRIVE>--[R]---B NPN
E
|
GND
---
 
J

Jeff Dege

Jan 1, 1970
0
Where do I put the LED?
What's the most usual practice?

---

+V
|
+-------+-------+
| | |
|K | [R]
[DIODE] [COIL] |
| | [LED]
| | |K
+-------+-------+
|
C
DRIVE>--[R]---B NPN
E
|
GND

---

In parallel to the coil?

Set R so that the LED gets only the current it needs. Depending upon +V
and the internal resistance of the coil, might also need a resister in
series with the coil to ensure it draws no more than it should.

Seems simple enough.

Thanks.

--
Law and its instrument, government, are necessary to the peace and safety
of all of us, but all of us, unless we live the lives of mud turtles,
frequently find them arrayed against us. Worse, we are very apt to
discover, facing their sudden inhibition of our desires, that their
reputed impersonality and impartiality are myths - that the government
whose mandates we almost instinctively evade is not the transcendental and
passionless thing it pretends to be, but simply a gang of very ordinary
men, and that the judge who orders us to obey them is another of the
same kind...
- H. L. Mencken
 
B

Bob Monsen

Jan 1, 1970
0
In series between the output pin and the base of the transistor?

A PIC will source 20mA or more from out output. That will really saturate
the NPN. You can probably cut that back to less than 10mA using a resistor
between output and base, and still maintain saturation. If you do this,
you can just put the LED in series here.

--
Regards,
Bob Monsen

PATRICIA PAIWONSKI gave Ben Caxton the all-out kiss of brotherhood
before he knew what hit him.
 
R

Rich Grise

Jan 1, 1970
0
+V
|
+-------+-------+
| | |
|K | [R]
[DIODE] [COIL] |
| | [LED]
| | |K
+-------+-------+
|
C
DRIVE>--[R]---B NPN
E
|
GND

---

In parallel to the coil?

That's the one. :)
Set R so that the LED gets only the current it needs. Depending upon +V
and the internal resistance of the coil, might also need a resister in
series with the coil to ensure it draws no more than it should.

No, you buy a relay that has a coil rated for +V volts. The resistance of
the coil (and the applied voltage) is what determines its current.
Seems simple enough.

Yup!

Cheers!
Rich
 
J

Jasen Betts

Jan 1, 1970
0
But what if I want to add an LED indicating that the relay is thrown?

Driving an LED from an output pin is easy - LED + current-limiting
resistor in series between the pin and ground.

But driving an LED and a relay from the same pin?
Where do I put the LED?

In series between the output pin and the base of the transistor?

may reduce the drive takes drive current to the base of the transistor,
will work if that's not critical.
In series with the relay coil?

will be passing all the relays coil current, could destroy the led,
In series between the emitter of the transistor and ground?

will be passing all the relays current, may reduce VBE
Between the output pin and ground, parallel with the transistor?

may reduce the drive available to the transistor,
Seems to me that any of these would work.
What's the most usual practice?

in series with a resistor, both parallel with the relay coil

it's least likely to make a critical difference.

putting it before the transistor limits the avalailable current or voltage
putting it in series with the relay (or emitter) limits you to relays with
low current coils.

in parallel with the relay it makes little difference as the relay is
probably consuming more current than the LED etc...

Bye.
Jasen
 
Top