Background
A while back, I found some widespread night lamp control modules on AliExpress.

Using them, I made a few battery-powered desktop lamps. But I wasn't very satisfied with their functionality, so I decided to develop my own dimming control modules.
At the heart of Chinese boards is a chip marked as JL7022WE. It appears to be a uASIC. With a little research, it's not hard to figure out that there are many different versions of these chips with various markings. For example, the SGL8022W can be considered an easy-to-buy full-fledged equivalent. At least for the white board, since the green has two output channels instead of one. A version of the SGL8022 with two outputs does exist, but it has a different marking (SGL8023W).
Implementation
In my implementation, I would like to highlight the following advantages over the Chinese modules:
- Operation without battery (only from an external power source (USB)).
- Safe operation even during battery charging.
- Faster charging for batteries with higher capacity.
- Flicker-free brightness control.
- LED short circuit protection.

I also chose SGL8022W as the main control IC. But there is a problem: unfortunately, it is not known exactly which PWM dimming frequency your sample of SGL8022W will use. Measurements by some enthusiasts on the Internet show that the frequency can be as low as 100-120 Hz in stepless mode (I want to use this specific mode). So I opted for a linear brightness control method. To ensure sufficient efficiency, I reduced the supply voltage to 3.6 V with a TPS63000 buck-boost converter. The SGL8022W can operate without any problems at this voltage.
The TPS63000 is an incredible discovery for my project because it automatically switches from step-down operation to boost operation and back to maintain the set voltage. Also, the converter has power-save mode for light loads. This is relevant when the system enters standby mode, so I enabled it.
The linear dimming circuit is a constant-current sink in my case. The filtered PWM signal from SGL8022W is mapped to the reference voltage using a resistive divider.
The reference voltage is 0.1 V. The 0.51 Ohm measurement resistor sets a maximum current of 196 mA through an LED when PWM is 100%. R25 compensates the operational amplifier's input offset by injecting a small voltage.
Sev
Sagar 001
Kevin LO
Guillermo Perez Guillen