Posted: 10:48am 11 Sep 2025 Copy link to clipboard
Wolfgang Newbie
Hello user,
I'm a litte bit confused, because I can't manage to generate a PWM, see listing. What am I doing wrong?
The serial output is working, but PWM inputs produce an error
I tried other GP-Pins too, but no success.
Greets Wolfgang
Posted: 11:00am 11 Sep 2025 Copy link to clipboard
matherp Guru
See Manual page 11 then Manual page 149
Posted: 11:25am 11 Sep 2025 Copy link to clipboard
Volhout Guru
Hi Wolfgang,
PWM's on the RP2040(and RP2350) come in pairs. For each PWM block there is a A output and a B output. Look at the pinout of the Pico in the user manual. The commands in MMBasic have parameters for the A and B output separate. When not using the A output, you can leave the A parameter blank.
Volhout
Posted: 01:27pm 11 Sep 2025 Copy link to clipboard
Wolfgang Newbie
Many thanks,
the little detail named "double-comma" solved the problem. it works now, see picture: I hope I understand this right.
As a newcomer, I searched before through many forum posts and the manual too, to find information or examples about PWM settings, but I couldn't find an example that showed a double-comma setting before the duty cycle value.
My intention behind this kind of PWM is to dimm the brightess of my ST7796 as a function of daylight resp. night.
May be the manual can show a similar example code?
Thanks once more for your fast response.
Greets Wolgang
Posted: 01:53pm 11 Sep 2025 Copy link to clipboard
Volhout Guru
Hi Wolfgang,
You can assign a PWM to control the backlight (i.e BL=GP5)
Using the MMBasic "BACKLIGHT n" command you can assign a brightness value. This value can be taken form an ADC reading of a light sensor, or from a calculated time. So you do not have to control the PWM yourself. This all is supported by MMBasic commands.
Volhout Edited 2025-09-11 23:55 by Volhout
Posted: 03:46pm 11 Sep 2025 Copy link to clipboard
Wolfgang Newbie
Hi Volhout,
yes, the I knew the BL in Option LCD already before, but I want to control the brightness without this Options-possibility. (I am learning , because I don't want to input the Options everytime again with a new environment)
In the meantime I have tested a little bit more, and I think, that I now understand the double-comma information.
In order to use the PWM, (e.g. GP4/GP5)
SETPIN GP4,PWM 'Channel 2 with Duty A=30% SETPIN GP5,PWM 'Channel 2 with Duty B=50%
PWM 2,1000,30,50
Is this understanding correct?
Greets Wolfgang
Posted: 07:24pm 11 Sep 2025 Copy link to clipboard
Volhout Guru
Correct, the PWM runs at 1kHz for both channels.
Volhout
Posted: 06:17am 12 Sep 2025 Copy link to clipboard
Wolfgang Newbie
Hi Volhout,
now that I understand this, I can see that your suggestion regarding [BL] in the LCD options is the more practical approach, as it appears to be the better way to control the LCD brightness.
Many thanks once more
Wolfgang
Posted: 06:02pm 12 Sep 2025 Copy link to clipboard
stanleyella Guru
why dim lcd brightness. it wants brighter not dimmer? ili9341 led I power at 5V. should it be via resistor? been years just 5V.
Posted: 07:08pm 12 Sep 2025 Copy link to clipboard
Mixtel90 Guru
Depends what you are doing, Stan. Bright for fast graphics in a normal room or outdoors, dim for static stuff in a dark room. There's no point in hammering the backlight if you don't need to. :) Sometimes you might run it dim normally an switch to bright for an alarm indication.
. Edited 2025-09-13 05:09 by Mixtel90
Posted: 07:34pm 12 Sep 2025 Copy link to clipboard
stanleyella Guru
pwm led backlight is fine but could it be pulsed to be really bright?
Posted: 07:34pm 12 Sep 2025 Copy link to clipboard
Volhout Guru
Stan,
The 9341 that have a transistor to drive the backlight, power the backlight from the 3.3v lineair regulator on the lcd module. Regardless if you power from 3.3v or 5v you get roughly same brightness. Only thing that helpt a bit in brightness is if you short that transistor, but then you loose PWM control of the backlight. On my game*mite I replaced the transistor with a small Mosley that has less voltage drop.
Volhout Edited 2025-09-13 05:36 by Volhout
Posted: 07:47am 13 Sep 2025 Copy link to clipboard
Wolfgang Newbie
I use the ST7796, which is extremely bright, so I have now dimmed it to 30% to prevent it from shining so brightly at night.
Greets Wolfgang
Posted: 08:23am 13 Sep 2025 Copy link to clipboard
phil99 Guru
The ILI9488 IPS also very bright.
Posted: 08:24am 13 Sep 2025 Copy link to clipboard
Mixtel90 Guru
Most of the backlights are bright enough for most purposes. The main exception is when they are used outdoors, and that's always a problem for any transmissive display. Most of a mobile phone's power use goes into powering the backlight.
If you are having problems with the backlight not being bright enough, Stan, then make your lines a pixel thicker and/or use a bolder font. That will let more light through.
Yes, you can make a backlight extremely bright but its life is based on how hot it gets. That in turn is based on how easily it can dissipate the heat. You can increase the current but you must keep the *average* dissipated power within safe limits or you will kill the display as it overheats. A lot of current for peaks means longer spaces between those peaks so flicker increases. Forced air cooling helps if you can get it in the right place. :)
Posted: 10:20am 13 Sep 2025 Copy link to clipboard
Wolfgang Newbie
I have both displays in operation, both ILI9488 and ST7796, and I was wondering why the ST7796 appears significantly brighter.
I used the connections from the manual given for the ILI9341 and connect the LED pin to GP5 for brightness adjustment.
The displays are working inside the house.
Wolfgang
Posted: 12:12pm 13 Sep 2025 Copy link to clipboard
phil99 Guru
Two possibilities for a display being brighter. 1) The backlight may have more LEDs so can run at a higher current. 2) Different LCD technology. In-plane switching (IPS) type can pass more of the backlight than thin-film transistor (TFT) type. . Edited 2025-09-13 22:12 by phil99
Posted: 04:42pm 13 Sep 2025 Copy link to clipboard
Wolfgang Newbie
3) LED technology has improved, resulting in greater light output for the same amount of current.