Skip to content

Instantly share code, notes, and snippets.

@ericfont
Created December 1, 2025 01:19
Show Gist options
  • Select an option

  • Save ericfont/c686fa2d656d9e07ecf60975c7c734ba to your computer and use it in GitHub Desktop.

Select an option

Save ericfont/c686fa2d656d9e07ecf60975c7c734ba to your computer and use it in GitHub Desktop.
something working, with hystersis for comparator and summing input with feedback
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ericfont
Copy link
Author

ericfont commented Dec 1, 2025

@ericfont
Copy link
Author

ericfont commented Dec 1, 2025

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.

@ericfont
Copy link
Author

ericfont commented Dec 1, 2025

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

@ericfont
Copy link
Author

ericfont commented Dec 1, 2025

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.

@ericfont
Copy link
Author

ericfont commented Dec 1, 2025

hypothetical notch filter:

image

Might want to combine notch with general lowpass and maybe notch higher overtones too.

@ericfont
Copy link
Author

ericfont commented Dec 1, 2025

image

nice no jaggedy integration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment