![]() |
Forum Index : Microcontroller and PC projects : PWM will not work..?
Author | Message | ||||
Wolfgang Newbie ![]() Joined: 03/11/2021 Location: GermanyPosts: 22 |
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 |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10397 |
See Manual page 11 then Manual page 149 |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5243 |
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 PicomiteVGA PETSCII ROBOTS |
||||
Wolfgang Newbie ![]() Joined: 03/11/2021 Location: GermanyPosts: 22 |
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 |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5243 |
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 PicomiteVGA PETSCII ROBOTS |
||||
Wolfgang Newbie ![]() Joined: 03/11/2021 Location: GermanyPosts: 22 |
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 ![]() 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 |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5243 |
Correct, the PWM runs at 1kHz for both channels. Volhout PicomiteVGA PETSCII ROBOTS |
||||
Wolfgang Newbie ![]() Joined: 03/11/2021 Location: GermanyPosts: 22 |
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 |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2631 |
why dim lcd brightness. it wants brighter not dimmer? ili9341 led I power at 5V. should it be via resistor? been years just 5V. |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 8067 |
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 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2631 |
pwm led backlight is fine but could it be pulsed to be really bright? |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5243 |
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 PicomiteVGA PETSCII ROBOTS |
||||
Wolfgang Newbie ![]() Joined: 03/11/2021 Location: GermanyPosts: 22 |
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 |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2707 |
The ILI9488 IPS also very bright. |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 8067 |
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. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Wolfgang Newbie ![]() Joined: 03/11/2021 Location: GermanyPosts: 22 |
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 |
||||
phil99![]() Guru ![]() Joined: 11/02/2018 Location: AustraliaPosts: 2707 |
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 |
||||
Wolfgang Newbie ![]() Joined: 03/11/2021 Location: GermanyPosts: 22 |
3) LED technology has improved, resulting in greater light output for the same amount of current. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |