Square wave peak voltage value

Discussion in 'The Projects Forum' started by Dollarday, Aug 1, 2012.

  1. Dollarday

    Thread Starter Active Member

    Jan 25, 2012
    Hi people! :D

    Can you please help me with the following problem:

    I have an aperiodic square wave communication signal of 3.3V.

    The signal has variable (and unknown) DC offset.

    I would like to make a circuit that outputs the peak voltage of the signal at ANY given moment.
    (For example, if the DC offset voltage is 2,2V, the peak of the square wave is 3,3 + 2,2 = 5,5V and the circuit should output 5,5V)
    If the DC offset voltage changes to 1,1 the peak voltage of the square wave is 3,3 + 1,0 = 4,3V and the circuit should output 4,3V)

    Any ideas how I might achieve this?

    Preferably an analogue solution, the only thing I can come up with is:
    a) Use an ADC to sample the voltage over a small timeframe
    b) Use a microcontroller and code to find the highest voltage in that timeframe
    c) Use a DAC to display the peak voltage

    I'm sure someone out there has a more elegant solution :cool:

  2. wayneh


    Sep 9, 2010
    So, you want your offset to be determined by ONLY the most recent "low", as opposed to, say, an average of the last 3 lows?

    I think your approach is about right. Just keep sampling and accumulate an average (for better precision, to minimize noise) into avgLO unless/until you see a new sample with a value more than, say, 20% higher. Resample into a new container avgHI to accumulate the new average. At any time, you could grab avgHI-avgLO as your best estimate of the ∆.
  3. crutschow


    Mar 14, 2008
    You could use an analog sample-and-hold or a peak-hold circuit.
  4. ramancini8

    Active Member

    Jul 18, 2012
    Put your signal into an ac amplifier to strip out the dc content, then differentiate the signal (can be one circuit) to obtain a leading edge pulse, Use this pulse to trigger a peak sample hold, use the trailing edge pulse to reset the PSH. All of these circuits can be found in the National Semiconductor Linear Applications book.
    Dollarday likes this.