PDA

View Full Version : Easy LCD BackLight



Melanie
- 17th October 2004, 14:18
I thought I'd post as few LCD Notes, especially since there's a lot of interest in the 'Cool Blue' LCD's that have been discussed on the Olympic Timer Thread.

Previously in this forum section I have posted a way of performing "Easy LCD Contrast" using just two Resistors and a spare PWM pin from a PIC to give you software control over your Contrast. Figure 3, in the attached .jpg shows the arrangement for the Cool Blue along with the Resistor values that work real well.



'
' Subroutine Sets LCD Contrast Level
' ----------------------------------
SetLCDContrast:
DataA=DataA*40
HPWM 2,DataA,1000
Return

DataA is a Byte variable. Entry into the subroutine with DataA holding a value between 1 and 5 gives five steps of Contrast which is more than adequate. You can easily rehash the subroutine to your desired range.

Figures 1 and 2 give a couple of arrangements for "Easy Backlight", allowing you software control for the LCD's Backlight. Figure 1 shows the arrangement using a spare driver from a ULN2003, 2004, 2803 etc etc. Figure 2 shows the same arrangement using a low/medium power Transistor. Now I use BC639's because we buy them by the million and they only cost about a cent each when you do that. You don't have to use a transistor anywhere near that heavy.

The value of R1/R2 will depend on your supply voltage to the Backlight LCD. Select a value that gives no more than around 20mA when PWM=100%. You may want to run at a higher current at your own risk (I have run these at 40mA!!). Don't send me any LCD's under warranty on which you've blown-up the Backlights. Actually, if you're unfortunate enough to have done that (never yet seen it happen I should say), the single White LED is easily replaceable!



'
' Subroutine Sets LCD BackLight Level
' -----------------------------------
SetLCDBackLightOFF:
DataA=0
SetLCDBackLight:
DataA=DataA*51
HPWM 1,DataA,1000
Return

Similarly this routine sets fives steps for BackLight adjustment with DataA entering the subroutine at SetLCDBackLight in the range of 1-5. SetLCDBackLightOFF is self-explanatory.

If you've got a PIC with a couple of PWM pins, then you've got instant Software Control of both Contrast and Backlight. Usually, if I'm fitting an LCD, then the PIC is almost always something like a 28-pin device. My favourite is the 16F876 because you can devote all of PortC to the LCD for example... (4 Data Pins, E, RS, and both HPWM's all nicely fall out of PortC).

If you're running the BackLight at 5v (there are good reasons why I don’t do that), you can just plug the Backlight pin straight into the PIC without the intermediate Transistor or Driver. Why don't I run my BackLight from 5v? Quite simply, I tend to run my PIC circuits at only a very few mA, this allows me to put in cheap and cheerful Regulators. Any significant current draw on cheap Regulators varies the +5v by a few millivolts... now if I'm using the ADC's (as I invariably do), and I have my +VRef strapped to the +5v line, the small fluctuations on the +5v line correspondingly throw the ADC readings fractionally.

Melanie