Low Distortion Audio Oscillator Stabilized Via Trigonometric Identity - Page 1
Forum section: electronics / projects

author: ccktek
author_rank: Regular Contributor
timestamp: October 08, 2019, 04:14:55 pm
content: If the sine and cosine outputs of a quadrature sinusoidal oscillator are squared and summed, the result is a D.C. voltage whose amplitude is proportional to the amplitude of the outputs and independent of frequency:V = Asin2(ωt) + Acos2(ωt) where A is the amplitude of the two outputs;V = A(sin2(ωt) + cos2(ωt))V = A due to the trig identity sin2(θ) + cos2(θ) = 1.This voltage in conjunction with a voltage controlled amplifier, FET, or CdS opto-isolator in a servo-system feedback loop can be used to control and stabilize the oscillator’s output amplitude. In contrast with the control voltage from the more usual rectifier/filter, this voltage is free of ripple and responds nearly instantly to changes in oscillator output level.The approach is certainly not new, but it does not appear often in the usual sources of technical information. I wanted to test the concept in the design of a variable frequency audio generator having low distortion, constant amplitude with tuning, and negligible amplitude bounce and settling time with perturbations such as changes in frequency. The result is total harmonic distortion at or below .00035% at all frequencies (more on this later), amplitude constant within a db or so, and amplitude settling time with range switching less than 2 seconds in the 20-200Hz range and negligible in the 200-2KHz and 2K-20KHz ranges.For the quadrature oscillator I chose a two-integrator “cookbook” circuit. The squaring is done by AD534 precision multipliers. Squaring accuracy is good but not perfect, so the output of the summed squares is filtered with a 47K resistor and 4.7uf capacitor with minimal effect on settling time. For the control device I chose the SSM2018 voltage controlled amplifier. FETs and CdS opto-isolators have nonlinear resistance; from empirical experience I was concerned that they might be tricky to get working reliably in a variable frequency setting in which their operating levels might vary considerably.In operation the gain of the oscillator’s main feedback loop is set slightly below the point of oscillation. The SSM2018 is not part of this loop but rather is in a separate loop outside the main one. This second loop adds a small amount of positive feedback to sustain oscillation. The gain of the second loop is controlled by the SSM2018 and the summed outputs of the AD534s to maintain constant amplitude of oscillation.The SSM2018 is not free of distortion, but at least its distortion is reasonably low (about .01%), predictable, and does not vary drastically with expected changes in level. Only a small fraction of the 2018’s output is injected into the oscillator, so its effect on oscillator distortion is limited. This component is obsolete but still available; I happened to have several on hand.I obtained lowest distortion with OPA1642A op amps for the oscillator, although others featuring very low distortion specifications were nearly as good. Resistors are all metal film. Capacitors are polystyrene foil or equivalent in quality. R1 and R2 are conductive plastic types. The two 910-ohm resistors and the frequency-determining capacitors are matched between the two integrators to within 0.1%, possibly an overkill but not too difficult to accomplish; I wanted precise amplitude equivalence and quadrature between the two outputs.The most expensive component is the dual gang tuning potentiometer. I used a Bourns precision 10-turn wire-wound pot and expected some detrimental effect on distortion compared with single-frequency fixed resistance designs.The I.C.s are mounted in sockets, apparently with no adverse effects, but contacts may deteriorate with time, so soldering would be preferred. The range switch has silver plated contacts and a steatite wafer, good but not ideal; alternatives are limited.C1 is chosen empirically for flattest amplitude with changing frequency in the high end of the 2KHz-20KHz range. Its value depends on circuit layout and individual op amps; for some combinations it may not be necessary.To set up the oscillator I adjust R1 and R3 for about 1.4V RMS output and about 100mv control voltage at pin 11 of the 2018 with a goal of lowest possible distortion along with constant amplitude with frequency. These adjustments interact, and the control voltage varies with frequency. R4 is adjusted for minimum ripple at its wiper. R5 is adjusted for minimum 2nd harmonic in the output. Settings are most critical in the highest frequency range, so I do them at 10KHz and let the other ranges go along for the ride without further attention.I measured distortion at fixed frequencies: 100Hz, 230Hz, 1KHz, and 10KHz. In the 20-200Hz and 200-2KHz ranges THD is 1ppm to 2.5ppm, i.e. .0001% to .00025%. The adjustable gain output amplifier adds some distortion at the highest frequencies. For this reason there are two outputs, one adjustable, the other direct. Distortion at 10KHz is 3ppm into a 600-ohm load and 1.5ppm into a 3K load from the direct output; 10KHz distortion from the adjustable output amplifier is about 3.5ppm with either load and is essentially independent of output level setting. These distortion figures reflect only total harmonic distortion, not THD+noise.The digital frequency display is a kit originally designed by DL4YHF and widely available (search DIY Frequency Tester 1Hz-50MHz Crystal Counter Meter). The kit has an added one-transistor oscillator for testing crystals, useless in the current application. EI9GQ describes removing the oscillator and using the transistor and freed-up board space for a pre-amp suitable for HF ham radio use. TheHWcave modifies this modification (), and I modify that modification for appropriate input impedance and gain at audio frequencies for use in my generator.

