MCU to PNP interface

Thread Starter

cmartinez

Joined Jan 17, 2007
6,785
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?
 

Attachments

GopherT

Joined Nov 23, 2012
8,012
Right... so I need some sort of level translator then? because I can't change V1=12V and V2=5V
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.
 

crutschow

Joined Mar 14, 2008
24,360
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.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
6,785
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.
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.
 

Papabravo

Joined Feb 24, 2006
12,926
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.


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.



I don't understand, isn't the "out" node in my sim supposed to reach 0V when the transistor is inactive?
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.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
6,785
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.
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:
 

Attachments

Thread Starter

cmartinez

Joined Jan 17, 2007
6,785
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.
Isn't that similar to what Gopher recommended, and to what I just did?
 

Papabravo

Joined Feb 24, 2006
12,926
My, oh my... not only did that fix the problem, but it also gave me non-inverting logic. Thanks, man!


@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:
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.
 

crutschow

Joined Mar 14, 2008
24,360
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+.
 

Thread Starter

cmartinez

Joined Jan 17, 2007
6,785
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.
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?
 

GopherT

Joined Nov 23, 2012
8,012
You must have a sixth sense, because it is an open drain output (AT89S8052), and yes, it's bi-directional pins have very weak internal pull-ups, can barely source current.
What's the alternative?
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 ...
 

Thread Starter

cmartinez

Joined Jan 17, 2007
6,785
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 ...
Back to inverted logic then, but it's a better alternative, I guess.

Capture.JPG
 

GopherT

Joined Nov 23, 2012
8,012
Back to inverted logic then, but it's a better alternative, I guess.


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.
 
Top