NAND Drone

NAND Drone Synth

I’ve built a lot of square wave synthesizers. They are some of my favorite projects. They’re generally fairly straight forward but can provide hours of fun. Further they provide a great starting point for newcomers to audio electronics. That being said after stringing together so many 555 timers and 40106 inverters I was looking for a way to breath some new life into these builds. I decided to start playing with some simple digital logic to see if I could develop a deeper sound while still sticking with basic square oscillators. What I came up with was a super-simple drone synth using NAND gates to combine three 40106 oscillators.

Parts List:

2 – 40106 Hex Schmitt Inverter ICs (One will work but 2 is ideal)
1 – 4011 Quad NAND Gate IC
3 – 0.01 uf Capacitors
3 – 500K ohm Potentiometers
6 – 20K ohm resistors
3 – 10K ohm resistors

Pretty short parts list right? This one comes together pretty easy thanks to the 40106 oscillators low parts count. Even with so few parts though, it still sounds awesome. So lets have a look at the circuit.

Circuit Diagram

NAND Drone Synth Circuit Diagram

Note : I’ve split the 40106 inverters between two chips. Since the 40106 includes 6 inverters this can be completed with 1 40106 chip. However, the 40106 can act unpredictably when all 6 inverters are switching at high speed so the behavior may not be optimal.

This circuit can be split into a few simple parts which I’d like to have a look at seperately.

Square Wave Oscillators

This circuit uses 3 40106 Inverter based oscillators. I used these oscillators primarily for their relative simplicity though essentially any square source could be fairly easily implemented in this design. I used a 0.01uF capacitor to set the frequency range for the oscillation but feel free to experiment with other values to get the frequency you desire. I then limited the current using a 500K ohm potentiometer to allow me to move through a wide band of frequencies.

Buffers

After the square wave is created each signal is passed through an additional inverter. The frequency of the 40106 oscillator is defined by the charging speed of the capacitor. This capacitors charging is a directly result of the current flowing out of the output and through the resistor. This means any addition power draw we add to this output will impact the frequency. To avoid this we send the signal through the additional inverter which isolates any further components from the oscillator circuit.

Attenuation

Next up we pass each signal through a basic voltage divider. This is simply to lower the amplitude of the inverter outputs before sending them into the 4011 Quad NAND chip.

NAND Gate

Here’s where the magic happens! The signals are each connected to two of the NAND gates such that each NAND gate has a unique set of two input signals (Sounds a bit weird but should be clear if you look at the circuit diagram). These NAND gates will be high by default but will go low when both inputs are high. This means any pair of your oscillators going high at the same time will cause at least one of the NAND outputs to go low.

Mixer

Finally we send each NAND output through a 10K ohm resistor and combine them into one output line. You can then wire this to the output style of your choosing and start making noise. Note the output from the 4011 is fairly low amplitude (about 1.5V peak to peak) so you may need to amplify it before connecting to a speaker.

Bigger is Better

I chose to use three oscillators here for convenience however there is no real need to stop there. Just be aware as you grow the number of NAND gates needed to have every combination will grow very quickly. For 4 oscillators you would need 6 NAND Gates, with 5 you would need 10 and so on.

Sound Waves

I just wanted to finish off by showing some of the sound waves I captured on my oscilloscope to give you an idea of what this circuit outputs:

40106 Oscillator Continued

40106 Oscillator Schematic

I left my last post (40106 Triangle Waves) on a bit of a cliff hanger. I had shown how to pull a triangle wave from the circuit and identified some issues with the oscillator as it stood. Today I’d like to go over those issues and how I corrected them to get this oscillator up and running.

I do want to mention the oscillator design above is still in a somewhat rudimentary form. I expect there will be quite a bit of optimization that can be done on it as time goes on.

Buffering

Since we are pulling our outputs directly from the loop which sets the frequency, any elements we add to the circuit which draw current will affect the frequency. This is not ideal. What we need to do is isolate the oscillator circuitry from any further additions to the circuit. For the square wave this is extremely straight forward. Since the signal is binary (digital) we can simply send the output through a second inverter on the 40106 chip. Take note: this will invert the signal (when the original oscillation was high the buffered oscillation will be low) however since this is a repeating signal it won’t cause any impact.

The triangle is slightly more difficult to buffer since we need to concern ourselves with a range of analog values. I accomplished this by feeding the signal through an LM324 op-amp set up as a voltage follower with an additional 10uF capacitor on the output.

Amplification

After the buffering stage I was still left with dramatically different amplitudes for the two wave forms. The square wave after the buffer sat at almost 9V while the triangle was only 1.4V (The output voltage of the LM324). There’s a number of ways you can approach this inconsistency however I found myself somewhat limited by the parts I had on hand and by my decision to run this oscillator on a single 9V battery supply.

How I ended up overcoming this was by using voltage dividers to lower both signals to about 1V peak to peak. From here the selected input is sent into a very basic LM386 power amplifier.

This solution does introduce a large amount of noise into the square wave signal so you may choose to bypass the amplifier with the square wave and only use it on the triangle.

Set up this way I got both signals to reliably output approximately 5Vpp.

Decoupling

One issue I ran into a lot with this circuit, especially building on breadboards was noise. The frequency would bounce around and the wave-forms would not be crisp. This can be largely overcome by adding decoupling capacitors between the negative and positive supply lines. An excellent overview of decoupling (and many other common capacitor uses) can be found over at SparkFun.

