Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases

Backlight control - HD44780

Discussion about LCD's and other related hardware

Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo, Fast351, hydrolisk1792

Post Reply
limbo
Plugin Author
Posts: 1604
Joined: February 13th, 2005, 7:38 pm
Location: Athens - Greece
Contact:

Backlight control - HD44780

Post by limbo »

Diego (LCD Smartie User) just emailed me that the following circuit "working flawessly"
Image
He tested this schematic with an "Intech" HD44780 compatible, 2x16 LCD display and he is able to use the control backlight feature.

He also suggest a minor modification to schematic:
"Instead of using a 100 ohm resistor, put a 100 Ohm preset (potentiometer), to allow regulation of the backight's bright.
Instead of putting the preset between the collector pin and the display, connect it between the ground and the emissor pin of the transistor.
"


SO, MANY THANKS GOES TO DIEGO
You do not have the required permissions to view the files attached to this post.
Last edited by limbo on April 15th, 2007, 12:53 pm, edited 4 times in total.

Twizted
Posts: 10
Joined: July 5th, 2005, 9:31 pm

Excellent!!!

Post by Twizted »

Just what I came here to find!!!

This is quite possibly the first time I came to a forum looking for specific information and found it in the first try!!!

Anyway... I am glad this is doable via software now. onlything I would like to figure out now is how I want to mount it. I bought my display "4x20" on ebay for $9.99 with EL backlighting which I thought was a steal! Its HD44780 based and is pretty basic. Its Green when no backlite and is suppose to be blue when lit up. I am waiting on parts to come in to build the backlight inverter. The only thing I wish it did have was software controlled contrast :( But you cant have everything for $9.99 lol...

now for a new post to see if someone can help me with another display I have....

Heritz
Posts: 3
Joined: October 24th, 2005, 6:45 am

Post by Heritz »

So, I have a HD4478 Samsung 16pins with parallel port, made by myself. If I install that transistor and those resistors, will I be able to use the "Backlight off" feature on the LCD Smartie System Tray menu?

Other question, Diego says that is needed a BC547 transistor, but I have in home a BC547C transistor, will that work?

limbo
Plugin Author
Posts: 1604
Joined: February 13th, 2005, 7:38 pm
Location: Athens - Greece
Contact:

Post by limbo »

The backlight control is.... The backlight control :P
nothing more to say

You got the right transistor :)
There are minor differences between BC547 and BC547C, not a problem for this application.
Specs for BC547 can be found here: http://perso.wanadoo.es/chyryes/componentes/BC547.pdf


Basically many types of NPN transistors can fit in this schematic!

Heritz
Posts: 3
Joined: October 24th, 2005, 6:45 am

Post by Heritz »

Well, I've been working on the circuit, and... I have to say that those resistors isn't needed. Those resistors would make the backlight very dim, so, if you remove them, you will see the backlight with standard bright.

So, if you want your backlit standard but with control, just use the transistor and remove the resistors. If you use it, you will have a 1100ohms resistance and a very low voltage to supply the backlit.

Regards!

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

heritz, I found the same thing out with just about any display I tried, go directly to the LCD from the transistor. If I put any resistor value in there it would kill it.

J

Heritz
Posts: 3
Joined: October 24th, 2005, 6:45 am

Post by Heritz »

It would kill what?... the display?... No, I don't think it would kill it, just... you will have a very dim backlight, and I guess you don't want that.

As you said, just go directly to the LCD from the transistor.

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

I meant kill the backlight, like its real dim.

J

ReverseEngineered
Plugin Author
Posts: 192
Joined: January 18th, 2006, 11:09 pm
Location: Saskatoon, Saskatchewan, Canada

Post by ReverseEngineered »

Again, I realize this is old, but thought an electrical engineer's knowledge might be helpful here. (For others reading this post, looking for backlight control).

The specific arrangment of the transistor in this circuit is of a voltage amplifier, which if driven into saturation (in other words, given a sufficient current from base to emitter), will act as a switch. Used in this manner, the current through the backlight will be I=V/R. In this case, the voltage is that across the resistor, which is the supply voltage (5V) minus the voltage drop across the transistor (about 0.3V when fully on) and the LED backlight (about 2V; should be listed in the datasheet). As well, the required (full-brightness) current should be listed in the datasheet. Using this, the value of the top resistor should be:

Code: Select all

       V_supply - (V_transistor - V_LED)
R = ---------------------------------------
                       I_LED
I will provide an example of this using my 2x40 LED backlit LCD. According to the datasheet, (TM402CBC from Tianma), the forward voltage drop appears to be 4.2V (since that's the rated voltage of the anode on the datasheet), and the current is max 410mA. We'll plan to drive it at 400mA, which leaves little headroom, but this isn't much of a concern (overdriving an LED will shorten its life, but it takes a lot to burn it out). Given our information so far, this is our resistance:

Code: Select all

R = V/I = [ 5V - (4.2V + 0.3V) ] / 400mA = 0.5V / 400mA = 1.25 ohms
This is quite a small resistance, but is important none the less. If we were to drive it without a resistance, it could technically draw an infinite current (although the actual current would be limited by the amplification of the transistor, given by h_FE, and the base current).

Given this, let's find out how much base current is required to ensure that the transistor is on. In saturation (switch action), the base-emitter current (Ib) times the DC gain (h_FE) should be significantly larger than the collector-emitter current (Ic). Since Ic is 400mA, and h_FE is typically 100-300 for an NPN small-signal transistor (like a 2N3904 or BC547), Ib should be about 10% of Ic. This is important, because as Ic increases, the gain decreases (transistors aren't perfect); for my 2N3904, it decreases to 30 when Ic is 50mA.

"Wait a minute," you might be saying, "isn't the peak current for a 2N3904 or BC547 only 200mA?" Yes, you're correct! I'm glad you caught that now, instead of burning out your transistor (or at least burning your finger on it). If you were to push this limit, your current gain would probably drop enough that you would just end up limiting the output current to about 200mA. If you were to try pushing it harder (perhaps increasing Ib to 200mA or more), you would quickly burn up the transistor.

But first, let's assume that this would work (we can always use a different transistor). We want to set Ib to be 10% of Ic, or 40mA. We use the base resistor to do this. Once again, I=V/R. This time the voltage drop across the resistor is the 5V supply from the parallel port, minus the 0.7V drop between the base-emitter junction of the transistor. Moving our formula around to get R=V/I, we get:

Code: Select all

R = (5V - 0.7V) / 40mA = 107.5 ohms
If the resistance is significantly higher than this, we won't be fully activating our switch, which means our backlight will be dim.

"Aha," you say, "so THAT'S why my backlight was so dim." Yes, essentially. The resistors given in the previous schematic were correctly balanced, but the current through the LED was being determined by the 100 ohm resistor. This would have given a current of only:

Code: Select all

I = V/R = [ 5V - (0.3V + 4.2V) ] / 100 ohm = 50mA
This would be enough to light the backlight, but would only be approx. 1/8 of the brightness (the brightness isn't directly proportional to the current, but it's close enough).

So the most important thing is having the correct resistances. If the collector resistor is too large, we won't have a bright enough LED; too small and we'll burn it out. If the base resistor is too large, the switch won't fully turn on and the collector current will be limited to Ib x h_FE (where h_FE would probably drop below 30). Too small and we risk burning out the base-emitter junction (it is also rated at 200mA peak, and the entire device itself has a maximum heat dissipation).

"But if you had no resistors, wouldn't you get an infinite current and burn out the transistor and the backlight?" Technically, yes: that is, IF we could pull an infinite base current. However, our base current is coming from the parallel port, not a battery. It just so happens that the parallel port has current limiting protection built into it, just in case it should see a short circuit. Let's see what's happens now.

