+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2003
    Posts
    2,358

    Default Easy LCD Contrast

    Here's a useful and very simple way of controlling the contrast on an LCD with just two Resistors and a line of code. If the PIC in your project has an unused available PWM channel (eg 16F628, F876 etc etc), then this will enable you to control your LCD's contrast over it's usable range and at absolute minimum cost.

    HPWM 1,Contrast,1000

    Where Contrast is a byte variable in the range 0-125. Steps of 25 seem to be adequate (ie Contrast=0, 25, 50, 75,100 or 125) where zero is maximum and 125 is minimum. Stepping above 125 is pointless as your display will disappear into obscurity.

    The value for Resistors R1 and R2 I've set at 1K5, mainly because I've been told we have almost 2 million of that value in stock and please can I find a way of getting rid of them. Decreasing R2 to say 680R will increase the bottom-end contrast, but the software variable Contrast might need larger steps (say steps of 40) and increased span (eg 0-240).

    You really don't get much cheaper or simpler than this...

    Melanie
    Attached Images Attached Images  

  2. #2
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    989

    Default

    Thanx Melanie,
    I will be able to try that out in my current project which is a
    2x16 LCD. I'm not worried about a few dollars/cents for a trimpot,
    but any saving of space on any PCB is a blessing, and so is
    software control over hardware
    Art.

  3. #3
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323

    Default Thanks Melanie!

    Well it's just amazing how simple and easy that is!
    Works Great!



    steve

  4. #4
    Join Date
    May 2007
    Posts
    604

    Default

    Will this work with a graphic LCD?

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

    Default

    If your LCD's Contrast is adjusted the same way as in a standard LCD, then yes. Just try it - you have nothing to lose but a few minutes out of your life.

    There's a lot of goodies buried in this forum, you just have to dig around a little.

    Good to have your vote of confidence Steve. *smiles*

  6. #6
    Join Date
    May 2007
    Posts
    604

    Default

    OK, thanks.

  7. #7
    Join Date
    Nov 2003
    Location
    Sao Paulo - Brazil
    Posts
    92

    Default Re: Easy LCD Contrast

    Hello Guys !


    I Know that this is an old post, but I would like to implement this solution on my project.

    I´m using a 16F877A @ 4Mhz, a 4x20 lcd and DT_Interrupts.

    I´m using the Timer0 for pulse counting, Timer2 as a 500 ms Time base and Timer1/CCP1 for pulses "on-time" reading.

    My doubt is : Can I use CCP2 to implement the contrast control as sggested by Melanie ? Or, as all timers are being used by the mains program, I can not implement it ?

    SHould I move to another PIC, 18F2520, for example ?

    Thank you !

    Regards,

    Sèrgio Pinheiro

  8. #8
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    765

    Default Re: Easy LCD Contrast

    all your timers are in use

    ccp1 can use timer 1 or 2 , and ccp2 can use timer 1 or 2 , since you have used both timers else where u need a chip with more timers for another pwm output

    i would look at using an 18f device , that includes a lot more for the very simular price
    i would recommend the 18f26k22 or 18f26k80( FOR 12BIT ADC) for a 28pin device , or if you like perhaps go 48pin 18f46k22
    for About the same pricing , it supports alot more timers , 4 PWM PORTS min

  9. #9
    Join Date
    Nov 2003
    Location
    Sao Paulo - Brazil
    Posts
    92

    Default Re: Easy LCD Contrast

    Thank you friend !

    I have some 18f2520 gere with me. I'll tive a try !

    Thank you again !

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  3. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  4. How to change contrast LCD?
    By MCU Destroyer in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 3rd July 2005, 13:16
  5. Easy LCD BackLight
    By Melanie in forum Schematics
    Replies: 0
    Last Post: - 17th October 2004, 13:18

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