Connect with us

Question about using PNP as 12V switch, but driven by CMOS

Discussion in 'Electronic Basics' started by James W, Mar 2, 2004.

Scroll to continue with content
  1. James W

    James W Guest

    I need to switch a 12Vdc load. I'd like to use a PNP transistor, because
    this would allow me to simply ground the base(though a resistor) to
    turns things on. However, this circuit will generally be driven by a

    My understanding is that one would typically use a PNP as a top-side
    switch, i.e. connect the emitter to 12V, and the collector to the load,
    and finally, the load to ground.

    A pullup on the base would switch the transistor OFF, and pulling the
    base down through a resistor, would turn the transistor ON.

    However, this means that there will be 12V on the base, and the
    microprocessor is at 5V, so things are not good.

    Clearly, one doesn't have this issue using a bottom-side NPN transistor,
    but then one has a tougher time turning the transistor ON when the
    microprocessor is not present.

    (If this 'switch stuff' is confusing.. just realize that I'd like to be
    albe to 'override' the microprocessor with a physical switch from time
    to time)

    So, is there any simple design that allows me to have a simple "ground
    this pin with a switch' override of a microprocessor controlled
    transistor switch for 12V?

    p.s. Load current is ~150mA inductive (a coil relay to be specific)
  2. Gareth

    Gareth Guest

    I don't see why it is more difficult, you just need to pull the base
    high instead of low. Why can't you connect the base to +12V (or +5v)
    through a resistor? Maybe you don't have a positive voltage where you
    want the switch or something like that?
    Is there any reason why you can't just bypass the transistor with the
    switch so that the switch directly activates the relay? I mean use an
    NPN transistor between the relay and ground, and connect the switch
    between the relay and ground.

    If, for some reason, you can't do this you can use an NPN transistor
    controlled by the microcontroller to pull the base of the PNP transistor

    You could also do it the other way round and have an NPN transistor
    activate the relay, and pull the base high using a PNP transistor. The
    PNP transistor being turned on by connecting a resistor to ground.


  3. Gareth

    Gareth Guest

    James W wrote:

    Don't forget to add a diode when switching an inductive load.

  4. Use an NPN transistor/PNP transistor combination as follows:

    +-----+ VCC
    .-. |
    10k| | |
    | | |
    '-' |
    | |e
    1k | |c
    ___ |c |
    uC -|___|-b| |
    |e .--|--.
    | | |
    | |Load |
    | | |
    | '--|--'
    | |
    +-----+ GND

    created by Andy´s ASCII-Circuit v1.24.140803 Beta

    uC = 5V means load is powered
    uC = 0V means load isn't powered

    Another way is to use a zener diode:

    | |
    .-. |
    | |1k |
    | | |
    '-' |
    | ___ |e
    | 1k |c
    - |
    ^8.2 Znr |
    | Load
    uC +---+ |

    created by Andy´s ASCII-Circuit v1.24.140803 Beta

    Bob Monsen
  5. James W

    James W Guest

    hmmm, this doesn't look right... There's nothing to limit the base
    current through the PNP, is there?

    - jim
    In this one, seems like we might run into trouble if VCC were to rise
    above 13.2V. I know I said 12V, but in fact, this is an automotive
    installation, so VCC could rise to ~14 or so volts.
  6. James W

    James W Guest

    If I connect the base to +5, then I'll have quite a bit of base
    current.. No?

    Your idea of using the switch to bypass the circuit is interesting. I'll
    think about that.

    - jim
  7. Right, increase the 1k from the uC to the base to 47k. 1k might allow too
    much current to flow through the upper PN junction. Or, you could use an
    emitter resistor.
    OK. This won't work with VCC above about 13.8V. A zener that puts you in the
    range of VCC to VCC - 0.7 when uC goes from 5V to 0V would be required, but
    if you can't predict VCC with any accuracy, this method isn't very useful.
  8. You probably don't need any additional current gain from the level
    shifting circuit to change the 0 to 5 volt swing from the micro to the
    12 to 11.4 volt base swing on the PNP. So I suggest you use a second
    transistor, an NPN as a level shifter on the output of the micro. Tie
    the base directly to the +5 volt supply and connect the micro output
    to the emitter through a current limiting resistor. Micros are
    usually better at pulling down than up, so this should transfer the
    micro pull down directly to the PNP base (which gets connected
    directly to the NPN collector. You should still keep the PNP base to
    emitter resistor, selected to drain about 10% of the current through
    the NPN to make sure the PNP turns off completely. Don't forget a
    diode across the inductive load to let its current run down with only
    a diode drop across it when the PNP switches off. A 1N4148 or
    something else smallish is fine.

    A 560 ohm emitter resistor on the NPN will allow about 4v/560=7.1mA to
    pass through the NPN to the base of the PNP, while a 1k base to
    emitter resistor will detour about .6v/1000=.6mA leaving about 7.1mA
    -.6mA= 6.5mA to drive the 150 mA load with a gain required of
    150/6.5=23. Use a PNP rated for several times the 150 mA to have
    plenty of gain at the expected load to get a low saturation drop.
    Something rated for 600 ma or more should do fine.

    The thing I like about this arrangement is that it puts no load on the
    5 volt supply and the PNP base current is regulated independently of
    small variations in the 12 volt supply.
  9. No, he is right. I wasn't paying attention initially. Using a 1k resistor,
    when the uC brings up the voltage to 5V, then the base of the NPN will sink
    about (5 - .7)/1000 = 4.3mA. If the NPN has a beta of 100, that means it'll
    sink 430mA. The PNP transistor acts like a diode from VCC to the collector
    of the NPN transistor, so all 430mA (minus the 1.2mA that goes through the
    10k resistor) goes through the base. Thats too much, obviously.

    By increasing the size of the base resistor, the current allowed through the
    NPN transistor is decreased. You can say that the current at the collector
    of the PNP transistor is

    Ic = beta^2 * 4.3/R

    assuming the same beta for both of the transistors. Assume 100. Then we have

    Ic = 43k/R

    So, by putting in a 47k resistor, the current at the collector of the PNP
    transistor is limited to a bit less than an amp, which is probably OK. More
    resistance will limit it even further.

    Note that Vcc doesn't enter into the equation, thus one can use this to
    level shift with impunity.

    Bob Monsen
  10. electricked

    electricked Guest

    I'm new but I think that's what the 10K and the 1K resistors are there for.

  11. Gareth

    Gareth Guest

    You need a resistor between the +V and the base of the NPN transistor,
    just as you would need a resistor between the base of the PNP transistor
    and ground.
    You could also bypass the relay with a mechanical switch.

  12. Limiting the current is a necessity for sure, but doing so with a high
    resistance in a base circuit of the previous stage seems the worst possible
    thing to me. It depends on a Beta that can vary over a wide range especially
    with a rising temperature, so the transistor may well go into thermal
    runaway under some conditions. Since the whole thing is gonna be run off
    spiked voltage with poor regulation and inductive loads facilitating
    oscillation, this method looks like relying on the accuracy of a weather
    forecast for 12.09.2525 :).

    Won't the usual solution "limit the current where it flows" be more
    appropriate? Something like placing a 470R-1K resistor in the NPN's
    collector circuit maybe.

  13. If you do that, the final current would then depend on VCC, and thus be
    dependent on those spikes you were worrying about. You could put a resistor
    between the emitter of the NPN and ground, if you are worried about the laws
    of physics suddenly failing.

    Using a 150k resistor, for example, means that for his application, assuming
    a beta of 200 (which is high) the current through the collector of the NPN
    would be limited to something less than 6mA. I'm guessing that with this
    current, thermal runaway isn't an issue. With a more likely beta, the
    current is even less.
    - Bob Monsen
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