As quoted from ePanorama:
The parallel port data pins are TTL outputs, that can both sink and source current. In ordinary parallel port implementations the data outputs are 74LS374 IC totem-pole TTL outputs which can source 2.6 mA and sink 24 mA.
From this we can see two things:
  • We aren't getting much current from the parallel port, since we are asking it to source (provide) current.
  • We could get a lot more out of it if we instead used it to sink current.
Aside from this, let's see what the prescribed circuit would do in this case. Since the collector resistance is essentially zero and is trying to draw an infinite current, the actual collector current will instead depend on the available base current. With no base resistor we should be getting an infinite base current, but because it's limited by the output of the parallel port's driver, we will instead see approx. 2.6mA. The resulting collector current is:

Code: Select all

Ic = h_FE x Ib = 30 (under significant Ic) x 2.6mA = 78mA
This is obviously brighter than the case using the 1kohm resistor on the collector, but there's a long way to go (it's still less than 1/5 of the brightness).

So what do we do? Well, we could use two transistors. The overall gain would be the gain of both multiplied together, which would certainly be enough to power the LED (30*30 = 900, 2.6mA * 900 = 2.34A max). Of course, we already had the problem that this transistor can't handle much more current than this anyway, so we also need to pick a different transistor. We could just replace our current transistor with a darlington pair--this is what looks like one transistor, but is actually two together inside of a package. This would not only be able to provide our current gain, but would also be able to handle the current we need. OnSemi has the BC517, which is a cheap NPN Darlington pair that can sink 1A with a minimum gain of 30000; more than enough for our application. Unfortunately, Darlington's do have some small disadvantages. The base-emitter voltage is doubled because there are two transistors; but this isn't particularly important because we have a full 5V to use at the base. What could be a problem is that Vce(sat)--the voltage across the collector-emitter when a sufficiently strong current is at the base to cause saturation--also increases by 0.7V to become 1.0V. This unfortunately doesn't add up; how can we provide 4.2V to the LED if our 5V supply gets dropped 1V by the transistor? Well, we can't, and though it's hard to say exactly what the effect will be, it's quite possible that this small 0.2V will just cause the LED to become dimmer. Why? Because there is a linear--but steep--relationship between the voltage across a diode and the amount of current it will allow through. If we sneak just below this 4.2V forward voltage drop, we may lose quite a bit of current, yet still be turned on and have plenty of current flowing. If we were to drop the voltage much lower than this, the current would also drop quickly to the point that it would probably just turn off. Bad news.

So, this is what we have so far. A single transistor won't work because we don't get enough current gain. A Darlington might work, but the high Vce(sat) might prevent the backlight from lighting (or atleast fully), even without a resistor (which is a tricky situation that we don't want to play with, since even a small variation in the supply voltage could cause the current to rise quickly and blow the LED).

With this in mind, we are down to two options. Either we use two transistor amplifiers one after another to create our switch; OR we use a PNP transistor. Why a PNP? Because the parallel port can only source 2.6mA, but it can sink 24mA (note that the 2.6mA is internally limited, but the 24mA may not be!), and turning on a PNP requires presenting a ground voltage to the base, thereby sinking current into the parallel port.


Now I'm laughing to myself. All this talk about using two amplifiers and Darlingtons, and yet this whole time I've been limiting my thinking to using a BJT (bipolar junction transistor). Though certainly the oldest, most abused transistor ever, we have several new ones which would work just as well. In particular, the standard MOSFET (the main component of almost every IC in your computer) has properties which overcome almost all of these problems.

What makes a MOSFET special? For one, it doesn't consume any base current. Well, that's not entirely true, but it's absolutely miniscule, and is only consumed during a switch from on-to-off and vice-versa. Also, it's a voltage-controlled device as opposed to a current-controlled device; it doesn't care what the input current is, only the input voltage, so our lack of current isn't a problem, since we have more than enough voltage.

Now the only problem is finding an appropriate MOSFET. The BS170 is quite common, and though it is capable of handling our desired current, it's Rds (resistance across the drain-source, which is basically the same thing as the collector-emitter of the BJT) is 5 ohms; significantly higher than the 1.5 ohms we need to drive our LED properly. Also, anything higher powered becomes REALLY powerful--more than we really need--there just doesn't seem to be a happy medium.

The IRFD110 from International Rectifier is a rather common--albeit strange--model. It comes in a 4-pin DIP, where the 2 drain pins are connected together. It has an Rds of approx 0.59ohm and can handle drain current up to 1A. This is essentially a drop-in replacement for our old BJT transistor.


Unfortunately I'm running out of time here, and am having some small trouble determining the required resistances in order to use this MOSFET. The value of the gate resistor isn't very important (in fact, it could be left out), but 100 ohms usually works well to avoid problems (in case the gate breaks down this will prevent a bad short-circuit from gate to source).

The real problem is the drain resistor (equivalent to the collector resistor). The drain current, Id, and the resistance, Rds, depend both on the gate voltage (Vgs=5V in our case) and the drain-source voltage (which would be approx. 0.8V for my LED). There are graphs shown on the datasheet that describe the relationships between these three values. Of course, changing our external resistor changes Id, and therefore changes Rds, so picking a resistor values requires some trial and error, and I just don't have time for that at the moment.


So, all in all, this is what we've come up with:
- Driving a transistor and/or LED without a resistor is dangerous
  • The previous circuit works (only partially) because the source current of the parallel port is limited
    - We need to use some alternative configuration: perhaps putting another common-emitter amplifier in front of the existing one, or using an PNP transistor to take advantage of the parallel port's superior sinking ability
    - Picking the right transistor, especially with MOSFETs, can be challenging

    My final suggestion then is to use a PNP transistor, such as the 2N4918. Although they have smaller amplification (barely enough to maintain saturation), they are a cheap, simple solution to the problem which--although not ideal--will give much better performance than the previous circuit.



    Given a more reasonable forward voltage drop on the LED backlight and more time, picking out a good MOSFET (like the IRFD110) and the appropriate resistors is your best bet. Until then, simply substituting a PNP transistor (using the circuit below) will do the trick.

    Image

johnmacd
Posts: 26
Joined: March 6th, 2006, 3:08 am

Post by johnmacd »

I'm confused. I was able to get my hands on a 20x4. I have been looking around and there are several schematics out there on how to wire it up. Some use pots, some use tranistors. Frankly I'm confused. It looks like the one above (on the first post works) but are the following components:

22K 100K and 1K are these resistors?

the BC547 is a Transistor, Bipolar, npn

_X7JAY7X_
Hardware Genie - Plugin Author
Posts: 374
Joined: February 16th, 2005, 10:24 pm
Location: Michigan

Post by _X7JAY7X_ »

The 22k is pot or potentiometer. The others are resistors. The BC547 is an NPN transistor rated at 100mA. You should be able to substitute in a 2n2222 for the BC547 or any other NPN.

J

johnmacd
Posts: 26
Joined: March 6th, 2006, 3:08 am

Post by johnmacd »

Thanks. That's what I figured, I just wasnt sure since those are not the standard symbols that are use. I will try this out this week and report back.

ReverseEngineered
Plugin Author
Posts: 192
Joined: January 18th, 2006, 11:09 pm
Location: Saskatoon, Saskatchewan, Canada

Post by ReverseEngineered »

Standard symbols depend on where you are from. Unfortunately, like so many other things, North America uses different terms and symbols than Europe. The symbols and part numbers that I use are those used in Canada, and in the rest of North America.

The BC547 can be interchanged with the 2N2222. As long as beta (or hFE) and Ic(max) are the similar, you should be able to use any NPN transistor. As I showed in the formulas above, the values of the resistors will vary depending on what the voltage drop and the required current are for your backlight. Either use those formulas to determine suitable resistor values, or work backwards and determine the current that would result from the values in the circuits you have seen. If the current is much higher than what your LCD is rated for, you'll have to change the resistor values using the formulas I have provided. Too low of current is okay (not as bright), too high will burn it out instantly.

If you have questions, feel free to post the voltage drop and forward current of your backlight and I will give you the resistor values to use. This will prevent you from blowing anything up. :D

johnmacd
Posts: 26
Joined: March 6th, 2006, 3:08 am

Post by johnmacd »

ReverseEngineered wrote:If you have questions, feel free to post the voltage drop and forward current of your backlight and I will give you the resistor values to use. This will prevent you from blowing anything up. :D
I'm looking at the spec sheet for the LCD module : http://www.femacorp.com/Products/LCD/Ch ... CM204P.pdf and I'm unsure which is the voltage drop and foward current. Sorry to be so 'dense'.

ReverseEngineered
Plugin Author
Posts: 192
Joined: January 18th, 2006, 11:09 pm
Location: Saskatoon, Saskatchewan, Canada

Post by ReverseEngineered »

In the bottom right corner of the datasheet is a small box that says LED Backlight Specifications. It gives the two important values: forward voltage (drop) and forward current.

To power this fully from a 5V supply, the resistor value should be:

Code: Select all

(5V - 4.2V)/0.375A = 2.13ohms
Since the forward voltage drop is almost the same as the power supply anyway, and the voltage drop increases with current, with 5V across it the current should still be within a safe limit. All told, you're probably safe hooking this up without a resistor at all. You will, however, still need a resistor on the base of the transistor. This resistor should be:

Code: Select all

(5V-0.7V)/(375mA/10) = 115ohm
This isn't a standard size, but 110 or 100 ohm will be just fine.

My backlight has almost these exact same characteristics and it works great like this. Light it up! :D[/code]

johnmacd
Posts: 26
Joined: March 6th, 2006, 3:08 am

Post by johnmacd »

Wow, now my head hurts.... :)

So the schematic on the first post is the one I can use. I think I'm making this more complicated than is really needed.

The resistors should be 1.5 or 2 watts. I arrived at that from Watts=Amps x Volts

Watts=.375 x 4.2
Watts=1.575

So the resistors can be 2 watts 100 ohm and 1K ohm

Could I use a 20K pot? I have some that I could get my hands on.

for the tranistor I'll use a 2n2222 eqivalent.

ReverseEngineered
Plugin Author
Posts: 192
Joined: January 18th, 2006, 11:09 pm
Location: Saskatoon, Saskatchewan, Canada

Post by ReverseEngineered »

Actually, the resistors can easily be 1/4 or 1/8 watt. The power you calculated was actually how much is used by the LED backlight, not how much is lost in the resistor.

For a quick review of how power works, P=VI. Here the current is the current going through it, and the voltage is the difference in voltage across it. For the LED backlight, V is 4.2v, since it has 4.2v at one end and 0v (ground) at the other. To keep the transistor turned on, the base resistor supplies much less current to the base than is flowing through the collector (and hence through the LED backlight); in this case I've chosen 1/10th (a common rule).

To calculate the power of this base resistor, assume that the turn on signal from the parallel port is +5V. The emitter of the transistor is at 0V, and there is a 0.7v drop across the base-emitter (putting the base at +0.7v). This means the voltage across the resistor has to be 5v-0.7v=4.3v. At 100ohms, the current flowing through it is 4.3v/100ohm=0.043A. Thus, the power dissipated is 4.3v*0.043A = 0.185w, or just over 1/8watt. It would be safe to use a 1/8w here, but I'd recommend a 1/4w, just to keep it from getting hot.

