Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Teensy 3.2 - How to use timer with OctoWS2811 lib

  1. #1
    Junior Member
    Join Date
    Mar 2019
    Location
    France
    Posts
    13

    Teensy 3.2 - How to use timer with OctoWS2811 lib

    Hi all,

    I need to execute my program with a precis timing, and for that I used to use "IntervalTimer" functionality and librarie.
    But it doesn't work if I use OctoWS2811 to drive RGB leds. This is the same issue with TimerOne and TimerThree.

    Is it normal? Is there another way to execute precis timing?
    I mean set a flag in interrupt timer function, and execut program in the main function only when this flag is set and clear it inside.

    Thank a lot

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,012
    How precise? 1 ms - 10 us? Is the loop() doing anything much?

    How many times/sec is loop() being called?

  3. #3
    Junior Member
    Join Date
    Mar 2019
    Location
    France
    Posts
    13
    I need a loop executed between 10 and 100 times/sec (I need make tests).

    The main loop manage the LEDs animations and take into account informations received by I2C to change strip's colors.
    How precise? 1ms is a maximum, 0.1ms is ideal

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    9,012
    Should be easy to just watch a changing timer value. If T_3.2 is not burdened will easily pass 1K or 10K or more loops /second.

    This example could easily count and display the counts per second of loop entry: ...\examples\02.Digital\BlinkWithoutDelay\BlinkWit houtDelay.ino

    Better tools may be elapsedMillis or elapsedMicros - examples on PJRC.com.

    Give it a try and maybe measure the longest time between loops calls - to be sure when needed it won't be a late arrival.

  5. #5
    Senior Member mortonkopf's Avatar
    Join Date
    Apr 2013
    Location
    London, uk
    Posts
    899
    explore non-blocking ws2811/12 library if using less than 600 leds? https://github.com/PaulStoffregen/WS2812Serial

  6. #6
    Junior Member
    Join Date
    Mar 2019
    Location
    France
    Posts
    13
    Thank a lot for your replies and your help.
    It seems that many of my issues was due to the fact I forgot that OctoWs8211 is an blocking library...

    Also did you know there is a way to use I2C in slave mode with OctoWS8211?

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,294
    OctoWS8211 is non-blocking. It returns quickly to your program and the LEDs are updated by DMA while your code continues to run. That is what non-blocking means.

    Quote Originally Posted by toto_brico View Post
    Also did you know there is a way to use I2C in slave mode with OctoWS8211?
    I2C slave mode and OctoWS8211 should work together. If they are not working, maybe you should share a (simple, small code) test case that shows us how to reproduce the problem you're seeing?

    On the timing, consider WS2812B LEDs use ~425 Hz PWM internally. Expecting 0.1 ms sync to LEDs is meaningless when their own internal PWM is much slower.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •