I have 1kHz square wave I would like to measure the max and min voltage of. But, it is asymmetrical in both amplitude and duty cycle and it has a 1MHz 1V signal on it. The input impedance should be > 100kOhm and the output goes into an ADC without a load.

I went through some theory of opamps. Understand the half wave rectifier, the peak detector and the first order low pass filter. It all seems useful. But I was wondering what best way to do this. I know the duty cycle. Those are fixed values of either 4%, 50% and 96%. The amplitude is either around -5 or -10 at the negative side and around 5 or 10V on the positive side. Any change in voltage I would like to detect within 10 periods (10ms). I would like to measure at better than 100mV accurately.

The only thing I know that works is making a buffer with gain 1, a diode, and R and C that settle at the average of the positive duty. And then divide that voltage by the (known) duty cycle. But the voltage drop of the diode was less constant than expected. For the negative value I could do something similar.

But I am quite sure there is a more elegant way. Before you know it, getting rid of the 1MHz in negative feedback RC combined with the diode of the peak detector works. Thanks!

  • \$\begingroup\$ Since you say you're going into an ADC anyway, why don't you just rig the op-amp (or even passives preceding it) to soundly reject the 1 MHz and provide buffering to drive the input impedance of the ADC, then sort out the actual measurement of the desired signal aspects in software? \$\endgroup\$ Commented May 18, 2020 at 15:52
  • \$\begingroup\$ I try to get the burden off the MCU actually. In such a way that at any time, I can collect a correct measurement \$\endgroup\$ Commented May 18, 2020 at 21:12

1 Answer 1


You could rig up a low pass filter with a corner of, say, 30KHz, and take over 24dB off of the 1MHz signal. Add another pole if that's not good enough. The 1KHz waveform should be relatively unaffected and can be measured directly.

  • \$\begingroup\$ I was wondering what that would do with the square wave. That has quite some harmonics, right? Also: what mechanism to use? Peak detector or try to integrate and divide by duty cycle. \$\endgroup\$ Commented May 18, 2020 at 21:14
  • \$\begingroup\$ 30 KHz bandwidth lets you keep about the first 14 odd harmonics, which should replicate your square wave fairly closely. You can move it up if you want more. \$\endgroup\$ Commented May 19, 2020 at 16:37
  • \$\begingroup\$ Great! And then the million dollar question I have: can I combine the peak detector and low pass filter in one? \$\endgroup\$ Commented May 19, 2020 at 19:56
  • \$\begingroup\$ This seems to do both low pass and peak detection: electronics.stackexchange.com/questions/452622/… , Could the diode at the output be IN the feedback loop, doing away with two diodes at the input? \$\endgroup\$ Commented May 19, 2020 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.