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

Thread: [queued] TriantaduoWS2811, a 32-channel WS* library for Teensy 4.0 using FlexIO & DMA

  1. #1
    Member
    Join Date
    Mar 2013
    Location
    Hillsboro, OR
    Posts
    20

    [queued] TriantaduoWS2811, a 32-channel WS* library for Teensy 4.0 using FlexIO & DMA

    Here's a project I've been working on to generate 32 WS* channels of up to 1000 LEDs each, with zero processor overhead through the use of FlexIO and DMA and external shift registers. Some features:

    1000 LEDs per channel at 30 FPS, though the number of LEDs and frame rate can be traded off. 10 LEDs at 3 kHz should be attainable.
    Consumes three Teensy pins and zero processor time
    Double-buffered to reduce tearing artifacts with video
    Each channel is configurable for RGB, GRB, or GRBW
    If you're really nuts, you could probably fit three of these on a Teensy, for 96 total output channels. Right now it's hard-coded to FlexIO 1

    This would also be a good starting point for any project that needs a lot of outputs updated relatively (3.2 MHz) quickly, directly from RAM.

    Code and lots more details here:
    https://github.com/wramsdell/TriantaduoWS2811

  2. #2
    Senior Member crees's Avatar
    Join Date
    Dec 2016
    Location
    Utah
    Posts
    215
    Ward awesome job! I commented on your facebook share as well.

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,120
    Great stuff!

  4. #4
    Member
    Join Date
    Mar 2013
    Location
    Hillsboro, OR
    Posts
    20
    Thank you! In thinking about this some more, I'm tempted to do some more work with FlexIO and shift registers because it's just such a powerful combination. I *think* one could do 96 channels of PWM with 200ns resolution using 8 IOs: two clocks and 6 data lines. That would be an interesting feat.

  5. #5
    Junior Member
    Join Date
    Jan 2018
    Posts
    10
    Amazing, thank you!

  6. #6
    Junior Member
    Join Date
    Feb 2016
    Posts
    10
    This looks extremely interesting! Have you looked at extending it to a second flexIO for more outputs int the meantime? Also, is there an integration with FastLED already so I can save myself some work ?

  7. #7
    Member
    Join Date
    Mar 2013
    Location
    Hillsboro, OR
    Posts
    20
    Nope, I've never investigated FastLED. Is it a front-end/back-end sort of thing where I could easily swap in my drive code and leverage the existing value manipulation functions?

  8. #8
    Junior Member
    Join Date
    Feb 2016
    Posts
    10
    I think so! I haven't really modified the library myself either, but I'm following several contributors who have, for example Yves Bazin, who wrote a similar parallel output library for the ESP32: https://www.reddit.com/r/FastLED/com...ws2812b_strip/

  9. #9
    Junior Member
    Join Date
    Feb 2016
    Posts
    10
    So, I just tried this library on a Teensy 4 with a PCB that is meant for a new interactive art LED installation. It works! Mostly!

    Here's some questions / feedback:
    - Defining LEDCOUNT in your own code and smaller than in TDWS2811.h breaks the library, and in fact the Teensy 4 becomes unstable, refusing serial communication. This is fixed by just changing the value inside the library header, but I'm not quite sure what's happening there.
    - Is there a way to see if a frame has fully rendered? Or a counter that ticks once per frame? I want to calculate actual framerates and update LEDs exactly once per frame, as fast as possible.
    - Only some of my LEDs work with this library. I'm using a cheap 16 LED ring from Aliexpress, and some batches from it work, while others don't. Unfortunately they don't really say which LED type they use, but it could be that they switched from WS2812b to SK6812. On paper, they're protocol compatible, but there might some tiny timing differences that make it fail. Happy for others to confirm this one though.
    - Only the first channel seems to be actually set to DEFAULT_CHANNEL_TYPE in the header (one of the last lines in the header file).
    Last edited by Robin_B; 04-01-2020 at 06:39 PM.

  10. #10
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,768
    Quote Originally Posted by Robin_B View Post
    So, I just tried this library on a Teensy 4 with a PCB that is meant for a new interactive art LED installation. It works! Mostly!

    Here's some questions / feedback:
    - Defining LEDCOUNT in your own code and smaller than in TDWS2811.h breaks the library, and in fact the Teensy 4 becomes unstable, refusing serial communication. This is fixed by just changing the value inside the library header, but I'm not quite sure what's happening there.
    - Is there a way to see if a frame has fully rendered? Or a counter that ticks once per frame? I want to calculate actual framerates and update LEDs exactly once per frame, as fast as possible.
    - Only some of my LEDs work with this library. I'm using a cheap 16 LED ring from Aliexpress, and some batches from it work, while others don't. Unfortunately they don't really say which LED type they use, but it could be that they switched from WS2812b to SK6812. On paper, they're protocol compatible, but there might some tiny timing differences that make it fail. Happy for others to confirm this one though.
    You didn't mention if you used a level shifter such as (https://www.adafruit.com/product/1787), as well as the capacitors and resistors specified by the typical guides (https://learn.adafruit.com/adafruit-...best-practices). This is one of the value adds that the Octows2811 shield gives you.

    Here is an older article that was one of the first to mention about using level shifters on Teensy: https://happyinmotion.com/?p=1247

    Over the years, I've some WS2812B's that wouldn't work unless I powered them with 5v and used a level shifter. The newer ones that use SK6812's instead of WS2812B's, can be run at 3.3v, so for small number of LEDs, I just power it with 3.3v, or if the device is powered by 3.7-4.2v lipo batteries, use VIN.

    Here is one article comparing the two: https://www.pololu.com/category/180/...sed-led-strips.

    As I recall there were at least 2 generations of WS2812's as well. So who knows whether your LEDs were manufactured with old chips or new. I suspect you probably had SK6812's, and one batch went back to WS2812B's.
    Last edited by MichaelMeissner; 04-01-2020 at 06:38 PM.

  11. #11
    Junior Member
    Join Date
    Feb 2016
    Posts
    10
    For this project I'm using the 74AHCT595 as recommended in the documentation in the first post, whose outputs are apparently level-shifted to 5V. However, I don't have an oscilloscope handy to actually verify that.

  12. #12
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,768
    Quote Originally Posted by Robin_B View Post
    For this project I'm using the 74AHCT595 as recommended in the documentation in the first post, whose outputs are apparently level-shifted to 5V. However, I don't have an oscilloscope handy to actually verify that.
    Ok, just checking the obvious. Evidently the resistor and capacitor are also needed for large installations that are not battery powered, as is keeping the distance down (none of that applies to me, but it sounds like you might need it). And of course there is the possibility that some of your LEDs just are not wired professionally within the LED itself.

  13. #13
    Junior Member
    Join Date
    Feb 2016
    Posts
    10
    Yep, thanks! It's a valid point, as I've been bitten by this before (the worst was one a previous projects where I was using 74HC245 instead of 74HCT245 level shifters, which was fine in lab conditions but started glitching when the ambient temperature dropped to outdoor temps ). For the current project, I have enough LED rings of the batch that works to build it all, so right now it's not a big deal for me. Once our Makerspace reopens I can check the actual values with an oscilloscope on the LEDs that don't work.

  14. #14
    Hello,

    Do you know if this lib is compatible with teensy 4.1/teensyduino 1.52 ?

    I have troubles making it working.

Posting Permissions

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