# Variable Frequency PWM to Analog Circuit?

I need to convert a PWM to analog signal. But the issue is, frequency of PWM may change. So, RC-filter option is not preferred. What kind of circuitry would be appropriate for this?

There exists an IC named LTC2644, which operates exactly as I want, but not meeting my frequency requirements.

• If LTC2644 doesn't meet your needs, tell us your needs. Commented Mar 21, 2017 at 13:50
• RC filter is not susceptible to PWM frequency change in a acceptable range. Well if the 30Hz to 100kHz range of LTC2644 isn't enough, I would start to think that maybe the problem is somewhere else. Commented Mar 21, 2017 at 14:23
• @glen_geek 5Hz to 500Hz PWM range. Commented Mar 22, 2017 at 10:44
• @MarkoBuršič 5 to 500Hz variable frequency range. What do you mean by 'not susceptible to PWM frequency change'? I am thinking of filter performace characteristics, especially delay time. Commented Mar 22, 2017 at 10:47
• Information about your question like that should go in the question, not be hidden in a comment that everyone except who you address it to probably won't see. Commented Mar 23, 2017 at 10:41

What you want is not possible. You now say that the PWM frequency can vary from 5 Hz to 500 Hz (200 to 2 ms), but that you want the filtered result to settle within 5% in 5 ms.

Think about it. How is the output supposed to settle to the average value within 2.5% of the pulse period? Until the pulse is over, how can you possibly tell what it's on-fraction is. Unless all your pulses are on for less than 5 ms, there is no way to extract the information from each pulse that fast.

• I thought you got the idea that, every new frequency will be valid after completion of 1 cycle - on a rising or falling edge. Ofcourse we cannot expect performance characteristics in the middle of a cycle. That's why I gave the LTC2644 example. If you check the "PWM Input to DAC Output" graph on the first page of datasheet, it will be easier to understand, visually. Commented Mar 23, 2017 at 14:16
• @Eray: Not gonna look up a datasheet, especially when no link supplied. Pertinent information to your question should be in your question. I don't really care what the LT<whatever> does. Explain what you want done. Commented Mar 23, 2017 at 15:45

For a 5 - 500 Hz PWM frequency range, with a PWM input signal having clean edge transitions, a simple microcontroller seems a reasonable solution. It should contain a timer and a digital-to-analog converter for output. Not many simple microcontrollers have built-in DAC - perhaps one of PSOC-4 types.
The timer is used as an incrementing counter, initialized to zero on one PWM edge, and incrementing until the corresponding alternate edge, whereupon count value is saved (C1), and re-zeroed. The next input edge completes one PWM cycle...the counter's value is saved once again (C2). The ratio of C1/C2 is scaled and written to the DAC.The PSOC-4 series is targeted for simple analog/digital crossover applications like this.
It is inevitable that one PWM period delay must be accepted as the minimum settling time for PWM period-chages.

simulate this circuit – Schematic created using CircuitLab

A DAC can be avoided with some extra effort. Many microcontrollers contain analog-to-digital converters. One general-purpose I/O pin can be used to charge a capacitor, whose voltage is monitored by the microcontroller's ADC. The I/O pin must be capable of normal High/Low as well as tri-state digital states. An op-amp (low bias current) buffer is required to keep the capacitor from discharging through the load.
Although a current source charging and discharging (charge pump) would be ideal, a resistor charging the capacitor is possible too with a little extra calculation of appropriate charge times.

• thanks for your solution, but I want to design a circuitry. Cannot use an MCU. Commented Mar 23, 2017 at 9:49

edit: a much better (but rather more mathematical) approach is to use a resistance and a capacitor in series. By using either the general equation for the capacitance (1/jwc) or (1/2*pifC) you can find the frequency. However it might be slightly inaccurate as its not a sinusoidal signal. If you need an accurate representation you can use signal analysis for the simple circuit (look for circuit response)

Finally you can use ways to measure or convert capacitance to resistance. You probably can find either an op amp circuit for that or some other method