I have built a switch-mode power supply where the output voltage is controlled by a PWM signal from a microprocessor. The power supply is based on an XL4015. The feedback pin is normally fed by a passive resistor network that sets the output voltage- it's effectively a comparator relative to 1.25V. In this case the feedback pin is connected to the output of an op-amp which compares the output voltage with the filtered PWM voltage.
Vin is the PWM signal, Vout is the output voltage of the SMPSU and Vfb goes to the feedback pin on the XL4015. Unfortunately the circuit oscillates at about 10kHz, presumably because there is no gain-limiting feedback.
The red trace is the feedback signal, and the blue trace is the ripple on the SMPSU output voltage. The steps in the ripple are caused by the 40kHz operating frequency of the SMPSU.
Is there a simple change to this circuit that will make it more stable?