I2C breaks when initializing ESP32_LED_STRIP RMT

LEMAOR
Posts: 6
Joined: Thu Aug 17, 2017 7:51 pm

I2C breaks when initializing ESP32_LED_STRIP RMT

Postby LEMAOR » Wed Sep 20, 2017 12:21 am

So this one is a bit hard to describe here goes my best attempt:

a) code uses i2c to read and get raw values from an mpu6050 (accelerometer-gyro)
b) It also uses a led strip (WS2812 type) using https://github.com/Lucas-Bruder/ESP32_LED_STRIP this one was the only library for C i could find for addresable leds

c) i have a task that calculates pitch and roll with a complimentary filter, and another one that prints the values.

so this is what is happening: I initilice i2c and the comunication and start getting some values, proper values. I have timed this loop up to 7 solid minutes with no problemat all but as soon as i initialize the led strip it starts returning garbage.

IMPORTANT: the most vexing part, is that i have the same code running on protoboard on a dev board and it works, but i changed into a pcb and the weird behavoir started.

now i did my best to replicate the devboard on the new pcb, i added pull up resistors to the i2c rails (5k). At this point i already checked and both esp32 are revision 0.


my main code looks like so:

Code: Select all

void app_main()
{
     ESP_LOGI("Main tag","starting accelerometer");

      print_mux = xSemaphoreCreateMutex();
    i2c_master_init();
    vTaskDelay(200/portTICK_PERIOD_MS);
    xTaskCreate(mpu6050_complimentary_filter, "i2c_mpu6050_complimentary_filter", 1024 * 3, NULL, 90, NULL); //calculate angles
    xTaskCreate(angle_print, "angle_print", 1024 * 2, NULL, 4, NULL); //print angles every 500ms else if on main loop we overflow make monitor console

    vTaskDelay(30000/portTICK_PERIOD_MS); // wait to see if accelerometer is working properly


        init_Addresable_leds();
     ESP_LOGI("Main tag","addresable initilalized");
      vTaskDelay(500/portTICK_PERIOD_MS);
}

Code: Select all

Angles by complimentary filter...  ROLL: 1.868587    PITCH: 4.100168    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.856133    PITCH: 4.101508    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.867535    PITCH: 4.084947    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.877190    PITCH: 4.089179    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.879230    PITCH: 4.099995    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.873662    PITCH: 4.120989    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.844929    PITCH: 4.094360    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.840526    PITCH: 4.108929    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.861139    PITCH: 4.103582    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.837508    PITCH: 4.109424    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.859383    PITCH: 4.109167    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.859133    PITCH: 4.111785    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.858522    PITCH: 4.117200    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.860672    PITCH: 4.129315    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 2.821155    PITCH: 5.061262    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.961496    PITCH: 4.222400    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.858341    PITCH: 4.120047    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.882372    PITCH: 4.110199    Yaw: 0.000000
(33213) intr_alloc: Connected src 47 to int 17 (cpu 0)
I (33213) Main tag: addresable initilalized
Angles by complimentary filter...  ROLL: 1.856133    PITCH: 4.101508    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.867535    PITCH: 4.084947    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.877190    PITCH: 4.089179    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.879230    PITCH: 4.099995    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.873662    PITCH: 4.120989    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.844929    PITCH: 4.094360    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.840526    PITCH: 4.108929    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.861139    PITCH: 4.103582    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.837508    PITCH: 4.109424    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.859383    PITCH: 4.109167    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.859133    PITCH: 4.111785    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.858522    PITCH: 4.117200    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.860672    PITCH: 4.129315    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 2.821155    PITCH: 5.061262    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.961496    PITCH: 4.222400    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.858341    PITCH: 4.120047    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.882372    PITCH: 4.110199    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.876676    PITCH: 4.118143    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.571568    PITCH: 4.339398    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.830631    PITCH: 4.152345    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.830631    PITCH: 4.152345    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831013    PITCH: 2.172300    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831013    PITCH: 2.172300    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831013    PITCH: 2.172300    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831013    PITCH: 2.172300    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831391    PITCH: -1.767590    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831391    PITCH: -1.767590    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831391    PITCH: -1.767590    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831391    PITCH: -1.767590    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831766    PITCH: -5.668081    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831766    PITCH: -5.668081    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831766    PITCH: -5.668081    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.831766    PITCH: -5.668081    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832137    PITCH: -9.529564    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832137    PITCH: -9.529564    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832137    PITCH: -9.529564    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832137    PITCH: -9.529564    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832504    PITCH: -13.352435    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832504    PITCH: -13.352435    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832504    PITCH: -13.352435    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832504    PITCH: -13.352435    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832867    PITCH: -17.137077    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832867    PITCH: -17.137077    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832867    PITCH: -17.137077    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.832867    PITCH: -17.137077    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.833227    PITCH: -20.883869    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.833227    PITCH: -20.883869    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.833227    PITCH: -20.883869    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.833227    PITCH: -20.883869    Yaw: 0.000000
Angles by complimentary filter...  ROLL: 1.833584    PITCH: -24.593201    Yaw: 0.000000



