Tuesday, October 30, 2012

[Open 7400 Logic Competition Entry] Using two CD4007 IC as an op amp to generate sine waves

The CD4007 dual complementary pair and inverter is primarily intended for digital logic circuits. It contains an inverter, and two pair of PMOS and NMOS transistors that can be configured to implement any CMOS logic gates. Since we now have access to pairs of transistors, it should be okay to use these transistors for other purposes than digital, in other words: analog. This idea is not new, in fact this article has already mentioned this possibilty, and now I would like to take the challenge to build something somewhat useful out of it, as simple as possible.

First, a bit of demo. Here is the CD4007 op amp working as a sine wave oscillator. It can even drive a small loudspeaker through a capacitor (try to listen to it):

Now comes the explanations. I have actually started a bit on this late last year, and posted its explanations and results there (in Indonesian language). I will repeat some of my earlier post here, in a different language that is.

The circuit for the op amp is shown here:

It needs two CD4007s: one for the differential input stage, and one for the gain stage. Since simplicity is what we are after (not necessarily high performance), I did not use active loads (current mirrors) on the differential input stage, and use a pair of 100k resistors instead. The good thing about this CD4007 though is that the differential input pair transistors are on the same chip, so it would definitely help the matching. If you are after even better matching, using a 1% resistor (not a 5% like I did) would be a good idea.

There are two potentiometers in the circuit. One is the bias voltage for the current source (pin 6-7-8) through a simple voltage divider. The reason to use potentiometers in that voltage divider and in the gain stage is because we are not too certain about the behaviour of the transistors. These transistors need correct operation mode (saturation), and tuning the potentiometers is a simple way to ensure that.

A bit of tuning was necessary to make the op amp work. First we need to adjust the current in the differential pair such that the DC voltage level on its output is 'reasonable' (mid-rail). Then we adjust the other potentiometer to adjust the gain, enough to make it work. The way I did the tuning was by putting the op amp in a simple inverting amplifier and tune the potentiometers until I get the correct output.

The op amp in breadboard looks like this:

The inverting amplifier test circuit I used looked like this:

A terrible video showing that the circuit works can be seen below. I wanted to emphasize that the amplifier works with different DC offset of the input signal as an op amp should do.

Here is a picture of the circuit configured differently, now as an integrator (replace feedback R with C). It generates a triangle from a square wave input.

And finally, the oscillator circuit. The schematic looks like this:

On breadboard, it looks really messy:

But it works. It generates a sine wave!

Trying to tidy it up a little, I made a PCB version of the op amp, which looks like this:

Unfortunately due to lack of time (deadline is coming), I haven't got it to work correctly yet.

Next step:
While the op amp is indeed simple, but tuning may not be a pleasant thing to do. So it would be really nice to get fixed resistor values, and possibly use active loads and final output stage (this one doesn't use a final  --push-pull amplifier-- output stage but surprisingly its theoretically not-too-low output impedance is sufficient for all our purposes!?)

Another idea is to be more extreme, use dedicated inverter ICs such as the 4069, and work that one out as an op amp if possible.