AVR/PNP transistor issue

Go To Last Post
12 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello all, I'm having a weird issue. I am using an I/O pin on the AVR to turn on/off the backlight of an LCD. I am not, however, switching the backlight directly from the AVR. Instead, I am using a PNP transistor. See attached circuit. The problem I am having is when the I/O pin is programmed low, there is still voltage (~4V) seen at the I/O pin, and when the pin is programmed high there is 5V seen on the pin (as expected). Essentially, the backlight is always on. I disconnected the transistor and 10k pull-down resistor from the avr, and, as expected, when the pin is programmed low there is 0v seen and when programmed high there is 5v seen. So the AVR is working properly. Any ideas why I'm seeing a voltage on the I/O pin when its programmed low? Any help would be great.

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try an NPN instead of the PNP.

Leon Heller G1HSM

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I can't use a PNP transistor. The LCD Module I am using doesn't have a GND pin soley dedicated to the LCD backlight. So i have to use a PNP transistor to control the LCD backlight + pin. Thanks,

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Put that resistor in SERIES between the port pin and the transistor base. No resistor to ground. You will then find that it works, pretty sure!

That 120 ohm resistor will only give you 10ma, more or less. Thats not much as many LCD backlights are spec'd for several hundred milliamperes. You should be able to see it, though. Barely, if the room light is dim.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to add a series resistor to the base of the transistor. As shown, your circuit should work as the voltage between the base end emitter should be near zero when the AVR writes a logic '1' thus turning the transistor off. The reason you see 4V when a logic '0' is that the voltage across the base/emitter junction will only be around 0.7V, thus the need for a series resistor.

At a guess, you've wired the transistor wrongly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
when the I/O pin is programmed low, there is still voltage (~4V) seen at the I/O pin

That is to be expected because there is no base resistor. The +5v is shorted to ground through a diode (e-b junction) and the I/O pin (+5v - Vd = 4v). Wouldn't be surprised if the I/O pin and/or transistor e-b junction are damaged. The base resistor should be low enough to guaranty that the transistor is saturated when the I/O pin is low.
Quote:
the backlight is always on

This implies the transistor is fried and not turning off. If the base is at +5v the transistor should be off and no backlight current. Not sure why you have a 10K to ground. It doesn't do anything for you and wastes power because it draws current when the backlight is off.
Quote:
I can't use a PNP transistor. The LCD Module I am using doesn't have a GND pin soley dedicated to the LCD backlight.

Most LED backlights are simply floating LEDs (i.e. not connected to +vcc or gnd) so the LED+ can be tied to +vcc or the LED- can be tied to gnd. Therefore you can use an NPN if you want. I generally use an NFET because there is no power wasted in the gate, it can be driven directly from the I/O pin and the Rds is generally very low so less voltage is wasted in the switch (e-c junction).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The reason the backlight is always on, is because R1 is allowing transistor U5 to always be on. As Leon said, use a PNP. PNPs are used for high-side switching (which is what you're doing), and NPNs are used for low-side switching.

As has also been pointed out, the transistor needs a resistor in series with its base. Unless of course you want to test the current-handling capability of the AVR output driver pin.

A simpler alternative would be a small P-channel MOSFET.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think the general consensus is that I need a SERIES resistor between the I/O pin and the base. Also, I need to size R2 such that the backlight gets enough current. I looked at the data sheet of the LCD and it requires 80 mA, so I'll size the resistor accordingly.

Quote:
The base resistor should be low enough to guaranty that the transistor is saturated when the I/O pin is low.

I'm not quite sure how to size this resistor. Here is the cut for the transistor I'm using.

http://www.diodes.com/datasheets...

I suspect I’m interested in one of the various saturation voltages. Any guidance?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

At saturation, the beta of the transistor drops to around 10.

So, 80ma of collector current, beta of 10 means a base current of 80ma/10 = 8ma.

If the emitter of the PNP is at +5V, then the base is 0.7V lower than that, or 4.3V. Your base resistor should then be

R = V/I = 4.7v/8ma = 590 ohms.

I would use a 470 ohm base resistor to be good and solid.

If you make the port pin a logic high, then, the PNP will be off and the backlight will be off. If you make the port pin logic low, the PNP will be on, and saturated, and the backlight will be on. You can even PWM the control signal and get varying backlight brightness.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
At saturation, the beta of the transistor drops to around 10.
fyi, On Semiconductor's low Vce(sat) transistors appear to be better.
MMBT589L
With a Vce of -0.1 volt and -80ma Ic, DC beta is about 75.

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to make a couple of changes to your circuit. first, as mentioned, you need to put a resistor in series with the base of the transistor. without it, when the AVR pin goes low, the base of the transistor is forward biased with about 5V. With nothing to limit the current, either the transistor or the AVR pin will eventually fail. Second, that pull down resistor on the base needs to removed. If you want the transistor to default off, then the resistor needs to connect from the base to the emitter, not ground. The only reason it's usually connected between the base and ground is because the most common circuit is a low side drive where the emitter of the transistor is connected to ground.
You may or may not also need a series resistor between the transistor collector and the LCD backlight anode. Many LCD modules come with the appropriate current limit resistor built in. Check the data sheet for your LCD module for details on what value resistor would be needed, if any.

Here's an example of what I mean...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was taught beta of 10 while in saturation in the 70's. I have used this rule of thumb since with never an issue. I will leave it to the young adventurous engineers to take a chance on a beta of 75. Of course, the fix would be to just lower the value of the base resistor. Not a major issue.
Besides, a ham said it was OK!
KA7EHK de WA6MOK
:)