Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
thanks
Here is the Bode plot of the EDN circuit compared to a conventional opamp Low Pass Filter. Note that it is almost a 2nd-order Butterworth response with a cutoff frequency of 2388Hz.
View attachment 96838
In order to properly filter PWM, the frequency of the PWM would have to be at least 10X the filter cutoff freq. Here is the time-domain response of the two filters to 20Khz PWM that suddenly switches from 10% duty-cycle to 90% duty-cycle at 1ms. Note the settling time, the residual 20KHz ripple, and the -2.5V DC offset intrinsic in the EDN circuit.
View attachment 96839
If you make a circuit like this, it should do what you want
Assuming you have a signal that ranges from 0V (0% duty-cycle of a 1.4V PWM) to 1.4V (100% duty-cycle of a 1.4V PWM), here is a circuit that offsets a 1Vpp Sine wave +- 500mV.
V(offset) lite blue trace represents the smoothed PWM I showed in post #25; ranges from 0V to 1.4V.
V(sine) green trace represents the reference Sine wave, in this example, 10Hz.
V(out) red trace is the Sine Wave offset by +-500mV, as a function of the smoothed PWM.
View attachment 96871
To make the effect of the offset variable, replace R4 with a 20K pot wired as a rehostat. This will make V(offset) produce shifts of the Sine wave that are bigger than +-500mV or smaller than +- 500mV, but still centered such that no shift occurs when the PWM is 50%, i.e. V(offset) = 0.7V.
If the amplitude of V3 is externally variable, you can eliminate the voltage divider R6/R7. If V3 is fixed amplitude, you can vary just the Sine amplitude at V(out) without affecting the shift by replacing R6/R7 with a 20K pot.
Assuming you have a signal that ranges from 0V (0% duty-cycle of a 1.4V PWM) to 1.4V (100% duty-cycle of a 1.4V PWM), here is a circuit that offsets a 1Vpp Sine wave +- 500mV.
V(offset) lite blue trace represents the smoothed PWM I showed in post #25; ranges from 0V to 1.4V.
V(sine) green trace represents the reference Sine wave, in this example, 10Hz.
V(out) red trace is the Sine Wave offset by +-500mV, as a function of the smoothed PWM.
View attachment 96871
To make the effect of the offset variable, replace R4 with a 20K pot wired as a rehostat. This will make V(offset) produce shifts of the Sine wave that are bigger than +-500mV or smaller than +- 500mV, but still centered such that no shift occurs when the PWM is 50%, i.e. V(offset) = 0.7V.
If the amplitude of V3 is externally variable, you can eliminate the voltage divider R6/R7. If V3 is fixed amplitude, you can vary just the Sine amplitude at V(out) without affecting the shift by replacing R6/R7 with a 20K pot.
...
im not understanding the first point too well. Is the 0% and 100% offset adjustable by 2 different pots?...
No. The shifting of the Sine wave by +- 500mV is directly controlled by changing the PWM duty cycle from 0% to 100%. Hence you need the low pass filter of post #25 to convert the PWM signal to V(offset), which is shown in the simulation of post #29 as V4.
so how to adjust 0% offset and 100% offset at the circuit in post #25?
example: if I want to adjust the 0% to +10mv and 100% to 200mv
(millivolts added to the sinevawe out)