snazzify
Posts: 14
Joined: Fri Jul 29, 2016 4:49 am
Location: California, USA

PWM hardware for dimming LCD

Sat Jul 14, 2018 2:26 am

I'm using the pigpio pwm hardware on gpio18 of a Raspberry Pi 3 to adjust the brightness of an LCD with a FAN5333 chip. I tested some software pwm code but dimming is unstable so im trying pwm hardware.

Bash command:

Code: Select all

pigs hp 19 1000 500000
C program:

Code: Select all

#include <stdio.h>
#include <stdint.h>

#include <pigpio.h>

int main(int argc, char *argv[])
{
   if (gpioInitialise() < 0) return 1;

   printf("start piscope\n");
   printf("press return to continue\n");
   getchar();

   gpioHardwarePWM(18, 1000, 500000);

   printf("STOP piscope\n");
   printf("press return to continue\n");
   getchar();

   gpioHardwarePWM(18, 0, 0);

   gpioTerminate();

   return 0;
}
Both the bash command and c program seems to work well and very stable. But my Raspberry Pi 3 B starts to crash and the lcd flickering when playing a game with RetroPie.

drgeoff
Posts: 8487
Joined: Wed Jan 25, 2012 6:39 pm

Re: PWM hardware for dimming LCD

Sat Jul 14, 2018 11:11 pm

Inadequate PSU whose voltage falls too much when RPi begins working harder and drawing more current?

User avatar
Pekka
Posts: 19
Joined: Mon Nov 19, 2012 4:11 pm

Re: PWM hardware for dimming LCD

Mon Jul 16, 2018 4:57 am

The HW PWM and 3.5 mm audio jack share the same hardware and cannot both operate at the same time. So if the game generates audio on the jack, this is the cause of screen flickering.

User avatar
joan
Posts: 13556
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: PWM hardware for dimming LCD

Mon Jul 16, 2018 6:58 am

Pekka wrote:
Mon Jul 16, 2018 4:57 am
The HW PWM and 3.5 mm audio jack share the same hardware and cannot both operate at the same time. So if the game generates audio on the jack, this is the cause of screen flickering.
That sounds the likely problem.

I suggest using http://abyz.me.uk/rpi/pigpio/cif.html#gpioPWM rather than gpioHardwarePWM. It is not as flexible but is more than good enough for dimming LEDs etc., and will not conflict with PWM audio.

Return to “Advanced users”

Who is online

Users browsing this forum: No registered users and 11 guests