Making a pin sink?


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Aug 2007
    Posts
    67

    Default Making a pin sink?

    Silly question...

    How do I make a pin sink current? I want to use a single pin to open a PNP transistor used as a power switch on the positive rail.

    Do I set it as an input? Do I set it as an output then set it's low state? I guess the direct question - how do I programatically connect a pin to ground? I'd prefer a straight PBP solution.


    And a follow-up question...

    Is it safe to use this switch to actually drive the PIC? So the Pic is downstream, using a push button to temporarily "jump" the transistor, when the Pic boots up it begins to sink current from that transistor causing it to come open, then when the button is released, the Pic continues to operate as usual - essentially latching it's own supply open. When I want to power down, I make that pin stop sinking current which should shut down the Pic (after it's 10uF cap discharges) which should give it time to cleanly execute the last program statements - basically pulling its own power supply.

    But the first question is most important... trail and error, but I'd feel better hearing the "right way" from someone who knows.

    Thanks!

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Do I set it as an output then set it's low state?
    YUP.

    Think of it like this. LED connected anode to positive rail. To make it light with the cathode connected to a PIC pin you would output LOW. (LED has a drop down resistor)

    The same pin will also have a 100K resistor to the positive rail in the transistor case to keep it from floating low.

    I can not see why the transistor idea would not work, have not tried it though.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default

    kevj, What is the potential on the emitter of the transistor in reference to ground? I am assuming you are using it as a pass transistor for the supply to some other circuitry. If you are trying to switch a voltage potential greater than 5volts + .7 volts then the PIC pin connected thru a resistor directly to the base of the transistor will not work. The PIC pin will not open it's circuit completely but have the VDD source voltage present. You will have to put a diode in series with the 1k resistor to the base of the transistor (cathode towards the PIC) so as to block the 5 volts being sourced from the PIC pin. Then a resistor of about 10k from the base of the transistor to the emitter.

    Dave Purola,
    N8NTA

  4. #4
    Join Date
    Aug 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Dave-

    The emitter will see the same 5v supply that's going to Vdd on the PIC. I want to use a single transistor to turn on and off some downstream components.

    After reading more about BOR and using MCLR, I'm not going to use the same transistor to switch the supply to the PIC itself anymore.

    So it's basically just a PNP on the supply side of several downstream components. As those components are spread out a bit and my board space is super limited, I wanted to switch them all with 1 transistor (well within it's power rating), rather than putting NPN's on the ground side of all the components or having to route ground traces everywhere.


    Right now I've got the schematic like this......


    {5v Supply} ----------------------- {PIC}
    |
    |
    -------------{NPN}------ collector to downstream loads --->
    |
    |----- base via a 2k resistor direct to PIC pin set as Output


    I've seen this setup in several other schematics and never saw a diode in there - maybe that's only required if driving the pic's supply itself as I stated in my OP?

    When the Pic boots up, it'll bring that pin low to turn on the downstream stuff, then before "shutting down" it'll bring it high then sleep which will bring it's MCLR low as well as pulling Vdd below the BOR - so it should be shut all the way down.

    What I don't understand is why that pin (to the PNP base) doesn't drop back to ground when the PIC goes into reset. I've tried it with an LED being sunk, and the LED does go out as soon as the PIC shuts down, so it would seem that reset does not cause all the output pins to click back to ground.

    Can someone give me a warm fuzzy that this is correct? I don't want a PIC in reset to allow a pin to float back down to ground (after being in reset for say - a week or two), and all of a sudden that PNP comes open again and powers up all the downstream stuff without the PIC being alive. Nothing really bad would happen except it would quickly kill the limited onboard battery supply.

    Thoughts?

    Thanks!!

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    When the pic boot, usually all I/O are configured as input. The small nifty voltage could be just enough to trigger your transistor, PNP or NPN. What we usually use if we can't deal with the settle delay (Bor, Power up timer etc etc) OR to keep things safe while using Bootloader or ICSP, is to add a simple resistor between the Base and the Collector. This way it solve the problem.

    <IMG SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2175&stc=1&d=119670537 4">
    Attached Images Attached Images  
    Last edited by mister_e; - 3rd December 2007 at 18:15.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Aug 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Thanks e. That's perfect. That's exactly the way I've got it in my schematic. I'm using a 2k resistor for the base, and a 20k for the bridge to Vcc (I read "use 10x the amount") on another site.

    I'm still don't totally understand exactly what's happening or why I need the bridge to Vcc, but I see it in every example I look at so it's in there.


    Anyway, using that example, there should be no way for the Pic to continue to sink current and open the transistor when it is in reset - correct? Or should I switch that pin to an input programatically before allowing the Pic to go into reset?

    Part of the output of that transistor is what will hold MCLR high, so that's the main reason I want to make sure once it's off it stays off. I've got a tact switch that jumps over all of this via a diode to boot up the Pic.

    Thanks again... I think I'm on the right track anyway.

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. DS1820 with 16f688
    By jessey in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd May 2009, 05:07
  3. Advice-scrutiny for my serial controller
    By kevlar129bp in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th December 2008, 17:11
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts