Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Singing the PNP Blues

Status
Not open for further replies.

Atomsk102

New Member
I'm trying to use bipolar transistors as the output stage of a circuit controlled by an NXP LPC9221 µC. The illustration shows two of the configurations I've tried, and one about which I have questions.

"On" and "Off" mean current flows or does not flow through the load resistor, in response to a given output from the controller.

The "switch" represents the µC pin, connecting to either +3.3v or ground.

**broken link removed**

Fig 1: shows a low-side NPN based switch. This works fine, but I want to move the transistor to the high-side of the load.

Fig 2: shows my attempt to use a PNP, on the high side, to switch current to a load. In this instance, the transistor never turns off, even when I set the output high. I suspect that's because of the difference in voltage between the load and controller circuits.

Fig 3: shows what I believe will do what I want, switch 12v, from the high side of the load, using a 3.3v signal.

I'd like to know, is there a better solution to this problem, one that uses only one transistor?
 
In figure 2, the base resistor of the transistor is never connected to its emitter voltage to turn it off.
In figure 3, when the NPN transistor turns on, the PNP transistor also turns on then both transistors burn out because there is no resistor in series with the base of the PNP transistor to limit the base current.
 
No there's not, and NONE of your solutions work either! :D

Check my PIC tutorials under Hardware Extras for how to do it.

Strictly for my own educational purposes, what's the difference in what he shows and your tutorial. (See attached)
 

Attachments

  • sinksource.JPG
    sinksource.JPG
    44 KB · Views: 879
Strictly for my own educational purposes, what's the difference in what he shows and your tutorial. (See attached)

hi AllVol,

The fig #1 looks OK to me.

With fig #2, the pnp, its the base drive voltage thats the problem.

For an emitter voltage of +12V, the base is always at -12V via the base resistor to 0V or [12 -3.3] = -8.7V.

So it never turns OFF.
 
Last edited:
In Fig. #2, can you set the LPC9221 I/O pins to a high Z state?
 
I'd like to know, is there a better solution to this problem, one that uses only one transistor?

You have a 3.3v signal swing and a transistor only needs a ~1v signal swing to go from saturation to cutoff, so you don't need voltage gain at this point; use a Zener diode with resistors as a level shifter and input attenuator for this high-side switch.

Use the PNP of fig. 2 with a 1K base resistor. Run a 100Ω resistor from the base resistor free terminal to +12v. From this same base resistor terminal hook up the cathode of a 9.1v Zener diode, then the Zener anode connects through a 100Ω resistor to the switch wiper.
With zero base current, there is then 10 mA flowing through this base drive circuit.

When the switch is at +3.3v the Zener is just turning off and the transistor is shut off by resistor going to +12v.
When the switch is at gnd, current flows through the Zener and so it is on and it turns the transistor on. The Zener cathode will be at ~+10v with respect to gnd.

If the input "switch" can't sink 10 mA, change the two resistors to 1k but then your RL has to have a higher value and your base resistor can probably go to zero Ω.
 
Last edited:
There is a way to do this using one pnp transistor. The circuit is shown below. Note that to turn the pnp off, you must put the output pin into a high impedance state, or change to an input. This is what most of us do when confronted with these types of limitations. HTH. :)
 

Attachments

  • pnp.gif
    pnp.gif
    5.3 KB · Views: 717
Last edited:
In Fig. #2, can you set the LPC9221 I/O pins to a high Z state?

Apparently not high enough Z.

The device has three output modes, Bi Directional, Push/Pull, and Open Drain.

I tried Push/Pull and Open Drain, but neither one could make the circuit in Fig 2 shut off.

I'm re-working my hardware to test the modified Fig 3 circuit now.
 
I'm re-working my hardware to test the modified Fig 3 circuit now.

Maybe your test instruments are leading you astray.

I'd start from zero.
What voltage & current can your input signal source or sink and what voltage & current does your load need?
I can't imagine needing the power gain of two transistors to accomplish this [level shift of (12/2 - 3.3/2) = 4.5v and gain of 12/3.3= 3.6] interface function.

Also, CMOS gates can be used as linear inverting/non-inverting amplifiers, so if you have some spare gates and a Zener, you can use them.

:confused:
 
Thanks Willbe:

I had a feeleing that a Zener could do the job, but I didn't know how to set up the circuit.

Analog:

That may work too. I might not have had the pull up installed correctly, when I tried it.
 
hi AllVol,

The fig #1 looks OK to me.

With fig #2, the pnp, its the base drive voltage thats the problem.

For an emitter voltage of +12V, the base is always at -12V via the base resistor to 0V or [12 -3.3] = -8.7V.

So it never turns OFF.

In figure two, didn't the OP just make a mistake in his schematic, leaving the switch, which represents his uC output, high. In the verbage, he has the output being low, which would work, wouldn't it?
 
What voltage & current can your input signal source or sink and what voltage & current does your load need?

My input can handle about 20mA, source and sink. It runs at 3.3V, but the device can tolerate 5V at the inputs.

I don't have the exact numbers on the current requirements of each load yet, but they all require 12V in.

For testing, I just used LEDs and 2N3906s. I figured, if I needed more current, I could go to something like a TIP125, later on.
 
Why not just use a driver chip like a 74hc244 or even a ULN2004 (in conjuction with the transistors)? Wouldn't this be simplier? Or do you have real estate concerns? Or is it just because you want to design it this way?
 
There is a way to do this using one pnp transistor. The circuit is shown below. Note that to turn the pnp off, you must put the output pin into a high impedance state, or change to an input. This is what most of us do when confronted with these types of limitations. HTH. :)
This will never work. It is because of the intrinsic diodes to Vss and Vdd on the IO pins of CMOS chips. Even when the pin is in Hi-Z or input mode, the pin voltage cannot rise above Vdd + 0.7V or 4.0V in this case nor can it go more than 0.7v below Vss.
The 2 transistor method (Fig 3), modified with the extra base resistor, will work. Just invert your software/logic level to the pin in the chip if needed.
I wouldn't touch the zener idea with a 10ft pole. Think what will happen if the 12V line rises or spikes to 16V or higher for some reason.
 
Last edited:
This will never work. It is because of the intrinsic diodes to Vss and Vdd on the IO pins of CMOS chips. Even when the pin is in Hi-Z or input mode, the pin voltage cannot rise above Vdd + 0.7V or 4.0V in this case nor can it go more than 0.7v below Vss.

If in Hi-Z, the I/O pin allows enough current to forward bias the E-B junction of the transistor, then I'd say you're right, but I doubt that it does.

As a precaution, I guess one could put a diode on the output of the I/O pin to prevent that from happening.
 
As a precaution, I guess one could put a diode on the output of the I/O pin to prevent that from happening.

Please tell us how this diode should be fitted, pointing to the I/O pin or pointing to the PNP base?
 
Last edited:
I wouldn't touch the zener idea with a 10ft pole. Think what will happen if the 12V line rises or spikes to 16V or higher for some reason.

That could prove problematic, since the circuit will eventually go into an automotive environment. I don't want to regulate the 12v input, just take it directly from the car's power circuit (fused, of course).

I agree with others, that the two transistor solution is a bit parts-intensive, but it seems like the only way.

I tried NPN transistor between the load and the positive supply. That didn't work because the base current had to pass through the load resistance, when the circuit is "on". That caused the transistor to turn on only partially, unless I had a very low load resistance.

It seems to me, I need both transistors for a truly robust circuit, the NPN for voltage gain, and the PNP for current gain.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top