I have a task to design a driver to drive 3W power LED. I have only 4 wires to dim 7 LEDs individually, so I decided to use WS2811 "magic" driver for PWM. The rest of the circuit is to provide constant current for the LED.
U1A, U1B create loop to control current through the LED. D1 (zener) and RV1 (trimmer) allow to set maximum current. Q2 shorts this set voltage to ground with frequency of 2Khz and variable PWM, to control LED brightness. So - I'm not changing current throught the LED - I turn it on (maximum set) and off to set the brightness. I know this is not simplest way to do it, but I've got boards for it for free.
What is the problem?
At lower duty cycles it works ideally. Probe is connected between Q1 drain and ground, 12V is stable. Set current is about 310mA, and when Q1 conducts it has 400mV voltage drop, so it's limiting the current well.
However, at higher duty cycle circuit "has time to think" and it starts to oscillate.
It has always higher voltage drop, so no damage to LEDs, it works well, but I would love to have it working 100% correct. And one more thing: using a resistor as a load instead of diode also makes it completly stable.
How to make it more stable, keeping ability to dim with 2kHz?