Author Topic: How to digitally control the brightness of 16x2 LCD  (Read 4616 times)

0 Members and 1 Guest are viewing this topic.

Offline MrOmnosTopic starter

  • Frequent Contributor
  • **
  • Posts: 260
  • Country: np
  • BE in Electronics and Communication
How to digitally control the brightness of 16x2 LCD
« on: August 10, 2016, 12:28:18 pm »
Hi, is it possible to digitally control the brightness of 16X2 LCD. I have searched all over my workshop, I don't have a pot laying around. So, I was thinking If I could use Arduino itself to control the brightness of the LCD. PWM? How do I do it?
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: How to digitally control the brightness of 16x2 LCD
« Reply #1 on: August 10, 2016, 12:31:14 pm »
brightness or contrast? pwm in any case but for contrast it might get tricky
 

Offline MrOmnosTopic starter

  • Frequent Contributor
  • **
  • Posts: 260
  • Country: np
  • BE in Electronics and Communication
Re: How to digitally control the brightness of 16x2 LCD
« Reply #2 on: August 10, 2016, 12:35:06 pm »
brightness or contrast? pwm in any case but for contrast it might get tricky

Sorry, I meant contrast!!
 

Offline JPortici

  • Super Contributor
  • ***
  • Posts: 3461
  • Country: it
Re: How to digitally control the brightness of 16x2 LCD
« Reply #3 on: August 10, 2016, 12:41:48 pm »
i think you could be able to do it with filtered pwm, the pwm source must be able to sink current
google seems to confirm
 

Offline rob77

  • Super Contributor
  • ***
  • Posts: 2085
  • Country: sk
Re: How to digitally control the brightness of 16x2 LCD
« Reply #4 on: August 10, 2016, 01:11:58 pm »
filtered PWM would work... but the question is how will you adjust the contrast in software with user controls (buttons, encoder) if you don't see the text on the LCD because of wrong contrast setting ?  :-//
every piece of those cheap 16x2 displays from china  is different (that's my experience at least), there is no universal contrast setting for them - so you can't use a pre-set value in software.
the best way is a multi-turn trimpot (cheap one from china is more than good enough) and set the contrast for every piece individually.
if you really don't have a trimpot around and you need it for a one-off then try different values of fixed resistors to make the right voltage divider for the contrast, the contrast is not drifting on those LCDs (at least not noticeably) so the fixed divider is ok.
 

Offline batteksystem

  • Regular Contributor
  • *
  • Posts: 167
  • Country: hk
    • My ebay store
Re: How to digitally control the brightness of 16x2 LCD
« Reply #5 on: August 10, 2016, 01:22:14 pm »
Another way you could probably use a digital potentimeter, microchip has a tons of these with lots of selection, fairly easy to use (I believe it is controlled by I2C) but hell expensive.

Offline madires

  • Super Contributor
  • ***
  • Posts: 7763
  • Country: de
  • A qualified hobbyist ;)
Re: How to digitally control the brightness of 16x2 LCD
« Reply #6 on: August 10, 2016, 01:54:08 pm »
filtered PWM would work... but the question is how will you adjust the contrast in software with user controls (buttons, encoder) if you don't see the text on the LCD because of wrong contrast setting ?  :-//
every piece of those cheap 16x2 displays from china  is different (that's my experience at least), there is no universal contrast setting for them - so you can't use a pre-set value in software.
the best way is a multi-turn trimpot (cheap one from china is more than good enough) and set the contrast for every piece individually.
if you really don't have a trimpot around and you need it for a one-off then try different values of fixed resistors to make the right voltage divider for the contrast, the contrast is not drifting on those LCDs (at least not noticeably) so the fixed divider is ok.

I can confirm that from my experience with the TransistorTester project. Several graphic LCD controllers set the contrast by software and it's no easy to find a suitable default value for the contrast. Still there are several users which got problems with the display after upgrading the firmware, because their display requires some uncommonly low or high contrast value. And some screw up the contrast while adjusting it in the contrast setting function. Therefore I've added a special reset mode selectable while powering on.
 

Online linux-works

  • Super Contributor
  • ***
  • Posts: 1997
  • Country: us
    • netstuff
Re: How to digitally control the brightness of 16x2 LCD
« Reply #7 on: August 10, 2016, 02:06:18 pm »
pwm for brightness, digital pot for contrast.

Offline MrOmnosTopic starter

  • Frequent Contributor
  • **
  • Posts: 260
  • Country: np
  • BE in Electronics and Communication
Re: How to digitally control the brightness of 16x2 LCD
« Reply #8 on: August 10, 2016, 04:23:16 pm »
filtered PWM would work... but the question is how will you adjust the contrast in software with user controls (buttons, encoder) if you don't see the text on the LCD because of wrong contrast setting ?  :-//
every piece of those cheap 16x2 displays from china  is different (that's my experience at least), there is no universal contrast setting for them - so you can't use a pre-set value in software.
the best way is a multi-turn trimpot (cheap one from china is more than good enough) and set the contrast for every piece individually.
if you really don't have a trimpot around and you need it for a one-off then try different values of fixed resistors to make the right voltage divider for the contrast, the contrast is not drifting on those LCDs (at least not noticeably) so the fixed divider is ok.

I made a voltage divider using two 4.7k resistors and connected the contrast pin to it. I had to play around with few resistor values to get the result I wanted. 4.7k seems to be the sweet spot for all  4 LCDs I have. I think fixing the contrast in hardware is a better idea for any LCD project. Trim pot is just too much hassle and no one is going to use it anyway.  Thanks everyone!!
 

Offline danadak

  • Super Contributor
  • ***
  • Posts: 1875
  • Country: us
  • Reactor Operator SSN-583, Retired EE
Re: How to digitally control the brightness of 16x2 LCD
« Reply #9 on: August 10, 2016, 08:02:47 pm »
I used a PWM on a PSOC UP to control contrast on a 16 x 2 and 20 x 4.

In code when part started up it output a standard value on PWM which equated to V.

If the user could not see display he started it up coupled with a button push. That
triggered in code a routine that slew the PWM value from min to max, slowly, and when
LCD screen came into view able contrast he/she could press button again to freeze at that
value.

Same routine was used when system was setup in a utility and the optimal user perceived
contrast value was saved for future user startup.

Don't forget to LP Filter the pwm out to get DC for contrast pin. See attached design considerations.

Regards, Dana.
Love Cypress PSOC, ATTiny, Bit Slice, OpAmps, Oscilloscopes, and Analog Gurus like Pease, Miller, Widlar, Dobkin, obsessed with being an engineer
 

Offline macboy

  • Super Contributor
  • ***
  • Posts: 2254
  • Country: ca
Re: How to digitally control the brightness of 16x2 LCD
« Reply #10 on: August 11, 2016, 04:59:50 pm »
The contrast pin virtually never needs a pot, so using one will just waste power. For these HD44780 type modules, all that is required in my experience is a resistor to ground. Often a value of zero works, i.e. connect the contrast pin directly to ground. Otherwise just play with the value until you find the one the works for your module. If you really want/need end user adjustability, then you could try PWM.
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 11500
  • Country: ch
Re: How to digitally control the brightness of 16x2 LCD
« Reply #11 on: August 14, 2016, 02:38:11 pm »
I've used filtered PWM to control contrast, works fine. Doesn't solve the issue of variability between units of course.

What's a real pain in the ass are the LCD modules (big ones, in my experience) whose contrast adjustment range spans both positive and negative voltages!
« Last Edit: August 14, 2016, 02:39:42 pm by tooki »
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: How to digitally control the brightness of 16x2 LCD
« Reply #12 on: August 14, 2016, 03:35:16 pm »
Quote
I meant contrast!!

The simplest would be to use a digital pot.

Alternatively, use a pulse generator (pwm for example) + charge pump (diodes + capacitor).
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf