Created
December 1, 2025 01:19
-
-
Save ericfont/c686fa2d656d9e07ecf60975c7c734ba to your computer and use it in GitHub Desktop.
something working, with hystersis for comparator and summing input with feedback
Author
Author
Note, a simple IIR digital filter can act as a capacitive RC block to remove DC: https://en.wikipedia.org/wiki/High-pass_filter#Discrete-time_realization
Author
so to decimate the delta PWM signal, apply that formula y[n]=x[n]-x[n-1]+a*y[n-1] and continuously accumulate that, and dump every nysquist sampling rate sum as the delta for that nyquist sample. If can get the oscillation to be around 96kHz, then a simple boxcar averager will null that oscillation when downsampling to 48kHz.
Also note during analog reconstruction, a simple notch filter will null around that oscillation.
Author
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


lowering RC to just 1kohm + 1nF results in the RC charging going all the way to either rail, which is good because that means that every PWM pulse has an identical symmetric charge and discharge profile, thus the total integration of that signal would equal the total integration of a PWM. That is good for consistency, so not sensitive to RC values and so can digitally reconstruct exactly.