More oscillators!


At some point, for reasons I can't remember now, I tried simulating some simple sinewave oscillators. Here's one of them. This one uses a single transistor to provide the gain and a series of RC elements to provide the phase shift. The original circuit might have been from one of Graf's collections of circuits (I borrowed the Oscillators one from the library last year), though it's a fairly common circuit and you'll find it reproduced elsewhere. Books tend to simply present it as being a sine-wave oscillator along with a formula for determining the frequency from the values of the RC elements. In this blog, I'm going to use the simulator to look at it in a bit more detail and see how good it is at producing a sine wave.


Basic Circuit


Here's the basic circuit as it's usually presented. The original had a 3k3 resistor for the collector load, but I changed that for a 2k2 (the transistor I'm using evidently has a much higher hFE than what was used originally in that circuit).



Here is the output waveform from running a transient test on the circuit


As you can see, the output sine wave isn't all that good a shape. A sine wave can have a modest amount of harmonic distortion and still look quite reasonable to the eye so, if we can see that it actually looks poor, it really is.


How Does it Work?


The transistor is configured as a common-emitter amplifier. We say the emitter is common because the input is applied between the emitter and base and the output is between the collector and emitter (as the transistor has three legs, one always has to be shared by input and output). The common-emitter configuration gives us voltage gain - it amplifies the signal at the base - and it also inverts the signal, giving a 180 degree phase shift. The output signal is fed back through three RC networks to the input. At some frequency, the delay through those elements will result in another 180 degrees of phase shift (nominally 60 degrees for each RC pair) and we meet the conditions for oscillation from positive feedback (360 degrees of phase shift around the loop and enough gain to balance the losses).


That's kind of an ideal picture where we might imagine the transistor makes a good (linear) amplifier, the gain works to just balance the losses, and we'd see nice sine waves all around the loop. The reality is much different.


At start-up, the signal will build (it initially comes from noise generated by the power being applied). After a few cycles, it limits because it has grown to be almost the same, peak-to-peak, as the supply voltage. At the top end, it slows just short of the rail (giving quite a soft top) because of the very non-linear characteristic of the base as the voltage there reduces. It's also the case that each RC stage loads the previous one, with the last one working into the very non-linear load that the transistor represents, so any idea that we get a nice, neat 60 degree phase shift from each stage flies out the window. It's very messy and a simulator approach rather than an analytical one makes a lot of sense. 


Further Investigation


Here's the circuit as I extended the scope of the simulation, with test meters to measure the waveforms at various points. I included an initial condition of 0V at the transistor base to ensure that it started properly [needing something extra to kick an oscillator into life is common with simulation - this one sits sulking with its output at 4.3V if you don't give it a bit of encouragement].



Here are the waveforms


Looking at those waveforms, you can see that the reality is miles (kilometers, if you prefer) away from the ideal. For large signals, the single-transistor common-emitter amplifier is very poor in its linearity [I ought to do a 'Transistors' blog on it, really] and the signal out is very different in shape to the signal at the base that generates it. We also have a situation where the transistor input is loading the RC networks, so they don't really filter the output signal in the way you might expect.


It's occured to me that one interesting way to think about what is happening is that we have an analog computer that's solving the problem of: 'what waveform do we need at the output so that, fed round the circuit and amplified by the transistor, it results in a perfect copy of itself?' The waveform we see on the 'scope is a solution to that problem (I say 'a' rather that 'the' because it's possible that there might be more than one solution - in fact there is, because a bit more thought shows that there's a static dc level that is also a solution, though whether that would actually happen in reality - as opposed to the simulator, where it's the natural solution - is a different matter).




Here it is built on a breadboard. You can see how simple it is.



Here's the 'scope trace of the output. On the breadboard, my transistor has a different gain to the one in the simulator and that has moved the dc operating point of the output slightly lower. As a consequence, the limiting is at the bottom, as the transistor runs into saturation, rather than at the top.




Here's the result if I get the oscilloscope to do an FFT of that waveform




That gives us a better idea of just how poor a sine wave it is. Ideally, there would just be the fundamental (half a division in from the left-hand edge), but as it is there seems to be every harmonic possible in addition (except, curiously, for the 8th harmonic - perhaps they take it in turns to have the day off).


Well, I think that's enough experimenting with this. There may well be other uses for the circuit, but if you want a good quality sine wave then it either needs considerable improvement (several transistors, with feedback around them to linearise the response, would be a good start) or you'd need to consider something else, maybe a Wien bridge oscillator. Here's an interesting application note (page 29 onwards) that will help if you ever want to try for one with a really, really low distortion figure [this must rank as one of the best application notes ever written]: