PDA

View Full Version : Controlling LCD B/L



solidus
- 10th September 2009, 23:19
@ DEVICE pic16F876 ' System Device
@ DEVICE pic16F876, WDT_ON ' Watchdog Timer
@ DEVICE pic16F876, PWRT_ON ' Power-On Timer
@ DEVICE pic16F876, BOD_ON ' Brown-Out Detect
@ DEVICE pic16F876, LVP_OFF ' Low-Voltage Programming
@ DEVICE pic16F876, CPD_OFF ' Data Memory Code Protect
@ DEVICE pic16F876, PROTECT_OFF ' Program Code Protection
@ DEVICE pic16F876, XT_OSC
ADCON1=7
ON INTERRUPT GOTO KESME
INTCON = %11110000 ' Tmr0 aktif
OPTION_REG = %01010101'Pull up dirençleri İPTAL- Bölme oranı 1/64.

Define LCD_DREG PORTC ' LCD data portunu belirle
Define LCD_DBIT 4 ' 4 bit'lik veri yolu
Define LCD_RSREG PORTC ' LCD register seçme portunu belirle
Define LCD_RSBIT 2 ' LCD register seçme bitini belirle
Define LCD_EREG PORTC ' LCD enable portunu belirle
Define LCD_EBIT 3 ' LCD enable bitini belirle
Define LCD_LINES 2 ' LCD'deki satir sayisi
trisb=%11111111
TRISC=%11111101


LCDK VAR BYTE
Z VAR BYTE
Led_isik VAR BYTE
SAYAC VAR BYTE
LCD_Led VAR PORTC.1
'tmr0=0
Lcdk=0
BASLA:
PAUSE 300
LCDOUT $FE,$80,"HI!"
LCDOUT $FE,$C0,"LCD BACK LIGHT CONT."
LCDOUT $FE,$94,"B.0 & TMR0"

DISABLE
KESME:
if INTCON.1=1 then
z=1
Led_isik=0
SAYAC=0
Lcdk=0
endif
if z=1 then
if Lcdk=0 then
LCD_Led=1
Lcdk=1
endif
SAYAC=SAYAC+1
if SAYAC=62 then
SAYAC=0
Led_isik= Led_isik +1
endif
if Led_isik=8 then
LCD_LED=0
Led_isik=0
SAYAC=0
Z=0
Lcdk=0
endif
endif
RESUME
ENABLE
END


Hi I want to control LCD B/L with B.0 and Tmr0 interrupts. But still some problems. I can't find it. Pls Help me !!

Charles Linquis
- 11th September 2009, 16:52
The backlight of an LCD generally cannot be controlled through the digital interface.

You will need a FET (I use an FDC610) with the source connected to GND, the drain connected to the backlight (-) terminal, and the backlight (+) terminal connected to 5V. Your LCD may require a 5 ohm .5W resistor between the (+) terminal and 5V to limit the backlight current (check the datasheet).

Connect a 10K resistor between the FET gate and GND and also connect
the gate to a PIC output pin. Whenever you want to turn on the backlight, bring the output pin high.

Melanie
- 11th September 2009, 18:18
http://www.picbasic.co.uk/forum/showthread.php?t=794

solidus
- 12th September 2009, 10:38
Hi Melanie,
Do I have to use pwm for lcd lihgt ?

Acetronics2
- 12th September 2009, 10:57
Hi,

As I do not understand your comments and variables ( Turkish ??? )

One good question would be :

What do you want to do ???

- on/off control ??
- dimmer ??

Alain

Melanie
- 12th September 2009, 14:39
Well, you don't have to use PWM... but if you do, then you will have control over the Brightness and will be able to adjust for your own comfort level. If you have two PWM channels available, then you can do the same thing for your LCD's Contrast. Search the forum for Easy Contrast if you want to do that.

If you just want to turn your LCD's Backlight ON/OFF then any I/O Channel will do, but you must know how much current the Backlight will require... if it requires more than 25mA, then you need an external Driver of some sort.

Charles Linquis
- 12th September 2009, 20:47
If you just hook things up like I describe above (using an N-channel, logic-level FET driver) all you have to do is set the pin to "1" to turn the backlight ON, and set it to "0" to turn it off.

PWM is not required unless - as Melanie says, you want to control the brightness of the backlight. And I have never seen a backlight that takes less than 200 mA.
You will not be able to drive the backlight directly from a PIC pin.

Melanie
- 12th September 2009, 21:17
Actually Charles, the 'Cool Blue' displays take about 20-25mA to give you more than adequate illumination (as they only have a single high-intensity white LED performing the Backlight - rather than a whole bank of Yellow or Green LEDs). You can drive those directly from a PIC pin... and they've been around for about five/six years now...

See post #12 here...

http://www.picbasic.co.uk/forum/showthread.php?t=632&highlight=cool+blue

Charles Linquis
- 13th September 2009, 03:35
Wow! Thanks!
I have an application that can use that. My PIC circuit is powered by a tiny AC -> 5V switcher (1"X2"), and I barely have enough extra power to run the backlight. This display solves the problem.

Acetronics2
- 13th September 2009, 10:18
Hi, Charles

And keep in mind those "new" backlights need " not so far " from 5 v supply !!!

Mine are rated 5v @ 0°C and 4.7v @ 25°C ...

Regards

Alain

Melanie
- 13th September 2009, 12:10
Hmmm... this 5v business is debateable... I've run them from close to 24vDC (with a suitable current limiting Resistor of course - at the end of the day it is no more than an LED). I must admit, the early ones (back from 2004) that have been run 24/7/365 at about 70% brightness are starting to get a bit dim, and you need to turn the brightness up to about 90% to achieve the same level as a new unit... We've have ONE dud B/L LED in that five-year period (after 3 years service at near 100% brightness supplied from about 20vDC).

Hey, nice picture Alain - nice to know what folks look like... *smiles*

Charles Linquis
- 13th September 2009, 16:46
I think the confusion here is the trouble that a lot of people have with LEDs:
You can't just run them like a lamp, you need a current-limiting resistor.

The forward voltage of most backlights is 4.2-4.7V, so if you need to provide them with 100mA of drive, you need (5-4.5) = .5V/100mA = 5 ohms in series.
You can power the same backlight from 24V, but then you would need (24-4.5 = 19.5/100mA = 195 ohms in series. Please note that in the latter case, the resistor would dissipate close to 2watts.

A few LCDs have the resistors "on board", but most require external current-limiting resistors.

Acetronics2
- 13th September 2009, 17:02
Hey, nice picture Alain - nice to know what folks look like... *smiles*

Hi, Mel

I knew you would love it ...

You've always been a romantic girl ...

BTW ... Try to find the Film " Always " by Steven Spielberg, starring R. Dreyfuss ...

you'll love it.

really

Best Regards

Alain

Ioannis
- 14th September 2009, 11:13
I must admit, the early ones (back from 2004) that have been run 24/7/365 at about 70% brightness are starting to get a bit dim...

Well, 5 years are almost half the LED life provided that LED are kept cool at room temperatures.

If the temperature is higher than 25C, then the 44.000 hours seems resonable enough.

Ioannis