Overview
Digital potentiometers (digiPOTs) are versatile and widely used, for example to filter or generate AC signals. Some applications require adjustable frequency. In such designs, a programmable solution that allows frequency adjustment through an appropriate interface is useful for development. This article describes a simple programmable oscillator design in which oscillation frequency and amplitude can be tuned independently using digiPOTs.
Circuit description
Figure 1 shows a typical diode-stabilized Wien bridge oscillator capable of producing accurate sinewave output at VOUTPUT from about 10 kHz to 200 kHz. The Wien bridge has two legs: one is a bandpass filter and the other is a voltage divider. In this example an ADA4610-1 rail-to-rail precision amplifier is used, and an AD5142 digiPOT provides two independently controllable potentiometers, each with 256-step resolution. Resistance values are set by SPI programming, as shown in Figure 2. Alternatively, the I2C-controlled AD5142A can be used. Both are available as 10 kΩ or 100 kΩ potentiometers.

Figure 1. Amplitude-stabilized programmable Wien bridge oscillator with resistances implemented by digiPOTs.

Figure 2. Functional block diagram of the AD5142.
Operation and tuning
In the classic oscillator circuit shown in Figure 1, the paths through R1A, R1B, C1 and C2 form the positive feedback, while R2A, R2B and the two parallel diodes D1 and D2 or their equivalent resistance R_DIODE form the negative feedback. In this configuration, equation 1 applies:

To sustain stable oscillation, the phase shift in the loop gain must be eliminated. Expressed as an equation, the oscillation frequency is:

Where R denotes the programmable resistance on the AD5142:

D represents the decimal equivalent of the programmable digital code in the AD5142, and RAB represents the total resistance of the potentiometer.
To maintain oscillation, the Wien bridge should be relatively balanced; that is, the positive feedback gain and negative feedback gain must be coordinated. If positive feedback (gain) is too large, the amplitude at VOUTPUT will increase until the amplifier saturates. If negative feedback dominates, the amplitude will decay.
In the circuit shown, the gain R2/R1 should be set to about 2 or slightly higher to ensure the signal starts to oscillate. The alternating conduction of the diodes in the negative feedback loop causes the gain to be temporarily less than 2, allowing the oscillation to stabilize.
Once the desired frequency is set, the oscillation amplitude can be tuned via R2 without affecting frequency. The amplitude is given by:

In this expression, ID and VD represent the diode forward current through D1 and D2 and the diode forward voltage, respectively. If R2B is shorted, the oscillation amplitude will be approximately ±0.6 V. When R2B has the correct magnitude, the loop reaches balance and VOUTPUT converges. In the Figure 1 circuit, R2B is implemented as a separate 100 kΩ digiPOT.
Conclusion
Using the described circuit and a 10 kΩ dual digiPOT, oscillation frequencies of 8.8 kHz, 17.6 kHz and 102 kHz can be tuned by setting resistances to 8 kΩ, 4 kΩ and 670 Ω, respectively, with frequency error as low as ±3%. Increasing the output frequency can increase frequency error; for example, at 200 kHz the error rises to about 6%.
When using this circuit in frequency-sensitive applications, take care not to exceed the digiPOT bandwidth limit, which depends on the programmed resistance. The frequency tuning shown in Figure 1 requires R1A and R1B to have equal resistance values. Because the two channels can only be programmed sequentially, this creates an instantaneous critical intermediate state, which may be unacceptable for some applications. In those cases, use a digiPOT that supports daisy-chain mode (for example AD5204) to allow simultaneous resistance changes.