RMT based NeoPixels (WS2812B) flickers when WiFi is used

tltltl
Posts: 6
Joined: Mon Dec 18, 2017 1:49 pm

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby tltltl » Mon Oct 22, 2018 7:34 am

This problem sadly never got resolved.
We tried many different things. We used different pieces of SW, different libraries, different approaches (RMT, separate pinned task, etc).
As far as we could tell, we couldn't make any progress except that some approaches flickered a bit more and some a bit less.

An interesting fact is, that we use multiple identical devices and IF it flickers, it flickers on all of them in the exact and identical pattern. ESP32 rev0 vs rev1 didn't make a difference either.
Also we investigated the signal and we're certain that, the RMT-signal comes out scrambled on the level of ESP. So we're certain that the flickering isn't because of our HW.

We're certain as well that it correlates with WiFi. If not using WiFi we *never* had any issue. If using WiFi (regardless of what: udp, tcp, sta, ap, etc) the issues randomly appears.

I'd really appreciate it, if you could post any news you find along the way - maybe I can try some of your approaches as well and I'm happy to answer any question you may have...:-)

cheers!

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby ESP_Sprite » Tue Oct 23, 2018 2:37 am

Is there any chance you can build a minimal application that shows this issue, so we can reproduce it easily?

cranphin
Posts: 8
Joined: Mon Apr 02, 2018 12:31 pm

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby cranphin » Tue Oct 30, 2018 5:02 pm

Right, I think I actually fixed my problem..
I created the interrupt handler (rmt_driver_install for RMT, digitalLeds_initStrands for the WS2812 library) from the main task (app_main), which apparently defaults to being on core 0. This also makes the interrupt handler being handled on core 0 (as documented on https://docs.espressif.com/projects/esp ... ore-issues).

Changing things so that the interrupt handler is created from core 1 seems to solve my issue! :) Still testing though.

nokeyboard
Posts: 1
Joined: Sat Dec 08, 2018 10:28 pm

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby nokeyboard » Sat Dec 08, 2018 11:10 pm

Hello!

I have the same issue - ws2812b pixels glitches when wifi transferring data.

I've tried use another core following the advice given by @cranphin but no success.

There is my part of code for leds. It makes simple rainbow effect. And when esp32 transferring data pixels start flickers with wrong colours. I use this lib for pixels: https://github.com/FozzTexx/ws2812-demo.

Code: Select all


....
wifi logic
....

void strip_init();
void app_main(void) {
    // Initialize NVS
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK( ret );

    wifi_init();
    wifi_remote_control_init();
    strip_init();
}


#define WS2812_PIN  18
#define LED_COUNT 132            // this is the number of WS2812B leds on the strip
#define delay_ms(ms) vTaskDelay((ms) / portTICK_RATE_MS)

// rgbVal pixels[LED_COUNT];

void rainbow(void *pvParameters)
{
  const uint8_t anim_step = 10;
  const uint8_t anim_max = 100;
  const uint8_t pixel_count = LED_COUNT; // Number of your "pixels"
  const uint8_t delay = 25; // duration between color changes
  rgbVal color = makeRGBVal(anim_max, 0, 0);
  uint8_t step = 0;
  rgbVal color2 = makeRGBVal(anim_max, 0, 0);
  uint8_t step2 = 0;
  rgbVal *pixels;


  pixels = malloc(sizeof(rgbVal) * pixel_count);
  memset(pixels, 0, sizeof(rgbVal) * pixel_count);

  while (1) {

    color = color2;
    step = step2;

    for (uint8_t i = 0; i < pixel_count; i++) {
      pixels[i] = color;

      if (i == 1) {
        color2 = color;
        step2 = step;
      }

      switch (step) {
      case 0:
        color.g += anim_step;
        if (color.g >= anim_max)
          step++;
        break;
      case 1:
        color.r -= anim_step;
        if (color.r == 0)
          step++;
        break;
      case 2:
        color.b += anim_step;
        if (color.b >= anim_max)
          step++;
        break;
      case 3:
        color.g -= anim_step;
        if (color.g == 0)
          step++;
        break;
      case 4:
        color.r += anim_step;
        if (color.r >= anim_max)
          step++;
        break;
      case 5:
        color.b -= anim_step;
        if (color.b == 0)
          step = 0;
        break;
      }
    }

    ws2812_setColors(pixel_count, pixels);

    delay_ms(delay);
  }
}

