ws2812b + teensy 4.0: LED strip only shows few frames when powered on

Status
Not open for further replies.
Hello,

recently I soldered my teensy 4.0 and ws2812b LED strip setup together with a new thicker cable for better electricity flow.
Before that it worked quite well, but now it is acting weird and whenever I power the LED strip it just shows a few frames and then gets stuck. Sometimes even only a couple of the 144 LEDs update and then it freezes.
Maybe this helps you to understand the problem: When I'm plugging in and unplugging the power cord for the LED strip really fast and repetitive I can actually see some motion happening on the LEDs because then they acutally update a couple of times.
Unfortunately this is a bit exhausting, so I would like to know what's the issue.

The only things I can think of that changed after soldering are that the cable is thicker now and I am using a logic level converter (https://eckstein-shop.de/SparkFun-Logic-Level-Converter-Bi-Directiona-Shifter-Pegelwandler) because I was told that the 3V data signal of the Teensy has to be converted to a 5V signal in order for the LED strip to work correctly. Which is weird because before I wasn't using one and it worked fine. I also tried the new setup without the logic level converter but I ran into the same problem. I tried a lot of different Arduino sketches but none of them worked as they should.

I used this code for example (It was recommended to me by a different user on Reddit I guess):
Code:
/* New Product Test Sketch by Chemdoc77
   used to test new RGB LED strips and Matrix that I purchase.
   Note:  Uses FastLED's Parallel Output procedure to work with a Teensy 4.0
*/

#include <FastLED.h>

#define DATA_PIN  7
int brightness = 40;

// Teensy 4.0 Stuff ================
#define NUM_LEDS_PER_STRIP 144
#define NUM_STRIPS 1
#define NUM_LEDS   NUM_LEDS_PER_STRIP  
CRGB leds[NUM_LEDS_PER_STRIP * NUM_STRIPS];

void setup() { 
  delay(1000);
  // Teensy 4.0 Stuff ==============
    FastLED.addLeds<NUM_STRIPS, WS2812B,DATA_PIN,GRB>(leds, NUM_LEDS_PER_STRIP);
  //USE for WS2811:      
 // FastLED.addLeds<NUM_STRIPS, WS2811, DATA_PIN >(leds, NUM_LEDS_PER_STRIP);
  FastLED.setBrightness(brightness);
  FastLED.setMaxPowerInVoltsAndMilliamps(5, 1500);
   set_max_power_indicator_LED(13);
  fill_solid(leds, NUM_LEDS, CRGB::Black);
  FastLED.show();
 
}
void loop() {  

     fill_solid( leds, NUM_LEDS, CRGB::Red);
     FastLED.delay(500);
      
     fill_solid( leds, NUM_LEDS, CRGB::Black);
     FastLED.delay(500);
    
     fill_solid( leds, NUM_LEDS, CRGB::Blue);
     FastLED.delay(500);
      
     fill_solid( leds, NUM_LEDS, CRGB::Black);
     FastLED.delay(500);
     
     fill_solid( leds, NUM_LEDS, CRGB::Green);
     FastLED.delay(500);
      
     fill_solid( leds, NUM_LEDS, CRGB::Black);
     FastLED.delay(500);
       
     fill_solid( leds, NUM_LEDS, CRGB::Yellow);
     FastLED.delay(500);
      
     fill_solid( leds, NUM_LEDS, CRGB::Black);
     FastLED.delay(500);

     cd77_colorwipe_dot(CRGB::Red, 0, NUM_LEDS, 40);
     cd77_colorwipe_dot(CRGB::Blue, 0, NUM_LEDS, 40);
     cd77_colorwipe_dot(CRGB::Green, 0, NUM_LEDS, 40);
   
}

//==================== Functions ===============================


void cd77_colorwipe(CRGB color,  uint16_t to, uint16_t wait) {
  for (uint16_t i = 0; i <to; i++) {
    leds[i] = color;
    FastLED.delay(500);
  }
}


void cd77_colorwipe_line2(CRGB color, uint16_t wait) {
  for (uint16_t i = 0; i <NUM_LEDS; i++) {
    leds[i] = color;
    FastLED.show();
   }
}

void cd77_colorwipe_line(CRGB color, uint16_t wait) {
  for (uint16_t i = 0; i <NUM_LEDS; i++) {
    leds[i] = color;
    FastLED.delay(wait);
   }
}


void cd77_colorwipe_dot(CRGB color,uint16_t from,  uint16_t to,  uint16_t wait) {
  for (uint16_t i = from; i <to; i++) {
    leds[i] = color;
    FastLED.delay(wait);
    leds[i] = CRGB::Black;
    FastLED.show();
    
    
  }
}

void cd77_colorwipe_dot_fast(CRGB color) {
  for (uint16_t i = 0; i <NUM_LEDS; i++) {
    leds[i] = color;
     FastLED.show();
    leds[i] = CRGB::Black;
    FastLED.show();
    
    
  }
}

I also tried the default blink sketch of FastLED as well as the OctoWS2811 library, but that didn't get me any further to solving the problem.

Using an Arduino Uno it works perfectly, so I don't think I did something wrong at soldering the components.
If I am missing out something really important, please tell me.
Does it maybe have to do with teensy's clock or something like that?
 
That ws2812b strips are very timing sensitive. I did not event get them to work with FastLED. Adafruits NeoPixel worked somehow.

Regarding that 5v/3v issue, you can power them with 3v if the data in high is also 3v. It worked for me on 3.3v boards without a "Pegelwander".

Could be an idea to disable irqs during the update.
 
Try adding this before the include for FastLED.h

Code:
#define FASTLED_ALLOW_INTERRUPTS 0

When I try to add that line I get this error:

Code:
Arduino: 1.8.12 (Windows 10), TD: 1.52-beta3, Board: "Teensy 4.0, Serial, 600 MHz, Faster, US English"

In file included from C:\Users\finle\Desktop\DemoReel100\DemoReel100.ino:2:0:

D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.001

 #    pragma message "FastLED version 3.003.001"

                     ^

In file included from D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/fastled_arm_mxrt1062.h:10:0,

                 from D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/platforms.h:23,

                 from D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/FastLED.h:52,

                 from C:\Users\finle\Desktop\DemoReel100\DemoReel100.ino:2:

D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h: In member function 'virtual void FlexibleInlineBlockClocklessController<LANES, FIRST_PIN, T1, T2, T3, RGB_ORDER, XTRA0, FLIP, WAIT_TIME>::showPixels(PixelController<RGB_ORDER, LANES, ((1 << LANES) - 1)>&)':

D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h:102:3: error: 'MS_COUNTER' was not declared in this scope

   MS_COUNTER += (1 + (microsTaken / 1000));

   ^

D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h: In instantiation of 'uint32_t FlexibleInlineBlockClocklessController<LANES, FIRST_PIN, T1, T2, T3, RGB_ORDER, XTRA0, FLIP, WAIT_TIME>::showRGBInternal(PixelController<RGB_ORDER, LANES, ((1 << LANES) - 1)>&) [with unsigned char LANES = 1u; int FIRST_PIN = 7; int T1 = 250; int T2 = 625; int T3 = 375; EOrder RGB_ORDER = (EOrder)66u; int XTRA0 = 0; bool FLIP = false; int WAIT_TIME = 50; uint32_t = long unsigned int]':

D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h:99:36:   required from 'void FlexibleInlineBlockClocklessController<LANES, FIRST_PIN, T1, T2, T3, RGB_ORDER, XTRA0, FLIP, WAIT_TIME>::showPixels(PixelController<RGB_ORDER, LANES, ((1 << LANES) - 1)>&) [with unsigned char LANES = 1u; int FIRST_PIN = 7; int T1 = 250; int T2 = 625; int T3 = 375; EOrder RGB_ORDER = (EOrder)66u; int XTRA0 = 0; bool FLIP = false; int WAIT_TIME = 50]'

C:\Users\finle\Desktop\DemoReel100\DemoReel100.ino:125:1:   required from here

D:\Programme\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h:170:14: warning: unused variable 'wait_off' [-Wunused-variable]

     uint32_t wait_off = _FASTLED_NS_TO_DWT((WAIT_TIME-INTERRUPT_THRESHOLD));

              ^

Error compiling for Board Teensy 4.0.
 
Code:
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>

#define NUM_LEDS 144
#define DATA_PIN 7

CRGB leds[NUM_LEDS];

void setup() {
       FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
}

void loop() { 
  // Turn the LED on, then pause
  leds[0] = CRGB::Red;
  FastLED.show();
  delay(500);
  // Now turn the LED off, then pause
  leds[0] = CRGB::Black;
  FastLED.show();
  delay(500);
}

In this sketch I get that error but also in other sketches like the one I postet at first
 
The console log I postet was thrown by exactly this sketch:

Code:
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>

FASTLED_USING_NAMESPACE

// FastLED "100-lines-of-code" demo reel, showing just a few 
// of the kinds of animation patterns you can quickly and easily 
// compose using FastLED.  
//
// This example also shows one easy way to define multiple 
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014

#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)
#warning "Requires FastLED 3.1 or later; check github for latest code."
#endif

#define DATA_PIN    7
#define LED_TYPE    WS2812B
#define COLOR_ORDER GRB
#define NUM_LEDS    144

CRGB leds[NUM_LEDS];

#define BRIGHTNESS          50
#define FRAMES_PER_SECOND  120

void setup() {
  delay(2000);
  // Use NEOPIXEL to keep true colors
  FastLED.addLeds<1, LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}


// List of patterns to cycle through.  Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };

uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
  
void loop()
{
  // Call the current pattern function once, updating the 'leds' array
  gPatterns[gCurrentPatternNumber]();

  // send the 'leds' array out to the actual LED strip
  FastLED.show();  
  // insert a delay to keep the framerate modest
  FastLED.delay(1000/FRAMES_PER_SECOND); 

  // do some periodic updates
  EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
  EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
}

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern()
{
  // add one to the current pattern number, and wrap around at the end
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

void rainbow() 
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, NUM_LEDS, gHue, 7);
}

void rainbowWithGlitter() 
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

void confetti() 
{
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, NUM_LEDS, 10);
  int pos = random16(NUM_LEDS);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
}

void sinelon()
{
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy( leds, NUM_LEDS, 20);
  int pos = beatsin16( 13, 0, NUM_LEDS-1 );
  leds[pos] += CHSV( gHue, 255, 192);
}

void bpm()
{
  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  for( int i = 0; i < NUM_LEDS; i++) { //9948
    leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
  }
}

void juggle() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds, NUM_LEDS, 20);
  byte dothue = 0;
  for( int i = 0; i < 8; i++) {
    leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
}
 
Does anyone have an idea on how to solve this?

FinleyOderSo:

I am no expert on WS2812B LED strips, by any means, but I do have three 10-meter strings of WS2812B LEDs strung together & hung around the underside of our back patio, all being controlled by a Teensy 4.0 (using an IR remote to command the Teensy), so maybe with that behind me, I can try to help a little.

With the sketch that I wrote, when I add the "#define FASTLED_ALLOW_INTERRUPTS 0" as suggested earlier, I get the same compile error that you are seeing & cannot load/run my sketch. Without that addition (or by explicitly changing it to "#define FASTLED_ALLOW_INTERRUPTS 1"), my environment is reporting "FastLED version 3.003.003" & everything compiles/runs just fine. Maybe updating your version of the library would be worth a try ??

Here are the particulars of my Arduino build environment:

Arduino version: 1.8.12
Teensyduino version: 1.51
Arduino IDE Configuration:

Tools/Board: "Teensy 4.0"
Tools/USB Type: "Serial + MIDI"
Tools/CPU Speed: "600MHz"
Tools/Optimize: "Fastest"
Tools/Keyboard Layout: "US English"
Tools/Port: "COMx Serial (Teensy 4.0)"

Here are the pertinent lines in my setup() function (it looks similar enough to yours that I feel that yours is likely correct):

Code:
#include <FastLED.h>
#include "GRB_colors.h"

#define NUM_LEDS 900
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define SPLASH_COLOR    UV_PURPLE
#define RGB_LED_PIN 7

void setup()
{
   // initialize the LED library
   FastLED.addLeds<1, WS2812B, RGB_LED_PIN>(leds, NUM_LEDS);

   pinMode(RGB_LED_PIN, OUTPUT);

   int intensity = 2;

   // Example: fill_solid( leds, NUM_LEDS, CRGB(50,0,200));
   fill_solid(leds, NUM_LEDS, SPLASH_COLOR);

   // blink the LED with increasing intensity at startup
   for (int i = 0; i < 4; i++)
   {
      for (int j = 0; j < 5; j++)
      {
         FastLED.setBrightness(intensity - 1);
         FastLED.show();

         // wait for 1/20 second
         delay(100);

         FastLED.setBrightness(0);
         FastLED.show();

         // wait for 1/20 second
         delay(100);
      }

      intensity *= 4;

      // wait for 1/4 second
      delay(PATTERN_DELAY_STEP);
   }

   // wait for a small bit before starting
   delay(100);

[ . . . go do some other setups to allow LEDs to either blink between two colors, scroll two colors like a marquis, or display any one of ten pre-defined patterns ]
}  // setup()

Maybe you could substitute this into your setup() & see if you get the intended blinks in increasing intensity.

Mark J Culross
KD5RXT
 
Thank you for your effort but...
I have the same versions for Arduino, Teensyduino and FastLED installed and also the same configuration as you. I can also implement the line:
Code:
#define FASTLED_ALLOW_INTERRUPTS 1
But it doesn't solve the problem. I had to modify your code a little because I don't have:
Code:
GRB_colors.h
It didn't help either.

Could it be that the board is somehow damaged?
 
FinleyOderSo:

Sorry, I overlooked the "GRB_colors.h" file . . . that was my local rework of the "RGB_colors" file for the GRB color order used by the WS2812B strips that I have.

On the subject of library versions, I made my comment about updating the library because your earlier console log shows 3.003.001 vice 3.003.003.

I suppose it's possible that your board is damaged as you suspect, especially if any of its inputs were accidentally directly exposed to >3.3VDC (the Teensy 4.0 is not 5VDC tolerant). You might try using a different I/O pin for your DATA_PIN & see if that makes any difference.

Let us know what you find . . .

Good luck & have fun !!

Mark J Culross
KD5RXT
 
I'm seeing the same issues as FinleyOderSo.
To avoid any power issues I started with a 24 pixel NeoRing.
The following code:
Code:
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>

#define DATA_PIN    2
#define LED_TYPE    NEOPIXEL
#define NUM_LEDS    24

CRGB strip[NUM_LEDS];

void setup() {
  FastLED.addLeds<LED_TYPE, DATA_PIN>(strip, NUM_LEDS);
  FastLED.setBrightness(16);
}

void loop() {
  for (int dot = 0; dot < NUM_LEDS; dot++) {
    strip[dot] = CRGB::White;
    FastLED.show();
    delay(50);
    strip[dot] = CRGB::Black;
  }
}
does not compile for Teensy 4, throwing the error:
In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/fastled_arm_mxrt1062.h:10:0,

from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms.h:23,

from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/FastLED.h:52,

from C:\Users\Paul\Documents\Arduino\Teensy4_NeoPixel24_FastLED\Teensy4_NeoPixel24_FastLED.ino:2:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h: In member function 'virtual void FlexibleInlineBlockClocklessController<LANES, FIRST_PIN, T1, T2, T3, RGB_ORDER, XTRA0, FLIP, WAIT_TIME>::showPixels(PixelController<RGB_ORDER, LANES, ((1 << LANES) - 1)>&)':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h:102:3: error: 'MS_COUNTER' was not declared in this scope

MS_COUNTER += (1 + (microsTaken / 1000));

^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/fastled_arm_mxrt1062.h:9:0,

from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms.h:23,

from C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/FastLED.h:52,

from C:\Users\Paul\Documents\Arduino\Teensy4_NeoPixel24_FastLED\Teensy4_NeoPixel24_FastLED.ino:2:

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/clockless_arm_mxrt1062.h: In instantiation of 'uint32_t ClocklessController<DATA_PIN, T1, T2, T3, RGB_ORDER, XTRA0, FLIP, WAIT_TIME>::showRGBInternal(PixelController<RGB_ORDER>) [with int DATA_PIN = 2; int T1 = 250; int T2 = 625; int T3 = 375; EOrder RGB_ORDER = (EOrder)66u; int XTRA0 = 0; bool FLIP = false; int WAIT_TIME = 50; uint32_t = long unsigned int]':

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/clockless_arm_mxrt1062.h:45:22: required from 'void ClocklessController<DATA_PIN, T1, T2, T3, RGB_ORDER, XTRA0, FLIP, WAIT_TIME>::showPixels(PixelController<RGB_ORDER>&) [with int DATA_PIN = 2; int T1 = 250; int T2 = 625; int T3 = 375; EOrder RGB_ORDER = (EOrder)66u; int XTRA0 = 0; bool FLIP = false; int WAIT_TIME = 50]'

C:\Users\Paul\Documents\Arduino\Teensy4_NeoPixel24_FastLED\Teensy4_NeoPixel24_FastLED.ino:23:1: required from here

C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED/platforms/arm/mxrt1062/clockless_arm_mxrt1062.h:91:14: warning: unused variable 'wait_off' [-Wunused-variable]

uint32_t wait_off = _FASTLED_NS_TO_DWT((WAIT_TIME-INTERRUPT_THRESHOLD));

^

Error compiling for board Teensy 4.0.

When removing the first line #define FASTLED_ALLOW_INTERRUPTS 0, the sketch compiles fine, but does not work. All LEDs are max white [while I set FastLED.setBrightness(16);].

However, if I replace the Teensy 4 by a Teensy 3.2 and use exactly the same sketch, including the #define FASTLED_ALLOW_INTERRUPTS 0, everything compiles and runs fine.

Here is the hardware setup [showing Teensy 3.2 connected]:
IMG_20200507_095223.jpg

The NeoPixel ring is powered from pin Vin [5V].

Arduino 1.8.12, Teensyduino 1.51, FastLED 3.3.1, Windows 7.
I also tried FastLED 3.3.3 [the latest version cloned from Github] but that did not help.

Regards,
Paul
 
FinleyOderSo:

Sorry, I overlooked the "GRB_colors.h" file . . . that was my local rework of the "RGB_colors" file for the GRB color order used by the WS2812B strips that I have.

On the subject of library versions, I made my comment about updating the library because your earlier console log shows 3.003.001 vice 3.003.003.

I suppose it's possible that your board is damaged as you suspect, especially if any of its inputs were accidentally directly exposed to >3.3VDC (the Teensy 4.0 is not 5VDC tolerant). You might try using a different I/O pin for your DATA_PIN & see if that makes any difference.

Let us know what you find . . .

Good luck & have fun !!

Mark J Culross
KD5RXT

I tried 3.003.003 as well as different I/O pins.
And I don't recall connecting 5V to any I/O pin.
 
I changed my setup, so I use a 74HCT245 IC to step up data from 3.3 to 5 volts and now at least some (the first round about 70) of my 144 led's are working. Although if I only send data to like the first 25 led's I can also send data to the 120th led for example. Sending data to all led's as is said results in only the first about 70 led's lighting up. It feels like I'm not allowed to send too much data. This is just weird.
 
I'm seeing the same issues as FinleyOderSo.
To avoid any power issues I started with a 24 pixel NeoRing.
The following code:
Code:
#define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>

#define DATA_PIN    2
#define LED_TYPE    NEOPIXEL
#define NUM_LEDS    24

CRGB strip[NUM_LEDS];

void setup() {
  FastLED.addLeds<LED_TYPE, DATA_PIN>(strip, NUM_LEDS);
  FastLED.setBrightness(16);
}

void loop() {
  for (int dot = 0; dot < NUM_LEDS; dot++) {
    strip[dot] = CRGB::White;
    FastLED.show();
    delay(50);
    strip[dot] = CRGB::Black;
  }
}
does not compile for Teensy 4, throwing the error:


When removing the first line #define FASTLED_ALLOW_INTERRUPTS 0, the sketch compiles fine, but does not work. All LEDs are max white [while I set FastLED.setBrightness(16);].

However, if I replace the Teensy 4 by a Teensy 3.2 and use exactly the same sketch, including the #define FASTLED_ALLOW_INTERRUPTS 0, everything compiles and runs fine.

Here is the hardware setup [showing Teensy 3.2 connected]:
View attachment 20010

The NeoPixel ring is powered from pin Vin [5V].

Arduino 1.8.12, Teensyduino 1.51, FastLED 3.3.1, Windows 7.
I also tried FastLED 3.3.3 [the latest version cloned from Github] but that did not help.

Regards,
Paul

Hey Paul, I am seeing the same issue as well. I have all current libraries and am testing with the FastLed DemoReel100 sketch and am getting bright white. The funny thing is I can see the sketch running and updating the strip correctly but the colors are almost imperceptible due to being almost entirely washed out by the bright white. This is making me think that it is maybe not a timing or interrupt issue nor a 3.3v data pin issue? Like some others have mentioned the Adafruit Neopixel library seems to work just fine as I tested with that just to make sure none of my hardware or wiring was bunk and that library seems to work just fine...but all of my code relies on FastLed so a solution is still needed for me. Are you also seeing faint color changes on your nearly all-white neopixel ring?
 
Are you also seeing faint color changes on your nearly all-white neopixel ring?

Yes, I also see this. Both with my sketch above as well as the DemoReel100 sketch.

In the meantime I upgraded to Teensyduino 1.52 [to support the Teensy 4.1] but that did not make a difference.
So now I'm running Arduino 1.8.12, Teensyduino 1.52, FastLED 3.3.3, Windows 7.
Arduino IDE Configuration:
Tools/Board: "Teensy 4.0"
Tools/USB Type: "Serial"
Tools/CPU Speed: "600MHz"
Tools/Optimize: "Fastest"
Tools/Keyboard Layout: "US English"
Tools/Port: "COM1 Serial (Teensy 4.0)"

Code:
//#define FASTLED_ALLOW_INTERRUPTS 0  // 0 = disable interrupts
#include <FastLED.h>

#define DATA_PIN    2
#define LED_TYPE    NEOPIXEL
#define NUM_LEDS    24

CRGB strip[NUM_LEDS];

void setup() {
  FastLED.addLeds<LED_TYPE, DATA_PIN>(strip, NUM_LEDS);
  FastLED.setBrightness(16);
}

void loop() {
  for (int dot = 0; dot < NUM_LEDS; dot++) {
    strip[dot] = CRGB::White;
    FastLED.show();
    delay(50);
    strip[dot] = CRGB::Black;
  }
}

Bottomline I think the timing is corrupted and the interrupts should be disabled as Paul suggested in msg #3. But that does not compile...

Regards,
Paul
 
I was able to get rid of the compilation error when #define FASTLED_ALLOW_INTERRUPTS 0 was added to the top of the sketch
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLE D/platforms/arm/mxrt1062/block_clockless_arm_mxrt1062.h:102:3: error: 'MS_COUNTER' was not declared in this scope

MS_COUNTER += (1 + (microsTaken / 1000));

^

by uncommenting lines 34 & 35 in C:\Users\Paul\Documents\Arduino\Libraries\FastLED\platforms\arm\mxrt1062\led_sysdefs_arm_mxrt1062.h:
Code:
extern volatile uint32_t systick_millis_count;
#  define MS_COUNTER systick_millis_count

The sketch compiles fine now [apart from the warning that variable 'wait_off' is unused]. However, the timing issue resulting in wrongly lit LEDs is still present.
Question ofcourse is why these 2 lines were commented out in the first place.

Paul
 
I'm Having the same problem, sketch works fine with Teensy 3.6 but not with Teensy 4.0, with Teensy 4.0 it lights up all white.
 
I am currently very busy with other projects and hope to be able to motivate myself for the Teensy LED project soon again.
Then I will also try what PaulS mentioned.
 
Since I would like the FastLED library to run on a Teensy 4.0 as well, I did some more tests.

First I upgraded to Arduino 1.8.13, TeensyDuino 1.53 and Windows 10.
Subsequently installed FastLED 3.3.3 using the Library manager .

Set the Arduino IDE configuration as follows:
Tools/Board: "Teensy 4.0"
Tools/USB Type: "Serial"
Tools/CPU Speed: "600MHz"
Tools/Optimize: "Fastest"
Tools/Keyboard Layout: "US English"
Tools/Port: "COM1 Serial (Teensy 4.0)"

Then added a levelshifter [NXP 74AHCT2G125 on Adafruit #1212 breakout board] and a NeoPixel ring:

IMG_20200703_154644.jpg

and ran this most basic sketch:
Code:
// #define FASTLED_ALLOW_INTERRUPTS 0
#include <FastLED.h>

#define DATA_PIN    2
#define NUM_LEDS    1   // yes, 1 LED only

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  leds[0] = CRGB::Red;
  FastLED.show();
}

void loop() {
}

Unfortunately, it did not work out: the LED is lit full white.
PS: I had to uncomment #define FASTLED_ALLOW_INTERRUPTS 0 otherwise it wouldn't compile and threw the 'MS_COUNTER' was not declared in this scope error.
Changing the clockspeed to 150MHz also did not help.

Hmm, I'm stuck here...any ideas what to try next?

Paul
 
I'm stuck with this too, I've also did all the upgrades and changes but nothing helps, all LEDs full white. On teensy 3.6 it works.

I have no idea on what to try next.

FOB.
 
Solved by easy workaround

After more digging on the Internet, found this post on Reddit [Chemdoc77 is also a forum member here].
Apparently you have to setup FastLED as if it operates in Parallel Output Mode.
Now my basic sketch above looks like:
Code:
#include <FastLED.h>

#define DATA_PIN    7
#define NUM_LEDS    1
#define NUM_STRIPS  1

CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<NUM_STRIPS, WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
  leds[0] = CRGB::Red;
  FastLED.show();
}

void loop() {
}

...and works!

You could also try this sketch that is referred to in that Reddit post - works fine.
Mind you, there is a limitation on usable pin numbers, see here. For a single [parallel?] output you can use any of the mentioned pin numbers.

Paul
 
I use following with Teensy 4 which works for me

Code:
#include <WS2812Serial.h>  // leds
#define USE_WS2812SERIAL  // leds
#include <FastLED.h>      // leds
...
FastLED.addLeds<WS2812SERIAL, DATA_PIN, BRG>(leds, NUM_LEDS);
 
Status
Not open for further replies.
Back
Top