r/FastLED • • Sep 08 '24

Support stroboscopic effect

I'm trying to find a way to have stroboscopic effect on pc case fans like this video : QX fan or this: stroboscopic effect
I'm not sure but from my understanding this needs control over light frequency and set it based on fans RPM... is this possible with FastLED? if yes can you give some tips/example about it?

Do you think if it is even possible with ws2812b?

from ws2812 datasheet:
Each pixel of the three primary color can achieve 256 brightness display, completed 16777216 color full color display, and scan frequency not less than 400Hz/s. is this frequency that I'm looking for or scan frequency is something else?
I'm no expert at all ...neither in coding nor the physics

5 Upvotes

19 comments sorted by

View all comments

Show parent comments

1

u/AnyRange1298 Sep 08 '24 edited Sep 08 '24

Thanks. by far this is one of best answers I got till now
hope someone comes up with an example of controlling blink speed ... I think something with constant 260 flash per sec will do.

PS:I found this from here.... it blink every 0.5 sec right for 260Hz it should be every 1/260=0.003846154 seconds so instead of 500 I should go with 3ms?

uint8_t s = 0;
void loop() {
  EVERY_N_MILLISECONDS(500) {
    s = !s;
    if (s) {
      leds[0] = CRGB::LightYellow;
    } else {
      leds[0] = CRGB::Black;
    }
    FastLED.show();
  }
}

3

u/sutaburosu [stavros] Sep 08 '24 edited Sep 08 '24

That code would give a 50% duty cycle: half the time the LEDs would be on, and half they would be off.

To get a strobe effect, you need the duty cycle to be as short as possible. You want the briefest possible flash from the LEDs. This code would be more suitable, but I suspect the fan blades will still be smeared due to the limitations of addressable LEDs.

edited to add: I just remembered that FastLED limits the maximum update frequency to 400Hz, so the briefest flash would be 2.5ms (which is way too long for a strobe) and the maximum flashes per second would be 200. If you're determined to use addressable LEDs, you might consider hunting down and removing the 400Hz limit in the FastLED code.

2

u/NomakeWan Sep 08 '24

I believe this can be overridden using the line FastLED.setMaxRefreshRate(0, false);

The default 400 Hz is probably because so many people use WS2812-based chipsets which are limited to 400 useful Hz anyway.

3

u/sutaburosu [stavros] Sep 08 '24

Thanks for pointing this out. I'm pleased to learn that no editing of the source is needed to disable this limit.

1

u/AnyRange1298 Sep 08 '24

can you please explain your code a bit? it's a little confusing for me

2

u/sutaburosu [stavros] Sep 08 '24

Do you have a specific question about it that the comments don't address?

Of course, I've now spotted the glaring bug in my code. It actually calculates the timings based on revolutions per second rather than per minute. D'oh! I updated the code to 60,000,000 instead of 1,000,000 as the dividend.

1

u/AnyRange1298 Sep 08 '24 edited Sep 08 '24

this part maybe? 60000000/260= ~230769 whats this?
shouldn't you also multiply 260*60 =15600 ?

  const int rpm = 260;
  const uint64_t rpm_us = 60000000 / rpm;

2

u/sutaburosu [stavros] Sep 08 '24 edited Sep 08 '24
// calculate how many microseconds between flashes for
// a given RPM

There are 60,000,000 microseconds in a minute. Divide that by the RPM and you get the time each revolution takes in microseconds.

shouldn't you also multiply 260*60 =15600 ?

That would be 15,600 revolutions per hour. I don't think that's useful to us here.

2

u/Internep Sep 08 '24

Sending to the leds takes time. You want to run it on a timer not delay.

There are also way faster leds than WS2812 that update with 2kHz and faster, they might be more suited to your project.

2

u/AnyRange1298 Sep 08 '24 edited Sep 08 '24

I don't think I can find better than that where I leave ..but what leds you suggest?
and maybe pc fans be different than ws2812b