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

Build A Simple Gate Sequencer

Gate Sequencer

For the past week or so I’ve been working on building a 4017 based matrix gate sequencer. I originally started thinking about this project after purchasing a set of Kawasaki electronic drum pads from a local thrift store. I wanted to create a tool I could use externally to trigger the drums in a continuous loop. As I began to design This build though i began to realize it’s full potential went well beyond that.

As this sequencer goes through each step it outputs a voltage (approximately 5V) at the top most pin on the matrix. By connecting this top pin to any of the 6 pins directly below it you can send this signal out through the associated output on the side of the gate sequencer. Because these signals are being sent at approximately 5V they are perfect for switching low voltage transistors such as the 2N3904 (essentially allowing it to turn on or off an electronic switch wherever you send it). By using these outputs to switch on or off transistors they could be used to trigger a sound from a toy, gate an oscillator, turn on or off a channel on a mixer, trigger an envelope or anything else you desire.

Click here for details on setting up triggers in a drum toy

Gate sequencer 4017

I’ve also included some basic controls common to more traditional sequencers like the Baby 8. These include a rate control to adjust the clock speed, a hold switch which pauses the sequence, a step selector switch which allows you to select how many steps the sequencer goes through before restarting and a clock out for syncing other sequencers or circuits to the gate sequencer’s clock rate.

Parts List:

  • 555 Timer IC
  • 4017 Decade Counter IC
  • 2 – 4.7 K ohm Resistor
  • 1 – 100 ohm Resistor
  • 200K ohm potentiometer
  • 1 – 10 uf Electrolytic Capacitor
  • 1 – 0.1 uf Ceramic Capacitor
  • LEDs (one for power and one for each step)
  • 1N914 Switching Diodes (One for each step)
  • Rotary Switch (number of positions equal to number of steps plus 1)
  • Toggle Switch – power
  • Toggle Switch – hold
  • Hook up wire (lots)
  • Ribbon Cable (Strands equal to number of steps)
  • Proto-Board
  • Clock out jack (I used 3.5 mm headphone jack)
  • Ground Connection Jack (I used banana)
  • 6 – Output jacks (I used bolts but banana jacks are ideal)
  • Matrix connections (I used pin headers but you can use whatever you have available, requires 1 out and 6 in per step)
  • 9V battery clip

Schematic:

This is the schematic I drew up while building the gate sequencer. For simplicity sake I did not draw out all of the steps but they will each mimic the first two shown on this schematic. Bear in mind though that the 4017 output pins do not go in order, make sure to check the pin out diagram to make sure you are setting up the steps in the correct order. For 8 steps you should be pulling from pins 3, 2, 4, 7, 10, 1, 5 and 6 in order.

I wanted to mention as well as it is not clear on this schematic. If you are using fewer than all 10 steps from the 4017 counter you will need to wire the output of the next pin higher than the ones you have used to the final position of your rotary switch so that the counter resets after going through the steps you have used rather than the full 10. For example my gate sequencer uses 8 steps (outputs 0 to 7 on the 4017) so I wired output 8 (pin 9) to the final position of my rotary switch.
AND gate for gate sequencer
If you are using this device to trigger circuit bent toys you may also run into an issue where you are not able to trigger the same noise for two consecutive steps. This is because if you send the signal to the same output for multiple steps the output will remain high rather than sending a pulse for each step. I was able to find the fix above from Peter Edwards of Casper Electronics who used it in a similar project he built a few years ago. In order to correct this you can place an AND Gate on each output and send the clock pulse into the second input on each AND gate as shown above. This will cause the output to pulse in time with the clock when the signal from the matrix stays high for multiple steps.

The Build:


The first step of the build was to populate the circuit. Following the schematic I had created while testing and designing my gate sequencer I placed and soldered all of the on board components. I also used a number of short leads to put the steps in order on the board so that I could work with them easier going forward. One thing I want to mention is the row of diodes shown in the above picture were actually removed and placed on a secondary board (more details to follow) to simplify the finished product.

At this point I also mapped out the surface of my project box and populated the off board components (switches, knobs and LEDs). Due to the number of components on the box I used a piece of graph paper cut to the size of the surface to plan the device locations then used a pin to mark each one through the paper. From here I drilled the holes for the larger components and secured them in place.

pin headers

