Controlling LCD B/L


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Jan 2009
    Posts
    4

    Default Controlling LCD B/L

    Code:
    @ 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 !!

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    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.
    Charles Linquist

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

  4. #4
    Join Date
    Jan 2009
    Posts
    4


    Did you find this post helpful? Yes | No

    Default

    Hi Melanie,
    Do I have to use pwm for lcd lihgt ?

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink Which Goal ???

    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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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.

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    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.
    Charles Linquist

  8. #8
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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/show...ight=cool+blue

  9. #9
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    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.
    Charles Linquist

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  11. #11
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    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*

  12. #12
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    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.
    Charles Linquist

  13. #13
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Melanie View Post
    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
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  14. #14
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,817


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie View Post
    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

Similar Threads

  1. Is this code not initialising the LCD properly?
    By Platypus in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 30th January 2010, 19:14
  2. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  3. LCD Problem
    By karenhornby in forum General
    Replies: 3
    Last Post: - 19th June 2008, 11:43
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. Dedicated LCD Controller question
    By chuckles in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th February 2006, 14:44

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts