Now Reading
Logic Noise: Candy, Candy Oscillator Sounds

Logic Noise: Candy, Candy Oscillator Sounds

2023-04-25 08:22:06

Welcome to half one in every of a sequence taking you down the rabbit gap of DIY digital synthesizers based mostly on (largely) CMOS logic chips. As a substitute of synths being commodity gear made by giant company enterprises, we’ll be constructing with the most cost effective accessible components, utilizing and misusing digital logic. In brief, don’t count on pre-packaged easy tones, as a result of we’ll be making inventive noise machines.

In case you’re the chiptunes kind, you’ll most likely discover one thing you want right here. In case you’re the circuit bender or electro-noise-punk kind, that is gonna be proper up your alley. In case you similar to to see CMOS chips wriggle and squirm in unintended methods, be at liberty to look over my shoulder. In case you’re the sort who insists {that a} screwdriver can’t be used to pry open a paint can, then perhaps you’d higher move along. There’s a skinny line between the glitch as bug and the glitch as fascinating discovery, and we’ll be dancing throughout it.

To offer you a style of what we’re as much as this session, here’s a fast demo.  Take a look after which we’ll get all the way down to it.

It All Begins With Squares

single-oscillator-breadboardWe’ll begin off with one oscillator (yawn!) after which flip it into one thing far more fascinating actually rapidly. Making this circuit playable takes just a little extra experimentation, however that’s the entire level. And alongside the best way, we’ll be laying the groundwork for far more difficult circuits in a while. We’re beginning firstly, however the curve is steep.

Our easy oscillator circuit relies round a logic inverter. An inverter is a chip that outputs the other logical voltage degree from what’s put in: if the enter sees the excessive voltage degree, it units the output low (and vice-versa).

To see the best way to make a fast and soiled oscillator out of an inverter, take into consideration what would occur when you linked an inverter’s output again into its enter. If the enter begins off low, the output goes excessive. However since they’re linked, the enter is now pulled excessive which in flip units the output to low, and we’re again the place we began. This high-low-high-low suggestions circuit provides us a primary oscillator, solely there’s a pair extra nuances we’ll must look into.

40106_pinoutThe chip we’ll be utilizing for our oscillator is the CD40106BE; additionally referred to as the HEF40106, relying on who makes it (datasheet, PDF) which is a hex inverter with hysteresis. It’s a terrific chip for our functions as a result of it’ll work on a large voltage vary in order that we don’t should stress about powering it. 5V is an efficient minimal, however 9V batteries aren’t any downside and 12V is simply peachy. Hex simply implies that there are six inverters in the identical chip. You may see how they’re laid out beneath. Pin 1 is the enter of the primary inverter. Pin 2 is its output, and so forth.

Hysteresis is simply Greek for: state dependence. In our explicit case, it implies that the brink worth that the chip makes use of to find out whether or not the enter is excessive or low is dependent upon whether or not it’s at the moment excessive or low. The 40106 chip has two threshold values: a decrease worth that’s lively when the enter is already excessive and the next worth that’s used when the enter is low. For the normal use, this supplies a level of noise immunity; if the enter is at the moment excessive, however fluctuating round a bit, it has to drop decrease than the decrease threshold to alter state.



Right here, we depend on hysteresis to make our oscillator run. In case you substituted an inverter with out hysteresis, its output would sit on the (single) voltage threshold. Why? When the output voltage will get a tiny bit above the brink, it pulls the enter up with it, and it switches the output low. When the output goes a tiny bit beneath the brink, it switches again the opposite means. As a substitute of an oscillator, you find yourself with the chip thrashing backwards and forwards internally simply to carry a continuing center voltage degree on the output.

In case you add hysteresis into the combination, you get an oscillator. As a substitute of wiggling imperceptibly round one switching threshold, we’ve got two thresholds. Because of this the chip received’t swap its output low till the enter rises at the very least as much as the upper enter degree. Now, that occurs fairly quick: after I construct the circuit with straight suggestions, I get a sq. wave that oscillates at 4.3 MHz, a couple of orders of magnitude too quick for human listening to. We have to gradual the suggestions down.

To decrease the pitch down into the audio vary, we run the suggestions by a resistor to restrict the present within the suggestions path, after which cost up a capacitor with this present. The time it takes the capacitor to cost up from the decrease threshold voltage to the higher is dependent upon the present that it’s provided. That implies that the frequency is decided by the scale of the resistor and the capacitor. A bigger resistance limits the present, slowing the cycle down. A bigger capacitor requires extra cost in an effort to attain a given voltage, which additionally leads to a slower cycle and thus decrease pitch.



So look over the oscillator circuit for a second and we’ll recap. Think about that the enter voltage simply crossed the decrease threshold. As a result of the enter voltage is low, the output is ready excessive. The excessive output and low enter causes present to move by the resistor which slowly prices up the capacitor till the enter voltage is increased than the excessive threshold, when the logic switches state and the output goes low. The low output then slowly discharges the capacitor till it drops beneath the low threshold and the cycle repeats. Tadaa! A sq. wave on the output bouncing between the 2 logic voltage ranges.

However what in regards to the enter? Keep in mind that the enter sees the capacitor charging and discharging between the 2 threshold ranges. As a result of the output voltage is fixed and the voltage on the capacitor is growing over time, the present that flows by the resistor drops just a little in the course of the cycle, so what we get is a “triangle” wave that’s made out of exponential curves relatively than straight strains. (Ok for gov’t work.) We’ll use this “triangle” waveform in a few weeks after we transfer on to linear-mode logic chip abuse, so simply maintain it behind your head for now. For the time being, a scope hint is value a thousand phrases.


Right here in yellow is the inverter’s output; a pleasant 5V sq. wave at 321 Hz. The inexperienced hint is the enter, which reveals the slowed-down charging and discharging of the capacitor. You may as well see simply precisely the place the inverter’s decrease and higher threshold values are, marked off by the dashed strains. As quickly because the voltage on the capacitor reaches the related threshold voltage, the output switches state. And that’s the essence of the “leisure oscillator” — it’s a easy suggestions oscillator that takes benefit of the inverter’s hysteresis and is slowed down by charging up a capacitor.

And right here’s what it seems like. I used a potentiometer for the resistor, and I’m twisting the knob in the course of the demo.

Construct It

trimpot-oscillator-testsSufficient idea. It’s time so that you can construct yours.

To truly hear this factor, we’ll additionally want to attach it to an amplifier and speaker. I like to recommend the most cost effective powered “laptop” audio system you’ll find as a result of they’ve built-in amplification with quantity management and also you received’t actually care when you break them. I’ve even reduce off the traditional 1/4″ plug on the top of mine and soldered on alligator clips to make them simpler to connect to breadboarded circuits.

In case you’re going to attach DIY noisemakers as much as one thing beneficial, you’re going to need to scale back the output all the way down to line ranges: let’s say one volt peak-to-peak. In case you’re operating on a 9V battery, meaning dividing down by an element of nine-ish. You are able to do this with a easy voltage divider (see beneath).
Lastly, there’s two particulars that you just virtually all the time have to consider with CMOS chips. First, they make spikey calls for on the ability provide as the interior transistors are switching. To easy this out, I often add a 0.1 uF or 1 uF capacitor simply throughout the chip’s energy pins. Second, the unused inputs ought to ideally be linked to floor (or VCC, your alternative). Meaning grounding pins 3, 5, 9 11, and 13. And don’t neglect to hook up energy to pins 7 and 14.

A sensible circuit would look one thing like this:


Fireplace up your audio system / amp and provides it a pay attention till you may’t take it anymore. For me that took about 5 seconds. (For my spouse, about three.) Let’s see how rapidly we will add just a little pitch management and dynamics to make issues extra musical.


First let’s work on altering the pitch up. The frequency is decided by how rapidly the capacitor is stuffed up by the resistor, so we’ve bought to alter one or the opposite. Altering the capacitance is tough, so we’ll work on the resistor. Any means that you may put a variable resistance on this circuit is truthful recreation. A potentiometer, as above, is fairly apparent.

A lightweight-dependent-resistor photocell is a superb choice. You may then use gentle to manage the pitch by waving your fingers round, which is kinda cool. But it surely will get a lot cooler while you invite the LEDs over — something that you just’ve bought that may activate and off an LED can change the pitch of your oscillator. In case you’ve been racking your mind about the way you’re going to hook your Arduino as much as this circuit: PWM to get totally different brightnesses and “management” the pitch.

After which there’s DIY resistors. Some outdated VHS tapes have a pleasant resistance that will increase linearly throughout their size, however you might have to attempt a couple of earlier than you discover the fitting model. (A extremely thick layer of graphite laid down by a darkish pencil works nearly as properly.) Take a look at the matte facet of a bunch of tapes with an ohmmeter first earlier than you go ripping them out of the cassettes. My copy of “12 Monkeys” has 37 KOhms per inch, which is just about excellent utilizing a barely smaller capacitor. I’ve taped the VHS tape all the way down to a bit of cardboard and linked it to the circuit with alligator clips. I play it by tapping on the tape with one other clip. Good vibrations!

"Originalstylophone" by Dhscommtech at en.wikipedia. Licensed under CC BY-SA 3.0 via Wikimedia Commons
Originalstylophone” by Dhscommtech CC BY-SA 3.0

If you’d like a number of discrete notes, like a piano, you may join a wide range of resistors with one finish linked in widespread to the capacitor. On the opposite finish, connecting again to the output, you connect a wire that you just use to pick out which resistor is within the circuit. See the stylophone for inspiration.

In case your DIY resistor doesn’t have the identical vary as mine, otherwise you simply need to play totally different pitches, you should use no matter dimension capacitor it is advisable to get the vary you need, naturally. The chips don’t prefer to put out greater than a few milliamps, so attempt to maintain the minimal resistance above 2 KOhms in order for you the chip to run in spec.

