The power supply is designed to operate power LEDs directly from the mains voltage. It is intended mostly for white LED, but it can also be used for other colors,
such as blue, green, red, yellow, or even UV. The schematic of this switching supply is in Fig. 1. The supply works as a flyback self oscillating converter.
The LED for simplicity is not separated from the mains. Assumed such assembly to prevent the possibility of touching conductive parts.
The secondary winding supplying LED serves also as an auxiliary (feedback) winding. T1 performs the function of power switch.
KSC5027 can be used. This power supply operates in current mode. LED current is sensed by the shunt resistor Rx.
At the drop of about 0.65 V it starts to open auxiliary transistor
T2 (eg, BC547, 2SC945, BC237), which limits the base current of T1 and thus the PWM duty cycle. Since the output voltage is small,
Schottky diode is used as a rectifier. It has greater efficiency due to lower voltage drop. For simplicity there's no voltage feedback.
Fig. 2 illustrates how to add voltage feedback and thus make the supply survive when LED is disconnected or fails open. The transformer Tr1 is wound on a core EE,
the middle column 4.5 x 4.5 mm (from auxiliary supply of an old ATX PC supply).
The primary winding has 180 turns wire diameter of 0.2 mm. The secondary winding has 6 turns triple-wire 0.5 mm. First
half of primary is wound (90 turns), then secondary, and finally the other half of primary. You can also use ready-made transformer
designed for 5V switching power supplies. The auxiliary winding of ready-made transformer is not used. T1 requires no heatsink up to 5W output power.
Shunt Rx is calculated according to the formula
R = 0.65 V / I
I is desired LED current. LED is not necessary to be operated at maximum current. You can use less current, it will increase its efficiency and life time. This power supply operates at a frequency of about 80kHz.