ESP32 (WT32-ETH01) and TLC5973 LED Driver - Flickering issue

juma08
Posts: 2
Joined: Sat Oct 14, 2023 2:56 pm

ESP32 (WT32-ETH01) and TLC5973 LED Driver - Flickering issue

Postby juma08 » Sat Oct 14, 2023 3:15 pm

Hello everyone,

I’m facing issues with the TLC5973 LED driver when paired with the WT32-ETH01 microcontroller. In my project using Arduino I use the TLC5973 to control LEDs. When I try dimming just one color, everything works perfectly. However, as soon as I dim two or three colors, at high brightness flickering starts to occur.

I have a stable power supply and adding a capacitor didn’t make a difference. After some debugging and using an oscilloscope, I noticed that some of the PWM pulses from the TLC appear shorter than they should be. This might explain the flickering.

I’ve attempted several things but turning off the WiFi and Bluetooth on the WT32-ETH01 with WiFi.mode(WIFI_OFF); and btStop(); commands seemed to help a lot, but the flickering is still not entirely gone. Therefore I assume it could be an Issue with the timing or Interrupts which occur.

Has anyone had experience with this hardware combination or can offer tips on optimizing the timing? Is it feasible to rewrite the library to be better suited for the TLC5973 and the WT32-ETH01?

my code looks like this to fade the LEDs:
  1. #include <TLC5973.h>
  2. #include <WiFi.h>
  3. #include "esp_bt.h"
  4.  
  5. byte LED = 4;
  6. uint16_t N = 1; // One LED on each output
  7.  
  8. TLC5973 strip = TLC5973(N, LED);
  9.  
  10. int fadeValue = 0;              // Start with LED off
  11. bool increasing = true;         // Direction of fade
  12. const long intervalFade = 10;    // interval for fading (milliseconds)
  13. unsigned long previousMillis = 0;
  14.  
  15. void setup() {
  16. //  WiFi.mode(WIFI_OFF); //To turn Wifi off
  17. //  btStop();
  18.   Serial.begin(9600);
  19.   strip.begin();
  20.   strip.setPixelColor(0, 0, 0, 0);
  21.   strip.show(); //Send Data
  22. }
  23.  
  24. void loop() {
  25.  
  26.   unsigned long currentMillis = millis();
  27.  
  28.   if (currentMillis - previousMillis >= intervalFade) {
  29.     if (increasing) {
  30.       fadeValue += 1;
  31.       if (fadeValue >= 4095) {
  32.         increasing = false;
  33.       }
  34.     } else {
  35.       fadeValue -= 1;
  36.       if (fadeValue <= 0) {
  37.         increasing = true;
  38.       }
  39.     }
  40.  
  41.     strip.setPixelColor(0, fadeValue, fadeValue, fadeValue);
  42.     strip.show();
  43.  
  44.     previousMillis = currentMillis;
  45.   }
  46.  
  47. }

The routine out of the TLC5973.cpp which sends the data looks like this:
  1. void TLC5973::show(){
  2.    noInterrupts(); // Need 100% focus on instruction timing
  3.    for(uint16_t i = 0; i < numWords; i=i+3){
  4.       writeWord( 0x03AA);    //Start
  5.       writeWord( pixels[i] );
  6.       writeWord( pixels[i+1] );
  7.       writeWord( pixels[i+2] );
  8.       waitGSLAT(4);
  9.    }
  10.    waitGSLAT(4);
  11.    interrupts();
  12. }
I already deactivated Interrupts before the communication but when WIFI and bluetooth are ON there is massive Flickering at the LEDs. The TLC5973 documents are attached.

Any help or recommendations would be greatly appreciated!

Thanks in advance.
Attachments
TLC5973.h
(728 Bytes) Downloaded 249 times
TLC5973.cpp
(1.82 KiB) Downloaded 242 times

juma08
Posts: 2
Joined: Sat Oct 14, 2023 2:56 pm

Re: ESP32 (WT32-ETH01) and TLC5973 LED Driver - Flickering issue

Postby juma08 » Tue Oct 17, 2023 10:56 am

I solved the flickering Issue for WIFI / BT OFF. I had to adjust the number of NOPs in the TLC5973.cpp to fit the Timing.

Code: Select all

void TLC5973::writeZero(){
    pulse();
    NOP;
    NOP;
    NOP;
    NOP;
}

void TLC5973::writeNone(){
       NOP;
       NOP;
       NOP;
       NOP;
       NOP;
       NOP;
       NOP;
       NOP;
}
But still while WIFI /BT ON there is massive flickering. I think the Timing needs to be adjusted for this use case to deal with the Interrupts of WIFI / BT. Maybe something like this WS2812 firmware attached. They use a combination with Inline-Assambler...

Who is online

Users browsing this forum: No registered users and 74 guests