Shop OBEX P1 Docs P2 Docs Learn Events
Driving Relay Digitally From Stamp? — Parallax Forums

Driving Relay Digitally From Stamp?

ArchiverArchiver Posts: 46,084
edited 2001-05-01 22:33 in General Discussion
Hi all,
I'm still tying to figure out the circuit to drive a 120VAC 12amp
solenoid from the Stamp.

From the FAQ:
"Another excellent way to switch a high-current load is using a power
MOSFET. Radio Shack sells the IFR-510 which is ideal for use with the
Stamp and quite inexpensive (less than $2)."


Would someone mind looking over the schematic below and point out what
if anything is wrong or missing? I'd appreciate it as this is the
first time I've used a digital device to drive a relay and I'm coming
up against the wall of my knowledge.
I am uncertain what rating Power MOSFET I will need, and what rating to
use for the DIODE to protect the relay coil. It will be a first for me
using these components. I'll be ording from RadioShack.




To Hi-Power
Relay 120VAC Coil

/\
|
|
O
Low Power RELAY 5VDC COIL
0 0
___________
|_________|
| |
| |
5VDC | |
+
|--|<|--| DIODE protects
|
|
|
|__________|
BS2 | |
GROUND PIN | | N-CHANNEL
0
|--->| | POWER MOSFET
| | | |
|_______________________|____| |_________
| | |
| |
|
-- |

|
|
|
0
BS2 Pin Out




Thanks.
Cheers,
-Neal

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-04-27 22:51
    Typically, you'll drive the gate of the FET with the Stamp pin. You should
    put a 1M resistor from the gate to ground to avoid problems when handling
    the circuit with the power off.

    You'll ground the source and connect the drain to the "cold end" of the
    load. You need enough Idd capacity in the FET to handle the coil's load. If
    you are driving the coil at 5V and the coil's resistance is 100 ohms, then
    you are drawing 5/100 = .05A or 50mA. You don't want a transistor or FET
    right at 50mA because you want some cushion, but 100mA would be OK. The
    510 -- if I remember -- goes to about 2A. A 2N2222 is even cheaper and more
    common and will handle 100mA without much problem. Probably would handle
    more with some cooling.

    If you want to use a 2222, connect the base to the stamp through a small
    resistor (say 1K). Ground the emitter, and connect the collector to the
    "cold end" of the load. These are not as good a switch as a FET, but for
    your purposes, they should do fine and you can buy about 10 2N2222's for
    what an IRF510 will cost.

    Al Williams
    AWC
    * Floating point math for the Stamp, PIC, SX, or any microcontroller
    http://www.al-williams.com/awce/pak1.htm


    >
    Original Message
    > From: lovegasoline@y... [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=HnHvN0QTK9zhIoIHFqy9acOF3f9f8lTj_TDviPO3WT-I7WB6zhy1m3NsWxmPC81h8SBqKkt5cWynPvp10cU]lovegasoline@y...[/url
    > Sent: Friday, April 27, 2001 3:49 PM
    > To: basicstamps@yahoogroups.com
    > Subject: [noparse][[/noparse]basicstamps] Driving Relay Digitally From Stamp?
    >
    >
    > Hi all,
    > I'm still tying to figure out the circuit to drive a 120VAC 12amp
    > solenoid from the Stamp.
    >
    > >From the FAQ:
    > "Another excellent way to switch a high-current load is using a power
    > MOSFET. Radio Shack sells the IFR-510 which is ideal for use with the
    > Stamp and quite inexpensive (less than $2)."
    >
    >
    > Would someone mind looking over the schematic below and point out what
    > if anything is wrong or missing? I'd appreciate it as this is the
    > first time I've used a digital device to drive a relay and I'm coming
    > up against the wall of my knowledge.
    > I am uncertain what rating Power MOSFET I will need, and what rating to
    > use for the DIODE to protect the relay coil. It will be a first for me
    > using these components. I'll be ording from RadioShack.
    >
    >
    >
    >
    > To Hi-Power
    > Relay 120VAC Coil
    >
    > /\
    > |
    > |
    > O
    Low Power RELAY 5VDC COIL
    > 0 0
    > ___________
    > |_________|
    > | |
    > | |
    > 5VDC | |
    > +
    |--|<|--| DIODE protects
    > |
    > |
    > |
    > |__________|
    > BS2 | |
    > GROUND PIN | | N-CHANNEL
    >
    > 0
    |--->| | POWER MOSFET
    > | | | |
    > |_______________________|____| |_________
    > | | |
    > | |
    >
    |
    > -- |
    >
    >
    > |
    > |
    > |
    > 0
    > BS2 Pin Out
    >
    >
    >
    >
    > Thanks.
    > Cheers,
    > -Neal
    >
    >
    >
    >
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-27 23:59
    --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:

    Hi ya Al,

    Thanks a bunch!
    (whew! wiping sweat from furrowed brow)

    > Typically, you'll drive the gate of the FET with the Stamp pin. You should put
    a 1M resistor from the gate to ground to avoid problems when handling the
    circuit with the power off.

    Does this hold true and is it recommended if I use a 2N2222 or is the
    latter more forgiving?

    > You'll ground the source and connect the drain to the "cold end" of the load.
    You need enough Idd capacity in the FET to handle the coil's load. If you are
    driving the coil at 5V and the coil's resistance is 100 ohms, then you are
    drawing 5/100 = .05A or 50mA.

    Calculating driving a 5VDC/55 Ohms Relay coil gives me a 90mA draw
    then.

    > You don't want a transistor or FET
    > right at 50mA because you want some cushion, but 100mA would be OK. The
    > 510 -- if I remember -- goes to about 2A. A 2N2222 is even cheaper and more
    > common and will handle 100mA without much problem. Probably would handle more
    with some cooling.

    What about 90mA? Cutting it too close? Can you recommend one that can
    handle 90mA with a modest price tag?
    The transistor world is still a maze to me and the reference books I'm
    using (by Forrest M. Mimms III) unfortunately don't go into enough
    detail. My books offer no explanation of abbreviations used in
    labeling transister ratings: Vceo, Vcbo, Vebo, Vce(sat), Vbe(sat)Ic(mA)
    such as used in the RadioShack.com catalogue.
    Radioshack lists a 2N2222A (part #900-5428), but I can't figure out the
    rating abbreviations.

    I've added the resister below for MOSFET, kosher?


    To Hi-Power
    Relay 120VAC Coil

    /\
    |
    |
    O
    Low Power RELAY 5VDC COIL,
    0 0 55 ohms, contact rated 10A,120VAC
    ___________
    |_________|
    | |
    | |
    5VDC | |
    +
    |--|<|--| DIODE protects
    |
    |
    |
    Drain> |__________| N-CHANNEL
    BS2 | | POWER MOSFET
    GROUND PIN | |
    0
    |--->| |
    | Source> | | | <Gate
    |_______________________|____| |_________
    | | |
    | |
    |______________________/\/\/\____________|
    | |
    | 1K |
    |
    -- |
    |
    |
    0
    BS2 Pin Out
  • ArchiverArchiver Posts: 46,084
    edited 2001-04-28 01:09
    No, you shouldn't need a grounding resistor for a 2N2222 -- they are pretty
    tough. The problem with FETs is that the insulator under the gate (the gate
    oxide) is very thin (the thinner the better). That means that a high voltage
    can punch through that oxide without much current. When you pet the cat you
    get really high voltages but with no current. For normal electronics that
    isn't a problem -- but with MOS that oxide is very sensitive.

    > Calculating driving a 5VDC/55 Ohms Relay coil gives me a 90mA draw
    > then.

    Yeah... almost 91mA.


    >
    > > You don't want a transistor or FET
    > > right at 50mA because you want some cushion, but 100mA would be OK. The
    > > 510 -- if I remember -- goes to about 2A. A 2N2222 is even
    > cheaper and more
    > > common and will handle 100mA without much problem. Probably
    > would handle more with some cooling.
    >
    > What about 90mA? Cutting it too close? Can you recommend one that can
    > handle 90mA with a modest price tag?
    > The transistor world is still a maze to me and the reference books I'm
    > using (by Forrest M. Mimms III) unfortunately don't go into enough
    > detail. My books offer no explanation of abbreviations used in
    > labeling transister ratings: Vceo, Vcbo, Vebo, Vce(sat), Vbe(sat)Ic(mA)
    > such as used in the RadioShack.com catalogue.
    > Radioshack lists a 2N2222A (part #900-5428), but I can't figure out the
    > rating abbreviations.


    >
    > I've added the resister below for MOSFET, kosher?
    I'd use a 1M resistor not a 1K. Also, the gate (the middle pin) should be
    connected to the Stamp. The source goes to ground and the drain connects to
    the coil:

    +V ---- Coil ---- Drain


    Stamp
    > Gate

    Ground
    Source

    The 1M resistor goes from Gate to Ground. The diode is OK.

    The transistor ratings are not too hard to get a handle on. V is voltage, of
    course. The c, e, b is for collector, emitter, base.

    There are several parameters you will mostly be interested in for a bipolar
    transistor:

    1) Its Ic (collector current).

    2) The Vbe (base emitter voltage which for a silicon transistor is about .6
    or .7V).

    3) The Vce max and saturated. When we use a transistor as a switch, the
    collector tries to go the same voltage as the emitter when the transistor is
    on. But it can't really do that, so the Vce(sat) tells you how close it
    gets. A good transistor should be able to get to .2V or so of the emitter.
    The maximum Vce will determine how much voltage you could apply to your coil
    before you damage the transistor.

    There are many other parameters, but for logic switching, that's the biggest
    ones you care about unless you are trying to build extremely fast switches.

    Think of a bipolar transistor as a diode going from base to emitter. As long
    as you put at least .7V on the base, the transistor will turn "on" to some
    extent.

    What happens is that the current you inject into the base will show up
    multiplied by the transistor's beta on the collector up to a point. When you
    use the transistor as an amplifier, that's the effect you count on. So
    consider this set up:

    Base circuit: 5V into a 10K resistor
    Emitter: grounded
    Collector: 12V and a 200 ohm resistor to the collector

    Because the base-emitter is a diode (sort of), and the emitter is at 0V, the
    base must be at .7V. So the voltage across the 10K resistor is 4.3V (5-.7).
    And the current in that resistor is 430uA. Current is the same in a series
    circuit, so the base current must be 430uA also.

    Say the beta of the transistor is 100. That means the collector current
    would be 43mA. With a 200 ohm resistor and 43mA, the voltage across that
    resistor is 8.6V. Since the supply is 12V, that means the voltage at the
    collector is 3.4V.

    What if the base voltage goes to 5.7V? Now the base current goes to 500uA,
    the collector current is 50mA, and the voltage drop is 10V, which gives you
    2V on the collector. So a .7V increase in the base gives you a 1.4V decrease
    on the collector. So the gain is -2.

    In real life, you don't usually ground the emitter since it gives you
    problems in other ways (cross over and thermal stability problems -- in
    particular, the thermal problems don't show up in my simple analysis because
    I am skipping some subtle but important things). In real life, you'd put a
    resistor in the emitter leg and figure that the collector current and the
    emitter current will be the same (which is almost true if Beta is high
    enough).

    So let's go with the same example, but this time, put a 100 ohm resistor
    between the emitter and ground and keep the 200 ohm resistor in the
    collector.

    Input = 5V
    Emitter voltage = 4.3V (5 - .7)
    So the emitter resistor has 4.3/100 = 43mA
    And the collector also has 43mA
    So the voltage across the collector resistor is again 8.6V and Vc is 3.4V

    Notice that now Beta isn't important except that it is high because Beta
    isn't a very stable parameter (it varies with temp and per device).

    Go to 5.7V again and:
    Ve = 5V
    Ie = 50mA
    Ic = 50mA (about)
    Vc = 12 - (.05 * 200) = 2V

    Same result, but better performance. Also, now the gain is purely the
    collector resistor (Rc) divided by the emitter resistor (Re). Change RC to
    220 and verify that the gain is -2.2.

    But you don't want an amplifier, you want a switch. Go back to a grounded
    emitter and keep the 200 ohm resistor in Rc. Say you put 10mA into the base
    (5/.01 = 500 ohms). Since Beta is nominally 100, the collector current is 1A
    right? Nope. The transistor will flatten out (saturate). Think about this.
    What if Ic was 1A (and that didn't harm the device). The voltage across Rc
    would have to be 200V. So there is no way to do that unless Vc can be
    negative (-188V, to be exact). But Vc can only drop to about .3 or .2V
    before the transistor flattens out. So in real life, you will have about
    11.8V across Rc (59mA) and that's it. That's saturation and that's how you
    switch with a transistor.

    FETs are almost the same, but they use voltage (Vgs) instead of current (Ib)
    to vary their "transconductance" (think of it as resistance). That makes
    FETs work a lot like the old hollow state tubes. Think:

    Gate = Base
    Source = Emitter
    Drain = Collector

    And don't forget you have a voltage-oriented device with a FET instead of
    current.

    All of this discussion assumes NPN transistors. PNP is the same, but the
    current directions all reverse. For what you want NPN is all you need.

    Sorry for the long post, but maybe if you puzzle some of it out, you'll
    understand transistors better.

    The Art of Electronics is great and I love it. However, it isn't a quick
    read. Check out some of Joe Carr's books (what a loss that he passed away
    not too long ago).

    Regards,

    Al Williams
    AWC
    * Connect a PS/2 keyboard to any microcontroller:
    http://www.al-williams.com/awce/pak6.htm
  • ArchiverArchiver Posts: 46,084
    edited 2001-05-01 22:33
    --- In basicstamps@y..., "Al Williams" <alw@a...> wrote:


    [noparse][[/noparse]large snip of a wealth of info]

    Hi ya Al,

    > Sorry for the long post, but maybe if you puzzle some of it out, you'll
    > understand transistors better.

    Thanks for taking the time to share your knowledge. Yes, puzzle it out
    is the right turn of phrase. I think a stout cup of tea and a
    hermetically sealed chanber will provide the conditions for
    understanding entering the spirit of the logic and values behind
    transistor switching cicuit operation.
    I ordered some 2N2222A's along with a bunch of other components and a
    BS2. Tommorow I'll take delivery and start fumbling around going
    through various tutorials, trying different circuits out, hopefully not
    frying things. I need to get my hands dirty and tool around so the
    abstractions can incarnate themselves more solidly onto my workbench.
    Thanks again for the lesson!

    Cheers,
    -Neal
Sign In or Register to comment.