Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 10 of 10

Thread: switchable 12V pull-up resistor

  1. #1

    switchable 12V pull-up resistor

    I'm using Teensy 3.1 in an automotive interface that includes a connection to the OBD2 k-line. That specification requires a terminating 510 Ohm pull-up resistor from the k-line to +12V. If there is an external device connected to the bus, it will have a terminating resistor; when there is no such device, I'd like the Teensy to be able to enable the pull-up.

    From what I gather, this requires some fashion of high-side switching, since the k-line idles at +12V. It seems I could accomplish this with a NPN transistor feeding a PNP transistor, or through MOSFETs with the same arrangement. There are of course details that I'm trying to figure out. Do you have any advice about a good way to accomplish this? It seems like there are some high-side driver ICs that might do what I want, although the current isn't very high for just a pull-up, so they are overkill. I'd like to keep it compact as possible (surface mount is good) so it will fit on my board. (I could do it on a daughterboard, which may be the most cost-effective way now that my main board is already a few revisions in.)

    Thanks,
    Jason

  2. #2
    So maybe someone is willing to comment on this schematic? (Adapted from post 11 of this thread.)

    It uses an NPN transistor to drive the P-channel MOSFET. Since the car operates at ~14.4V, the resistor dividers would mean the gate is about 7V when the transistor conducts, if the K line were at ground. But what about when K idles (nothing pulls it to ground)? In that case, the idea is that the pullup resistor (R1, the one I'm trying to selectively switch into the circuit) pulls the K line up. Won't that floating K line prevent the MOSFET from working correctly? I know I'm missing something obvious due to my ignorance. Does the MOSFET care only about the gate-source voltage, making the drain irrelevant?

    Click image for larger version. 

Name:	Screen Shot 2015-08-15 at 4.15.03 PM.png 
Views:	1839 
Size:	29.5 KB 
ID:	4884

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,066
    This should work fine, assuming you connect something that is a load (consumes power, never sources power) between K and GND.

    The TP0610K is specified at 10 volts on its gate. You should probably reduce R3 to something well under 800 ohms, or just replace it with a wire.

  4. #4
    Thank you Paul. I really appreciate your help (and great products). I had thought that reducing R3 may be in order, just wanted to stay well clear of the 20V max voltage differential. I will go with your recommendation.

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,066
    Another way to do it with only bipolar transistors....

    Click image for larger version. 

Name:	transistors.jpg 
Views:	178 
Size:	7.2 KB 
ID:	4890

  6. #6
    Thanks. Do I not need a series resistor between the Teensy and the NPN?

  7. #7
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    494
    No -- the 10k controls the current in the NPN quite well (but 10k isn't ideal...).

    Basically, the Teensy pulls the NPN's base to 3.3 V. Therefore the emitter is at 3.3-0.7 = 2.6 V, and so 2.6/10k = 260 uA flows to GND. This also flows in the NPN's collector and to the PNP's base which amplifies it by the PNP's gain. Say this is 50 -- then the PNP will conduct 50*260u=13 mA.

    However the 510 ohm needs 14.4/510 = 28 mA. This means that actually the PNP can't pull the 510 fully to supply.

    In circuits like this it is good practice to consider 'worst case conditions' - the resistors have 5 % variation, the PNP beta may not be that good, the 14.4 V could rise to 16 (or higher). Working backwards, you need:

    16/510*1.05 = 33 mA in the PNP collector
    this means 33/50 = 0.7 mA in the base.
    This means the NPN emitter R is (3.3-0.7)/0.7/1.05 = 3.5k
    -- so choose a 3.3k resistor.

    It might also be better to have a pull-up R on the PNP (between base and emitter) -- 10..100k would be OK there and not affect much else.

    Also, the NPN dissipates nearly 500 mW - depending on your setup, a small amount of heatsinking might be useful
    Last edited by Jp3141; 08-17-2015 at 03:34 AM.

  8. #8
    Thank you that helps my understanding considerably. Is there any reason to use the PNP instead of a p-channel MOSFET?

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    27,066
    Oh, yeah, good point on the resistor value if the PNP gain is low.

    The mosefet circuit should be fine, and uses less power.

  10. #10
    Senior Member Jp3141's Avatar
    Join Date
    Nov 2012
    Posts
    494
    A p-channel FET would need a R from its gate-source to turn it off when the NPN turns off (else the gate is 'floating' -- you can't say what votlage is on it).

    You want to get good VGS on the device (say 5 V); on the other hand you don't want >> 10 VGS (many p-channel can take 20 V briefly though).

    So -- going back to the original 10k; it has 2.7 V across it. If you use twice this (say 22k), then you'll get 2.7/10k*22k = 6.0 VGS on the FET which will be good. Note that at battery < ( 6.0 + 2.7), you won't get that much, but it'll still be ~OK.

Posting Permissions

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