in the code above you can see that after a couple of seconds after addresable leds has been initialized i start losing reliabilty on the data obtained, as i said it seems that if dont set addresable init() i get solid data for minutes

im lost here, maybe is an interrupt that conflicts with the i2c?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: I2C breaks when initializing ESP32_LED_STRIP RMT

Postby kolban » Wed Sep 20, 2017 1:51 am

How many LEDs are you using and how are you powering them? Could the current draw from the LEDs be causing trouble at the other components? I believe a WS2812 can consume 60ma at full power.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

jimbob
Posts: 29
Joined: Fri Aug 05, 2016 10:47 pm

Re: I2C breaks when initializing ESP32_LED_STRIP RMT

Postby jimbob » Wed Sep 20, 2017 12:33 pm

Can you physically disconnect the LEDs and try running the same code? That way you know if it's noise/browning out of the power supply?

LEMAOR
Posts: 6
Joined: Thu Aug 17, 2017 7:51 pm

Re: I2C breaks when initializing ESP32_LED_STRIP RMT

Postby LEMAOR » Wed Sep 20, 2017 3:01 pm

on the matter of the current, what i tried previously was to simply not turning on the leds at all.

you can see in the code below how you setup the library and then you populate an array and afterwards you use the comand show to well send the bits to the addresable leds.

so what i did was to comment that part, which means the leds are not brigth at the moment of the test, and even so i2c keeps returning bad data.

i kind of feel there might be a conflicting interrupt or something, then again i do have the code running somewhere else :/

i do would like to feed the pcb from an external source and see if that will do the trick

the leds are soldered but i guess i feel desperate enough to try detach them from the pcb







Code: Select all

init_Addresable_leds(void)
{
  struct led_strip_t led_strip = {
        .rgb_led_type = RGB_LED_TYPE_WS2812,
        .rmt_channel = RMT_CHANNEL_1,
        .rmt_interrupt_num = LED_STRIP_RMT_INTR_NUM,
        .gpio = GPIO_NUM_21,
        .led_strip_buf_1 = led_strip_buf_1,
        .led_strip_buf_2 = led_strip_buf_2,
        .led_strip_length = LED_STRIP_LENGTH
    };
    led_strip.access_semaphore = xSemaphoreCreateBinary();

    bool led_init_ok = led_strip_init(&led_strip);
    assert(led_init_ok);
    
    
    
   /*
    struct led_color_t led_color = {
        .red = 5,
        .green = 0,
        .blue = 0,
    };

   
        for (uint32_t index = 0; index < LED_STRIP_LENGTH; index++) {
            led_strip_set_pixel_color(&led_strip, index, &led_color);
        }
        led_strip_show(&led_strip);

       
        
    }
    
    */
  }  

Who is online

Users browsing this forum: No registered users and 103 guests