PWM dimming of backlight -- any down side?

Hi -- I'm using this DFR0669 screen (with an ESP32) and it works fine. I turn the backlight on or off with the BLK pin. It is controlled by an ILI9488.

Can I safely try dimming the backlight using a PWM pin?

Relevant part of the screen module schematic shows the screen's 3.3v volts pulled high by the screen (i.e. so it's on unless BLK is pulled low)... if I send a PWM on that pin, is it going to mess with the voltage regulator(s) on the screen in some way? Or can I just try it and see how it goes?

dfr0669_blk

Side question: are there any effects of using a PWM pin on a microcontroller? E.g. some consumption of resources in the background that would affect a very busy program running? Is is PWM pretty effortless for microcontrollers to do?

I think you can just try and see how it goes, it appears to be a fully independent part.

PWM is done using a hwTimer and requires almost no effort at all.

What voltage is Vcc in that schematic?

Because Vcc as well as 3V3 is used in the schematic, that means Vcc could be a different voltage to 3.3V, for example 5V. But, in your circuit, is Vcc also 3.3V?

If Vcc is 3.3V then I see no problem connecting BLK to an ESP pin.

If Vcc is higher than 3.3V, then, in theory, connecting BLK to an ESP pin could damage it. In practice, that 10K resistor will probably protect the ESP, but it would be better to use another transistor between the ESP pin and BLK.

In the specification it says

Operating Voltage: 3.3V-5.5 V

which for an ESP32 would mean you should use 3.3v.

That said, the screen will use significant current, and how the whole thing is powered will matter. If you power the whole thing using 5v (say USB) that means that the regulator on the ESP32 will power also the screen. It should be capable of doing this (they are usually rated for 600mA) but the ESP32 board may get a little warm.

Thanks all! -- PWM works just fine to dim the screen.

However thanks for the PSU notes -- the screen is getting 5V for Vcc directly from a PSU, and the ESP32 board driving BLK is of course TTL 3.3V. So far, so good (it has run for ~a month without issue) -- does this mean that the 10k is protecting the GPIO pin adequately? Or am I risking a slow damage to the pin over time?

Not slowly over time, it can basically burn out any moment or never. It is not a matter of wear.

I would consider using a transistor to drive the pin LOW, a simple multi-purpose one would do. I have BC547B's for it, It would invert the logic, but that doesn't really matter much.

Thanks -- is this the basic idea?

I have PN2222A's around... seems like that would work too, yeah?

Should do yeah. I would omit the 10K pulldown, and you may need to fiddle a bit with the base resistor value. I guess if the duty cycle equals a 100% the backlight has to be fully off. Also the voltage drop can be relevant compared to the transistor on the backlight

Thank you --

My current code is doing digitalWrite for values 0 and 255, and analogWrite for anything in between, for whatever that's worth. (Though probably it just does that under the hood anyway?)

Apologies -- would you mind elaborating a little? I'm a newbie with transistors. :slight_smile:

If the voltage drop of your transistor is significantly more than the one on the board, the transistor will not pull the input fully down.

That depends on the MCU. in most cases it is actually 2 different things.
I found that analogWrite did not even depend on the oinMode in one case, and it disabled digitalwrite in another case, though that was only on a specific pin. Personally i would stick to one or the other. On an AVR, digitalWrite(0 checks if PWM is controlling the pin, if so disables it and then sets the pin. attaching at detaching the timer (or the compare register or whatever it is) seems like something inefficient. (early esp8266 core could not go above 90% duty cycle, but i am sure that is a thing of the past. PWM on an ESP32 is near perfect.

1 Like

I see, thanks. Sounds like a "try it and find out" situation, then. I'll see what happens.

Another person suggested removing R21 from the screen module PCB -- I was able to locate it on the board so I think I might try that first... then (IIUC) I should be able to use it without any extra components, which sounds very tempting. :slight_smile:

Also a solution i would probably go for.

2 Likes

EDIT: spoke too soon! The screen isn't actually turning off now! I was fooled by a black screen but the backlight is still on... any ideas why that may be?

EDIT2: disregard, more informed question coming soon...

EDIT3: was just the digitalWrite() after analogWrite() issue... everything actually works fine. :slight_smile:


In case anyone with the same screen finds this thread: I removed R21 and all seems to be as expected. I measure 4.5V on the VCC side of where it used to be and 0 or 3.2V on the other side, as expected. Screen works fine and is dimming as expected. Thanks again to everyone for the help.

Here's a pic in case it's useful:

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.