How do I filter a square wave to get an analogue voltage?
There is no linear way ot get a perfect average voltage from the waveform, but passing it through a low pass filter will reduce the strength of the higher frequency components of the square wave, without much changing the DC (average) component. Since the lowest frequency AC component is the fundamental frequency and low pass filters generally attenuate higher frequencies more than lower frequencies, the fundamental frequency is the hardest to acceptable eliminate with a simple low pass filter. But if you add a notch filter to the low pass filter, at the fundamental frequency, you can more easily get an acceptable average output. The combination of notch and low pass is often referred to as a Cauer or eliptical filter In general, the higher the pulse frequency, the easier it is to filter out the AC in a given amount of delay time to produce an acceptable average voltage. That is, the delay between some change in the pulse duty cycle (percent of on time) and an acceptably stable average