With the 0.1 uF capacitor that I’ve chosen 10K Ohms is an efficient decrease restrict for the resistance, in any other case the pitches get annoyingly excessive. Due to this, you may need to toss a 10K resistor in sequence with no matter variable resistance scheme you’re utilizing. In any other case, you’ll find yourself annoying the canine or disrupting bats’ flight paths.

See Also


In case you’d similar to to show this factor on and off, we’ve bought a couple of choices. Best is to wire the VCC energy provide by a pushbutton. Press the button, the chip will get juice and makes noise. Launch, no energy and silence. A fast means to enhance on this circuit is so as to add a pretty big (10uF to 100uF) capacitor simply after the swap. While you launch the button, the capacitor will present sufficient cost to run the circuit for a short while, smoothing out the discharge of the word.

In any other case you may lean on the LDRs once more, and make your self a light-dependent quantity management by including an LDR to the voltage divider that I steered above to get the sign all the way down to line ranges. Ping this LDR with an LED, and once more you’ve bought digital management over the quantity. We’ll do quantity management extra critically in a couple of weeks, however for now you may cobble one thing along with an LDR if you actually need one now.

In case you’re constructing alongside, now is an efficient time to check a few of this out on the breadboard, and perhaps attempt to play a easy melody or no matter. At the least attempt the button within the energy provide trick, and take a look at experimenting with totally different power-fade-out capacitor sizes. As soon as your accustomed to one oscillator, we’ll throw in one other.

Timbral Modulation

Now it begins to get fascinating. (Oh, that is just the start!) We’ve bought 5 inverter gates nonetheless unused, any of which might be used so as to add richness / modify the easy sq. wave we’re placing out thus far. So let’s make an oscillator sync impact. If we construct up one other oscillator and use it to activate and off our first oscillator and set issues up excellent, we’ll get the generally nasal, generally biting timbres of digital hard sync.



Construct up a second oscillator similar to the primary, and join the second’s output to the enter of the primary oscillator by a diode and an roughly 1 KOhm resistor. (The resistor limits the output present to maintain the chip in spec.) When the second oscillator is excessive, it is going to conduct by the diode and maintain the enter on oscillator one all the time excessive, successfully turning it off. However when the second oscillator goes low, it is going to launch oscillator one to do its regular factor.

The frequency of the primary (quick) oscillator acts as a timbre modulator, and the second oscillator controls the general perceived pitch. Let’s take it to the scope.


The inexperienced hint on prime is the second oscillator, set to the frequency that determines the pitch. It’s a boring sq. wave. However the yellow hint on the underside is the synced, increased frequency hint that we use as output. You may see that when the inexperienced oscillator goes excessive, it conducts by the diode and forces the enter of the yellow oscillator excessive, and correspondingly its output low. When the inexperienced oscillator output goes low, the yellow oscillator is free to do its factor once more; the diode solely conducts a method. So we see the yellow oscillator begin again up at its increased frequency till it will get reduce off in mid-cycle by the inexperienced oscillator going excessive once more.

This circuit sounds much more fascinating than the preliminary boring outdated sq. waves, and it’s much more expressive when you may change the frequency of the synced oscillator. A potentiometer is OK, however right here’s a terrific place to make use of an LDR to offer you management over the timbre by waving your hand round over the photocell. The one caveat is that when the frequency of the synced oscillator approaches that of the syncing oscillator, you don’t get any sound anymore. So to mess around, it makes a number of sense to place the LDR in sequence with a potentiometer in an effort to play with the vary of the impact.

For additional credit score, drive the synced oscillator’s frequency by pointing an LED on the LDR. Now nonetheless you management the LED will management the high-frequency part of the timbre. How shut you get the LED to the LDR modifications the depth of the impact, from refined to essentially nuts. The pitch continues to be managed with the potentiometer you’ve bought operating oscillator two, however the timbre is managed by the LED. After all, nothing stops you from making use of the identical trick to the pitch oscillator both.

Conclusion, and Subsequent Week: Sequencers

So by now you’ve bought one thing constructed up in your desk that’s both making utterly autonomous noise with blinking LEDs, otherwise you’ve constructed an expressive guide digital instrument. In case you get something good, file it and hyperlink to it within the feedback part. (And tell us how you probably did it.)

Subsequent week we’ll add a sequencer to the essential leisure oscillator framework right here, so keep tuned. And when you’d prefer to pre-order your self some components, we’ll want a 4040 counter chip and (my favourite CMOS logic chip on the earth?) a 4051 8-way analog swap. You’ll additionally need an assortment of resistors, most likely an LDR or two, and a bunch of diodes available. And when you haven’t bought these low-cost powered laptop audio system sorted out but, get on it.

See you then.

Source Link

What's Your Reaction?
In Love
Not Sure
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top