author: ejeffrey
author_rank: Super Contributor
timestamp: October 08, 2019, 04:55:34 pm
content: Quote from: ccktek on October 08, 2019, 04:14:55 pmThis is only true if the amplitude of the quadrature signals is accurately identical or at least tracking much better than the overall amplitude. You are basically relying on the amplitude of the cos() term while the sin() is zero crossing and vice versa but if those components are poorly correlated that information will be wrong. If this turns out to be a problem one trick would be to buffer and filter the squared quadrature signals separately and compare them to slowly servo the relative gain of the two quadratures.

author: TimFox
author_rank: Super Contributor
timestamp: October 08, 2019, 09:03:45 pm
content: The trig identity should work to stabilize a quadrature oscillator, but I am not aware of any commercial application. The quadrature generators that I own use the zero crossing of one channel to operate a sample-hold to sample the peak voltage of the other channel to derive a gain-control signal.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 08, 2019, 10:14:49 pm
content: Quote from: ejeffrey on October 08, 2019, 04:55:34 pmMore specifically, for an integrator,Vin = A cos(ωt)Vo = A/ω sin(ωt) + CSo you need to divide by frequency, if you wish to use the same mechanism in a VFO. (In a double integrator VFO, you vary both integrator gains proportionally.)A real circuit also has nonzero input offset, and I suppose we can throw finite gain into the mix as well (though that doesn't have much impact here).Another (better?) way to look at it, is what it is: a differential equation. In that case we havex'' + A x' + B x = 0or equals nonzero if it's a driven or injection-locked* oscillator, as the case may be.The solution of this equation gives B as the frequency-determining term, and A as the loss or gain, as the case may be. We might implement this as two integrators cascaded, with the second output fed back to the first (inverted as needed), and with a variable (+/-) feedback from the first (i.e., local negative/positive feedback) to control amplitude.*The homogeneous solutions of a linear ODE are linearly independent of the driving term in an inhomogeneous equation; this shows that injection only causes locking in a nonlinear system. Which is what all real stable oscillators are; it's more a matter of whether we realize it, or choose to model it that way, or not.Quote from: TimFox on October 08, 2019, 09:03:45 pmI think some DDS or trig algorithms do this -- namely, a CORDIC where complex multiplication is used to represent angles. In short, the a + bi registers numerically represent the integrator outputs.Rounding errors will cause the magnitude to diverge over time. A normalization step fixes this. The normalization doesn't need to be perfect; if a lesser amount is used (a ratio closer to 1 than 1/|z| is), the error can be kept low. This allows manyoptimizations to be made, as calculating 1/|z| exactly is relatively difficult.Tim

author: ccktek
author_rank: Regular Contributor
timestamp: October 08, 2019, 10:26:28 pm
content: This is only true if the amplitude of the quadrature signals is accurately identical or at least tracking much better than the overall amplitude.Indeed. That's why "I wanted precise amplitude equivalence and quadrature between the two outputs" as stated about half way down the text.You are basically relying on the amplitude of the cos() term while the sin() is zero crossing and vice versa but if those components are poorly correlated that information will be wrong.The identity says that the summed squares voltage is constant regardless of the arguments of the sin and cos functions as long as these arguments are the same and the amplitudes are equal. This is true even if the frequency is arbitrarily low, right down to DC, at any point in the waveforms, not just at zero crossings.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: October 09, 2019, 12:16:20 am
content: Oh, related topic, the Hilbert transform is sometimes used to process radio signals for example. This gives the 90° phase shift of an arbitrary, band-limited signal, which can be used in sideband-selective modulations (SSB, PAM), or transformed by the above identity (or rather its analytical version, A(t) e^(2 pi j phi(t)) ) into an amplitude-and-phase form used for synthesis and analysis.Tim

author: moffy
author_rank: Super Contributor
timestamp: October 09, 2019, 02:48:06 am
content: Very impressive! Especially the low distortion over the frequency range. How did you measure it? It's not easy without specialised equipment. I couldn't find any data on a AD1642 opamp but did find info on the AD642, which is what I assume is meant. Again, congrats.

author: ccktek
author_rank: Regular Contributor
timestamp: October 09, 2019, 03:35:36 pm
content: Many thanks to all for your interest and comments.moffy, you’re right, there is no such i.c. as AD1642. The correct model number is OPA1642:http://www.ti.com/lit/ds/symlink/opa1642.pdfRegarding moffy’s question about measurements: The measurement part of the project required more time and patience than the generation part. Early on I used a Keithley 2015 THD multimeter, good down to around .005% THD. Below that level I used a passive notch filter in conjunction with a 2nd harmonic compensation filter and amplifier of my own design, this in conjunction with either the 2015, an HP 334a distortion analyzer, or HP 3580a spectrum analyzer (the later version with frequency readout). This last combination was necessary for the lowest distortion levels. Along the way I repeatedly checked for consistency among the methods including with and without the filter/amplifier at distortion levels high enough for this to be possible. Adequately low noise floor required 10-, 3-, and frequently 1Hz bandwidths on the 3580a. Scan times at these bandwidths were long – there’s a reason that the 3580a scans at up to 200 seconds per division. I narrowed the trace to one harmonic at a time and used either very slow manual scanning or one of the lengthy automatic scans. For the distortions quoted in my descriptions I did measurements, often repeated, at 15 combinations of frequency, output source, load, and output level requiring 30 harmonic measurements (harmonics above the 3rd were never detectable in the final design). In retrospect I wish I’d invested in a high quality sound card and FFT software. Oh, well, working with old technology is still fun, and the equipment was on hand.

author: Kleinstein
author_rank: Super Contributor
timestamp: October 09, 2019, 03:55:18 pm
content: The amplitude stabilization could profit from good matching of the capacitors. This could help to have the same amplitude for the 2 square parts and also reduce the swing for the analog control signal.Even if the 2 square paths are not well matched the 2 phase amplitude circuit still reduces the residual ripple quite a lot. The dual AD534 is a quite expensive solution though.

author: dom0
author_rank: Super Contributor
timestamp: October 09, 2019, 04:01:05 pm
content: I wonder if it may not be simpler and cheaper overall to just use an ADC, micro and digital PGA / multiplying DAC to control the loop gain instead of all the clever analog shenanigans. After all, with precision parts, the control range can be made quite small, and any good audio ADC, which are relatively cheap, would be good enough to serve in this function.That being said, anything achieving non-linearities on the order of a few ppm is quite the achievement.

author: RoGeorge
author_rank: Super Contributor
timestamp: October 09, 2019, 07:42:38 pm
content: Quote from: ccktek on October 08, 2019, 04:14:55 pmBrilliant idea, thanks for sharing!That constant (and theoretically instant) amplitude detection is priceless, especially at very low frequencies.Later edit:Slightly changed the first 2 equations inside the quoted text, by replacing V with V2and A with A2.

author: SiliconWizard
author_rank: Super Contributor
timestamp: October 09, 2019, 08:11:49 pm
content: Have you figured how much phase shift (from the ideal pi/2) would make this approach not meet a given amplitude accuracy? (Unless your quadrature oscillator is perfect, there will always be some...)

author: ccktek
author_rank: Regular Contributor
timestamp: October 09, 2019, 09:46:53 pm
content: Quote from: dom0 on October 09, 2019, 04:01:05 pmIntriguing idea, probably worth trying. I'd be concerned about digital noise finding its way into the analog shenanigans, as the signal levels there are extremely low.

author: ccktek
author_rank: Regular Contributor
timestamp: October 09, 2019, 10:03:40 pm
content: Quote from: SiliconWizard on October 09, 2019, 08:11:49 pmNo, but this would lead to a useful design criterion, especially if necessary tolerances of the frequency-determining capacitors and potentiometer could be related to phase error.As Kleinstein points out, matching of capacitors between the integrators is important, but to what degree analytically I don't know. As mentioned in my original posting I was compulsive about this; I matched as best I could with an LCR meter.

author: moffy
author_rank: Super Contributor
timestamp: October 09, 2019, 11:19:07 pm
content: Quote from: ccktek on October 09, 2019, 03:35:36 pmEven high quality soundcards seem to be limited to about 100db for distortion measurements. You would still need your notch filter, but there is reasonable and free software available for the FFT side. One thing I found out reading some specs is that THD for audio ADC's increases with sampling frequency. 96k gives worse distortion than 48k in general.

author: dazz1
author_rank: Frequent Contributor
timestamp: September 23, 2025, 12:19:37 am
content: Quote from: ccktek on October 09, 2019, 09:46:53 pmI am really impressed by this concept. Very impressive results from a relatively simple circuit.My experience with analog multipliers is that they are not great performers. I am also wondering about using a ADC, DSP, DAC type circuit to do the maths. Modern instruments routinely mix digital and analogue so I think the problem is solvable.I won't be replicating your design because I don't have an application for such a high performance instrument. I have an old Chinese made Dick Smith Electronics Wein Bridge Oscillator, young enough to have transistors, but old enough not to have any ICs.