It could be done, but there would be some designing involved. You would be better starting from the other PWM circuit I showed that translated voltage into PWM, then you could have a capacitor charge and discharge.