Seeking advice on very gentle fade to off - Sunset Animation

Hi,

I’m attempting to add an annular sunset animation to a planetarium, but I’m a little out of my depth.

The idea is to have this ring of 630 (x3) LEDs around the room run through some soothing sunset colors and drop to zero light over the course of about two minutes.

With a bare bones example that goes Yellow light → fade to darkness, everything works well until the last ten steps or so where the light level in the room appears to go “KaCHUNK!” “KaCHUNK!” in big jumps because there are a lot of LEDs and they’re the only light in the room during this animation.

I’m betting that the level can be smoothed out a bit by only dipping one or a few LEDs at a time, instead of the entire ring, but getting some sort of “random selection until every LED has dropped one level” is escaping me.

I’d appreciate any advice or input. Thanks!

What I’m playing with from one of the demo scripts:

seconds = 0
delta_acc = 0
running = 0
duration = 120
pixel_h_step = array(pixelCount)
pixel_h_acc = array(pixelCount)
progress = 0

export function triggerBeginSunset(){
  running = 1
  seconds = 0
  delta_acc = 0
  progress = 0
  for (i = 0; i < pixelCount; i++) {
    pixel_h_step[i] = random(0.002) - 0.001
    pixel_h_acc[i] = 0
  }
}

export function triggerReset() {
  running = 0
}

export function inputNumberDuration(s) {
  duration = s
}

export function beforeRender(delta) {
  delta_acc += delta
  while (delta_acc > 1000) {
    delta_acc -= 1000
    seconds += 1
    for (i = 0; i < pixelCount; i++) {
      pixel_h_acc[i] += pixel_h_step[i]
      //pixel_h[i] = clamp(pixel_h[i], -0.05, 0.05)
    }
  }
  progress = ( (seconds / duration) + ((delta_acc/1000)/duration) )
  t1 = time(.25)
  t2 = time(.15)
}

export function render(index) {
  if (running) {
    
    //h = 0.06 + pixel_h_acc[index]
    
    shift = (0.02 * progress)
    shift = shift * shift
    h = 0.06 - shift
    //h = 0.06
    //s = 1 - (s * s * s * s * s)/2
    s = 1
    
    v = clamp(1 - progress, 0, 1)
    
    hsv(h, s, v)
    if (v == 0) {
      triggerReset()
      v = 1
    }
  } else {
    rgb(0,0,0) 
  }
}

Hey @ctag! Welcome to the forum, and congrats on putting up such a functional first pattern here.

Are you possibly using WS2XXX LEDs? They have a much worse dim-to-black curve (especially on the low end) than the APA102/SK9822/GS8208 strips. Let’s assume that changing out your LEDs isn’t an option.

Temporal dithering (turning a color on and off quickly to create additional dimming steps) probably isn’t an option with 630 LEDs.

I like your proposed solution of trying to be sure to only dim one at a time. Just also beware that your color accuracy is going to fall apart on the lowest intensities. Say you’re on WS2812B LEDs and each of R, G, and B has 8 bit values. If R = 4/256, and G = 2/256, no matter which color is reduced next (R = 3/256 or G=1/256), you’re going to see a big jump in the final mixed hue.

While there’s a lot of ways to do this, here’s an approach I might take, chosen mostly for it’s simplicity in explaining:

  1. Randomize all 630 LED indices in an array (see Fisher-Yates in JS)
  2. Reduce their intensity by some amount in that order (*= .7 or -= .001 or something)
  3. Repeat after some number of milliseconds

There’s a lot of nuance possible, like whether you reduce higher existing intensities more, or how you decide on your timing between subsequent reductions.

Seeing the code you’ve already produced, it seems like this is the right level of detail to leave the fin parts to you! But if you get stuck on the implementation of the above, let me know. I’m in a week where I’ll have extra time and energy to help out and write some code.

3 Likes

@jeff Thank you for the assistance!

Yes, they’re WS2811 strips. Oh well. That’s what I get for diving head first into this.

I made it back up the mountain today and got a very minimal test of that randomization going. The jarring steps in brightness are gone!

Next visit I’ll start tweaking it to look and act more like a sunset, and hopefully we’ll be using it for our star tours soon!

3 Likes

Circling back around to this, I’m interested in possibly changing out the LEDs, and would be glad to get some feedback on what to go with. I plan to buy 5m to test with, and if they work well do the full 35 meters.

Looking here it seems that the GS8208 is an easy choice for being 12V, but if the other variants outperform in low-light fading, without much need for fast animations, I’d consider replacing the 12V power supplies as well.

And from reading here it looks like the SK9822 may be a better/cheaper choice than the APA102s for my applications.

The gs8208 is much better compared to WS2812 and the like, but still nowhere near the range of the sk9822/apa102.

If the WS2812 is close, the gs8208 might be enough, and let you keep your 12V setup. The GS8208 has built in gamma correction which will change the appearance of colors compared to other LEDs that work on a linear scale.

You might want to test both for your setup.

True APA102 are very hard to find these days, and pretty much anywhere selling APA102 is actually selling SK9822.

SK9822 do color shift slightly towards green when working at dim levels, but maintain a high PWM rate (no flicker). True APA102 drop from 20khz PWM down to about 400Hz when working with low levels via HDR, but maintain color balance.

2 Likes

4 months ago
Circling back around to this

If I say I’m circling back again, does that mean I’m spiraling? :sweat_smile:

A member at the planetarium wrote in for a grant to finish the LED lighting upgrade, and it got awarded! We’ve got a couple hundred dollars to get things driven to done.

I really appreciate the help so far. Wizard’s LED comparison has been rattling around in my head for a bit now. Since the current LEDs already aren’t quite as bright as I’d like them to be, it seemed like we could either try tacking on additional 12V strips in parallel or go with 5V ones and rig up addition 5V PSUs in the attic. But doubling up the 12V strips would overload the 150W PSUs we already have; or at least it would exceed the maximum current on paper.

My plan right now is to buy a strip of both SK9822 and GS8208 and put them through their paces. I’m looking at the two links below, but would certainly appreciate any input on other outlets to buy from.

GS8208: GS8208 12V Individually Addressable RGB LED Strip
SK9822: SK9822(Similar to APA102) RGB 60LEDS/M DC5V 12MM-Wide Digital Intelligent Addressable LED Strip Lights - 5m/16.4ft per roll [SK9822-60W10] - $37.98 :

I’d also like to double check my understanding of Pixelblaze. The unit itself (v3 std) can only support one type of LED strip at a time, but if I add an expansion board, it could run two different strips around the dome? And I wouldn’t have to use dual pixelblazes with network sync?

Correct – with the expansion board (either pro or basic), you can specify strip type on a per output basis.

1 Like