Circuit VR is where we talk about a circuit and examine how it works in simulation with LT Spice. This time we are looking at a common low-frequency oscillator known as the Wien bridge oscillator.
What makes an oscillator oscillate? A circuit with amplification that gets the same amount of the output signal fed back into its input, in phase, will oscillate. This is the Barkhausen criterion. Here, we’re going to look into what makes an oscillator work in simulation, and gain some insight into what happens when there’s too much feedback and too little.
In particular, we’ll look at the Wien bridge oscillator, a very simple design that originated as a way to measure impedance back in 1891. Modern versions add some additional features, but let’s start with the most simple implementation and work our way up.
If you think about the Barkhausen criteria, it is obvious we are going to have an amplifier in the middle of our oscillator. That makes sense. Without amplification, the signal would eventually die away from loss. You can think of an oscillator as an amplifier that keeps re-amplifying its output at a certain frequency — sort of an electronic perpetual motion machine. Of course, the extra energy comes from the amplifier, so no physical laws are being broken, and as long as there’s external power it will run.
Our circuit will consist of an amplifier and a filter circuit. In contrast to some other oscillators which use inverting amplifiers, the Wien bridge uses a non-inverting amplifier. Inverting a signal is equivalent to adding a 180-degree phase shift, which means that the filter network needs to come up with an additional 180 degrees to match the input and output phases. With the Wien bridge, the amplifier is non-inverting, so we need a filter circuit with zero phase shift. Let’s see how that plays out.
Consider this schematic (you can download
wien-network.asc from GitHub). With Spice, notice that
V1 is just a placeholder that tells the analysis code where to sweep the frequency.
RL, of course, is just a load resistor and doesn’t affect the operation of the circuit.
C1 form a high pass filter. At low frequencies,
C1 will tend to block signals.
C2 form a low pass filter. At high frequencies,
C2 will approach a short to ground. That means the combined network acts as a bandpass filter. The maximum signal will occur at the frequency when the reactance of
C1 is the same as the value of
R1. Since I used all the same values, that will be the same frequency where
C2‘s reactance is the same as
However, we can do it easier by building our circuit in Spice and running an AC analysis on it:
The white line corresponds to zero degrees phase and the dotted blue line crosses it in the red circle. Note that also corresponds with the maximum signal transfer. The math and the plot show the zero-phase-shift frequency is around 3.4 kHz.
But note that the gain here is about -9.6 dB — the output signal is about 1/3 of the input. We’ll need to set the amplifier gain to about three to compensate for this. (Would you like a quick refresher on decibels?) With this filter topology, it turns out that no matter what values of R and C you use, the zero-phase-shift gain is always 1/3, and the amplifier gain will always need to be greater than three.
It is all well and good to just read a number off a chart, but let’s quickly derive the filter gain. You can think of
C2 as complex impedances. At the frequency we care about, we know that the reactance of
C2) will be 4.7 kΩ. The circuit becomes a voltage divider with
C1 as the “top” element and
C2 as the bottom. Let’s call those elements Z1 and Z2.
Z1 will equal the square root of the sum of
R1 squared and
C1‘s reactance squared, which is really just two times 4700 squared (remember
C1‘s reactance is 4700 at resonance). So Z1 is about 6.6 kΩ.
Z2 is trickier because they are in parallel. There are several ways to think about it, but I like to take the reciprocal of 4700, square that, multiply by two and then take the square root. So Z2 is about 3.3 kΩ.
A voltage divider with 6.6 kΩ at the top and 3.3 kΩ at the bottom will work out to 3.3 / (6.6+3.3) = 3.3 / 9.9 = 1/3. If you are an algebra whiz, you can work this symbolically and find out that the answer is always 1/3 as long as resistance is positive.
Adding a 3X amplifier is easy. In reality, you need just a little bit more gain to overcome other losses in the circuit. (See
wien-osc.asc from GitHub.)
C2 network is the same as before, but now there is an op amp set up as a non-inverting amplifier. The gain is set by R3 and R4. R3 should be about 50K and the gain is 1 + R4/R3 which would be 3. With the 49.9K value the gain is just a bit more. In practice, keep in mind that component tolerances and temperatures will affect values, too.
There are two things you have to be careful with to make this simulate correctly. First, you need a real op amp model that has noise so the oscillation will start. There are other ways to introduce noise, but using a practical op amp model usually does the trick.
The other thing is you need the “uic” option on the .tran simulation card. Without this, the analyzer figures out a steady initial state for the capacitors, and you won’t get oscillation. These sort of things are necessary because the simulator components are too perfect.
That’s interesting to see the signal start off small and get a little bigger each time through the loop until it levels out just after 90 milliseconds. However, let’s zoom in after the oscillator has started up. Notice that the green trace (the + input of the op amp) is in phase and about 1/3 of the output signal in blue. Try it and select View | FFT on the plot pane’s menu to see the output at the desired frequency and some fairly low harmonics. Because there’s no automatic gain control (see below) there is some clipping, but it isn’t very severe, because in simulation it’s pretty easy to get the gain of the amplifier nearly exactly right.
The beauty of trying this in Spice is that it is very easy to adjust parameters and see what happens. Try changing
R5 to exactly 50 kΩ. Then bump it up higher. Then go a little lower. You’ll see that too much amplification results in distortion. Too little will cause the signal to die down eventually.
Many practical designs use a nonlinear device of some kind to adjust the gain dynamically. The brilliant idea that made Hewlett-Packard’s first product, the HP200A back in 1939, was to use a lightbulb as the gain adjusting circuit: as the voltage in the circuit gets higher, it heats up and the resistance increases, reducing the gain. The schematic appears in the original patent. Another common configuration uses diodes to allow gain to be higher on startup but then reduce as the signal level rises.
C2 independently. Obviously, if you change them together — or change
R2 together — you’ll just adjust the frequency.
If you are up for a challenge, can you replace the op amp with a FET or a bipolar transistor? Just remember the amplifier has to be in phase and have a gain greater than or equal to three at the frequency of interest, and closer to three to avoid distortion.
Because op amps are typically gain limited at higher frequencies, you don’t see the Wien bridge used much at higher frequencies. But there are many other kinds of oscillators you can try simulating. However, nearly all of them will have this structure of an amplifier with some sort of feedback. The total feedback, including the amplifier, has to be in phase and the total gain around the loop has to be one. In a simulation, it is really that simple. In practice, though, there’s a lot of gotchas like parasitic capacitance, unwanted nonlinearities, and other concerns. However, the simulation can help clear up your understanding of how things work and make the practical realization of your design as painless as possible.