# Measuring the amplitude difference between two sine waves - to 20 bit accuracy

Two sine waves, same phase but different amplitudes. I need to measure the difference between the two amplitudes to one part in a million over about a one second interval. The most obvious solution would be to rectify and smooth followed by an ADC, but there will always be very significant ripple. Is there any clever way of doing this by somehow "cancelling" the frequency to leave a pure smooth level output? Frequency is 1MHz

• How many cycles are there in one second? When you say "same phase" how close to same? And how big is the difference? And you actually want difference, not ratio, right? Commented Feb 14, 2021 at 16:52
• Lock-in amplifier? Commented Feb 14, 2021 at 16:55
• why do you think you'd need to rectify? Commented Feb 14, 2021 at 17:01
• Consider a transformer primary connected to both "hot" legs (assuming both inputs share a GND) : the primary voltage is the difference.
– user16324
Commented Feb 14, 2021 at 17:01
• @SpehroPefhany Sorry - missed a crucial bit of info - 1MHz. Now editted into question Commented Feb 14, 2021 at 18:20

The good news is that you really don't need a great ADC resolution for this. A handful of bits might totally suffice to make out a 20 bit difference resolution given enough oversampling!

No matter whether you take the approach of digitizing both sines separately or an analog-implemented difference, you'll be trying to detect the amplitude of a sine wave. And nothing else.

If you chose your sampling rate sufficiently high, you can correlate / band-pass filter for your tone of interest with such a high filter / window length that noise power gets strongly suppressed. In fact, non-sinusoidal noise in your input might be a friend here: it would allow to improve your SQNR after correlation due to dithering on the ADC.

Doing a digital filter or digital correlation (Basically, the same operation. Goertzel is just a specific way to implement correlation with a sinusoid.) on a computer has the distinct advantage of allowing you to design your process so that the ripples you mention (wherever they come from – harmonics, maybe?) get suppressed.

• Well he said that the signal is short, so not necessarily there is much time to oversample. Anyway he didn't say the range of frequency of the signal so we don't even know if it's feasible to sample Commented Feb 14, 2021 at 17:22
• didn't catch where he said that? What I gathered was 1 second, which, considering megasample ADCs come with every microcontroller, is very long. Commented Feb 14, 2021 at 17:31
• Not if you have ~10Hz signals like in vibration monitoring, for example. Need more info Commented Feb 14, 2021 at 19:48
• the frequency of the signal doesn't matter for oversampling, it's its bandwidth. and that has to be small, according to the question. Commented Feb 14, 2021 at 19:52
• Yes, in steady state. But if you only have 10 cycles of the signal you can't oversample the amplitude more than 10 times Commented Feb 14, 2021 at 19:56

20 bit accuracy is really a lot and need good layout and probably some calibration/compensation.

If you have two sines same frequency and in phase, I think the best course of action would be to simple subtract them, and, by definition you have a sine wave with the differential amplitude.

How to implement that really depends on the frequency: in low frequency you could use an opamp, in RF there is probably some trickery to do it (maybe just a transformer with the right windings).

Measuring a sine amplitude with precision after that will be quite easy, either as peak or as RMS (since it's sine it doesn't really matter). For example you could sample it or feed it to an RMS converter or to some kind of envelope detector/power meter.

The second idea that popped into mind is the Goertzel algorithm.

It is somewhat like the discrete Fourier transformation, but you can run the Goertzel algorithm for a single frequency. The output is a power signal proportional to the amplitude of the signal.

Analyse both signals with the Goertzel algorithm using the same coefficients and calculate the difference.

You can set the frequency to be detected, and you can "tune" the coefficients of the algorithm to meet your time period requirements.

My first idea was to suggest the use of two lock-in amplifiers - then it dawned on me that it is equivalent to a single bin FFT, which is the Goertzel algorithm.

Maybe a peak detector circuit for each sine wave followed by a slow but high resolution ADC.

An I/Q demodulator might work as well. Where one sine is used as signal input and the other is used as local oscillator input. With this you could also get the phase information, even though it isn't needed. But I am not quite sure, if this would work for |Sine 1| > |Sine 2| and |Sine 1| < |Sine 2| as well.

Without any doubt to me you should subtract the two 1 MHz signals right up front before doing anything else and, as per Brian Drummond's comment, you should use a transformer. The secondary voltage will be the difference signal and, this can be linearly amplified and measured using plenty of techniques. Put all your effort into the transformer design and shield it. This is pretty much how an induction balance metal detector works. It's also pretty much how you would process the output of a linear variable differential transducer (LVDT) if looking for really high resolution.