40106 Triangle Waves

Recently I completed a post discussing the 40106 Inverter and a simple square wave oscillator. I wanted to build on that post a little more today and look at how we can modify this same oscillator to output triangle waves along with square. These triangle waves will sound profoundly different than square waves in the audible range, giving our oscillator 2 distinct voices. Additionally, we can use the oscillator at a low frequency to drive a voltage controlled amplifier or filter. We can get much more variance from the rising and falling triangle wave in these applications than we would with the simple switching of a square wave.

So Where Are These Triangles?

40106 Oscillator with Triangle Output

If you read my previous post you may remember that this oscillator works by charging and discharging a capacitor. As the capacitor charges and discharges it allows the voltage to rise and fall at the input. This rise and fall causes the output of the inverter to turn on and off producing the square wave. What we can also do is take an output at the input of the inverter where the voltage is rising and falling to produce a triangle wave!

An Amplitude Problem

If you try building this circuit as is you’ll very quickly notice an issue with the design. Connecting a speaker to the output of the square wave sounds great but the triangle is barely audible! If you look at the two waveforms above you’ll see that the square wave has a peak to peak voltage of 6.32V. The triangle however is only registering a fraction of that at 1.22V. This is because the output of the inverter (where we draw the square) always outputs a full digital signal. Meanwhile the voltage at the input only rises until it reaches a threshold voltage. At that point the inverter changes state and the capacitor begins discharging again. In this case (running the 40106 on 9V) that threshold appears to be 1.22V.

So What Now?

In my next post I’ll be exploring the use of op-amps to buffer these outputs and equalize them to a usable voltage. Once we’ve accomplished this we’ll be able to start using this oscillator in all kinds of awesome projects. See you all soon!

40106 Hex Schmitt Inverter

The 40106 Hex Schmitt Inverter is an incredibly useful and popular IC in the world of DIY synthesis. It is cheap, easy to use and is central to one of the simplest oscillators around. Today I’d like to have a look at this chip, explain how and why it works and show you how you can use it to start making some noise.

A Hex Schmitt What-Now?

As the name suggests the 40106 chip is a Hex Schmitt Inverter (Or 6 Hex Schmitt Inverters) on a 14 pin chip. An Inverter is a digital component which takes an input (0 or 1) and outputs the opposite value. Typically in digital electronics these would be represented as 0V or 5V meaning if 0V is sent to the input 5V will be output by the output and vice versa. What makes a Hex Schmitt Inverter special is its capacity to take analog inputs rather than just 0 or 5V. The way this is accomplished is by setting a threshold voltage where the output changes. Looking off the datasheet for the 40106 we can see that in typical operation this happens at 0.9V when the chip is being powered with 5V or 2.3V when being powered with 10V. When the voltage on the input goes above that threshold the output turns off. When the input goes below that threshold the output a digital high voltage (usually 5V).

Dividing By Zero?

This Isn’t Going To Work

That probably all sounds as clear as mud so lets go over a simple use case to see if we can make some sense of it. We know that when you input a high voltage to an inverter it outputs a low voltage and vice versa. So what would happen if we connected the output back to the input? Now we’ve built a bit of a paradox! When the output is high it sends that high signal back to the input which makes the output low which makes the input low which makes the output high which makes the output low which makes…. you get the idea. The problem is since this is happening instantly its faster than the chip can handle and the whole thing breaks down.

Capacitor To The Rescue!

Simple 40106 Oscillator

What we need is a way to delay the signal traveling from the output back to the input so we can get a consistent oscillation. We can accomplish this by adding a capacitor between the input and the ground and a resistor between the output and input. The capacitor is initially in its uncharged state and the input is low. This low input voltage causes the output to go high, however an uncharged capacitor provides no resistance between the input and ground so all current flowing out of the output goes to ground and the voltage stays at 0V at the input.

As current flows into the capacitor it begins to charge which in turn resists more current traveling through it. This new resistance allows the voltage on the input to begin to grow proportional to the resistance provided by the capacitor. Eventually this voltage will reach the threshold voltage of the inverter and cause the output to go low. Then the whole thing happens in reverse, as the capacitor discharges the voltage drops until it falls below the threshold voltage and the output switches back to high.

The resistor functions to limit the current traveling from the output to the capacitor which slows the charging of the capacitor.

So How Do We Control This Thing?

Simple 40106 Oscillator with Control Pot

The key to taking this from a curiosity to something useful is control, we need to be able to select a frequency range and modify it in real time. Since the speed the inverter flips from high to low and back is governed by the charging and discharging of the capacitor we can control the frequency by controlling the speed the capacitor charges and discharges.

The first way to do this (as you may have guessed) is by changing the size of the capacitor. A smaller capacitor will charge quickly providing you a very high frequency while a larger capacitor will charge slower and provide a substantially lower frequency. Choosing the right capacitor is a great way to select a range of frequencies for your oscillator however as variable capacitors are rare and expensive this is not an ideal method for making real time changes to the frequency.

This leads us to the second method which is adjusting the resistance. This resistance limits the current flowing to the capacitor. The less current flowing to the capacitor the slower it will charge. Further since potentiometers (variable resistors) are common components we can add a knob to adjust the frequency of our oscillator on the go.

An easy way to calculate the approximate frequency with any resistor capacitor combination is using the equation f = 1.5/RC