- Place a Voltage Sensor block to monitor the voltage across the capacitor.
- Use a Switch block to compare the measured voltage to the threshold.
- Inside the path selected by the Switch block, place the PWM Generator block. Connect the duty cycle input of this block to the Signal Editor block.
- Configure the rest of your circuit as needed, ensuring that the PWM signal controls the relevant part of the circuitry.
- Switch block: https://www.mathworks.com/help/simulink/slref/switch.html
- Voltage Sensor block: https://www.mathworks.com/help/simscape/ref/voltagesensor.html