HD44780 LCD Prop controlled power.
matb_uk
Posts: 16
Hi All,
I'm in the final stages of a project i begun a couple of weeks ago and decided that i want to control power and possibly the backlight for my 4x20 Line LCD display from the Prop.
I've tried to use a transistor tied to 5v with the Base connected to a prop pin and the emitter connected to the LCD power. Now i'm probably incorrect but i thought that the way a simple transistor worked was power is supplied to the collector and when a small amount of voltage is applied to the Base, the voltage at the collector is allowed to flow to the emitter??
I'm using a 2n3904 NPN transistor i had to hand and i can see about 5v going in, the prop pin is supplying 3.3v to the Base (When i set pin:=1) but i only get about 2.67v from the emitter which isn't enough to supply the LCD (5v). What am I doing wrong? I really must look into learning basic electronics!
Thanks,
Matt.
I'm in the final stages of a project i begun a couple of weeks ago and decided that i want to control power and possibly the backlight for my 4x20 Line LCD display from the Prop.
I've tried to use a transistor tied to 5v with the Base connected to a prop pin and the emitter connected to the LCD power. Now i'm probably incorrect but i thought that the way a simple transistor worked was power is supplied to the collector and when a small amount of voltage is applied to the Base, the voltage at the collector is allowed to flow to the emitter??
I'm using a 2n3904 NPN transistor i had to hand and i can see about 5v going in, the prop pin is supplying 3.3v to the Base (When i set pin:=1) but i only get about 2.67v from the emitter which isn't enough to supply the LCD (5v). What am I doing wrong? I really must look into learning basic electronics!
Thanks,
Matt.
Comments
Bipolar junction transistors (all those 2N types) can indeed be used as a "switch", but what do we need to do to help the transistor switch?
First off, you are using the transistor in an emitter follower mode. The base-emitter junction drops about 0.6V (because it's just like a diode junction) so that the emitter will always be 0.6V less than the base in normal use. Put 3.3V on the base and you will get 2.7V on the emitter, exactly what you wanted it to do!
No?
Ok, you want to switch the whole LCD module's supply rail? Use a PNP with the emitter connected to +5V and drive the base low. As the base-emitter junction looks like a diode what's there to stop too much current flowing? Not much! Use a current limiting resistor in the base, the value of which is based on the current amplification (not voltage) of this configuration. If you need to switch 100ma and the transistor has a current gain (hFE) of 100 then you need at least 1ma flowing in the base. R=V/I where V=5V-0.6V-Vdrive. Double this or more at least to saturate/overdrive the transistor to make sure it turns on hard otherwise it could act more like a resistor and get rather hot (simple explanation).
Only one catch, to turn it off, unless the Vbe (voltage across the base emitter) is less than 0.6V then the transistor will turn on to some degree. With the emitter tied to +5V and the base being driven off by 3.3V that's a difference of 1.7V which is 1.1V too high. Quick fix is to insert an LED or two diodes in series in the drive signal and pull the base up to +5V with a "base cutoff" resistor of around 47K.
If instead you are trying to switch the backlight and not the whole module then using an npn in grounded emitter mode is far simpler, one npn plus one base resistor.
*Peter*
.. and thank you for your whirlewind tutorial about the basic (bipolar) transistor circuits
I would use the Propeller to drive an NPN on the bottom rail, and the open collector of the NPN to drive the base of a PNP on the top rail. Or better yet, use a TTL buffer chip to translate the logic input from the Propeller into a 5 volt TTL signal; just make sure you use a buffer that can source current, such as a TTL-compatible CMOS chip.
The modern extra bright LEDs - producing 1.000 to 10.000 mcd and working happily @30mA - now show again this smoother behaviour (=smaller exponential factor). When a manufacturer says: "Forward voltage 2.8 to 3.3" for a white or blue one, then this not only covers pruction margins, but a real behaviour. It will shine well at 2.8 V (around 2 mA), bright at 3.3V (20mA), and you can even test it at @40mA and 3.4 V.
Post Edited (deSilva) : 10/7/2007 8:09:21 PM GMT
Might not be quite that simple, but if you choose a low enough value for the B-E resistor it should work. Needs to be lower than your chosen PIN - base resistor.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The more I know, the more I know I don't know.· Is this what they call Wisdom?
What Peter didn't say: This is what it's all about Open Collectors
And I would not use the diodes/LED... I think a 47k between base and +5V should suffice when not "driving" the display off, but rather going tri-state.
Post Edited (deSilva) : 10/7/2007 8:48:59 PM GMT
A true open-drain port pin could drive the pnp without any threshold adjustment and although you can emulate an open-drain it is not a true open-drain in that the drain is still part of the silicon substrate and there are intrinsic diode junctions that normally isolate because they are reversed biased but take that drain a little higher than the VDD and they breakdown (normal conduction).
For clarity I have included a schematic
*Peter*
"Modern op-amps, like the popular model 741, are high-performance, inexpensive integrated cir-
cuits. Their input impedances are quite high, the inputs drawing currents in the range of half
a microamp (maximum) for the 741, and far less for op-amps utilizing field-effect input transis-
tors. Output impedance is typically quite low, about 75 * for the model 741, and many models
have built-in output short circuit protection, meaning that their outputs can be directly shorted
to ground without causing harm to the internal circuitry. With direct coupling between op-amps'
internal transistor stages, they can amplify DC signals just as well as AC (up to certain maximum
voltage-risetime limits). It would cost far more in money and time to design a comparable discrete-
transistor amplifer circuit to match that kind of performance, unless high power capability was
required. For these reasons, op-amps have all but obsoleted discrete-transistor signal amplifers in
many applications."
from Lessons In Electric Circuits, Volume III { Semiconductors
By Tony R. Kuphaldt
Fifth Edition, last update July 02, 2007
Fifth edition and they still refer to the 741 as popular!!!
741 is a classic but a dinosaur.
I have used opamps such as the LM358 etc as level translators from logic levels to higher voltages. The LM358 is cheap and versatile but slow and about 1.5V down on the high rail (give it +5V supply and you will only get 3.5V max out). There are plenty of pin compatible dual opamps that feature speed/drive/rail-to-rail operation so you can pretty much decide which is the best and cheapest to use at any time but in the meantime do your functional tests mostly with the humble 358.
A single transistor can switch 100's of milliamps whereas this would not be the norm for your low-cost opamps.
*Peter*
Thanks for shining a light on my online references.
Meantime, here's a pretty version. Hope I got the name right.
Fred
Post Edited (Fred Hawkins) : 10/8/2007 1:07:59 AM GMT
Shouldn't the collector be the output?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
Keep forgetting about them...
O.k. without the LED I measure 3.9 V when I presumed to pull-up to 5V. This is exactly 3.3 + 0.6.
Funny I never noticed... But as it is logic high it is o.k. for any logic chip.. Though not for a transistor...
The led is shown correctly and when the prop I/O goes low a small amount of current will flow and the led will glow, but we don't care about that. The led is not needed to turn the pnp on, it's just needed to turn it off because of the max 3.3V signal which is actually with respects to the pnp and it's common (+5V), a minimum 1.7V signal for the pnp so the pnp will never turn off. The led increases the 0.6V cutoff of the transistor to 2.2V or more.
Leds just happen to be diodes that like to let everyone know they are busy. Even transistors can emit light at their junctions to some very small degree. Knowing that leds are diodes with a predictable forward voltage drop depending upon their color etc then you can use them as very low-voltage zeners (normal low voltage zeners are useless), or even just to drop +5V down to around 3.3V for low current circuits.
*Peter*
Duffer
deSilva: yes, you are right that you can use IR leds. One reason they handle more current is because of the lower forward voltage drop hence less power dissipated compared to a visible led. I have used them recently simply to drop a +5V supply down to about 3.7V for the prop which was driving a non-standard LCD which had 3.6V logic level inputs (no data, found out the hard way)
*Peter*
Will this same circuit work with an output pin from the Prop (at 3.3 volts)?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
The same circuit will work just as well with the prop at 3.3V as it does with 5V logic. Although the base-emitter control current may only be around 2.5ma when driving from the prop this does not impact on the switching performance of the 2N2222 as it's typical current gain is around 100 and for various reasons you would only be controlling a load of around 200ma or less. Trying to switch more current would require far more base current to keep the transistor saturated so that it's collector-emitter voltage (when switched on) is as low as possible otherwise W = VI and things get 2 2 2 2 hot.
*Peter*
Can you suggest an alternate (simple) circuit or a different transistor that would be able to drive up to, say 500 ma?· Could this be done with just a lower resistor from the Prop output pin to the base to get more current flowing through there?· Or could I put two of these circuits in parallel to push 400 ma?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stan Dobrowski
Zetex also make a range of regular bjts that feature a very high current gain which translates into a low Vce which means they are happy to handle 4A or more in tiny packages.
For higher currents I would look to a logic-level mosfet but they are hard to find and expensive especially those which have a very low Vgt needed to interface to 3.3V logic.
*Peter*