So, from the schematic I posted earlier, R1 would be a 1/4w 100ohm. R2 would be about 2.0ohm, but you would be safe to leave it out. With a forward voltage drop of 4.2v and a power supply of 5v, the LED will automatically limit itself (the voltage drop rises with the current, to the point where an equilibrium will be reached before the LED burns out). I currently have my similar LED backlight hooked directly up to 5V and it hasn't burned out yet.

johnmacd
Posts: 26
Joined: March 6th, 2006, 3:08 am

Post by johnmacd »

I'm not sure if we are talking about the same wirring diagram.
Standard symbols depend on where you are from. Unfortunately, like so many other things, North America uses different terms and symbols than Europe. The symbols and part numbers that I use are those used in Canada, and in the rest of North America.
The one I was talking about was: Image

I tried this wiring over the weekend, and I couldnt get the lcd to work at all. I ended up wiring the LCD directly to the parallel connector without the use of any components using the following:

Code: Select all

LCD Pin Number	Symbol	Function	Parallel/Power Connection
1	Vss	Display power ground	Molex ground (either black wire)
2	Vdd	Display power +5V	Molex +5v (red wire)
3	Vo	Contrast Adjust. Altered by adjusting the voltage to this pin, grounding it sets it to maximum contrast. *	Molex ground (either black wire)
4	RS	Register select	Parallel pin 16
5	R/W	Data read/write selector. Its possible to read information from a display however there's no need for it here so grounding it sets it permanently write.	Molex ground (either black wire)
6	E	Enable strobe	Parallel pin 1
7	DB0	Data Bus 0	Parallel pin 2
8	DB1	Data Bus 1	Parallel pin 3
9	DB2	Data Bus 2	Parallel pin 4
10	DB3	Data Bus 3	Parallel pin 5
11	DB4	Data Bus 4	Parallel pin 6
12	DB5	Data Bus 5	Parallel pin 7
13	DB6	Data Bus 6	Parallel pin 8
14	DB7	Data Bus 7	Parallel pin 9
15	A	LED backlight power +5v	Molex +5v (red wire)
16	K	LED backlight power ground	Molex ground (either black wire)
I found the above at:
http://www.icehw.net/article.php?id=104

I wasnt sure if the LCD was even working, so I tried the second wiring just to prove that the LCD was working and it worked. So I guess back to the drawing board to see what I might have done wrong. The one major difference between the two wiring diagrams that I noticed (other than the fact that no components are used) was that R/W isnt used (goes to ground) and pin 16 on the LCD was wired directly to ground.

makarona
Posts: 30
Joined: March 15th, 2009, 10:59 pm

Post by makarona »

is there's a way to get backlight control on FTDI version ?

pranja
Posts: 5
Joined: June 10th, 2011, 2:09 pm

Re: Backlight control - HD44780

Post by pranja »

I was reading this topic, and I am little bit confused.

If I understanded correctly, 1kR and 100R resistors are not needed. What about that 22kR pot? I dont need any brightness or contrast control, just want standard image on lcd. Which values of resistor do you recommend?

I have 10kR pot, can I use it instead 22kR pot?

I have BC547 transistor.

mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Re: Backlight control - HD44780

Post by mattcro »

Depending on your LCD, you might still need the 100ohm resistor. If your LCD can take 5V directly for the backlight, then you can safely connect the backlight to the 5V supply. If not, you will need the resistor. Try different values between 10ohms and 100ohms to set the brightness.

You can leave out the 1kohm resistor and the transistor if you do not want to adjust (or turn on/off) the backlight.

You do need the pot for the contrast control. It only needs to be a small preset type because this is a set-and-forget thing - LCDs vary slightly and you need to adjust for best contrast at whatever viewing angle you use. You can use a 10k or even 4.7k pot instead of the 22k shown.

pranja
Posts: 5
Joined: June 10th, 2011, 2:09 pm

Re: Backlight control - HD44780

Post by pranja »

Thx. I will report if succeded.

Post Reply