Due to the sheer number of connectors required to build the matrix I was not able to use banana jacks (which would have been ideal). What I did have on hand though were a number of male to female jumper cables and a pile of pin headers. I cut 8 of the female heads for the top posts and used individual pin headers for the connections. To mount the individual pin headers i ran fairly high gauge solid core wire through the holes and soldered them to the short ends of each pin header. Next I pulled the wire back down the hole until the plastic guards on the pin headers sat securely against the top of the box. To secure them I poured a substantial amount of hot glue onto them from the underside of the box.

gate sequencer ribbon cable

In order to limit the rats nest I foresaw forming between the top of the box and the main board I used a small scrap piece of proto-board as a junction. From here I ran all the connections needed for each step. The ribbon cable shown here is attached back to the main board (orange is step 1 through to black for step 8). From the board there is an orange cable for each step to go to the rotary switch (attached to the reset pin), a green wire to connect to the LED for each step and a red wire to go to the top pin of the matrix for each step. Note the red wire is after a diode on each step while the orange and green are before it.


Here is a picture after each wire has been soldered to its place on the back of the lid. I also used hot glue to attach the small proto-board to the lid of my gate sequencer. Make sure you test all of the connections thoroughly prior to gluing it down. Check for any bleed between steps and that all the solder connections are strong. Once you glue it down it will be very difficult to modify.


I connected all of the pins on the matrix (excluding the top row) in rows and connected each row to the corresponding output on the side of the box. One more coating of glue and I was ready to make the final connections. First I connected the ribbon cable to each of the 8 steps on the main board. Then I worked my way around the components which needed to be connected to the main board. Once everything was connected I wired up the battery, power switch and power indicator LED. I secured the battery with some Velcro and after some brief troubleshooting (There was a faulty switch I had to change) it was ready to go.

I am currently in the process of setting up trigger bends on my drum pad. Once they are completed and running smoothly I will have another article up describing how you can use your new gate sequencer to trigger noises from circuit bent toys  and down the road you can expect to see me using gate and trigger voltages to control a variety of other devices. Within the next week or so I should also have a demo video of this device uploaded for you to check out.

Thanks for visiting and happy soldering!

Sourcing Parts

There are a number of great sources where you can purchase components as needed, today I’d like to go through a few of the ones I’ve used and hopefully give you an idea of where you can go to get all the parts you’ll need for any project you tackle. This is by no means a comprehensive list but the below suppliers are where I source the majority of my parts.

Local

Buying local is typically the most expensive way to get parts but that is balanced out by the instant gratification you receive from walking into a store, giving them your money and walking out with your components. Though I wouldn’t recommend purchasing large quantities of parts in this way it is incredibly useful to have a store you can run to if you find yourself missing a specific piece you need to complete your project. Not to mention the right shop’s staff can be an excellent source of expert advice.

Radio Shack – I’ve read and been told that Radio Shack can be a good source of parts but unfortunately where I am located (In Ontario) we only have Circuit City which I have not had very much luck with. Typically their prices are extremely high and the selection is almost none existent.

Independent Stores – Independently owned electronics retailers are typically your best bet for a local parts supplier, if you can find one… Unfortunately due to competition with online retailers and the niche nature of their products these shops are getting harder and harder to find, but if you live in a large enough city have a look around and you may find something great. Typically you will pay substantially more than you would ordering parts online but you will be able to get the components you need without causing delays to your project.

Online

All Electronics – All Electronics was the first site I began ordering from and I’ve always had good experiences with them. They have reasonable costs and an easy to navigate site. Though they do not have as large a selection as some other suppliers this can actually be beneficial when your starting out, there is nothing worse than wading through a thousand different types of 10 ohm potentiometers just to try and find a volume control .

Jameco – Jameco is similar in scope to All Electronics though I’ve switched quite a bit of my business to them as I’ve found they stock a few more obscure parts (some CMos logic chips and the like) which I wasn’t able to find through All Electronics. My recommendation would be to try both these sites to get a feel for them and where both of there strengths lie.

Digikey – A moment ago when I mentioned wading through a thousand types of potentiometers… welcome to Digikey. I would recommend waiting until you are fairly comfortable with component types, manufacturers and specs. Often times without a specific part number for what you’re looking for you will end up sifting through page after page of near identical parts into oblivion. That being said if ever there is a part you can not find elsewhere or an IC too obscure to be widely available. Digikey will have it.