12v switching by 5v ATMega - Source or Sink?

Discussion in 'Embedded Systems and Microcontrollers' started by Sloucher, Feb 7, 2012.

  1. Sloucher

    Thread Starter New Member

    Feb 7, 2012
    23
    0
    Hi Guys
    Can you help a wet behind the ears newby please?
    I have a 5v microprocessor (ATMega328) based circuit that is being used to control various combinations of leds that are supplied with 12v. One of the microprocessor pins (pin B in sketch) presents a pwm signal to the base of an NPN transistor and also the base of a pnp transistor to reciprocally fade two leds up and down. All works well, but I now need to add a switch controlled by pin A to isolate that part of the circuit so both leds can be fully off at the same time. Refering to the sketch attached, will the addition of the npn and pnp transistors inside the dotted area achieve the switching I need do you think?

    Also, I'm going to have to switch a second circuit using a further digital pin. The second circuit is basically a 556 based led flasher circuit driving no more than 250mA worth of led current. Could I simply sink this current with a single npn (2N2222) or do I need to source it with a similar setup as mentioned above?

    If I need to source it, can anyone suggest a transistor array with both npn and pnp suitable transistors?
    Sorry 'bout a)sketch quality and b)my naivety!!
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    The addition of the PinA drive looks OK, but I don't check you with the PNP driver off PinB: With only 5V on the base and a 12V source it probably is not turning off all the way.

    One workaround is to note the collector of the NPN is the inverted signal you desire, so replace the PNP with an NPN and drive that off the first NPN collector.

    I'd do another low side switch using an NPN similar to haw you drive the LEDs. It's the simplest way to go. If you limit your pin drive current to 5mZ then sinking 250mA requires a gain of 50. So using another 2222 will mean it is not hard into sat, but close enough so I would use it and not loose sleep. Others here will disagree and insist on a darlington config.

    And your sketch is worthy of any back-of-the-napkin drawing I have seen. It fits all industry standards as it fully expresses your concept with the least effort. :)
     
    Sloucher likes this.
  3. Sloucher

    Thread Starter New Member

    Feb 7, 2012
    23
    0
    Many thanks Ernie M.

    I'm quite clear over your suggestions regarding a low side switch for the extra circuit, but I'm afraid my limited knowledge has let me down a bit (a lot!) with the logic inversion bit of the other observation!

    Would I be right in thinking that what you are suggesting is much the same as post #10 here: http://forum.allaboutcircuits.com/showthread.php?t=48598 ? If it is, then I'm unsure as to what keeps the signal high in the absense of a connection to the supply line. The role of the single led and resistor in my circuit (20ma, 3.1v fwd volt) wouldn't perform the job of the 10k resistor would it? The arrangement I have at the moment seems to work ok, or it did when breadboarded it, but maybe I ought to look a bit more closely at the leds when they're supposed to be off, just to see if they do extinguish completely. Hope they do as I've already etched the board:rolleyes:!

    Thanks again for the help :)

    Bernie
     
    Last edited: Feb 7, 2012
  4. Sloucher

    Thread Starter New Member

    Feb 7, 2012
    23
    0
    Darn, message to self, open your eyes! Of course it would hold the signal high, d'oh. Only question remains is whether the voltage present on the first transistor collector makes any difference?


    Bernie
     
Loading...