Connect with us

Q: Transistor as a switch with pull down ?

Discussion in 'Electronic Basics' started by Benjamin Sølberg, Jun 26, 2007.

Scroll to continue with content
  1. Hi all.

    I am interfacing an PIC microchip to a relay by using a normal NPN
    transistor. The relay is connected between +12v and collector. A
    protection diode in reverse has also added. Emitter is grounded. My
    concerne is that by only adding a 10k resistor between base and the
    digital output pin (5v) the base will be floating if the PIC failes to
    start as all IO pins are default input. Would it be correct to add a
    pulldown resistor at 10k and replace the IO pin to base with say a 1k
    resistor.

    I have been looking at schematics by searching in google but it seems
    that every one of them i found are just having a IO to base resistor
    with no pull down.

    What would any of you advise ?

    Regards
    Benjamin
     
  2. Eeyore

    Eeyore Guest

    For what purpose ? The transistor's leakage current won't be enough to turn the
    relay on.

    Graham
     
  3. You might be right. I just wanna make sure that the transistor doesn't
    turn on because it is floating
    as the microcontroller is defaulted to an input pin upon startup.

    So to be short: Even if the micro controller does nothing else than an
    infinit loop after startup and the IO pis is
    defined as an input there are no chance of the base of the transistor
    can go beyond 0,7v and thereby setting
    the collector emitter in an on state, even so that no other resistor
    is on the base except the one from base to
    the IO pin (defined as an input) ?

    I hope you don't mind my exact question. I am just trying to make sure
    i understod everything.

    Regards
    Benjamin
     
  4. Eeyore

    Eeyore Guest

    If the uC defaults to an input on start up is there an internal pull-up ?

    Maybe it's wise to have a resistor from base to ground anyway. Say 4k7.

    Graham
     
  5. I think he's basically saying that internal leaking in the BJT plus
    any pin leakage (input pins still leak, though not all that much)
    shouldn't be enough to cause the transistor to pass 100's of mA. Even
    for a moment. Some folks may also worry about you rubbing your feet
    on a carpeted floor on a cold dry day and static-zapping the higher
    impedance base node of the BJT and doing something untoward. But it's
    not exactly floating as there are protection diodes and other
    impedances present on the node. So although I'm not an expert on the
    details, my experience would say it's just fine without the pull-down.
    But it won't hurt anything, either. And if this were pinned out to a
    connector, I'd add the pull-down.

    Jon
     
  6. Exactly my point, but looking at schematics around the net i usually
    only see a resistor between base and IO pin.
    And i was surprised so i just wanted to know if this is normal/good
    pratice.

    Regards
    Benjamin
     
  7. Hi

    The uC (PIC12F508) has internal pullup but you must enable it first as
    i understood from the spec.

    Ok so it looks like it is safe to just have the base to IO resistor.

    Say I remove the IC from the socket (to program it) and accidentally
    powers on the circuit, nothing is now connected
    to the base except for a resistor with one pin floating. Will it be
    able to turn on in any way (without the pull down resistor) ?

    Again, I am just trying to learn something from you guys :)

    Regards
    Benjamin
     
  8. John Fields

    John Fields Guest

    ---
    Good practice dictates that you know what your circuit is doing all
    the time, and even though it's tempting to think that a floating
    base won't affect anything downstream, it might.

    Consequently, it's a good idea to pull the base down (or up,
    depending on what your circuit's supposed to do) in order to take
    the uncertainty out of it.

    Be careful with attaching too much importance to what the donkey
    states.

    Note that he's back-pedaling in order to try to fix his earlier post
    and hasn't stated whether the pull-down should be on the µC side or
    on the transistor side of the series-connected base resistor.
     
  9. Even without that enabled, there is leakage. The spec for the part
    will disclose that value, too. The programable pull-up (weak mosfet)
    just adds to that.
    I can't tell you professional practice. My knowledge is as a hobbyist
    only. I have used pull-downs before, myself, just to make myself more
    comfortable. And if I were sending this line to a connector, I'd
    definitely use a pull-down. I want to KNOW where the input signal is
    going to be at, in that case. The extra resistor gives me comfort, if
    nothing else.

    But I'm not a professional, so others will have to weigh in on that
    score.
    If this is to an important relay, let's say, and you are likely to
    have folks replacing microcontrollers while powered up, I'd add the
    resistor. Yes, having a nice, low impedance to ground to hold the
    base is a 'nice to have.' In hobby stuff, I do it sometimes when it
    is convenient (I'm not wire-wrapping or point-to-point soldering it
    all up, in other words.)
    Well, if you are just asking if tethering the base to ground via a
    nice resistor will cover more unintended ground, then yes it will.

    Jon
     
  10. Hi JF

    :)

    I think I would add the pulldown between base and ground and a current
    limiter between base and IO.
    It seems to be the safest way for me.. as a hobbyist as well :)
    A 10K to ground and a 1K to IO (or perhaps a 4.5K)

    Would you agree on that ?

    Regards
    Benjamin
     
  11. I will add the pull down then from base to ground.

    Thank you all for your help.

    Regards
    Benjamin
     
  12. Eeyore

    Eeyore Guest

    Couldn't resist sniping eh ?

    Exactly what part of " base to ground " is unclear ?

    Graham
     
  13. That's the safer/surer side. Best of luck (though it seems you are
    going to be fine without luck in this case.)

    Since you are searching for various approaches here, you might also
    consider inserting a zener in series with your protection diode across
    the relay coil. The rate at which current declines is proportional to
    the voltage across (from dI/dt = V/L) it and adding a zener lets a
    somewhat larger voltage to develop which allows a faster dI/dt. That
    has some benefits, at times. Use something reasonable (most any
    common value.) If you don't have the diode or diode+zener, I believe
    what happens is that your BJT has its own breakdown voltage and the
    coil just dumps through the BJT after achieving its own breakdown
    voltage. That may or may not be okay, which is part of why diodes,
    zener+diodes, or RC snubbers are added.

    I don't recall reading what the coil current needs to be, but there is
    another consideration here in sizing your base drive resistor (not the
    pull-down.) If you plan to use the BJT as a switch, where the voltage
    between the emitter and collector is minimized and below say 0.3V or
    so, you should imagine that the BJT is well into saturation and the
    effective beta is then low. I usually figure about beta=20 for modern
    general purpose transistors and beta=10 for the old ones I may find in
    an old box of parts. That means you need to figure on about 1/20th or
    1/10th of the collector current into the base. Your PIC can handle a
    fair amount on its own (worst case is 25mA, I think, but that is an
    absolute maximum if memory serves and not something to rely upon for
    normal use.) And as yuo pull more current from the PIC, the voltage
    drops at the PIC's I/O pin. I figure about 80-90 ohms driving low and
    about 120 ohms driving high. Since you would be driving high, keep in
    mind that there is some voltage drop going on inside the PIC. Use
    that to help calculate your resistor.

    For example, let's say that you wanted the collector to handle about
    100mA for your relay and you are using a 2N3904. I'd say beta=20 and
    figure that the base needs 100mA/20 or 5mA. If the PIC is running on
    5V (I think you said as much), then the I/O pin will be at 5 - 5mA*120
    or about 4.4V (rough guess.) I usually figure a base-to-emitter
    voltage of about 0.7V when passing 100uA into the base. 5mA is about
    50 times that much. With about 60mV per decade of current change,
    this suggests about an additional 100mV or so (close to two decades
    worth.) So make it 0.8V. With 5mA, small general purpose transistors
    like this are getting a bit non-log-linear though after about 1mA of
    base current. So add another .1V just to be safe. Call it 0.9V. Your
    resistor is then (4.4V - 0.9V) / 5mA or 700 ohms. A 10k would
    obviously be too weak in a case like that. On the other hand, if you
    only need about 10mA for the collector current, that would drop the
    base needs to 10mA/20 or about 500uA. We are talking now about a base
    voltage of say 0.7V + 40mV or .74V. Your PIC will only drop about
    60mV, so now we compute (4.94 - 0.74) / 500uA or 8400 ohms for the
    base resistor. That's more like the 10k you are talking about,
    earlier.

    If you can accept a volt or more drop across the collector/emitter of
    the BJT, then your gain is more like beta=100 to 200. And you don't
    need as much base current to drive the collector current. But then
    you lose some of the voltage applied to the coil, too. And you may
    need to consider power dissipated in the transistor.

    Jon
     
  14. John Fields

    John Fields Guest

     
  15. neon

    neon

    1,325
    0
    Oct 21, 2006
    add hysterisis from the output so if it on it is on if off it is off
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-