PWM square wave to DC voltage simple conversion
Using microcontroller - you can read PWM using timer and then output corresponding value to DAC. Look for microcontroller with integrated DAC, that would be the simplest way.