Shop OBEX P1 Docs P2 Docs Learn Events
HD44780 LCD Prop controlled power. — Parallax Forums

HD44780 LCD Prop controlled power.

matb_ukmatb_uk Posts: 16
edited 2007-10-09 02:46 in Propeller 1
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.

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-10-07 12:11
    Who worries about theory anyway? Just stick it in there and let it do it's job [noparse]:)[/noparse]

    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*
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-07 12:27
    Peter Jakacki said...
    Who worries about theory anyway? Just stick it in there and let it do it's job [noparse]:)[/noparse]
    I think one could apologize this ambivalent remark by the bad influence of deSilva....

    .. and thank you for your whirlewind tutorial about the basic (bipolar) transistor circuits smile.gif
  • matb_ukmatb_uk Posts: 16
    edited 2007-10-07 16:45
    Thanks Peter. Again the propeller forum saves the day.
  • Dennis FerronDennis Ferron Posts: 480
    edited 2007-10-07 17:05
    Hmmm, I don't think the LED-voltage drop method will work very well. I've actually tried a similar thing to what you describe, and found that there is still a little bit of leakage current even when the LED is supposedly below it's voltage drop. If you look at the current-curve graphs in diode data sheets, there is indeed a sharp bend there, but only ideal (theoretical) diodes are really all or nothing; real diodes do conduct a little even below their minimum forward bias, due to heat and other factors. This is not much current, but combine that with a transistor that can amplify 100 or 300 times base current, and an LCD module that only requires a few milliamps to run, and you can see that it would not take many microamps of leakage current to get your LCD turned on partially. Even if the display doesn't come on fully, it might be a brownout condition that would goof up the internal controller on the LCD.

    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.
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-07 18:16
    Which reminds me to something slightly OT: Dennis describes the true characteristic curve of a LED quite well. In fact it is a more or less exponential function. If anyone has ever used germanium diodes he is aware of a "smooth" transition from leakage to infinity..

    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
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-10-07 19:22
    Just put a resistor between emitter and base, then set the Prop pin to an input (high impedence) to shut it off. You DO have a series resistor between your pin and the base, right?

    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?
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-10-07 20:24
    It's-Smoking-Again-User desires schematics to faciliate understanding.
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-07 20:44
    I just thought what could be added to Peter's posting, but find little - it is a brilliant description of all most important features of a bipolar transistor....

    What Peter didn't say: This is what it's all about Open Collectors smile.gif

    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.
    DIRA[noparse][[/noparse] dsppwr ] := onOrOff ' on = 1, off = 0
    

    Post Edited (deSilva) : 10/7/2007 8:48:59 PM GMT
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-10-07 22:22
    Unfortunately the prop cannot turn off a pnp with it's emitter tied to +5V as the prop pin must go to 4.4V or more. The led scheme will work and it shows you how you can make a single pnp work in this configuration so it's also useful for teaching purposes . Leakage is present in all materials and structures. The base cutoff resistor takes care of the pnp's leakage and any from the led etc. Of course there are more conventional approaches such as using an npn to drive the pnp etc.

    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 smile.gif

    *Peter*

    
                              +5V
                            .------.
                            |      |
                            |      |
                            |     .-.
                            |     | | 47K
                            |     | |
                            |     '-'
                             >|    |      ___     LED
                              |----o-----|___|---->|-----  PROP I/O
                             /|
                            |
    
                           LOAD
    (created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)
    
    
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-10-07 22:24
    Not particularly off topic: Would this sort of thing be better handled by an op-amp? (been reading my baby books again, who say:

    "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
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-10-07 22:33
    Fred,

    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*
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-10-07 22:57
    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
    258 x 176 - 4K
  • HarleyHarley Posts: 997
    edited 2007-10-07 23:05
    Good way to burn out that transistor, shorting power supply to ground.

    Shouldn't the collector be the output?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-07 23:07
    Peter Jakacki said...
    .... and there are intrinsic diode junctions that normally isolate because they are reversed biased but take that drain a little higher than the VDD

    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...
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-10-07 23:40
    The common-emitter mode is the normal mode when using a transistor as a switch. Common for an npn is the negative ground, common for the pnp is the positive supply (it's ground!). This circuit would be a pnp common-emitter. Emitter follower is just that, the emitter is the output and follows the input voltage and as I mentioned previously the output will be 0.6V less then the drive so it's good for current amplification or buffering.

    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*
  • DufferDuffer Posts: 374
    edited 2007-10-08 00:15
    I typically use a circuit like the following to·switch small devices (displays, LED arrays, etc). The NPN just provides a path to Ground when the control pen (on the base)·goes high.

    Duffer
    249 x 185 - 7K
  • deSilvadeSilva Posts: 2,967
    edited 2007-10-08 00:17
    Just a tip for "medium current" circuits: IR LEDs allow a higher current (100mA)
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-10-08 01:29
    Sorry to be pedantic duffer but your npn circuit is missing a vital current limit resistor from the prop pin to the base. The cutoff resistor is usually not needed in this type of circuit. Just as led requires a current limit resistor so do bipolar transistors. The circuit shown without any resistor effectively short-circuits the prop pin to ground through the base-emitter junction and it may only seem to work because the prop limits the current at some rather high figure for a while until something gives.

    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*
  • Stan671Stan671 Posts: 103
    edited 2007-10-08 15:14
    I have used a circuit like this in the past to have the BS2's·output pin drive something (such as a lamp or relay) that needs more current and higher voltage than it could provide alone.

    Will this same circuit work with an output pin from the Prop (at 3.3 volts)?
                               +12volts
                                  ^
                                  |
                                  |
                               +--+--+
                               |  L  |
                               |  A  |
                               |  M  |
                               |  P  |
                               +--+--+
                                  |
                                  |
    -------+                      |
           |     1K ohm       B |/ C
     Micro +<----/\/\/\---------|     2N2222 Transistor
           |                    |\ E
    -------+                      |
                                  |
                                  V
                                 GND
    



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Stan Dobrowski
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-10-09 01:32
    Hi Stan,

    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*
  • Stan671Stan671 Posts: 103
    edited 2007-10-09 01:55
    Thanks for the info, Peter.· It is good to know that my old-reliable is upward compatable.·<grin> I don't really know how transistors work - I just found this example and have used it a lot.

    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
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-10-09 02:46
    Push about 15ma into the base and the 2N2222 will handle 500ma with a Vce of 300mv -> 150mw power dissipation which is well within it's capabilities. However if the prop is sourcing 15ma it's output voltage will drop down to around 2.7V which means the resistor needs to be R=V/I = 2.7-0.6/15ma = 140R at least. Make the resistor around 100R to 120R or else use a darlington which needs far less drive current but has a higher Vce of 0.8V (still ok). For a darlington you could use a BC517 etc in a to92 pack that can handle up to 1A or 625mw with a base resistor of only 10K.

    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*
Sign In or Register to comment.