# Measure AC Sine Wave amplitude with ADC

I have created an AC sine way using a wien-bridge network.

I would like to measure the peak to peak voltage of this wave using my microcontrollers ADC.

I cannot just use this wave as an input to my Analog Input pin, as of course the electrical specification specifies no negative voltages, and I would only get a snapshot of the wave, and would have to take many measurements and take the max one.

I am looking for some discrete components I can pass this wave through to get a simple DC voltage representing the Peak to Peak (or just the positive) voltage of this wave.

One way is to use a peak detector, but this has a diode voltage drop, which gives an error in the result.

You don't say anything about frequency, but I'll assume it is much lower than the ADC's sampling frequency.

I would use a resistive voltage adder to bring the full signal within the ADC's range. The resistive adder has the advantage over the capacitively coupled adder that you don't have to take frequency-dependent attenuation from the capacitor into account. Suppose the ADC has a 0 V to 5 V range, and your signal is maximum 10 V peak-to-peak. Then you want Vout to be 0 V for -5 V input, and as close to +5 V as possible for +5 V input. The latter means that R1||R2 should be much smaller than R3. The former means that R1 should be equal to R2: if the input is zero then there's no current through R3, and R1 and R2 form a resistor divider between -5 V and +5 V. So if we choose R1 = R2 = 1 kΩ and R3 = 47 kΩ then the output signal will swing between 0 V and 4.95 V.

Now take enough samples to find the minimum and maximum values, and multiply the difference by 10 V/ 4.95 V, that will give you the peak-to-peak value.

Something like this should do for the buffering and level shift: If your Wien bridge output signal is very high impedance you will need a buffer before the capacitor also to prevent the voltage divider loading it.
You could rectify the signal too, but I would do the filtering/peak detection in the micro, since you have more control over it (unless there's a valid reason not to)

As most people point out a simple diode peak circuit will lose a little accuracy due to the forward voltage drop of the diode. However, with the help from a little opamp, all can be set right.

Below is a circuit called a precision rectifier. It has no (or very very very little) forward voltage drop since the output/feedback point is after the diode. Here is the wikipedia article on Precision_rectifier