MCU to PNP interface

Discussion in 'General Electronics Chat' started by cmartinez, Jan 5, 2016.

  1. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    I'm trying to interface an MCU to the inputs of a laser scanner head controller. (I have no problem with understanding its outputs)

    Here's what the controller's manual says about its circuitry.

    Capture01.JPG

    Anyway, I tried to simulate what the recommendation is for its PNP input using a 2N3906 transistor, and I'm getting very strange readings at its output.

    Capture02.JPG


    I don't understand, isn't the "out" node in my sim supposed to reach 0V when the transistor is inactive?
     
  2. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,308
    884
    The transistor is never turning off; V1 should be the same voltage as your logic Vcc.
     
    cmartinez likes this.
  3. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    Right... so I need some sort of level translator then? because I can't change V1=12V and V2=5V
     
  4. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,044
    3,808
    Right, easiest way is to add an NPN (2N3904) to the 4700 ohm resistor on the uC output. Then the NPN with a 1k to Vcc (and emitter to ground). Then connect your PNP to the node between the 2n3904 collector and it's 1k transistor.
     
    cmartinez likes this.
  5. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    I don't understand what your circuit is supposed to do. :confused:
    Why is there a voltage divider on the output? The spec says you need 10.2V minimum for the ON voltage.
     
  6. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    Yup, that's why I'm using 12V. As for the voltage divider (and the diode), I'm just trying to represent what the manual says.
    I'm guessing that the divider's there to allow for the intended input range of 10.2 to 30V max. I suppose it's because the thing's designed to work with either 12 or 24V standard industrial voltage.
     
  7. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    Pull the base up to V1 so the transistor will turn off. Also you need to prevent V2 from keeping it on. You can use an NPN in the common base configuration to do this.
     
    cmartinez likes this.
  8. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    My, oh my... not only did that fix the problem, but it also gave me non-inverting logic. Thanks, man!

    Capture.JPG

    @OBW0549, this looks a lot like a small circuit you once helped me with... one would've guessed that by now I would know this sort of basic stuff by heart :confused: ... shame on me :oops:
     
  9. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    Isn't that similar to what Gopher recommended, and to what I just did?
     
  10. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    He is attempting to model the input he is driving.
     
  11. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    Exactly
     
  12. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    Make sure that your microcontroller can source current into the base of the transistor. If it can't or is an open drain output I have an alternative that works great.
     
  13. Papabravo

    Expert

    Feb 24, 2006
    10,142
    1,790
    No it is not. Gopher placed then NPN in the CE configuration
     
    cmartinez likes this.
  14. crutschow

    Expert

    Mar 14, 2008
    13,009
    3,233
    The circuit has no resistor in the base of the PNP so the current is limited only by what the NPN can source.
    The resistor needs to be between the PNP base and the NPN collector, not from the NPN collector to V+.
     
    GopherT likes this.
  15. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    You must have a sixth sense, because it is an open drain output (AT89S8052), and yes, its bi-directional pins have very weak internal pull-ups, and can barely source current.

    What's the alternative?
     
  16. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    Like this?

    Capture.JPG
     
  17. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,044
    3,808
    R1 could be 100k and R2 could be 330k
    (add a 10k resistor to the Base of the PNP).

    Otherwise, a 2N7000 mosfet could be used in place of the 2N3904 (or any other logic level mosfet instead of the 2N7000.

    Otherwise, a ...
     
    cmartinez likes this.
  18. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,044
    3,808

    That works but I would have kept the 1K to the left of the 4.7k and made the 4.7k a true base resistor.
     
  19. cmartinez

    Thread Starter AAC Fanatic!

    Jan 17, 2007
    3,572
    2,537
    Back to inverted logic then, but it's a better alternative, I guess.

    Capture.JPG
     
  20. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,044
    3,808

    The way you have your connection, the 1k and 4.7k near the base of the PNP is making a voltage divider that limits current to the PNP (because of reduced voltage delta).
    Remove the 1k from the PNP's base. Connect it from the NPN's collector and the other end to Vcc.
     
Loading...