Skip to content

Add support for (non linear?) current limited LEDs in auto brightness limiter #5715

Description

@Szabolcs2008

Is your feature request related to a problem? Please describe.
I have ordered some 12V WS281x compatible LEDs from AliExpress (this), built a simple controller for them (2 channels with 600 LEDs). I realized that I had miscalculated the total current, so I had to current limit it in software. However, it kept tripping the psu's short circuit protection. After testing again with my lab bench psu, I figured out that WLED's current measurement was way off. The limit was set to 8 amps total (this is the rated current of my power supply), but the actual current draw was 10+ amps without getting brightness limited.
After some measuring around, I figured out that these LEDs were a little weird: The current is linear initially, but then it gets clamped at ~10 mA per led, regardless of the color after that point. I did a test again, but now actually recorded the data (I attached the file). It seems like these LEDs have a shared current limit across the colors channels. The limit is only applied when multiple channels are lit simultaneously within the PWM cycle. I could prove this by looking at the current draw with an oscilloscope, and seeing 1 to 3 distinct spikes.

Describe the solution you'd like
I would appreciate if more accurate current calculation for non linear current-limited LEDs got implemented. Ideally, this could be a new LED type, or maybe a toggle for current LED types (eg. WS281x, maybe a second custom type for WS281x). Different LED ICs probably have different thresholds, so the implementation should ideally be generic and parameterizable

Describe alternatives you've considered
My temporary solution was to greatly limit brightness

Additional context
I then wrote a test that goes through some colors and logs the LED current. Based on these measurements, I created a current profile model that matches the measured current with less than 1% prediction error. I used Claude to help prototype the algorithm in Python and produce a C implementation. I also made a proof of concept fork implementing this current model. I have been running it 24/7 on my own LED installation for ~2 months without having any issues, although it has only ever been tested on my exact hardware.

Current profile of one led (this is what I gave to Claude): 1led.txt
I uploaded all of the code I or Claude wrote to this repository
Current prediction code by Claude: predict.py
Proof-of-concept implementation is in this commit.

Thank you for your ideas for making WLED better!

Metadata

Metadata

Assignees

No one assigned

    Labels

    AIPartly generated by an AI. Make sure that the contributor fully understands the code!enhancementquestion

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions