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

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
    216
    Ward awesome job! I commented on your facebook share as well.

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,684
    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
    12
    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
    12
    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
    12
    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,851
    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
    12
    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,851
    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
    12
    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.

  15. #15
    Junior Member
    Join Date
    Oct 2020
    Posts
    5
    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.
    AHCT - Advanced High speed Cmos - TTL switching levels compatible inputs.

    TTL logic levels are: Log. 0 is between 0V to 0.8V and Log 1 is between 2V to 5V. So there is no problem with 3V3 CMOS logic.

    AHC - CMOS compatible levels - thresholds are 0.3*Vcc for LOW and 0.7*VCC for HIGH to be reliable. So with 5V Vcc it's 3.5V for HIGH and it's way beyond 3.3V from 3.3V CMOS logic. It might work, and sometimes it does, but it can't be considered as reliable design as the threshold value might be floating somewhere between 0.3*Vcc and 0.7*Vcc.

  16. #16
    Junior Member
    Join Date
    Feb 2016
    Posts
    12
    It might work, and sometimes it does, but it can't be considered as reliable design as the threshold value might be floating somewhere between 0.3*Vcc and 0.7*Vcc.
    I'm not quite sure what you're trying to say. Looking at the specs of a 74AHCT595 chip, it does state that:

    Both 74AHC595 and 74AHCT595 inputs are overvoltage tolerant. This feature allows the use of these devices as
    translators in mixed voltage environments.
    Specifically, for the 74AHCT595, a threshold of 2.0V for HIGH is mentioned when Vcc is 5.5V.

  17. #17
    Junior Member
    Join Date
    Oct 2020
    Posts
    5
    I'm not quite sure what you're trying to say. Looking at the specs of a 74AHCT595 chip, it does state that:
    As it's for driving WS2812x I'd expect Vcc=5V and therefore it doesn't make a sense to use AHC version as it has pretty much the same input levels (CMOS) as WS2812

    For the AHC version, that 3.3V HIGH from Teensy outputs might be not enough to be recognized as HIGH on that AHC input as threshold might be anywhere between 1.5V to 3.5V with 5V Vcc. High is still in the undefined region. You can use little bit lower Vcc, to be outside of undefined region or you can add for example diode between ground and GND to move threshold little bit

    For the AHCT is perfectly fine, as its undefined region is before 0.8V - 2.0V

Posting Permissions

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