void on_cpu_1(void *pvParameters) {

    printf("Init on CPU 1\n");

    ws2812_init(WS2812_PIN);
    xTaskCreate(rainbow, "ws2812 rainbow demo", 4096, NULL, 10, NULL);
    vTaskDelete(NULL);
}

void strip_init() {
    printf("Start strip\n");
    nvs_flash_init();

    xTaskCreatePinnedToCore(on_cpu_1, "on_cpu_1", 4096, NULL, 10, NULL, 1);
}



I'm new to using esp32 and RTOS and I will be grateful for any answer and the more detailed the better.

Thanks!

cranphin
Posts: 8
Joined: Mon Apr 02, 2018 12:31 pm

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby cranphin » Mon Dec 17, 2018 4:54 pm

Hi!

I don't know if it will help, but be mindful that with this line:
xTaskCreate(rainbow, "ws2812 rainbow demo", 4096, NULL, 10, NULL);
The rainbow task might still run on any/either core. So I'd recommend using:
xTaskCreatePinnedToCore(rainbow, "ws2812 rainbow demo", 4096, NULL, 10, NULL, 1);
instead.

Cheers!

mirronelli
Posts: 1
Joined: Fri Oct 11, 2019 3:59 pm

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby mirronelli » Fri Oct 11, 2019 4:05 pm

I had the same problem too and after reading a ton of posts have decided not to use wifi directly on the RMT host and instead made it receive commands via serial from another wifi enabled esp board.

this did increase the project costs by about 5 dollars but saved me hours and hours of trying everything possible.
the leds are now flicker free and fast.

there is a sample project for the led driving board as well as for the remote at:
https://github.com/mirronelli/neopixel

feel free to use or extend it

gryphon
Posts: 2
Joined: Tue Nov 05, 2019 6:57 am

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby gryphon » Tue Nov 05, 2019 7:22 am

I also had a similar problem while driving SK6812 leds with the RMT interface. Root cause for me was that the dynamic frequency scaling being set from 40MHz to 160MHz while RMT was attended to use 80MHz APB clock. When CPU clock dropped to 40MHz the automatic APB divider could not keep up and RMT ref clock dropped also to 40MHz. Setting pm_config.min_freq_mhz = 80 solved my issue.

fanhuanji
Posts: 9
Joined: Tue Feb 13, 2018 6:55 am

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby fanhuanji » Fri Nov 15, 2019 12:54 pm

gryphon wrote:
Tue Nov 05, 2019 7:22 am
I also had a similar problem while driving SK6812 leds with the RMT interface. Root cause for me was that the dynamic frequency scaling being set from 40MHz to 160MHz while RMT was attended to use 80MHz APB clock. When CPU clock dropped to 40MHz the automatic APB divider could not keep up and RMT ref clock dropped also to 40MHz. Setting pm_config.min_freq_mhz = 80 solved my issue.
Thanks for reminding, before reading this post, I've checked the data-line(which was directly probed at esp32 output) with oscilloscope and found some of the pulses was obviously wider than others, and that wrong signal caused the WS2812B to display wrong color.
Then I've compared the power management config with another project(which was working fine and finished one years ago).
After DISABLE the POWER MANAGEMENT from menu-config, the problem was gone.

The driver code I'm using for WS2812x series:https://github.com/CalinRadoni/esp32_digitalLEDs


Thank you.

cskilbeck
Posts: 11
Joined: Tue Dec 10, 2019 10:40 pm

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby cskilbeck » Tue Dec 10, 2019 10:43 pm

It seems that calling the RMT init functions from a task with high priority fixes this problem.

cskilbeck
Posts: 11
Joined: Tue Dec 10, 2019 10:40 pm

Re: RMT based NeoPixels (WS2812B) flickers when WiFi is used

Postby cskilbeck » Wed Dec 11, 2019 11:25 pm

Correction, the priority is not the issue, for me the solution is pinning the RMT task to core 1

Who is online

Users browsing this forum: No registered users and 294 guests