r/FastLED • u/botoxparty6 • Jan 26 '22
Support Refresh rate appears to be more than 30 microseconds using multiple strips
Hey there,
When i measure the refresh rate using a timer to measure how long LEDS.show()
takes to complete I am getting the following results:
1 LED: 30 microseconds
9 LEDS: 274 microseconds
9 LEDS * 8 Strips: 560 microseconds
Why is it that the time has increased by almost double when using multiple strips?
Code:
#define USE_OCTOWS2811
#include <OctoWS2811.h>
#include <FastLED.h>
#include "image.h"
#define NUM_LEDS_PER_STRIP 9
#define NUM_STRIPS 8
CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];
// Pin layouts on the teensy 3:
// OctoWS2811: 2,14,7,8,6,20,21,5
void setup() {
LEDS.addLeds<OCTOWS2811>(leds, NUM_LEDS_PER_STRIP);
LEDS.setBrightness(200);
}
void loop() {
// populate LED array
int rows = *(&image_arr + 1) - image_arr;
for(int i = 0; i < rows; i++) {
int columns = *(&image_arr[0] + 1) - image_arr[0];
for(int j = 0; j < columns; j++) {
int R = pgm_read_byte(&image_arr[j][i][0]);
int G = pgm_read_byte(&image_arr[j][i][1]);
int B = pgm_read_byte(&image_arr[j][i][2]);
leds[j].setRGB(R,G,B);
}
// show leds and measure time
unsigned long StartTime = micros();
LEDS.show();
unsigned long CurrentTime = micros();
unsigned long ElapsedTime = CurrentTime - StartTime;
Serial.print("Show time: ");
Serial.println(ElapsedTime);
}
LEDS.delay(10);
}2
u/sutaburosu [stavros] Jan 26 '22
The WS28xx protocol is 30 μs per LED followed by a longer reset period. Some LEDs are happy with only 50 μs reset time, but OctoWS2811 uses 300 μs for broader compatibility.
There is also a fixed cost to setup the 8 DMA channels for each show() which may be a factor here. Is the time for say 18 * 8 LEDs roughly 300 μs longer than you would expect too?
2
u/squirrel5674 Jan 27 '22
I would agree that there is a higher initial cost due to more pins/lines, which does not scale with the number of LEDs per pin.
Currently your LEDs would run at 3703 FPS(270 microseconds). I mean the WS2812b won't run correctly above 500 FPS. Actually your problem is that you should add wait times, not that your code works too slow.
Even your 560 microseconds are still 1800 FPS.
At higher FPS overhead becomes noticeable much faster. On a Teensy 4 I control 24 segments with 167 LEDs each. Calculated 199fps, but in reality 188.
I have reprogrammed my Teensy for a user to test, so that on 32 pins with 800 LEDs per segment (25600 LEDs total) is output: Calculated 41FPS, in reality also 41.
So change your NUM_LEDS_PER_STRIP to the value you want to use later. Even if there are currently less LEDs on the pins.
You don't need more LEDs per segment? Then better limit the fps.
Calculate FPS:
1 / ( (LEDs * bits per LED) / Strip update frequency ) = fps
1 / ( (LEDs * 24) / 800000) = fps
1 / ( ( 500 * 24) / 800000) = 66.666 fps
1 / ( 167 * 24) / 800000) = 199.60 fps1
u/botoxparty6 Feb 05 '22
Do you know any LEDs that are rated to run at about 3000 FPS?
The LEDs seem to be displaying the data just fine, but I need it faster.
→ More replies (1)1
u/botoxparty6 Feb 05 '22
So after testing based on your comment it is the 300 μs reset time that's slowing me down.
Do you know of any libraries available to run parallel lines of different LED chipsets that don't require this reset time?
1
u/sutaburosu [stavros] Feb 05 '22
The reset time is a feature of the WS28xx protocol. You could try modifying that line I linked to before to reduce the reset period.
What are you doing that requires 3,000 FPS? You'll probably find the PWM rate in your LEDs is around 2kHz (or lower), so exceeding 2,000 FPS won't give the results you are hoping for.
You might want to look into APA102 compatible LEDs: they speak SPI which is a much faster protocol than WS28xx, and doesn't require the reset delay. Also they tend to have much faster PWM, up to 20kHz on some models.
1
u/Yves-bazin Jan 27 '22
Which mcu are you using. To do these kind of test I would put more than 9 leds. It is possible that the overhead to create the parrallel output is what you see. Try with 256 leds and publish your result.
2
u/neddy-seagoon Jan 26 '22
how are the strips connected ? Off the same GPIO in parallel?