cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling LCD Contrast and Backlight with microcontroller?

KevinZ
Associate II

Hello, all, and Happy New Year.

I'd like to control the contrast and backlight for an 4x20 LCD display (like the NHD-0420AZ-FL-GBW-33V3) using the programming in the micro-controller, in my case, a STM32L010K4Tx. For instance, I want to control the contrast through a user dialog, or use the backlight to 'flash' the display to call attention to it.

The datasheet of the display's contrast pin just states, "Supply Voltage for Contrast (approx. 0V)".  A reference schematic just shows it connected to the wiper of a 10-20K pot connected at the ends to GND and VDD. For the backlight, the current is typically 15 mA at a voltage of 2.8-3.3v.

I think that I could implement micro-controller control using PWM output pins, but I suspect that I'll need some sort of low-pass filtering, to smooth out the pulses, and probably current buffering, with a transistor or MOSFET, to deliver more current than the controller can sink or source.

Has anyone done this type of thing before, and can point me to some datasheets or reference schematics that can get me started on this task?

Thanks so much for your advice and guidance.

-Kevin

1 ACCEPTED SOLUTION

Accepted Solutions
gbm
Lead II

From my experience with LCD test displays:

Contrast may be controlled by PWM output with RC filter. Use <= 1k series resistor and 1..10 u capacitor, set the output as open drain, duty should be quite low - between 0 and 1/10; frequency >= 1 kHz.

For manual regulation you don't really need a potentiomenter between Vcc and GND - just a variable resistor connected between GND and contrast control input.

View solution in original post

5 REPLIES 5
Chris21
Associate III

The contrast pin of the LCD expects a voltage, you would need a circuit such as an RC-type low pass filter to convert the PWM signal to a voltage.  I doubt you need any current buffering for that, likely there is very little current there.

For the LED backlight, I would expect that you could directly drive that with an I/O pin, and use PWM if you want to control the brightness.  (Although 15 mA is the maximum current, may want to use a transistor for this, as you mentioned).

SofLit
ST Employee

Hello,

For the backlight it's not mandatory to use a low pass filter. You can just drive it directly with PWM by taking into account the current to drive the backlight. 

For the contrast, measure the current that flows over the 10-20K pot (which is a voltage divider) to the LCD input . Your measurement can tell you if you should add buffering or not. I think better to add low pass filter in PWM output for contrast control. 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

If a 10-20k pot is fine as a voltage divider, then obviously MCU output doesn't need additional buffering.

gbm
Lead II

From my experience with LCD test displays:

Contrast may be controlled by PWM output with RC filter. Use <= 1k series resistor and 1..10 u capacitor, set the output as open drain, duty should be quite low - between 0 and 1/10; frequency >= 1 kHz.

For manual regulation you don't really need a potentiomenter between Vcc and GND - just a variable resistor connected between GND and contrast control input.

KevinZ
Associate II

@Chris21@SofLit, @Piranha and @gbm , thank you for your help and advice, And especially thank you, @gbm for providing some specific values and concrete circuit suggestion. I appreciate all your efforts to help me.

-Kevin