# pwm audio signal with low pass filter

I am trying to demodulate my PWM by using a low pass filter shown(the inductor of 6uH and capacitor of 10uF forms my low pass filter). The PWM was created using a triangular waveform produced by XFG1 function generator and a sine wave(which represents my audio signal) produced by XFG2 function generator. The sine wave is at 3kHz and the triangular wave is at 300kHz. I choose a cut-off frequency for my LPF to be at 20kHz. The problem I have is that the output frequency should be 3kHz,since am demodulating the PWM I should get my sine wave frequency(3kHz), but the probe(PR1) is showing 20.5kHz. Can anyone explain why this is happening?

The oscilloscope shows the output of the LPF filter(blue), and the output of the comparator(red).

Inaccuracy of your probe! Two reasons come to mind

1. We don't know what that probe does, mathematically (and, by the way, that's always a bad situation in a measurement environment). Possibly it's just getting some $N$ samples, and doing an $N$-point FFT on that, and looks for a maximum absolute value. Now, with $N$ being necessarily finite, the frequency resolution is finite, and maybe 20 kHz is just impossible to represent with that resolution, but 20.5 kHz is the closest possible point.
2. Your filtered signal does indeed contain your original sine, but it inevitably also contains some amount of the triangular wave's spectral components, which happen at 300 kHz and multiples of that. The job of your filter was to get rid of these, but any real filter only has finite attenuation, so it can't suppress strictly everything that comes through at higher frequencies. Now, these higher frequencies confuse the (mysterious) frequency estimator and slightly "pull" the displayed frequency higher.
• From experience, did building the actual circuit(shown above) alleviate the problems that the simulation had. Aug 13, 2017 at 10:48

Not sure of your simulation logic output impedance, but if Zout =0 then you have an infinite Series Q oscillator but with Zout> 2 Ohm it is underdamped.

So with no sine input your false simulation may oscillate. So add a series R of 50 Ohms to represent 74HC logic RdsOn

Looking deeper into your design , it appears you are spreading the 300kHz modulated square wave carrier using 1shot delay to create a narrower pulse and thus lower the energy at 300kHz compared to 1st comparator output . It may result in just noise unless you optimize all the RC, LC parameters. Not your typical PWM.

In short, all the logic and time delay cct may have no advantage over a better designed 3rd order (RCLC) LPF directly off the 1st comparator.

simulate this circuit – Schematic created using CircuitLab

improved design with self biased PWM with audio gain R2/R1 and analog gain with 1M feedback on logic and notch filter @300kHz demod.