Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new_pwm: sporadical flashing/flickering #1574

Open
verybadsoldier opened this issue Jan 16, 2019 · 2 comments
Open

new_pwm: sporadical flashing/flickering #1574

verybadsoldier opened this issue Jan 16, 2019 · 2 comments

Comments

@verybadsoldier
Copy link
Contributor

I have been using the ESP-PWM for quite a while in this project (LED controller):
https://github.com/verybadsoldier/esp_rgbww_firmware

The PWM is in my opinion 100% smooth and stable as I did not notice any flaws in in the past.

Now I am in the process of upgrading to Sming 3.7.0, ESP SDK 3.0.0 and to use new_pwm instead of SDK-PWM.
It is working smoothly now but I noticed that the PWM produced by new_pwm is less stable compared to SDK-PWM. When fading I see very short flashes every few seconds.

The effect is also visible in the demo Basic_HwPWM. I modified it slightly to this:

#include <user_config.h>
#include <SmingCore/SmingCore.h>
#include <HardwarePWM.h>

uint8_t pins[8] = {4, 5, 0, 2, 15, 13, 12, 14}; // List of pins that you want to connect to pwm
HardwarePWM HW_pwm(pins, 8);

Timer procTimer;
int32 i = 0;
bool countUp = true;

int maxDuty = HW_pwm.getMaxDuty();
int32 inc = maxDuty / 15;

void doPWM()
{
        if(countUp == true) {
                i += inc;
                if(i >= maxDuty) {
                        i = maxDuty;
                        countUp = false;
                }
        } else {
                i -= inc;
                if(i <= 0) {
                        i = 0;
                        countUp = true;
                }
        }
        HW_pwm.analogWrite(14, i);
}

void init()
{
        Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
        Serial.systemDebugOutput(true); // Enable debug output to serial

        const int period = int(float(1000)/(float(339)/float(1000)));
        HW_pwm.setPeriod(period);

        maxDuty = HW_pwm.getMaxDuty();

        // WIFI not needed for demo. So disabling WIFI.
        WifiStation.enable(false);
        WifiAccessPoint.enable(false);

        // Setting PWM values on 8 different pins
        HW_pwm.analogWrite(14, maxDuty);

        debugf("PWM output set on all 8 Pins. Kindly check...");
        debugf("Now Pin 2 will go from 0 to VCC to 0 in cycles.");
        procTimer.initializeMs(50, doPWM).start();
}

When running, every couple of seconds a subtle flashing of the LED is visible. It is really short, like the blink of an eye but it is noticable. I tested several times back and forth and the SDK-PWM does not show this effect using same code.

It might be related or even identical to this: StefanBruens/ESP8266_new_pwm#9

The hardware used for the LED controller is described here (might be relevant):
https://github.com/patrickjahns/esp_rgbww_controller

verybadsoldier added a commit to verybadsoldier/esp_rgbww_firmware that referenced this issue Jun 27, 2019
@slaff
Copy link
Contributor

slaff commented Jul 4, 2019

@verybadsoldier did you notice any improvement with the latest develop code?

@verybadsoldier
Copy link
Contributor Author

I am not using new_pwm anymore due to this flickering problem so I cannot say. Also I am still on 3.8.0. But as far as I know there were no commits to new_pwm in ages so I don't think the chances of a changed behavior is very high.

pljakobs pushed a commit to pljakobs/esp_rgbww_firmware that referenced this issue Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants