I reverse engineered and simulated the feedback circuit in an simple SMPS power supply the led represents the optocoupler .At a certain voltage the led drastically turns on just like a comparator and this sends a signal to the higher voltage or the mains which signals to lower the PWM .The voltage now is regulated.With the help of the optocoupler ,we cannot be electricuted in the output side.we can change the output by varying the zener diode or the resistor value.