Skip to content

Instantly share code, notes, and snippets.

@ericfont
Created June 29, 2025 07:11
Show Gist options
  • Save ericfont/01c7405d10e87ee8f47cb265a7fbf40a to your computer and use it in GitHub Desktop.
Save ericfont/01c7405d10e87ee8f47cb265a7fbf40a to your computer and use it in GitHub Desktop.
opamp cancel offset and charge two capacitors to either input voltage or input voltage minus some reference if input exceeded that reference
Display the source blob
Display the rendered blob
Raw
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="787" height="357"><defs/><g><rect fill="#000000" stroke="none" x="0" y="0" width="787" height="357"/><g transform="scale(1,1) translate(-362,-446)"><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 624 560 L 646 560" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 624 592 L 646 592" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 698 576 L 720 576" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#c0c0c0" paint-order="fill stroke markers" d=" M 646 544 L 646 608 L 698 576 Z" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#c0c0c0" stroke="none" font-family="sans-serif" font-size="14px" font-style="normal" font-weight="normal" text-decoration="normal" x="656" y="558" text-anchor="middle" dominant-baseline="central">-</text></g><g><text fill="#c0c0c0" stroke="none" font-family="sans-serif" font-size="14px" font-style="normal" font-weight="normal" text-decoration="normal" x="656" y="592" text-anchor="middle" dominant-baseline="central">+</text></g><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 608 640 L 608 620" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 608 612 L 608 592" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 598 620 L 618 620" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 592 612 L 624 612" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 608 592 L 624 592" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="604" y="586" text-anchor="start" dominant-baseline="alphabetic">1.9V</text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 624 496 L 624 544" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="630" y="526" text-anchor="start" dominant-baseline="alphabetic">1.9V</text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 624 544 L 624 560" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="630" y="558" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 560 640 L 560 656" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 570 656 L 550 656" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 566 661 L 554 661" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 562 666 L 558 666" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 720 496 L 720 576" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="726" y="542" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 560 560 L 588 560" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 588 548 L 588 572" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 624 560 L 596 560" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 596 548 L 596 572" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="579" y="546" text-anchor="start" dominant-baseline="alphabetic">10μF</text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 608 640 L 624 640" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="616" y="634" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 720 640 L 720 576" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="726" y="614" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 624 496 L 656 496" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 688 496 L 720 496" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#ffffff" paint-order="fill stroke markers" d=" M 656 496 L 688 480" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="672" y="511" text-anchor="middle" dominant-baseline="alphabetic">sw1</text></g><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 608 720 L 608 752" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 618 752 L 598 752" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 614 757 L 602 757" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 610 762 L 606 762" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 768 576 L 808 576" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 840 576 L 880 576" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#ffffff" paint-order="fill stroke markers" d=" M 808 574 L 840 574" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="824" y="591" text-anchor="middle" dominant-baseline="alphabetic">sw1</text></g><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 880 640 L 880 612" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 868 612 L 892 612" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 880 576 L 880 604" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 868 604 L 892 604" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="894" y="614" text-anchor="start" dominant-baseline="alphabetic">1nF</text><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 896 704 L 896 720" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 906 720 L 886 720" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 902 725 L 890 725" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 898 730 L 894 730" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 944 640 L 944 612" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 932 612 L 956 612" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 944 576 L 944 604" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 932 604 L 956 604" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="958" y="614" text-anchor="start" dominant-baseline="alphabetic">1nF</text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 880 576 L 944 576" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="900" y="570" text-anchor="start" dominant-baseline="alphabetic">1.9V</text><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 928 704 L 928 719" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="912" y="731" text-anchor="start" dominant-baseline="central">+1.6V</text></g><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 560 640 L 560 624" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 560 592 L 560 576" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#ffffff" paint-order="fill stroke markers" d=" M 560 624 L 544 592" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="570" y="587" text-anchor="start" dominant-baseline="alphabetic">sw1</text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 608 640 L 608 664" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 608 696 L 608 720" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#ffffff" paint-order="fill stroke markers" d=" M 608 664 L 624 696" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="618" y="659" text-anchor="start" dominant-baseline="alphabetic">sw1</text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 624 640 L 656 640" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 688 640 L 720 640" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#ffffff" paint-order="fill stroke markers" d=" M 656 638 L 688 638" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="672" y="655" text-anchor="middle" dominant-baseline="alphabetic">sw1</text></g><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 720 576 L 768 576" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="732" y="570" text-anchor="start" dominant-baseline="alphabetic">1.9V</text><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 944 640 L 912 640" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="928" y="634" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 880 640 L 912 640" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="896" y="634" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 560 576 L 560 560" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="566" y="574" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 464 560 L 449 560" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="413" y="560" text-anchor="start" dominant-baseline="central">+1.9V</text></g><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 464 560 L 496 560" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 528 560 L 560 560" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#ffffff" paint-order="fill stroke markers" d=" M 496 558 L 528 558" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="512" y="575" text-anchor="middle" dominant-baseline="alphabetic">sw1</text></g><g><text fill="#c0c0c0" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="679" y="750" text-anchor="start" dominant-baseline="alphabetic">charge bottom of cap at +1.6V if the opamp output exceeded +3.2V limit</text></g><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 768 688 L 790 688" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 768 656 L 790 656" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#01fd01" paint-order="fill stroke markers" d=" M 842 672 L 864 672" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#c0c0c0" paint-order="fill stroke markers" d=" M 790 704 L 790 640 L 842 672 Z" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#c0c0c0" stroke="none" font-family="sans-serif" font-size="14px" font-style="normal" font-weight="normal" text-decoration="normal" x="800" y="686" text-anchor="middle" dominant-baseline="central">-</text></g><g><text fill="#c0c0c0" stroke="none" font-family="sans-serif" font-size="14px" font-style="normal" font-weight="normal" text-decoration="normal" x="800" y="656" text-anchor="middle" dominant-baseline="central">+</text></g><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 912 640 L 912 656" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#807f7f" paint-order="fill stroke markers" d=" M 896 688 L 896 704" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 928 688 L 928 704" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#c0c0c0" paint-order="fill stroke markers" d=" M 912 656 L 928 688" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><path fill="none" stroke="#01fd01" paint-order="fill stroke markers" d=" M 896 672 L 864 672" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="880" y="666" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#50af50" paint-order="fill stroke markers" d=" M 768 576 L 768 656" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="774" y="622" text-anchor="start" dominant-baseline="alphabetic"></text><path fill="none" stroke="#57a757" paint-order="fill stroke markers" d=" M 768 688 L 753 688" stroke-linecap="round" stroke-miterlimit="10" stroke-width="3" stroke-dasharray=""/><g><text fill="#ffffff" stroke="none" font-family="sans-serif" font-size="12px" font-style="normal" font-weight="normal" text-decoration="normal" x="717" y="688" text-anchor="start" dominant-baseline="central">+1.6V</text></g><path fill="#ffffff" stroke="none" paint-order="stroke fill markers" d=" M 627 560 A 3 3 0 1 1 626.9999999999577 559.9999840784612 Z"/><path fill="#ffffff" stroke="none" paint-order="stroke fill markers" d=" M 723 576 A 3 3 0 1 1 722.9999999999577 575.9999840784612 Z"/><path fill="#ffffff" stroke="none" paint-order="stroke fill markers" d=" M 611 640 A 3 3 0 1 1 610.9999999999577 639.9999840784612 Z"/><path fill="#ffffff" stroke="none" paint-order="stroke fill markers" d=" M 563 560 A 3 3 0 1 1 562.9999999999577 559.9999840784612 Z"/><path fill="#ffffff" stroke="none" paint-order="stroke fill markers" d=" M 771 576 A 3 3 0 1 1 770.9999999999577 575.9999840784612 Z"/><path fill="#ffffff" stroke="none" paint-order="stroke fill markers" d=" M 883 576 A 3 3 0 1 1 882.9999999999577 575.9999840784612 Z"/><path fill="#ffffff" stroke="none" paint-order="stroke fill markers" d=" M 915 640 A 3 3 0 1 1 914.9999999999577 639.9999840784612 Z"/></g></g></svg>
@ericfont
Copy link
Author

sim

Can have a double-buffer set of capacitors...in phase one, set one of caps are used for reading and set two is written to, while in phase two, set two of caps are used for reading and set one is written to. Thus can do ADC conversion for any even number of bits.

@ericfont
Copy link
Author

for the very first bit, can simply read from the audio input. Subsequent bits will alternate between reading and writing with the two alternating sets of capacitors.

@ericfont
Copy link
Author

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