Skip to content

Instantly share code, notes, and snippets.

@ericfont
Created December 2, 2025 20:41
Show Gist options
  • Select an option

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

Select an option

Save ericfont/0070bcbd08789e07bea6ff62c07f7fb0 to your computer and use it in GitHub Desktop.
try delta double integration again
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 2, 2025

sim

image

@ericfont
Copy link
Author

ericfont commented Dec 2, 2025

This time using Schmitt-input flip flop with comparator (output blue), which seems to produce a very reliable transition (yellow) right when clock (green) goes up.
Screencast_20251202_154421.webm

The hysteresis is good cause sometimes the transition injects glitches into the analog input signal (red)

@ericfont
Copy link
Author

ericfont commented Dec 2, 2025

Add 10mohm feedback for output and apply a notch filter, so green final output has much less of the oscillation frequency:

Screencast_20251202_163950.webm

@ericfont
Copy link
Author

ericfont commented Dec 2, 2025

almost imperceptible latency:

image

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

adding a notch-filter for the oscillation combined with a lowpass:

image

This gives a pretty good reconstruction:

Screencast_20251203_022413.webm

The filters add just a tad of delay.

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

Here is 0.1V(peak) 20khz sine (yellow) being reconstructed w/ notch (green):

Screencast_20251203_023127.webm

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

my notch filter may be suffering from breadboard parasitics.

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

There is some glitch that happens when use input that is just DC with some offset away from the midpoint, which causes the output reconstruction to alternate between hitting each rail every second or so. By moving offset back to midpoint and adding an actual sine input, that glitch goes away:

image

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

For instance, here the input (yellow) is just a DC value that I'm changing every few seconds:

image

But if I get too close to the negative rail, then that triggers the output to enter an oscillatory state of decaying closer to the midpoint and then jumping to the opposite rail, which keeps repeating.

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

at it seems to be the 2nd integral signal that does this oscillation...the first integration signal stays around mid voltage:

image

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

It seems the second integral signal isn't properly integrating cause its top or bottom gets clipped:

Screencast_20251203_025522.webm

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

the signals when changing from one rail to the other:

image

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

So it seems once its has decayed enough so that the top of the 2nd-integral signal no longer clips, then that triggers the resumption of proper integration...but what happens is the decay keeps on happening and actually over shoots and hits the other rail.

To lessen likelihood of entering this situation, should always DC block the input signal.

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

zoomed out a bit:

image

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

If instead did two RC low pass filters in series, then I'd think at least the "integration" would always remain around the middle voltage, so wouldn't have this rail hitting issue. The capacitors would always be keeping the proper voltage. Would still need an opamp afterwards to amplify the signal so it is the same amplitude range as the input signal.

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

but if try two RC integrations, then get not so great frequency spectrum:

image

There is a 3rd harmonic. So the question I need to investigate is can I get rid of that harmonic with RC and just deal with RC-only, without having to even involve opamp? Or is the issue something else that can be avoided in some other manner?

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

the pwm seems to be close to 50% during rail transitions:

image

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

ADC 2nd integration (yellow) also hits the rails

image

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

image

@ericfont
Copy link
Author

ericfont commented Dec 3, 2025

image

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