EEVblog Electronics Community Forum
Electronics => Beginners => Topic started by: MrOmnos 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?
-
brightness or contrast? pwm in any case but for contrast it might get tricky
-
brightness or contrast? pwm in any case but for contrast it might get tricky
Sorry, I meant contrast!!
-
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
-
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.
-
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.
-
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.
-
pwm for brightness, digital pot for contrast.
-
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!!
-
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.
-
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.
-
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!
-
I meant contrast!!
The simplest would be to use a digital pot.
Alternatively, use a pulse generator (pwm for example) + charge pump (diodes + capacitor).