Quantcast
Channel: logic noise – Hackaday
Viewing all 14 articles
Browse latest View live

Logic Noise: 8-bits of Glorious Sounds

$
0
0

Logic Noise is all about using analog circuits to make sounds. Preferably sound that will be enjoyable to hear and useful for making music. Now, the difference between music, sound, and noise is certainly in the ear of the behearer, but you must admit that last installment’s simple square wave lacked a little something. (Although the sync oscillator circuit extension was kinda cool.)

This week, we’ll take our single wimpy square-wave oscillator and beef it up by adding a bunch of sub-octaves to the mix. And we’ll do it using a chip that’ll be really useful for us in the future as well: the 4040 binary counter chip.

Counters (binary or decimal) are going to be fertile ground for more musical noise experiments. Why so? Because octaves are just doublings or halvings of frequencies, and because a lot of rhythmic patterns have factors of two underlying them.  Just think about the most basic drum pattern you know: bass drum on the one, snare on one and three, and hi-hats on one, two, three, and four. Each different instrument fires off twice as frequently as the one before it.

But for now, enough blabber. We’ve got an oscillator to build.

Stacked Octaves Oscillator: The 4040

The 4040 (and other) binary counters do just what you’d think they do. They count up in binary. Count what? Clock pulses on the chip’s input. The 4040 is a twelve-bit binary counter, so it has twelve outputs (labelled Q in the pinout below) that display the number of pulses it’s seen on its clock input since the last chip reset. Counting up in binary turns out to be more useful than it sounds, and we’ll get to that after the chip pinout diagram.

4040_pinout

Most of the chip’s pins are taken up with these “Q” outputs. Q11 is the most-significant bit, and Q0 is the least. You could just read the number of elapsed clock cycles off of these binary outputs, but we’re going to think about this chip a little bit sideways.

Look at a counting pattern in binary: 0000, 0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, etc. What I’d like you to notice is that the least significant bit completes a 0-1 cycle every two counts, and that the next bit completes its 0-1 cycle every four counts, and so on. This isn’t strange. If you were to count to a million in decimal, you’d notice that the first digit completes its 0-9 cycle only after ten numbers had been counted, and that the second digit cycles ten times less frequently than the first digit and so on. We’re just not used to thinking of the frequency of change in each digit.

So if the clock input has a constant frequency, a binary counter can be used as a series of factor-of-two frequency dividers. Out of this one chip, we’ve got twelve stacked divisions of the clock input frequency, all running at once. Musically speaking, that’s twelve octaves, which is way more than the seven puny octaves you’ll find on a grand piano. In fact, the lowest octaves are likely to be periodic clicks more than anything you’d perceive as a pitch. The difference between rhythm and pitch is just a matter of degree, after all.

In fact the 4040 is built internally exactly as a cascaded series of frequency dividers, and this type of counter is called a ripple counter. The individual frequency dividers in a ripple counter are flip-flops. A flip-flop just changes state between the high and low voltages each time it gets a clock input. This is the same as dividing the frequency in half; the output requires two cycles of the input clock to get through one full high-low cycle of its own. So if you put in an 800 Hz signal, the output of a flip-flop is at 400 Hz. The 4040 is twelve of these chained together.

Before we leave the topic of counters, if you end up reading a datasheet note that some manufacturers label these outputs Q1 through Q12 instead of Q0 through Q11. Unfortunately, both options make sense. If you’re thinking of the outputs as a binary number, you’re used to thinking of the least-significant digit as the ones place, or 20. On the other hand, if you’re thinking of frequency division, the least significant output divides the input by two, or 21. I’m sticking with Q0 because it’s what my schematic editor does, but if you read along with a datasheet, you may have to convert between the two in your head.

The Circuit

So if we’ve got a source of twelve octaved square waves, let’s take some and mix them together. Simply take three high-value resistors and use them to connect three different Q outputs to your speaker’s input. I’ve used 100K resistors here, but the values aren’t critical.

stacked_oscillators_sch

Build this up and then play around with which of the Q outputs you’re using in your mix. The three octaves just next to each other give you a classic sound. In the scope trace below, the green trace is the clock input and the yellow output is the sum of Q0, Q1, and Q2. As you can see, the result is a glitchy ramp waveform. Building up “complex” waveforms out of square waves is an old trick of the eight-bit era, so if you’re of a certain age this’ll bring back memories.

stacked_scope_output
The gotchas in the circuit here include the usual caveats about providing enough local capacitance and grounding unused inputs. In this case, the unused input is the reset pin (pin 11). If you want to use it, all you need to know is that it sets all the counter outputs back to zero (low voltage) when a high voltage is present. This is handy for doing actual counting with the chip, but much less so for our purposes of pitch and rhythmic division, so we’ll just keep it grounded. But there’s probably some creative sync-oscillator setup lurking around here for you to discover and prove me wrong.

The Sync Extension

There’s no reason to feed the counter chip a simple square wave.  For instance, if you just happen to have the sync oscillator sitting around on your bench from last time, try that as input to the 3-octave divider.  Sometimes you one or the other output is out of the audible range, other times it’s back in.  As you sweep up and down the pitch, you get ridiculous aliasing and other artifacts.  We’re leaving the happy chiptunes universe and heading off somewhere else. Somewhere populated by angry machines.

Next Week

In the next installment, we’ll use the 4040 counter chip much more in line with what’s “normal” and use it to drive the eight steps of a switching sequencer using perhaps the most versatile of chips to have in your arsenal, the 4051 eight-way analog switch. So stay tuned!


Filed under: Featured, musical hacks

Logic Noise: The Switching Sequencer Has the Beat

$
0
0

Logic Noise is all about using logic circuits to make sounds. Preferably sound that will be enjoyable to hear and useful for making music. This week, we’ll be scratching the surface of one of my favorite chips to use and abuse for, well, nearly anything: the 4051 8-way analog switch. As the name suggests, you can hook up eight inputs and select one from among them to be connected up to the output. (Alternatively, you can send a single input to one of eight destinations, but we won’t be doing that here.)

Why is this cool? Well, imagine that you wanted to make our oscillator play eight notes. If you worked through our first installment, you built an abrasive-sounding but versatile oscillator. I had you tapping manually on eight different resistors or turning a potentiometer to eight different positions. This week, we’ll be letting the 4051 take over some of the controls, leaving us to do the more advanced knob twiddling.

Why is the 4051 awesome? Because this week’s projects are the tip of a large iceberg. There’s nothing stopping you from hooking up eight CD players or radios to the inputs and switching rhythmically between them. Or applying eight arbitrary voltages to each input and stepping through them at audio frequencies, creating an eight-step arbitrary wavetable synthesizer. And the 4051 pairs fantastically well with a microcontroller, if you’re the type who’d like to add computer control to your square-wave noise synths. These applications are above and beyond what we’re doing today, but it’s good to see the forest and the trees.

Sequenced Pitches: The 4051 Switch

Up to now, we’ve been changing the resistance in the feedback loop of our relaxation oscillator circuit to control the pitch. But what if we don’t want to have to control the pitch by hand anymore? We can pass off resistor-selection duties to a switch, for instance. So without further ado, I introduce to you the 4051 analog switch.

4051_pinout

On the bottom right (pins 9, 10, and 11) are the three digital inputs that select which way the switch will be active. Depending on the value of these three bits, the common pin will be connected to any one of the various X pins. A is the least-significant bit, and C is the most-significant. So when A=B=C=0, common is connected to X0 and when A=B=1 and C=0, common is connected to X3.

The power supply for this chip is a little bit complicated, because it aims to support both negative and positive (analog) voltages through the switch. In “normal” use, you’d connect VCC to +5V, VSS to -5V, and VEE to 0V, or the signal ground. What’s important here is that the VCC to VSS voltages span the input range, and VEE to VCC is in the relevant range for our logic signals. Since we’re passing single-sided (0V to 5V or 9V) square waves through the feedback path, and using the same voltage range for our logic signalling, we can connect both VSS and VEE to ground.

 

The Circuit

The circuit here builds on everything we’ve done so far, so dig out the 40106 chip for oscillators, the 4040 binary counter from last week to convert the clock stream into a binary count, and of course, your 4051 analog switch.

For this circuit, we’ll need two oscillators set up on the 40106 like before. We’ll call these two oscillators the “clock” and “pitch” oscillators. The clock oscillator will control the tempo and feed it’s output into the 4040 counter’s input. The pitch oscillator will have a number of options for its feedback resistor, selected by the 4051 chip, and the counter’s output determines which resistor is picked. This means that our circuit looks something like this:

sequenced_pitches_sch

OK, that’s a lot to take in at once, but it breaks down into familiar parts. On the left, we’ve got the circuit from the stacked oscillator example: a variable oscillator driving our binary counter that acts as a clock divider. On the far right, we’ve got a simple relaxation oscillator again, but where the feedback resistor would leave the inverter’s output the circuit splits up into eight individual resistors, passes through the switch, and returns back to the inverter’s output to charge up the capacitor. And there’s the secret. The switch is selecting which of the resistors are used to determine the pitch.

Actually building this circuit as written requires a lot of wiring, and it’s easy to get lost. Instead, I recommend starting off with just one of the feedback resistors and working your way up. With a single resistor in place, the pitch oscillator will only sound for 1/8th of the cycle. Start off by adjusting the timing oscillator fairly slow, and then get a reasonable pitch set up on the audio oscillator. Now you’re ready to add in another resistor into the sequence. And as a practical layout tip, notice that you’re eventually going to hook up five to eight resistors from the switch all into the same point. Make sure that you leave yourself a bit of space on your breadboard to make these connections.

What resistors should you use? If you have an endless supply of 100K potentiometers on hand, that’s ideal. But who among us does? Instead, it’s actually an interesting challenge to just grab a handful of different resistor values between 10K and 100K at random and try to make something musical out of them. In practice, it also makes sense to leave a couple positions on the switch empty. This breaks the feedback loop and gives you musical rests in the sequence.

Things really get fun when you mess around with the inputs to the selection bits A, B, and C. As drawn, we’ve hooked up the least-significant bit from our counter to the least-significant bit position on the switch and so on. This gives us a predictable counting-upwards-to-eight pattern. That is, we’re using the counter chip as a counter. (Yawn!)

Once you’ve got three or four resistors hooked up, try picking off other clock divisions as inputs. For instance, if you use a relatively fast clock input for selection bit A, you’ll get a rapid trill between two notes (even and odd values of X) and a slower progression through four of these pairs. There are so many patterns here that you’ve just got to experiment around.
With eight variable resistors to tune the pitches and multiple ways to control the rhythm patterns, this setup really isn’t too shabby. Prepare to spend at least a half hour just playing around after you’ve built it.

Sequenced Sync

So far, we’ve gotten a lot of mileage out of hard-syncing one oscillator to another and varying the timbre of the output by varying the (relatively higher) frequency of one oscillator by hand. Let’s automate that.

We’ll need one more oscillator for the sync function. (Good thing the 40106 has six inverters, right?) Now the circuit will consist of a clock oscillator to drive the counter and switch, a sync oscillator controlled by the switch, and a pitch oscillator that we can control directly to play music. Note that now we’re controlling the sync oscillator from the switch and the pitch oscillator by hand.

Before you go ripping up stuff off your breadboard, notice that you can set up the previous circuit’s pitch oscillator as this circuit’s (higher-frequency) sync oscillator very easily by changing out a lower-value capacitor and leaving the rest of the circuit in place. Swap in a 0.01 uF cap for the sync oscillator and then take the 0.1 uF cap that you just pulled out and build up your pitch oscillator with it. Connect the pitch oscillator’s output up to the sync oscillator’s input with a diode and current-limiting resistor just as we did last time. Hook up your amp setup to the sync oscillator’s output and bask in the awesomeness.

sequenced_timbres
Make sure that you explore the whole range of sync-rate modulation frequencies by tweaking the clock oscillator. It’s fairly obvious to run the sync-switching frequency around 2 Hz (120BPM), but really strange things happen as the switching frequency of the sync approaches the audio frequencies. I like this circuit a lot.

Extensions

There are too many ways to go with this circuit setup.

If you want to play with bizarre rhythms, you can use non-synchronized cycles to drive the A, B, and C pins. Instead of the single-oscillator-plus-counter setup we used here, build three random oscillators on the 40106 and use them as inputs to the 4051. You’ll get some really far-out patterns depending on the relative periods of the various clock oscillators.

Or you could keep the counter in the circuit but feed it an irregular clock source so that the steps it takes are wonky. You can build a strange clock by using diodes to combine the outputs of several oscillators that have different periods. Using Mickey Mouse logic you can AND or OR multiple oscillators together before the counter. Unless you’re very lucky or clever, it may not be “musical” but that’s in the ear of the beholder.

In either of the above two examples, substituting light-dependent resistors (LDRs) for the feedback resistors in the clocks will give you dynamically varying madness as the amount of light in the room changes. This can actually be very cool over the period of a day if you have the attention span for it and run the clocks fast enough that the sound is an evolving texture rather than a manic musicbox.

But you don’t even need the counter to have fun with the 4051. Putting two of them back-to-back (common pin to common pin) gives you an 8×8 switch: one of eight inputs can route to any one of eight outputs. And you can repeat the circuit as many times over as you need simultaneous signal paths. Similarly, two 4051s in parallel with a bipolar power supply make a workable eight-way input selector for your stereo.

Next Session

In the next installment, we’ll work on some amplifier and filter circuits using CMOS chips. For these, we’ll need a different inverter chip, the 4069UBE, that doesn’t have the built-in hysteresis of the 40106. (Note that the UB part is important — it’s an unbuffered output that we’re looking for.) Until then, have fun and post up your results in the comments.


Filed under: digital cameras hacks, Featured, slider

Logic Noise: Sawing Away with Analog Waveforms

$
0
0

Today we’ll take a journey into less noisy noise, and leave behind the comfortable digital world that we’ve been living in. The payoff? Smoother sounds, because today we start our trip into analog.

If you remember back to our first session when I was explaining how the basic oscillator loads and unloads a capacitor, triggering the output high or low when it crosses two different thresholds. At the time, we pointed out that there was a triangle waveform being generated, but that you’d have a hard time amplifying it without buffering. Today we buffer, and get that triangle wave out to our amplifiers.

triangle_square

But as long as we’re amplifying, we might as well overdrive the amps and head off to the land of distortion. We’ll do just that and build up a triangle-wave oscillator that can morph into a square wave, passing through a rounded-over kinda square wave along the way. The triangle sounds nice and mellow, and the square wave sounds bright and noisy. (You should be used to them by now…) And we get everything in between.

And while we’re at it, we might as well turn the triangle wave into a sawtooth for that nice buzzy-bass sound. Then we can turn the fat sawtooth into a much brighter sounding pulse wave, a near cousin of the square wave above.

What’s making all this work for us? Some dead-boring amplification with negative feedback, and the (mis-)use of a logic chip to get it. After the break I’ll introduce our Chip of the Day: the 4069UB.

If you somehow missed them, here are the first three installments of Logic Noise:

The 4069UB

4069ub_pinoutThe 4069UB is a hex (unbuffered) inverter. In fact, if you can remember the pinout of the 40106, this should look very familiar to you. The only difference is the lack of hysteresis (and the little squiggly symbols) in the inverters. But what a difference that makes! The lack of buffering and hysteresis in the inverter lets us use the individual amplifiers for analog purposes rather than digital / logic.

Remember that the “UB” part is mandatory for all of this to work. It stands for unbuffered, and that essentially means that there’s no special attempt made to convert the output into something digital inside the chip. (Some end in “UBE” or “UBF” or whatever. As long as there’s a “UB” somewhere, you’re set.) And it turns out that an unbuffered inverter is nothing more than a push-pull CMOS amplifier pair. Each “inverter” cell looks like this:

cd4069ub_inverters_schematic

Ignoring the input-protection diodes, you can see that it’s basically just two transistors: an N-channel FET connected between output and ground and a P-channel FET connected between output and the power rail. (That’s the Complementary MOS pair that gives CMOS chips their name.)

If you’re not brushed up on your MOSFETs, the N-channel conducts when the input gate is pulled to a high voltage, and the P-channel conducts when the input gate is pulled low. This means that when the input voltage is low, the bottom FET doesn’t conduct and the top FET does, pulling the output voltage high. And vice-versa for a high input voltage. This makes a rudimentary logic inverter. Hooray!

But what happens in-between? At mid-supply voltages, both of the transistors will be turned on to varying degrees. This makes an output voltage that’s continuous, analog, and the “opposite” of the input. In order to give the chip a decent logic output, it needs to have a high gain through this middle zone so that voltages that are just a bit higher than the midpoint result in outputs that are clearly a logic zero.

cd4069ub_transfer_function

The beauty of this chip for our purposes is the soft clipping effect that you get from the S-shaped gain curve above. That is, the gain rolls off (the line is less steep) near VCC and GND. This makes for a pleasing overdrive sound as we crank the amplifier up, and lets us control the amount of fuzz on the output by controlling the input volume and gain.

Buffers and Feedback

As we said above, the naked 4096UB chip has a very high gain right around the midpoint voltage, which is what makes it useful as a logic chip. To make it useful for amplifiying analog audio, we’ll use (negative) feedback to calm this gain down a little bit. By controlling the ratio of input signal to feedback, we can vary the output from nearly completely silent to distorted out to the limits of the voltage supply.

For starters, let’s aim to get a voltage gain of -1. That is, the output signal is just as big as the input signal but opposite in sign around the mid-point. This is an “inverting unity gain buffer” if you’re an electrical engineer. And buffers will allow us to listen in to signals that our amplifier’s input circuitry would otherwise swamp out.

Remember when we said that there was a triangle wave on the input terminals of the 40106 inverter? Did you try to plug them up to your amplifier? If so, it probably didn’t work although you can see it clear as day on the oscilloscope. Even when I can get it to work, there’s still a pitch shift that depends on the volume knob settings on my amplifier. Strange stuff! Clearly, the amplifier’s input circuitry is coupling with the oscillator. Putting a buffer circuit in-between will let the oscillator oscillate and the amplifier amplify without interacting with each other. That’s what buffers do. Let’s build.

buffer_schematic

The unity-gain buffer circuit is as simple as connecting the input through a resistor and then connecting another resistor with that same value in feedback between the output and the input. For intuition on how this works, let’s dig briefly into negative feedback amplifiers.

The intuition for this circuit (and all negative feedback topologies) involves first realizing that where the input signal and negative feedback meet, there can’t be any net signal voltage above or below the chip’s neutral voltage. If there were positive net signal, the inverter output would go negative until the feedback brought the junction of the two back down to neutral. If the input is negative with respect to neutral, the output will go positive and pull it back up. When the feedback path is working as intended, it’ll hold the input at the neutral voltage level.

A quick word about this neutral voltage. If you’re familiar with op amps, the neutral voltage is whatever’s present on the positive terminal. In our case, the chip switches from high to low around the mid-rail voltage, half of VCC, so that’s our neutral point. You can demonstrate this by unplugging the input and measuring what voltage level the output (and input) settle at with no signal present. It’ll be around VCC/2.

triangle_bufferedSo the first basic premise is that the feedback exactly cancels out the net signal where they meet up at the input of the inverter. This cancellation means that whatever signal current comes in through the input resistor has to get pulled on out through the feedback resistor. If you think of voltage as the force required to push a given current through a resistor, the output only has to work as hard as the input when the two resistors are equal. That is, when the input voltage is 0.1 volts above neutral, the output will be 0.1 volts below neutral because both are “fighting” the same resistance.

And there you have it: an “amplifier” with a gain of negative one. It doesn’t make the signal louder, but now you can plug the output of the buffer stage directly into your audio output and give it a listen without interference. And just for fun, this picture shows the input and output on the scope. Working as intended.

Amplifiers and Overdrive

Great. Now we’ve got a nice clean triangle wave oscillator. You’d think we were done here, but we still have five inverter gates sitting unused on the 4069UB. What could we do with five more amplifiers? Five more amplifiers that have a nice smooth rolloff much like old-school tube preamps do? Crank it up to 11 and see how it sounds!

To go from buffer circuit to amplifier circuit, we can either let the input signal flow in more easily (reduce the input resistance) or force the output to work harder (increase the feedback resistance). Either way, the goal is to increase the ratio of feedback resistor to input resistor, and thus the voltage gain.

So let’s build up another buffer circuit, but instead of a 100k Ohm resistor on the input, let’s use a 100k potentiometer so that we can let more signal in. Now it’s an amplifier, with the gain controlled by the ratio of the feedback resistor (at 100k Ohms) divided by whatever resistance we dial in on the input potentiometer. (You could use a larger pot than feedback resistor, and you’d be able to make the circuit quieter as well. But that’s boring.)

As you drop the input resistance down to zero, you’d naively expect the amplification gain to head off to infinity. Instead, we see that the gain reduces gradually as the output voltage approaches the GND or VCC power rails. What happens is that real-world effects like the chip’s amplification rolloff take over. Is this a bad thing? Not if you want a nice soft-clipping amplifier overdrive sound added to our triangle wave. Woot.

buffer_overdrive_schematic

Now as long as we have a bunch of free inverters sitting around, let’s take the output from the overdrive sound and re-amplify it again. The IC’s built-in soft clipping will limit the volume gain, but we’ll get something that’s ever more like a square wave as we keep passing the signal through further amplification stages. Note that the fuzz stage runs at full gain — without negative feedback. We’re going for fuzz distortion here. For my liking, a single extra amp stage suffices to get a nice fuzz tone, but you could chain up as many stages with and without feedback as you want. Heck, half of the chip is still sitting there unused, go nuts.

buffer_fuzz_schematic

Here are some example waveforms from the first-stage amplifier and the second. At the low-gain end of things, you can see that the first-stage triangle wave, in yellow, is not very distorted yet. But as we turn up the gain, the points get rounded over on top and it approaches a round square wave. (“Round square”?) The second-stage output, in green, starts off pretty much squared-out and gets more so. Between the two outputs, you have mild overdrive and full fuzz. Can’t complain about that.

The scope traces below show the overdrive output in yellow and the fuzz output in green with the volume knob turned increasingly up. You can see that the as you increase the gain, the fuzz channel takes off essentially where the overdrive channel leaves off.

triangle_montage

And don’t hesitate to feed other audio sources into this chip. A version of this circuit dates back to the late 1970’s, known as [Craig Anderton’s] “Tube Sound Fuzz” from his book Electronic Projects for Musicians. My wasted youth doesn’t look so wasted anymore, huh?

Sawtooth Waves

OK, so we’ve got a nice variable overdrive version of the triangle wave oscillator. What else can we do with our newfound analog powers? Here, the most bang for our breadboard buck is to add a diode into the feedback path of the oscillator, turning the triangle wave into a sawtooth.

buffer_sawtooth_schematic

How does that work? Well, instead of charging and discharging the timing capacitor through the feedback resistor as we’ve been doing, we charge it much faster through the diode. This makes the input voltage jump up, setting the output low almost instantly. The diode only conducts in the charging direction, so the capacitor has to discharge slowly through the feedback resistor. This goes on until it hits the threshold value where the output goes high again and charges up the capacitor very quickly through the diode again. In short, we’ll end up with a voltage waveform on the input here in yellow, and on the output here in green:

saw_pulse_scope

Now all that’s left to do is pass this sawtooth through the buffer amplifier above. That’s that raspy, bowed-string sound that a sawtooth wave makes. Played down low, you get the classic acid-house bassline. Go nuts. But wait, there’s more. We have a sawtooth plus overdrive, plus full-on fuzz.

Below is the scope trace from medium and full gain for the overdrive output in yellow and the fuzz output in green. With the sawtooth wave, the fuzz ends up converting the sawtooth into a kind of pulse wave. It’s not symmetrically square both because our sawtooth isn’t perfectly straight and because there’s some DC offset voltage propagating through the three stages that we haven’t been careful with. If you want to remove that, you can insert something like 0.1uF blocking capacitors between the stages, but I feel you lose some of the gritty character of this thing by doing so.

sawtooth_montage

Next Installment: Filters and Drums

Now that we have some classic analog synth waveforms under our belts, it’s time to add some filter effects and drums. To do so, we’ll continue down the analog path that we started this time, so if you don’t already have a couple of 4069UBs at hand, you have another week to scrounge some up.


Filed under: digital audio hacks, Featured

Logic Noise: Filters and Drums

$
0
0

Filters and Drums

Logic Noise is an exploration of building raw synthesizers with CMOS logic chips. This session, we continue to abuse the 4069UB as an amplifier. We’ll turn the simple unity-gain buffer of last session into a single-pole active lowpass filter with a single part. (Spoiler: it’s a capacitor.)

While totally useful, this simple filter is a bit boring and difficult to make dynamic. So we’ll look into an entirely different filter, the Twin-T notch filter, that turns out to be sharp enough to build a sine-wave oscillator on, and tweakable enough that we’ll make a damped-oscillator drum sound out of it.

Here’s a quick demo of where we’re heading. Read on to see how we get there.

Filters

Last session, we built an amplifier and played around with the gain: the ratio of how much voltage swing is output relative to how much is input. An active filter is an amplifier where this gain depends on the frequency of the incoming signal. This lets us carve out different frequency ranges that we’d either like more or less of. (In general, though, you don’t need an amplifier to filter. See passive filters versus active filters.)

When you pluck a string on a guitar, for instance, all sorts of frequencies are produced. But over time the string vibrations are damped out by the wood that the guitar is made of, and within a half-second or so, most of the vibrations left are related to the string’s fundamental vibrational frequency (determined by where your finger is on the frets). The higher frequency vibrations are the first to go. This suggests a sound synthesis strategy to make “natural” sounding instruments: generate all sorts of frequencies and then filter out the higher ones.

Single-pole Lowpass Filter

Given that we’ve already made a few simple amplifier circuits last time, it’s a quick step to understand the simplest of all filters: the single-pole filter. Here’s the circuit diagram:

filter.sch

Yeah, that’s an added capacitor. That’s all there is to it. But have a listen to the difference:

Remember the intuition about the negative-feedback amplifier from last time. We had two resistors, one between the input and the 4069, and the other in feedback between the (inverted) output and the input. When the input voltage wiggled around the 4069’s neutral voltage, the output wiggled in the opposite direction. And the ratio of the voltage swings, the gain, depends on how hard the feedback path has to work to cancel out the incoming signal current.

The same intuition works for the filter, as long as you understand one thing about capacitors. Capacitors pass current through them only reluctantly. The amount of current a capacitor passes before it’s “charged up” to a voltage that resists any further incoming current is referred to as its capacitance. Or, in electro-math: C = Q/V or V = Q/C, where Q is the charge on the capacitor, which is also the current (charge per second) summed up over time.

In short, the more charge you put into a capacitor, the higher voltage it develops to resist putting more charge into it. And how quickly this voltage ramps up is proportional to one over the capacitance and directly proportional to the current passing through.

For us, this means that it’s easy to pass a given current through a capacitor for a short while, harder to pass the same current through for a longer time, and impossible to get current through forever without increasing the input voltage to overcome the capacitor’s “charged-up” voltage. Or put another way: capacitors let high frequency current vibrations through easily, resist middle frequencies, and deny constant-voltage direct current.

So what happens when we put a capacitor in the feedback path of our unity-gain feedback amplifier? Since the capacitor nearly blocks very low frequencies, all of them have to pass through the resistor, and we get unity gain. As we increase the frequency, some of the current starts to pass through the capacitor and the total feedback resistance is lowered. This means that the output has an easier job cancelling out the input, and thus less gain at middle frequencies. At very high frequencies, the capacitor will pass currents so easily that almost none will even need to go through the resistor, and the gain drops even lower.

Put more succinctly, the capacitor resists lower frequencies more than higher ones. In a negative feedback amplifier, output gain increases when it’s harder to push current through the feedback path. So by putting a capacitor in the feedback path, we make an amplifier with more gain in the low frequencies and less gain for higher frequencies. Voila, a lowpass filter!

Variable Cutoff Lowpass Filter

What if we want to vary the cutoff frequency? In math, the cutoff frequency for a single pole lowpass filter like this is 1/(2 * pi * R * C). Practically, we can vary the cutoff frequency by changing the capacitor or by changing the input current through the resistor. So we’ll set the basic range by picking a capacitor value and vary the filter’s frequency response by turning a potentiometer. For the circuit here, the cutoff frequency ranges from 160 Hz at 100k ohms to 1600 Hz at 10k ohms.

But there’s one catch with varying the input resistor; we also change the overall gain which depends on the ratio of feedback resistor to input resistor. So if you’re going to be changing the frequency response by changing the input resistor a lot, you might also want to change the feedback resistor at the same time to track it, holding the overall (passband) gain roughly constant. For that, you’ll need a stereo / dual potentiometer, which is simply two potentiometers linked to the same shaft. With one knob, you control two identical resistors.

Before we leave the single pole filter, you can convert the lowpass filter here into a highpass filter simply by moving the capacitor out from the feedback loop and sticking it in front of the input resistor. Give it a shot!

Twin-T Filter

Our story gets significantly more interesting if we toss a more complicated filtering element in the feedback path, and one of our favorite filters is the Twin T. Instead of being a lowpass filter like the one above, the Twin T is a notch filter. Notch filters pass both high and low frequencies, but are tuned to knock out a particular frequency in the middle.

In its raw form, the Twin T filter is fairly useful for killing a specific nuisance frequency in a signal. Maybe you want to knock out power line noise (60Hz in the USA, 50Hz in Europe). Toss a Twin T filter that’s tuned to 60Hz into the chain, and you’ll get rid of most of the noise without damping down the rest of your signal very much. To see why it’s called a Twin T, have a look at the circuit diagram:

twint.sch

The Twin T works by combining two signal paths, each one T-shaped. The T with two resistors and a capacitor to ground is a simple lowpass filter, essentially a passive version of the one we made above. The other T with the series capacitors and resistor to ground is a highpass filter.

Highpass and lowpass sounds like everything should get through, right? Yes, but. At the frequency that the filter is tuned for (the “cutoff” frequency) the two outputs are exactly 90 degrees out of phase from the input, but in opposite directions. In theory, if both Ts are tuned to the same frequency the two paths exactly cancel each other out at the cutoff frequency and none that cutoff frequency makes it through at all. In reality, you can actually get the two branches fairly close to each other and get very good, but not perfect, cancellation of the tuned frequency.

What happens when we put a Twin T filter into the feedback path of an amplifier? Remember that the negative feedback logic requires the output to create more voltage the harder it is to push current back through the feedback path. So instead of knocking out the frequency that the filter is tuned to, we get that one particular frequency amplified. If there’s a little bit of noise entering the input at our tuned frequency, it’ll get amplified a lot and all of the other frequencies will get attenuated. And suddenly you’ve got a sine-wave oscillator.

Drums

Which brings us to today’s killer circuit, and a little bit of a refinement on the above explanation. The short version is that we detune the Twin T filter a little bit so that it only rings when it’s given an impulse and then dies out.

First let’s play a little bit and build up the Twin-T and 4069UB amplifier part of the circuit. It’s just the Twin-T filter from above set up in the feedback path of a 4069UB inverter stage, and then sent out directly through another 4069UB inverter as a buffer. It’s overdriven and you’ll hear the clicks of the trigger bleeding through, but it’s a start.

drums_simple.sch

Refinements

With the basic circuit working, let’s expand on it in two different ways. First, we’ll drive the drum with another oscillator circuit. Then, we’ll pass the audio out through a lowpass filter to knock off some of the trigger pulse bleedthrough.

Here’s the final circuit:

drums.sch

Starting on the left, we have a very low frequency oscillator set up on the 40106 and buffered using another 40106 stage. This simply puts out a nice reliable square wave. The signal then passes through a capacitor, which again has the effect of letting only the higher frequencies pass through. What makes it through looks basically like a quick pulse (in green).

drum_square_to_trigger

The trigger signal pulse is inserted into the feedback loop of the Twin T. It’s actually not crucial where you attach the trigger, but it’ll couple less with the Twin T section if you connect it here.

And finally, we’ll pass the signal through a lowpass filter to remove the clicky noise that comes from the raw trigger signal feeding through to the output.

Range

What values should we use for capacitors and resistors? Try to pick the component values so that the single capacitor in the lowpass T is twice as large as the two capacitors (2 C) and the single resistor is half as large as the paired resistors (1/2 R). This makes both Ts tune to the same frequency, given again by 1/(2*pi*R*C) where R and C are the values of the paired resistors and capacitors respectively.

In practice, try to get factor-of-two capacitors and leave the resistors adjustable wherever possible. Since we’ll be de-tuning the circuit on purpose to make the oscillations die out slowly, there’s not a reliable formula for the resistances. You’ll just have to pick capacitors and tweak the knobs until it works. That said, if you find you want frequencies outside of the range that you’re currently getting, don’t hesitate to swap out the capacitors.

Tweaking and Tuning

Detuning the Twin-T section is the secret to making this circuit work as a drum rather than as a sine-wave oscillator, and the approach you’ll have to take is a bit experimental, so let’s talk about tuning this circuit. If you align the two halves of the Twin T perfectly, as we mentioned before, only the one single frequency will be blocked, and thus only that one frequency will be amplified by the negative feedback circuit. You’ll get a very nice sine wave oscillator, but not drums.

If you detune the two halves of the Twin T from each other, especially if you do so by raising the cutoff frequency of the highpass filter so that it’s higher than the lowpass filter, a wider and wider band of frequencies are blocked by the Twin T, and thus receive the extra gain from the amplifier.

But as you spread the gain over a wider and wider band of frequencies, you get less gain at any given frequency. As you continue to detune the Ts from each other, you’ll reach a point where the circuit no longer amplifies any single frequency enough to oscillate indefinitely by itself. However, and this is the key here, the filter will oscillate for a while if you provide it with a strong enough impulse signal. And that’s exactly what we’re doing with the square wave coupled through the capacitor coming from the tempo oscillator. It’s nice to watch the damped waveforms on a scope if you’ve got one.

drum_trigger_and_pulse

So here’s a procedure for getting close to your desired sound. To enable oscillation over a wide range of frequencies, set the decay potentiometer as low as it will go. This sets the highpass leg of the T to a very high cutoff frequency, which means that it’s passing nearly nothing. This frees up the lowpass T section to determine the pitch, and for most of the tuning potentiometer’s range you’ll get oscillations. Pick the rough pitch you want by listening to the oscillator. Now you can tune up the decay pot until the oscillations are just damped out and you’ll be set.

But notice that the two potentiometers influence each other a little bit. That’s because the two legs of the T are simply electrically connected. So as you increase the decay to go from oscillator to drum, be ready to also tweak the frequency potentiometer to keep the drum tone at your desired pitch and decay rate.

Extensions

If you’re interested in exploring more active filter designs than just the single pole lowpass shown here, have a look at Rod Elliott’s great writeup on active filters. You can either break down and use op-amps and dual power supplies, or you can keep hacking and replace any of the op-amps in his circuits with a 4069UB stage as long as they only use negative feedback and have the op-amp’s positive terminal connected to ground. In particular, have a look at the multiple feedback topology and the biquad.

If you don’t need synth drums, you can simply tune the Twin T up and use the circuit as a sine wave oscillator. For a single set of capacitors it’s not very widely adjustable, but if all you need is a single frequency you can pick the right capacitors and you’re set. It’s not the best sine wave oscillator out there, but it’s hard to beat a one-chip build with a few passive components thrown in.

But don’t take our word for it: here’s a scope shot. The yellow line is the produced sine wave, and the purple is a FFT of the signal. Vertical bars are 20dBV, or a factor of ten. The first peak, at 150Hz is our sine wave, and the second peak is down in voltage by about a factor of 100. It’s not lab equipment, but it’s pretty solid for the abuse of a CMOS logic chip.

scope_0

And there’s nothing stopping you from feeding the circuit with audio-frequency trigger pulses if you want to freak out. The result is very similar to the sync oscillator we built before but it’s a lot mellower because the waveforms involved are fundamentally sine waves here.

Have fun!


Filed under: digital audio hacks, Featured, musical hacks

Logic Noise: More CMOS Cowbell!

$
0
0

Logic Noise is an exploration of building raw synthesizers with CMOS logic chips. This session, we’ll tackle things like bells, gongs, cymbals and yes, cowbells that have a high degree of non-harmonically related content in them.

Metallic Sounds: The XOR

I use the term “Non-harmonic” in the sense that the frequencies that compose the sound aren’t even integer multiples of some fundamental pitch as is the case with a guitar string or even our square waves. To make these metallic sounds, we’re going to need to mess things up a little bit, and the logic function we’re introducing today to do it is the exclusive-or (XOR).

An XOR logic gate has two inputs and it outputs a high voltage when one, and only one, of its inputs is at the high voltage level. When both inputs are low or both inputs are high, the output of the XOR is low. How does this help us in our quest for non-harmonic content? It turns out that the XOR logic function is the digital version of a frequency mixer. (Radio freaks, take note!)

Ideal frequency mixers take two input frequencies and output the sum and difference of the two input frequencies. If you pipe in 155 Hz and 200 Hz, for example, you’ll get out the difference at 45 Hz and the sum at 355 Hz.

Because we’re using square waves and an XOR instead of an ideal mixer, we’ll also get other bizarre values like 2*155 – 200 = 110 Hz and 2*200 – 155 = 245 Hz, etc. All said, the point is that we get out a bunch of frequencies that aren’t evenly divisible by one another, and this can make for good metallic sounds. (And Dalek voices, for what it’s worth.)

The 4070: Quad XOR

4070_pinout

Which brings us to our logic chip du jour. The 4070 is another 14-pin wonder, just like the 40106 and the 4069UB and the power and ground pins are in the same places. Since an XOR gate is a three-pin deal, with two inputs and one output, only four XORs fit on the 14-pin chip instead of six inverters.

By now, you’re entirely used to the 4000-series logic chips, so there’s not much more to say. This is a great chip to add sonic mayhem very easily to your projects.

Frequency Modulation with XOR: More Cowbell!

Let’s make some metallic noise. The first step is to mix two oscillators together. Whip up two variable-frequency oscillators on the 40106 as we’ve done now each time, and have a listen to each individually. Now connect each output to the inputs of one gate of an XOR in the 4070. As promised, the resulting waveform is a lot more complex than either of the two inputs.

Now tune them around against each other and listen to all the strange frequency components created as the sums and differences slide in and out. Cool, no? Here’s a bonus video that you can skip, but that demonstrates what’s going on with the frequency mixing.

Two-diode VCA

After a couple of minutes playing around, you’ll start to realize that this sounds nothing like a cowbell. We’ll need to shape the volume of the sound in time to get anywhere, and this means another step in the direction of “traditional” synthesizers. We’ll build up a ghetto voltage-controlled amplifier (VCA) and drive it with the world’s simplest envelope generator.

An active VCA takes its input signal and either amplifies or attenuates it depending on the control voltage (CV) applied on another input. When the control voltage is high, more of the sound gets through, and when the CV is zero, the output is ideally silent. Building a general-purpose VCA is a bit out of scope for our needs, so let’s just cobble something together with a few diodes.

This circuit works by cheating, and works best with digital logic signals like what we’ve got. When the input from the XOR is low, diode D1 conducts in its forward direction and all of the control voltage signal is “eaten up”, sunk into the output of the XOR chip.

Conversely, when the XOR is high, diode D1 is reverse-biased and blocks the CV, leaving it nowhere to go except through diode D2 and out to our amplifier. The resistor needs to be large enough that the XOR can sink all of its current, but otherwise the size is non-critical.

cap_square_to_pulesNotice what’s happened here. The voltage at the output is no longer the GND to VCC of our logic circuit, but instead ranges only from GND to the control voltage (minus a diode drop). So if we want to make a quieter version of the XOR input, we just lower the control voltage. It’s a simple voltage controlled attenuator. Now we just need to create a voltage signal that’s got something like the amplitude contour of a cowbell.

Remember how we converted square waves into trigger pulses by adding a series capacitor? The resulting voltage had this steep rise and exponential trail-off.

If we add in another capacitor, we can lengthen out the decay. And then while we’re at it, we can add in a potentiometer to control the rate of that decay.

diode_vca_with_envelope_no_diodes

Capacitor C1 converts the square wave into a pulse and charges up C2 very quickly, applying the positive voltage to the input of our VCA. The charge on C2 drains out through the variable decay potentiometer.

This simple circuit actually works well, but has one shortcoming. For long decay times, as illustrated above, the decay gets cut off when the control square wave goes low. If you only want short percussive hits, the simple circuit is enough. If you’d also like longer decays, you’ll need to add a couple diodes to chop off the negative part of the control voltage spikes.

diode_vca_with_envelope_sustain_no_diodes

Now that only periodic positive spikes are getting though to our decay capacitor, we have a nice variable-rate exponential decay voltage envelope. Here’s how it looks on the scope (with some extra capacitance slowing down the attack — envelope_with_xor_drumit might have been connected to the laptop soundcard). You can clearly see the control-voltage envelope chopped up by the diode action and the XOR’s output.

Putting the XOR frequency-modulated sounds through the two-diode VCA that’s driven by our quick and dirty envelope generator gets us a percussive metal sound.  But it it cowbell?  We still have to tune the oscillators up.

The classic, love-it-or-hate-it, cowbell sound of the 1980’s has to be the Roland TR-808. And if you look through the 808 service manual (PDF download) you’ll see that it uses two square waves from a 40106 chip simply mixed together. We’re improving on that by XORing, but we can still learn a bit from Roland. In particular, they tune their oscillators to 540 Hz and 800 Hz.

Because we’re XORing two oscillators together, our peaks come in at the sum and difference frequencies. This means that we’ve got to solve X + Y = 800 and X – Y = 540. Grab pencil and paper, or just believe me that you’ll want to tune up the individual square wave oscillators to 130 and 670 Hz respectively. At least, to get something like that classic cheesy cowbell sound.

Amplification Aside

We’ve been trying to stick to the use of purely CMOS logic chips here, but this session we broke down and used a transistor. The reason is that the audio input on our laptop insists on a bipolar, centered audio signal. In contrast, the output of our “VCA” sits mainly at zero volts with very short peaks up around one volt. The input capacitor in the laptop is charging up and blocking the VCA’s diode output. Boo!

Indeed, we can’t use our old tricks with the 4069UB as an amplifier here either. The 4069UB works great for signals that are centered around the mid-rail voltage, but distorts near either GND or VCC. Unfortunately, we’d like our quiet drum sounds to taper off to zero volts rather than the mid-rail, so we’ll have to use something else to buffer our audio with.

quick_and_dirty_transistor_amp.sch

The solution is to buffer the output with something suited to this unipolar signal, and the simplest solution is a plain-vanilla NPN transistor hooked up as a common-emitter amplifier common-collector amplifier. This configuration is a very useful analog buffer circuit; it puts out almost the same voltage as the input, but draws directly from the VCC rail and will certainly handle any sound card’s input capacitor. We used a 2N3904, but a 2N2222 or BC548 or whatever will work just fine.

Cymbals

Cymbals and similar metallic percussion instruments were pretty tricky to synthesize in the early days of drum machines. Until the LinnDrum introduced sampled cymbals, most just used a shaped burst of white noise. The aforementioned TR-808 used six 40106 oscillators linearly mixed together to approximate white noise. Again, we’ll improve on that by running it all through XORs with the result being somewhere between many oscillators and pure noise depending on how you set the oscillators up.

The inspiration for this circuit is the fantastic Synbal project (schematic in PDF) from “Electronics & Music Maker” magazine in 1983. It’s a much more complicated affair than what we’re doing here, but if you look at the left-hand side of the schematic, that’s the core. (If you’re copying the Synbal’s fixed frequencies for the oscillators, note that he uses 0.01 uF capacitors and we use 0.1 uF caps. Divide the feedback resistors by ten accordingly.)

cymbals.schThe trick to the cymbal circuit is making a lot of oscillators. We’ll hook up six of them, finally fully fill our 40106 chip. Then combine any pair in an XOR, take the output of that XOR and combine it with another oscillator. You’ve now got a complex oscillator that’s used up three 40106 oscillators and two XOR gates. Repeat this with the remaining oscillators and XOR gates and you’re nearly done. Connect the final two XOR outs through resistors to the output.

As with the cowbell circuit, this circuit can be made to sound “realistic” by picking the different component frequencies just right and tweaking the decay. We think that it makes a pretty decent hi-hat sound with a couple of the oscillators pitched high (1 kHz and up). On the other hand, if you’re into noise music you can skip the VCA altogether and tune the oscillators to similar, low frequencies. You get a vaguely metallic, almost rhythmic machine drone. Not to be missed.

Extensions

We’ve snuck it in under the guise of making a cowbell sound, but the quick-and-dirty VCA here is also useful for modulating most of the synth voices we made in the first few sessions. We went for a percussive attack by using a capacitor to couple the driving square wave to the VCA, but there’s no reason not to use a variable resistor in its place to charge up the capacitor more slowly. If you do this, note that the attack and decay potentiometers will interact, so it’s a little quirky, but what do you want for two diodes anyway? Also note that any other way you can think of delivering an interesting voltage to the junction of the two diodes is fair game.

The XOR-as-frequency-mixer technique is pretty great, but you can also get a lot of mileage by using the XOR as a logic chip. Combining different divided-down clock outputs (from a 4040, say) with XORs makes interesting sub-patterns, for instance. And we’ll get more use out of the XORs in two sessions when they’re coupled with shift registers.

Next Session

We’ve got a whole lot of possibilities by now. We’ve got some good, and some freaky, percussion voices. We’ve got a bunch of synthesizer sounds, and if you recall back to the 4051, we’ve got a good way to modulate them by switching different resistors in and out. It’s time to start integrating some of this stuff.

If you’re following along, your homework is to build up permanent (or at least quasi-permanent) versions of a couple of these circuits, and to get your hands on at least two 4017 decade counter chips. Because next week we’ll be making drum patterns and introducing yet one more way to make music.


Filed under: digital audio hacks, Featured, musical hacks, slider

Logic Noise: Sequencing in Silicon

$
0
0

In this session of Logic Noise, we’ll combine a bunch of the modules we’ve made so far into an autonomous machine noise box. OK, at least we’ll start to sequence some of these sounds.

A sequencer is at the heart of any drum box and the centerpiece of any “serious” modular synthesizer. Why? Because you just can’t tweak all those knobs and play notes and dance around at the same time. Or at least we can’t. So you gotta automate. Previously we did it with switches. This time we do it with logic pulses.

The 4017 Decade Counter

The featured chip this session, the one that gets it all done, is the 4017 Decade Counter. It’s a strange chip, left over from the days when people wanted to count things using IC logic chips instead of just running the input into a microcontroller. But therein lies its charm and usability.

4017_pinout

At its simplest, you input a clock signal and one of ten different outputs (Q0-Q9) is set high while the others are all low. On the next rising edge of the clock, the next output is set high and the previous is set low. This goes on until the count loops around the end.

One feature that makes the 4017 super useful is the reset pin. When a high voltage is set on reset, the first output (Q0) is set high and all the others zeroed out — the chip starts counting at zero again. The cool trick here is that you can connect the reset pin up to one of the Q outputs and the counter will automatically reset once it reaches that output. If reset is connected to Q2, for example, the count will go Q0 then Q1, and then immediately reset back to Q0 again: Q0, Q1, Q0, Q1… If you wanted an octal (divide by eight) counter, you just hook the reset pin up to Q8.

4017_timing

Eight steps is pretty standard (boring?) and you can get nice groove patterns by selecting odd sequence lengths. But if you want your standard drum machine, hooking the reset up to Q8 is the way to go.

Looking at the timing diagram, notice that the reset pin can also be used asynchronously. That is, the chip will reset as soon as the reset line goes high — it doesn’t wait to finish the current clock cycle. Here, for instance, we hit reset while clock step five (on Q4) was still active.

Async reset means that your reset source can come from outside the 4017 chip and its counter. For instance, you could connect the reset line through a pushbutton to VCC and reset the sequence at will. (If you do this, consider a pulldown resistor on the reset line to keep the voltage level well-defined when the button isn’t pressed.)

There are two more pins left over. The “Carry Out” pin is low when Q0-Q4 is high and high when Q5-Q9 are high. When the chip is counting up to ten, this produces a nice square wave with a cycle once for every ten counts. As the name suggests, this can be fed into another 4017’s clock input and you’ll have a count-to-100 device. Chain up the next carry out to a third 4017, and you can count up to 1,000 clock pulses. (Tie all the reset lines together to zero them at once, if you’re actually counting.) Carry out is less useful for us, but we’ll play around with it a tiny bit next session anyway.

Finally, there’s the “Inhibit” pin. In most implementations of the 4017 chips, setting inhibit high makes the chip ignore the incoming clock pulses. Some manufacturers’ chips have some slightly more clever logic where the inhibit line can be dual-purposed to count up for high-to-low transitions if the “clock” line is held low and the “inhibit” line toggled. We’ll not be using this feature, so just remember to tie the inhibit line (pin 13) to ground so that it’s not glitching around.

Back to what matters here. We’ve got a chip that’ll put out logic voltage signals on one pin after the other, clockable and resettable. That’s the heart of a simple sequencer. Most of what we’ll be doing this session is making these voltage steps play well with our quick-and-dirty CMOS logic synth modules.

The Basic Sequencer

The sequencer that we’ll be building up this session is nothing more than a 4017 clocked by a 40106-based oscillator that’s running at a “tempo” frequency rather than at audio rates. Indeed, you could stop there. But for the low, low price of another 4017 logic chip, some LEDs and resistors, you can have something deluxe.

Our version of this simple sequencer is going to be built from two 4017s with the clock and reset lines in common between them. This means that the two 4017’s will run in lockstep with one another at all times. We can use one 4017 for driving our synth devices and the other for driving ten status LEDs, without having to worry about the LEDs pulling the output voltages low if they draw too much current.

dual_4017s.sch

 

Of course, if you don’t want the LEDs, you can entirely omit the second 4017 from the circuit. Or if you’re feeling lucky, you could hang the LEDs off of the signal outputs directly. But since we’ll be already demanding a little bit more current from the 4017s than they’re designed for, we think it’s easily worth the extra chip for insurance and convenience. Plus, it makes for a lot cleaner layout on the breadboard.

Gating Oscillators with the 4017 Sequencer

The first thing you’d probably like to do with the sequencer is to play a bunch of notes. The quick-and-dirtiest way to do that with our current setup is to construct one oscillator per note you’d like to play and then have that oscillator sound only when the corresponding “Q” output of the 4017 is set high. That should be easy enough, and it is.

If you remember back from our first session, we used a diode to create a hard-sync oscillator sound by gating one oscillator with another. The oscillators all work by charging up a capacitor through the feedback resistor, recall, so if you can drain enough current out to prevent the capacitor from charging up, you can silence the oscillator.

4017_and_oscillators.sch

 

First look at the single audio oscillator on the top right, connected to the 4017 through input “A”. When the corresponding 4017 output is low, whatever current passes through the feedback resistor (RV2) to charge up the capacitor (C2) will get sucked out the diode (D1) into the 4017, and the oscillator won’t oscillate. When the 4017’s output is high, the diode blocks and the oscillator is free to do its thing. Easy and done.

The Diode OR Gate

But what if we want one note to fire multiple times? Here’s an interfacing trick that can be handy, called “Mickey-mouse” logic or less imaginatively, diode logic. The idea is that you can set up the desired default logic state with a pull-up or pull-down resistor, and then override it with signals coming in through a bunch of diodes. To add more inputs to the OR all you have to do is add more diodes to the circuit, which makes it useful when you need something odd like a seven-way OR function.

diode_or.schConsider inputs B, C, and D in this snippet from our full schematic. When none of B, C, or D are high voltage, none of the diodes (D2-D4) will be conducting, and the pulldown resistor (R3) will set the voltage going into diode D5 low, pulling current out of the oscillator and stopping it from working. When any of B, C, or D are logic high the 4017 will pass current through the corresponding diode and out to the junction with the resistor. When this point is high, the diode D5 won’t conduct and the oscillator runs, just as in the single-step version above it.

Why the diodes D2-D4? If one stage of the 4017 is high, say B, the other two must be low. Without the diodes in the circuit, we’d be shorting the two pins of the 4017 together, and all bets are off about the voltage at the junction labelled “Diode OR”. These diodes keep one pin of the 4017 from fighting with another.

Picking the value for the resistor in the diode OR circuit is a little critical. It needs have a low enough resistance that it can pull down the oscillator circuit. So R3 needs to be less than the value we’ve got dialed in on the variable resistor that tunes the oscillator (RV3). But R3 needs to be large enough that when the 4017 pushes its high voltage through the output diodes, the voltage at the junction rises enough to block diode D5.

The 4017 is only specified for an input or output drive current of three milliamps with a 10V supply, and only one milliamp at 5V, which means that we should use a pulldown resistor no smaller than 2.2K as a pulldown if we want a voltage higher than VCC/2 at the diode OR’s junction. Use something even larger helps reduce the demand for current on the 4017.

Indeed, it’s this requirement for the 4017 to source a bunch of current that motivates using a second 4017 to handle the LEDs. Our 4017 datasheets only specifies three milliamps of output drive or sink current connected to a 10V supply. (And this drops to one milliamp at 5V VCC.) With 1K resistors on the LEDs, we’re probably already drawing five to ten milliamps — way more than the chip is specified for. Adding more load to a single 4017 chip to drive the diode OR, or even more outputs, is asking for trouble. You could imagine buffering each output of the 4017, but at some point it’s just easier to toss another 4017 into the design.

Anyway, technical details aside, that handles controlling individual oscillators from the sequencer. And we’ve seen how to run one oscillator from multiple sequencer stages. With six oscillator per 40106 chip, you should be able to make reasonable melodies with a minimum of parts.

Gate-to-Trigger Pulse Circuit

Now it’s time to drive our percussion. If you remember the two-diode VCA from our Cowbell session, we actually built out a “gate to trigger” converter. In modular synth lingo, a “gate” signal is a logic signal that stays high as long as (for instance) a key is pressed, and then drops back down low instantly when it’s released. The 4017’s individual outputs look a lot like a gate signal — each output is high during its complete step and only during its step. Or cymbal’s decaying amplitude circuit, on the other hand, needed a quick pulse at the start of the step, called a “trigger” signal.

diode_vca_interface.sch

At the heart of the gate-to-trigger circuit is a capacitor (C1). Changes in voltage on one side of the capacitor let a bit of current through until the capacitor has charged up enough to resist further current. This turns the leading and trailing edges of our gate signal into positive and negative spike pulses.

We choose to only pass the positive voltage spike by using a diode (D5). The remaining problem, that we glossed over in the Cowbell session, is that the negative spike doesn’t pass through D5. In fact, without the diode pointing up from ground (D7) in the circuit, the right-hand plate of the capacitor C1 would get stuck at a negative voltage with respect to ground. Additional positive pulses sent through from the 4017 on the left-hand side would maybe raise the voltage up as high as zero volts, but certainly wouldn’t be enough to pass through diode D5 and make a sound. In short, you’d have one hit and then you’d never hear it again.

The diode up from ground (D7) prevents this situation by charging the right-hand side of C1 up to at least a diode-drop less than 0V after each negative spike. This makes the gate to pulse circuit work a little bit like a pump; when charge is pushed through the capacitor from the 4017 side, it passes through D5, and when charge is pulled back the other way it is sourced through the D7 “check valve” from ground.

If you buy that analogy, the rest of the cymbals interface circuit should be clear. A diode OR on the left-hand side allows multiple cymbal hits. Again, the choice of the pulldown resistor is important, but here there is a lot less demand for it to be tiny. The resistor R2 is only responsible for discharging the left-hand side of capacitor C1 between hits. If you’re running fast sequences, experiment with lower values.

Variable Trigger Pulse for the Twin-T Drum

Again, for the bass drum sound, we’re going to need a gate-to-trigger circuit, and aside from using a smaller capacitor than the one above, it’s just the same. But one thing we really like about twin-t drum circuits is the volume dynamics across different input voltage spikes. That is, if you hit the twin-t with a small voltage spike it’s quiet, and if you hit it with a large voltage spike it gets loud. Adding in this kind of variation into your drum patterns make them sound less robotic, so it’s worth thinking about and spending a couple of resistors on. And indeed, that’s all that we’ll need.

4069_drums_interface.sch

This circuit combines the outputs from the 4017 in an effective voltage divider. Since only one of the 4017’s outputs will be high at any given time, we can figure this out pretty quickly. When A goes high, there’s a voltage divider to ground formed by the 22K resistor R1 and the two 100K resistors in parallel, R2 and R3, for 50K. The voltage output at the junction of the resistors is 22 / 72 * VCC, or about 2.75V with a 9V supply.

When either of B or C is high, the effective resistor to ground has the parallel resistance of 22K and 100K resistors, or 18K. The resulting voltage spike has a peak around 1.4V, so it sounds a bit quieter. All of these pulses have to pass through the diode D1 as well, so they’re probably attenuated even further. You can just play around with the values until they sound right.

Output Mixer and Final Details

Finally, all of the various sound sources are combined simply by passing them through 100K resistors and connecting them together at the amplifier’s input. This simple summing “mixer” is quick and dirty and works just fine. If you want one sound source quieter or louder, you can change these resistor values within reason: how much you can get away with depends on the input impedance of the amplifier you’ve got it hooked into. Factors of two are probably OK. Experiment.

A more engineered solution involves removing the DC offset from each sound source and summing them (probably with variable gain) using operational amplifiers or similar. That’s a great idea, but that’s also another project in itself.

Inspiration

The classic 4017-based sequencer is the “Baby 10“.  The original was intended to drive voltage-controlled analog gear, so it put out an adjustable voltage with each step in addition to the on-off gate signals that we’re using. If you’ve got anything that’ll take control voltages, it’s easily worth the ten potentiometers to build out a full Baby 10. You’ll find tons of links on the web.

Next Session

This session was all about sequencing for control. Next session we’ll go back to crazy. We’ll continue to use the 4017, although next time in “unexpected” ways. But the main attraction is going to be a shift register, specifically the 4015. Mayhem ensues!


Filed under: digital audio hacks, Featured, musical hacks, slider

Logic Noise: Taming the Wild Shift Register

$
0
0

One of the best things about DIY synth building is that you can create devices that just don’t exist in the commercial marketplace. In this session, we’ll build a looper / sequencer the likes of which you may have never seen. And it’s groovy. Today we’ll also get back a little closer to the soul of the series. In this session, nothing is analog — this is pure Logic Noise.

The shift register is the centerpiece chip this session, and a great device in its own right. We’ve got a lot of ground to cover, so watch the teaser video and then let’s get going.

4015 Dual Shift Register

Shift registers are most commonly used as serial-to-parallel or parallel-to-serial converters. That is, they either take in a bunch of bits singly and then output them all at once, or they take in a bunch of bits all at once and then spit them out one by one. The 4015 is a (bit obscure) member of the former group.

Inside a shift register are a bunch of one-bit memory cells implemented as type D flip-flops. Each cell stores its input value when it receives a clock signal. What makes it a shift register is that the cells are arranged in a line, with a typical cell’s input hooked up to the output of the cell before it. When the clock pulses, the value in the first cell is transferred to the second, which transfers its value to the third, etc.

Think of a bucket brigade — a line of people passing buckets in one direction. Here, whether the buckets are full or not represents a logic state. After four buckets have been passed into the line, for instance, we could tell everyone to stop and look at the contents of their buckets. That’s a simple 4-bit serial-to-parallel shift register.

The 4015 has two completely independent 4-bit shift registers inside. There are a lot of different serial-to-parallel shift register chips out there, each with subtle differences, but it’s the fact that you get two registers in one chip that makes it a nice choice for Logic Noise applications. And, as we’ll see soon, with a little wiring you can easily convert it into a single 8-stage register.

4015_pinout

To use this chip, you connect up power and ground. Pull the “Reset” lines low to enable a register. Say we’re using the A register. Then, on the next positive-going Clock A transition, whatever logic voltage was present on the Data A input gets shifted in and shows up on the 1A output. Whatever value was on 1A gets shifted to 2A, and so on. The value that was on 4A disappears.

One caveat with this chip is that the clock line is picky — it wants nice clean clock transitions. If you’re trying to clock the chip with a dodgy signal, you can use our 40106 inverter with Schmitt trigger for its actual intended purpose (for once) and pass the signal through one inverter stage to get a nice clean clock out of almost any voltage input. That’s not our problem here, though, because we’re using the 40106 as our clock source to begin with.

The other caveat is more applicable, and you’ll see examples throughout the demo videos. The 4015 data and clock lines have very sensitive inputs and love to pick up stray signals. So when you unplug a wire, you’ll often hear crazy noises that are a product of driving the line with your power line frequency (50Hz in Europe, 60Hz in the USA).

The solution is to make sure that you’ve always got a defined voltage on the pin. If you’re going to be doing live-patching, this can be as simple as adding a 100k resistor to ground for any pin you’d like to default low. Most anything you connect will be able to lift the line up, but when you let it dangle it’ll come back down to ground.

Shift Register as Pattern Generator

OK, but why are we talking shift registers here? As you’ve hopefully seen in the teaser video: because they can be used as sequencer-like pattern generators and digital loopers. (And more!)

First, let’s hook up one side of the 4015 and trigger our drum and cymbal circuit with it. We got lazy and only built up three oscillators from the cymbal circuit, so it’s kind-of a cymbal / snare hybrid. We’re going with “snymbal”.

Any one of the four output taps from the shift register can serve as our gate source for the drum or snymbal. But we’ll take the traditional route and attach the bass to output 1A and the snymbal to 3A. (You could double the 3A pulse to the bass drum with a diode OR as we did last session if you really wanted the four-on-the-floor dance beat.)

Now all that’s missing is a clock and data source. A 40106 oscillator with a 10uF capacitor makes a good clock, and in the video we have a bunch of fun by putting another similar oscillator into the data line and de-tuning the two clocks from each other to make some longer rhythmic variations.

The circuit is as simple as the above description. Playing around with it is well worth your time.

first_steps_two.sch

Now if the patterns available in four bits aren’t enough for you, it’s time to connect up the second half of the chip. Because the chip has two independent shift registers, you could simply connect up more clock and data oscillators and away you go. Getting something that sounds good is then a matter of carefully adjusting the clocks to sync up with each other just right. Most people just copy the Clock A line over to Clock B.

If you want to create crazy polyrhythms, you can use the output from a 4017 counter to provide the second clock source. Copy the first register’s clock to the 4017’s input, connect the reset line to the desired rhythmic division, and use any convenient 4017 output (say, Q0 because it always pulses) as the second clock.

But for our purposes, things will get interesting enough soon. So after a little experimentation, we’ll take the most boring option and configure the 4015 as a single 8-bit shift register. To do this, simply connect both clock inputs to the same clock source and connect output 4A to the input Data B. That way, when a bit has worked its way through register A, it’s straight off on its way to register B.

8-stage.sch

Again, the logic of all this is very simple. What’s interesting is the way a shift register creates a stream of pulses that are rhythmically delayed from each other. You just have to hook it up to some sound sources, play around for a while, and you’ll see what we mean. Don’t forget to change up the output taps to see how it changes the resulting patterns.

At some point, you’re going to wish you had more control over the patterns shifting through the registers, and one way is to take over the Data inputs yourself as we did in the video. As mentioned above, these chips are very sensitive to stray signals, so you’re going to need to connect pull-down or pull-up resistors to the data lines to prevent them from taking on variable values when the pushbuttons aren’t pressed.

And soon after that, you’re going to hate having to press the button so often. Wouldn’t it be great if you could set up a pattern and have it simply repeat? The Logic Noise equivalent of a loop sequencer, or something? That’s exactly where we’re headed.

Shift Register as Looper

Making a pattern loop through a shift register is painfully simple. Just connect the last (or whichever) output back into the input data pin to make a data feedback loop. For eight steps, that’s 4B into Data A. For bizarre tempos, you can do whatever you like. Heck, you can even automate this return through a 4051 switch chip and select the number of steps externally. (Foreshadowing!)

looper.schA loop isn’t any fun unless we can insert and remove pulses from it. And conversely, it’s a real hoot once we can. Simply connecting pushbuttons into the data feedback won’t quite work. If you try to ground the data line while the 4015 is trying to drive it high, for instance, you’ll end up drawing too much current from the chip and it’ll glitch out. The solution is to insert a resistor into the feedback loop and connect up your pushbuttons on the Data A side of things.

As with all the examples this session, the circuit is dead simple. We’ve dropped the old Data oscillator, connected output 4B to Data A through a medium-sized resistor (10k should work great), and hooked up pushbuttons to ground and VCC. Almost no pain, tremendous gain.

Looping Oscillators

If you’ve been following along with Logic Noise, you’re already thinking of how to drive oscillators with this shift-register looping sequencer. Indeed, it’s so easy that we did it in the first session. The humble diode gate circuit that we used to create a sync oscillator does just the trick.

looper_oscillator.sch

For instance, when the shift-register’s first output is low, the diode D1 pulls down the oscillator’s timing capacitor (C1) and prevents it from charging up through the variable feedback resistor (RV1).

I’ve summed the oscillators’ outputs together with 100k resistors. Feel free to change the values here if you want one oscillator louder than the others. And feel free to use as many oscillators as you’d like notes or voices.

But do note that it gets cacophonous (or at least polyphonic) pretty darn fast. The difference between a shift-register sequencer and a “normal” sequencer is that you can insert multiple pulses into the shift register. For each pulse, you’ll play the pattern corresponding to the connected oscillators. Even with a small number of pulses circulating, you’d better tune up your oscillators to play nice with each other, because they’ll probably all be sounding together at some time.

The other drawback with this straightforward approach is that it’s simply a lot of wires to hook up. If you want to play eight notes, you need to build up eight individual synced oscillators. So let’s take a minute to build up a pitch generator that plays nice with our shift register looper.

The Melody Generator Aside

As far as I know, this circuit is the invention of folks in the Electro-Music Lunetta forum, but I’m sure it’s older still in some variant. It’s simple and brilliant and creates (mostly) harmonically related pitches with just two chips. It’s easily worth a diversion.

Last session, we used the 4017 counter chip to build a “normal” sequencer that puts out one pulse on each output once per cycle, and does so in order. We also discussed that you can change the length of the sequences by connecting the Reset pin to one of the counter’s outputs to restart the count before the tenth beat.

At its heart, the Melody Generator is just a 4017 counter running at audio frequencies. If we used an audio signal as input to the 4017, with the Reset line grounded, we’d get out a pitch that’s 1/10th of the input. Changing the count by connecting the reset pin to other 4017 outputs gives us other divisions of the input pitch. So far, so good.

Next, we automate the connection of the Reset line by using one of the more versatile chips, the 4051 8-way switch. This means that the 4051’s three select lines control which of the 4017’s outputs triggers its own reset, and thus the select lines control the resulting divided output pitch.

melody_gen_aside.sch 4015_pinout

 

The circuit is fairly simple, but you’ll have to be a little careful connecting up all of the lines if you’d like predictable results; the pins are in “random” order on both chips. Also note that we’re skipping the first two 4017 outputs, and using the first as our output. You want to hook up the 4017’s Q2 to the 4051’s X0 and so on. Here’s a cheat sheet to help.

You must build this circuit. You’ve got the 4017 from last session and the 4051 from a few sessions ago. You have no excuse.

Melody Generator Looper

The beauty of the Melody Generator circuit is that you can think of it as a black box. Feed in an audio-rate logic waveform and a three-bit binary signal, and you get out corresponding divided-down pitches. We can build up the oscillator in our sleep by now, but what about the remaining three logic signals?

If you like complete chaos, you could feed tempo-rate clock signals into the three 4051 inputs. The relative tempos of the oscillators make patterns that change over time depending on how close the oscillators are to being integer multiples of each other. Hard to control, but a freak-out in the good sense of the word.

melody_gen_looper.schIf you like complete order, think back to the way we originally drove the 4051, with a 4040 binary counter. Simply clock the 4040 with a tempo oscillator and you’ll run through all eight notes that the Melody Generator produces. Connecting the taps up in the wrong order can make interesting patterns.

Somewhere in the sweet spot between chaos and order lies this session’s masterpiece circuit: the Melody Generator Looper. All you have to do is hook up the three Melody Generator logic inputs to three different output taps from the looper.

Now be prepared to spend an hour or more exploring what this circuit will do. Add and remove pulses from the cycle, move the taps around, and experiment with how it all interacts with the percussion elements we’ve already built in.

Indeed, what makes this circuit weirdly satisfying is that it lies on the edge of controllability and chaos. When you introduce a pulse into the cycle, it changes the pitch of the Melody Generator’s notes, but it changes the rhythm of whatever you’ve attached as percussion. Only changing the taps around by manually re-wiring the circuit changes the rhythm of the melody. One extra pulse in circulation changes many notes. Somehow, though, it all seems to hang together musically.

Melody Generator Looper Royale with Cheese

So you want fries with that? How can we tweak this circuit to get even more out of it? Well, we’re glad you asked. Here are two simple tweaks that’ll make a real difference.

melody_gen_looper_variations.sch

The first tweak makes the Melody Generator play staccato notes instead of running each note into the next one. It’s the same old gated-oscillator trick all over again, honestly. Just connect up a diode to the capacitor in the audio oscillator that feeds into the Melody Generator, and run the other end down to the looper’s tempo clock.

Now you may have noticed that if you use something like our Twin-T bass drum in this circuit that it doesn’t re-trigger with each new pulse. That is, if you have three pulses in a row, the bass fires once and then not again until after there’s a gap. This is a side-effect of the way that the gate-to-trigger pulse circuit is built. We can work around this.

The cause of the single triggering behavior is that we’re using a capacitor to turn the rising edge of our square wave pulse into a short spike. If the looper-side of the capacitor cannot discharge before the next pulse signal, it doesn’t generate the spike and the drum doesn’t sound again.

The solution is just the same as with the staccato modification; use the tempo clock oscillator to pull the capacitor down halfway through the pulse. But in the case of the cymbal or bass drum interface circuits from last session, they draw a significant amount of current, probably enough to swamp the clock oscillator. So the full solution is to buffer the clock circuit with another stage on the 40106, but in practice you’ll need two stages because you want an actual copy of the clock and not an opposite-polarity copy (though the opposite-phase version makes a nice additional beat, as discovered by mistake in making the video).

Extensions

There’s so much more to do with this looper circuit. First, you could want to insert pauses where the Melody Generator doesn’t play any note. We connected the 4017’s Inhibit line to ground, but if you tie it low with a pull-down resistor you can silence the Melody Generator by sending it a logic high voltage. How to sequence this is left as a challenge to the reader. Driving it with an audio-frequency oscillator, on the other hand, produces something reminiscent of our XOR circuits.

Of course you could chain two 4015’s together to make a 16-step looper. Or more, if you’ve got the breadboard space. On the other hand, there are other shift register chips with longer sequences out there. Just be sure that you’re getting one with enough parallel outputs to be useful. For instance, the 4031 has a 64-step shift register, but only the last step is exposed (that said, you can make an awesome one-bit looper with that chip). Something bizarre like the now-discontinued 4006 would be fun if you can find one. The 4094 gets you eight stages and has some nice extras.

Finally, you can add in a 4070 XOR and make a linear-feedback shift register (LFSR) which is often used as a quick-and-dirty pseudo-random number generator. To make a maximum-length LFSR with our setup, connect taps 4A, 1B, 3B, and 4B back into Data A through cascade XORs. LFSRs aren’t so musically useful that we’re writing them up, but they’re still cool. Picking non-standard taps for your LFSR will create cycles with shorter periods, though, which are worse for random numbers but significantly better for musical applications.

Or use one 4-step shift register for the Melody Generator and the other to choose taps off of a 4040 binary divider for octavey arpeggios. It’s another level of complication, but it’s awesome. You’ll find two late-night YouTube videos here and here.

Next Session

We’re not done with Logic Noise by any stretch of the imagination, but with the end of this session, we’ve rounded out a body of tricks with digital logic chips (and their abuse to create analog waveforms) that’ll give you more than enough rope to hang yourself and some of your neighbors. If this were a college curriculum, we’ve just finished Logic Noise 101.

So next session we’ll take stock of where we’ve gotten so far, and start thinking about building up discrete circuits and how to interconnect them. We’ve had requests for a Bill of Materials (or shopping list?) for the series, and that makes sense just about now, because it’s time to build yourself a stand-alone Logic Noise synthesizer.

We’ll also include a literature review of sorts — links to further reading, projects, and directions to build on what we’ve done so far. In short, tying up all the loose ends that have come up along the way.

But Logic Noise 101 coming to an end also means that we’ll start up on Logic Noise 102 fairly soon. And the central topic is going to be one that we’ve studiously avoided so far: voltage control. Stay tuned for a whole new can of worms.


Filed under: Featured, slider

Logic Noise: Ping-pong Stereo, Mixers, and More

$
0
0

So far on Logic Noise, we’ve built up a bunch of sound-making voices and played around with sequencing them. The few times that we’ve combined voices together, we’ve done so using the simplest possible passive mixer — a bunch of resistors. And while that can work, we’ve mostly just gotten lucky. In this session, we’ll take our system’s output a little bit more seriously and build up an active mixer and simple stereo headphone driver circuit.

For this, we’ll need some kind of amplification, and our old friend, the 4069UB, will be doing all of the heavy lifting. Honestly, this week’s circuitry is just an elaboration of the buffer amplifiers and variable overdrive circuits we looked at before. To keep things interesting we’ll explore ping-pong stereo effects, and eventually (of course) put the panning under logic-level control, which is ridiculous and mostly a pretext to introduce another useful switch IC, the 4066 quad switch.

At the very end of the article is a parts list for essentially everything we’ve done so far. If you’ve been following along and just want to make a one-time order from an electronics supply house, check it out.

klangoriumIf you’re wondering why the delay in putting out this issue of Logic Noise, it’s partly because I’ve built up a PCB that incorporates essentially everything we’ve done so far into a powerhouse of a quasi-modular Logic Noise demo — The Klangorium. The idea was to take the material from each Logic Noise column so far and build out the board that makes experimenting with each one easy.

Everything’s open and documented, and it’s essentially modular so you can feel free to take as much or as little out of the project as you’d like. Maybe you’d like to hard-wire the cymbal circuit, or maybe you’d like to swap some of the parts around. Copy ours or build your own. If you do, let us know!

OK, enough intro babble, let’s dig in.

DC Bias Voltage

We perceive compression waves in the air as sound when they reach our ears. We make these compressions by pushing and pulling a speaker cone back and forth. And to make the cone move, we need to get current to flow one way and then the other through the speaker’s magnet windings.

Why the return to fundamentals? Because it’s important to think of the voltages and currents that we want to amplify as being bi-polar, oscillating around some central voltage level. When the signal voltage is higher than neutral, current flows one way and the cone gets pushed. When the signal is lower, current flows the other way and the cone is pulled. The neutral voltage around which we’ll oscillate is called a DC bias (or level) voltage.

In the course of Logic Noise we’ve ignored DC bias voltage whenever possible, but in mixing several signals together, we can’t do that anymore, because signals only add up correctly if they’re generated with respect to the same bias voltage.

envelope_with_xor_drumWe’ve gotten away without blocking DC voltages before because our square wave and triangle wave signals were biased around VCC/2, just like an amplifier with feedback built from a 4069UB inverter is. It all worked fine until we introduced the drum and cymbals circuits, which are so strange that they don’t really even have a well-defined DC level.

Blocking DC voltage is simply done by passing the signal through a capacitor. How large? Large enough that combined with the input resistance of the next stage in the audio chain, it doesn’t cut too much into our low frequency components. In the case of the 4069UB output amplifier stage, a 1 microfarad capacitor will do nicely.

So for now, let’s assume that we first pull the DC level off of any signals that we’d like to mix together, noting that we can “get away with it” for full-swing square waves. Now it’s time to get down to the mixing.

Mixers: Passive and Active

Passive Mixers

passive_mixer.sch“Passive mixer” is a two-dollar name for combining signals together by passing them through resistors. The higher the resistor value, all other things equal, the quieter the contribution to the overall mix.

It’s the simplest way to add a few signals together, and you should play around with passive mixing anyway, just to get the feel for it. The key to making a passive mixer work is using relatively large resistors for all of the mix inputs.

The downside of the simple passive mixer is that because all of the signals combine at the junction, one signal can influence the others. Essentially, each input signal can pull the junction’s voltage higher or lower than the neutral voltage, and this can feed back out to the other “inputs” through their input resistor. Passive resistor mixers are tremendously simple, but they don’t isolate the signal sources well from each other.

Active Mixers

The trick to active mixing is adding negative feedback. Otherwise, it’s just the same circuit as the passive mixer, but it’s a whole lot better.

active_mixer.schRemember from the session on filters that the inverter acts as if it were trying to zero out any net incoming signal current that shows up on the input pin; the logic is that if the voltage on the input rises up above the switching point, the output goes low and fights it back down again through the feedback path.

How much resistance is present in the feedback determines how hard the inverter needs to work to cancel out the input signal. More feedback resistance leads to larger voltage swings on the inverter’s output, which end up as louder tones in our headphones, so the feedback path is a great place to add in a master volume control knob.

In the passive mixer example, when one input was high, it raised the voltage at the junction which could then flow “backwards” to the other connected circuits through their input resistors. In an active mixer, when one input is high the inverter cancels it out by lowering the overall mixed output voltage until the input to the inverter sits at its neutral point again. By the negative feedback mechanism, the junction of all the summing resistors is held at a constant midpoint voltage, and none of the inputs can affect each other. Only the output voltage swings around.

Here we see the need to remove the DC level from the input signals — the 4069UB will do whatever it can to hold its input at roughly VCC/2 by pushing current through the feedback loop. A 1uF capacitor before each input resistor will take care of that.

Beyond isolating the inputs from one another, we can also control the gain of an active mixer by changing the value of the feedback resistor. This gives us a simple place to insert a master volume control just by replacing the feedback resistor with a potentiometer. The convenience of a master volume knob should not be underestimated.

If you’re mixing signals, and you have electricity at your disposal, you almost always want an active mixer.

Multiple Input Volumes

The main function of a mixer is to make a bunch of sounds with different volume levels play nicely together. For instance, the square wave output of a 40106 oscillator swings fully from GND to VCC, while the (unbuffered) triangle wave coming from the input of the same oscillator is a lot quieter. The bass drum circuit is also by nature fairly quiet, and the output of the VCA that gave the cymbal its percussive envelope swing only a few volts. Aesthetically, you’ll want to tweak the volume of each different sound source.

Kookie_Studio_MixerA studio’s mixing console is dominated by an impressive array of faders that fine-tune the volumes of the individual tracks. But before we end up investing in hundreds of dollars of fancy potentiometers, let’s see how far we can get with a bunch of one-cent resistors.

Let’s think about this like an engineer for a second. We want around one volt peak-to-peak of output signal, either for line-level inputs or for headphones. That means that if we’re seeing 9V peak-to-peak square waves, we’ll want to cut them down by about a factor of ten. On the other hand, the one or two volts peak-to-peak that we get out of the low-level signals can plausibly be run through with simple unity-gain buffering. (Bear in mind, this is all before the global output volume control knob.)

If we’re using a 100k potentiometer for the variable feedback resistance (and overall volume), this means that we can use something around 1M Ohm for the high-volume digital signals to knock the amplitude down by at least a factor of ten. Using a 100k Ohm resistor for the quieter signals means that they’ll pass through with unity gain when the channel’s volume knob is turned up to maximum. Of course, you can tweak these values to fit your exact preferences by picking different resistor values.

So round up a bunch of noise-making devices and pick some input resistor values that make them sound good together. (Remembering to remove the DC level with a capacitor if necessary.) If the end result works, nobody will know that you didn’t spend hundreds or thousands on a mixing board.

Headphone Out and Line Out

We saw DC bias issues on the input side, and DC bias raises its ugly head again on the output. Our amplifier’s output is centered around VCC/2, but for headphones (or other speakers) we ideally want no current to flow at this neutral voltage level. This suggests two solutions. First is to create a constant “virtual ground” voltage level at VCC/2 and feed the headphones with our signal and the virtual ground. The other is to strip the DC bias off of the signal and connect the downstream headphones or amplifier to real ground.

Virtual Ground

virtual_gnd.schThe clever way to create a virtual ground at the 4069UB’s neutral voltage (roughly VCC/2) is to set up an inverter with negative feedback as usual but with no input signal. The output of this inverter will be constant and exactly at the inverter’s switching midpoint, so we can use this voltage as the symmetric voltage midpoint that we need for the headphone’s “ground” connection. In the circuit here, a big (100uF) capacitor keeps the VCC/2 level steady. If you’re only going to be driving headphones, or if you’ll only be running the circuit on batteries, this is the hi-fi way to go.

The virtual ground solution runs into trouble when our circuit and the amplifier share a ground connection, as can happen when both are powered by (switching) AC adapters. Then the output’s virtual ground (around VCC/2, remember) gets connected directly to actual ground, and that’s not good. The 4069UB will struggle trying to pump out VCC/2 into a short to ground, probably get hot, and certainly not work so well. The moral of the story: if you use a virtual ground voltage, don’t connect it to actual ground.

Output Capacitors

output_caps.schIf you might have this shared-ground situation, the simple solution is to include DC-blocking capacitors on the output for each of the two stereo channels. While it was easy enough to just say “1uF capacitors” on the input side, the size of output caps should probably be larger but this depends on the load resistance and the amount of current we’ll need to drive into the load.

For example, I have a pair of headphones with 32 Ohm drivers inside, which puts the cutoff frequency of a 100uF capacitor at 1/(2*pi*C*R) = 1/(2*pi*100uF*32 Ohms) = 50 Hz — a low pitch, but one I’d like to hear. Maybe 220uF would be better for low impedance headphones. On the other hand, a less-demanding pair of 600 Ohm headphones will run fine with a 100uF cap down to around 3 Hz which is way below human hearing, and more like a fast tempo than a low note. You could probably get away with 10uF in this case.

In sum, the capacitor-based solution won’t end up shorting to ground, but requires a fairly big capacitor to pass bass notes. The virtual ground solution is clever and works perfectly well with headphones or when battery powered. Shorting the virtual ground to actual ground is to be avoided.

(Discrete) Stereo Mix

Stereo audio is nothing more than a right and left channel, that is two inverters on the 4069UB instead of one, but it’s a great step forward for our synth devices. You can either send all of one instrument voice to the left or right channel, or connect a single voice to both channels through different input resistors.

stereo_output_dongle_smallIt’s nice to have a simple stereo jack breakout board at this point — something you can simply clip or plug into your circuit and then connect up to your headphones or amplifier. Ours was made by soldering a 3.5mm stereo jack to a scrap of copper-clad, traces hand-drawn with a Sharpie, and etched. We tossed on some small wire loops to serve as nice ‘scope test points, because it’s nice to see as well as hear what’s going on.

Let’s take a break from all this theory and build up two capacitor-decoupled mixer circuits.

The 4066 Quad Switch

We’ll play around with ping-pong stereo just to show off, and use the 4066 quad switch chip to do it. Just above, we plugged a given voice into either the left or right channel, or both, and then swapped them around. Now, we’ll use the 4066 switch IC to do the plugging and unplugging for us.

The 4066 quad switch is both as useful and as simple as it sounds — it’s four logic controlled single-pole, single-throw switches in a package. If you want to connect and disconnect stuff, naturally under logic control, this IC is a great solution.

4066_pinoutPreviously we’ve looked at the 4051 8-way switch and used it to select one from eight possible inputs. The limitation with the 4051 is that it’s only possible to select one from the eight inputs at a time. The 4066, on the other hand, is just a set of four switches. This lets us build setups where more than one input channel is active at a time.

Here, we’ll be using the 4066 to route two sound inputs each into one or both of our right and left outputs. Take one voice, say a quiet one like the drum or cymbal circuit, and connect it through two 100k resistors into two switches from the 4066. The other side of each switch is connected to the left and right 4069UB amplifier circuits, respectively. When only the “left” switch is active our drum sound comes out the left side, and vice-versa. When neither is active, the drum is silenced, and when both are active the drum will be centered in the stereo field, and a bit louder because you’ve got two drum signals in place of one.

We can repeat the same hookup for a second voice. Let’s assume that the second voice is a loud one, like a VCC-to-GND square wave or similar. For comparable volume level with the quieter sound, we’ll need to run this loud input through a larger resistor, say 1 MOhm. Any of these input resistors can be substituted with a potentiometer if you’d like smooth control of the volume level. And again, if any of the input signals are not centered around VCC/2, pass them through a 1uF cap on their way into this circuit and don’t forget to de-couple the output or use a virtual ground.

4066_stereo_router.sch

Now we can turn on and off the left and right channels for inputs A and B with logic-level voltages at the four inputs.

Getting Fancy

Now don’t forget our sequencing tricks from previous sessions. For instance, adding a 4017 counter to the mix would allow us to trip the different 4066 switches in order by tapping off of the counter stages. Panning two similar sounds (triangle wave and square wave in the demo below) between the two stereo channels in sequence or in pairs can make a neat, evolving sound texture out of very simple sources.

The 4066 switch makes a great general-purpose control for turning on and off a given voice. We’re using it here for panning effects, but you could also imagine hooking up four different pitch oscillators to the four switches and playing a simple tune just by selecting which notes make it through the switches at a given time.

And as you can hear in the videos, the 4066 switch works fast enough to be fed audio signals into the switch control port. Every time a jumper wire is pulled out of the board, it couples with the 50 Hz power-line frequency and makes more overtones as the input frequency and the 50 Hz switching frequency mix with each other, for a sound that’s not unlike what you’d get by running both signals through an XOR.

An on-off switch seems like a humble device, but it’s very broadly useful. So have some fun switching elements on and off in the stereo field here, but don’t think that you’ve seen the last of the 4066.

Next Session

As promised previously, next session we’ll start getting into a little more advanced Logic Noise circuits, and in particular getting into voltage control. The 4046 phase-locked loop IC has a small voltage controlled oscillator inside it (among other parts) so it’ll be our first stop. We’ll make sweeping pitches without turning knobs. Stay tuned!

PS: Parts List

A number of folks have asked for a parts list for the Logic Noise series. Here goes.

I’ve tried to keep the variety of parts used as low as possible, for instance by using 100k resistors as a standard value whenever they’ll work. All potentiometers we’ve used so far are also 100 kOhms. Capacitors have been between 10nF and 10uF, a fairly normal range, and we’ve used 100nF caps for almost all of pitch-determining applications. The point of all this is that you can buy these parts in large enough volume to hopefully get a discount.

ICs / Actives:

All of the 4000-series ICs are available under different names from different manufacturers.  Most of the chips in my drawer are from TI or Fairchild, but I’ve got a bunch from ON and NXP.  Most of the time, they’re interchangeable:
CD4xxx from TI and Fairchild Semiconductor
MC14xxx from ON Semiconductor
HEF4xxx from NXP

In buying ICs, I almost never buy one, and for most of these parts the volume discounts start at 10 pieces. Take the quantites below to be rough suggestions. You can never have too many useful parts.

  • 10x 40106 hex inverter (you’ll use these everywhere)
  • 10x 4069UB inverter, amplifier (UB is crucial)
  • 4x 4051 eight-way switch
  • 4x 4066 quad single-pole switch
  • 2x 4040 binary counter
  • 2x 4017 decimal counter
  • 2x 4015 shift register (or 4094 if you won’t use the dual-clock functionality)
  • 2x 4070 XOR
  • 2x 2N3904/2N2222/BC548 or similar NPN signal transistors

(and soon:)

  • 2x 4046 PLL
  • 2x 4007 misc gates

Passives:

  • 100x signal diodes, e.g. 1N4148.
  • 100x 100k Ohm resistors (our mainstay)
  • 100x 10k Ohm resistors (also useful)
  • A handful of odd-value resistors here and there. Get an assortment if you don’t already have one.
  • 100x 0.1uF (100nF) capacitors. Ceramic/MLCC is fine.
  • 100x 1uF capacitors. ditto
  • 10x 10nF capacitors, ditto
  • 10x 10uF capacitors, electrolytic, 16v is fine.
  • 10x 100uF capacitors, electrolytic, ditto.

Potentiometers:

  • 10x 100k Ohm linear potentiometers (this is where most of your budget will go, and honestly 20 wouldn’t be too many)
  • 1x 100k stereo / dual potentiometer for bass drum circuit

Misc:

  • Some pushbuttons, but again you’ll never have too many
  • Breadboard and a lot of breadboarding wires
  • 9V battery and clips to connect to breadboard, or power supply
  • Powered computer speakers or amp and speaker
  • 3.5mm audio jack / stereo cable for output

Filed under: Featured, hardware, misc hacks, slider

Logic Noise: 4046 Voltage-Controlled Oscillator, Part One

$
0
0

In this session of Logic Noise, we’ll be playing around with the voltage-controlled oscillator from a 4046 phase-locked loop chip, and using it to make “musical” pitches. It’s a lot of bang for the buck, and sets us on the path toward much more interesting circuits in the future. So watch the intro video right after the break, and we’ll dig straight in.

4046 Phase-Locked Loop

The 4046 Phase-locked Loop (PLL) chip is a fantastic chip to experiment around with. In fact, it’s so versatile that we’ll spend the next three sessions exploring it. And still, we’ll only scratch the surface. Hackaday’s own Bil Herd is also in love with the 4046, and we’ve posted up tutorials on using it before. We won’t be using any of the intended functionality of the chips here, so check those links out when you’re done making bleepy-bloopy sounds.

PLL’s are sweet circuits. In normal use, you put in a waveform with a given frequency, and the PLL outputs a square wave that’s synced to the input, but at a higher frequency. It works by having a voltage-controlled oscillator (VCO) inside, and driving the VCO with a voltage signal that depends on the frequency difference between the internal VCO and the external signal. So far so good, by changing the voltage of the internal VCO depending on how out of sync it is, you can sync up the internal and external waveforms.

The trick to getting frequency multiplication is to divide-down the internal VCO’s output frequency, say by four, and then sync that divided-down result to the input. When the one-fourth speed VCO signal is synced up to the input, the straight VCO signal is running four times as fast as the input. Voilá, a frequency multiplier.

Simplest VCO

That’s all very clever, but for this session, we’ll just be using the built-in VCO. It’s a quick-and-dirty introduction into the world of voltage control, which has been what’s made the modern synthesizer work since at least the 1960’s.

To use the 4046’s VCO, we’ll only be using a few of its 16 pins. The VCO has an inhibit pin, pin 5, that we need to connect to ground, along with the usual VCC and GND pins. The voltage input for the VCO is on pin 9, and the output is on pin 4. And finally, the frequency range is controlled by selecting the capacitor on pins 6 and 7, as well as the frequency (and optionally offset) resistors on pins 11 and 12, respectively.

simple_vco.schAs you can see from the schematic here, it’s a no-brainer. A capacitor of 10nF and a frequency-selection resistor of 100K works just great. Since the product of these two controls the center frequency, you could also use a 100nF (0.1uF) cap and a 10K resistor. According to the datasheet, any value resistor between 10K and 1MOhm works just fine. You can also use a 100K pot here if you’d like to adjust the center frequency later.

There’s an extra (optional) complication with the offset resistor (R2). Adding a resistor to ground here shifts the whole frequency range upwards, which is nice if you’d like the minimum frequency to be something other than zero. The offset resistor has to be larger than the frequency-selection resistor above, but otherwise can be infinite. This would be a great place for a 1M or 10M potentiometer. We’re just skipping over it for now.

And that’s it. Two external parts, a resistor and a capacitor, and you’ve got a voltage-controlled square wave oscillator. Now all we need is a voltage source to control it. First up, a potentiometer hooked up as a voltage divider. One end to VCC and the other to GND, with the middle (wiper) terminal to the VCO’s voltage input. It’s just about the same functionality as the resistor-tuned oscillator from before, though.

Voltage Control

The fun in putting synth parts under voltage control is making up wacky sources of control voltage. Turning a knob with your fingers is great, but handing that duty over to some circuitry is better. And that, in a nutshell, is what brought the synthesizer out of the laboratory and gave birth to the modern synthesizer as musical instrument. In this video, we use an intermittent voltage source — a piece of VHS tape and a crocodile clip used as a voltage divider — to illustrate some of the things that you can do with a VCO that you can’t do with our resistor-controlled version.

You’ll notice that the voltage input is very sensitive. In fact, when it’s not connected to anything, it’s changing frequency wildly because it’s picking up power-line interference. We think the noise is great, but if you’re doing something musical, you’d have to tune up all your other instruments to the power-line frequency. In the video, we solve this problem two ways.

vc_one.schFirst, adding a capacitor to the voltage input of the VCO holds on to the last voltage for a while. This lets the last note continue to play even after removing our finger from the keys, or the croco clip from the VHS tape, as it were. Second, adding a resistor to ground, ideally one with fairly large value so that it doesn’t drag the control voltage level down, silences the VCO in-between actions. And mixing the two results in a pitch that slowly decays. (Whether that’s useful or not depends on you.)

Portamento, the sliding of pitch between notes, is also achievable with just a capacitor, although the speed will depend on the output impedance of whatever you’re using as your voltage source, so it’s not entirely reliable. There are better portamento circuits out there, but they’ll probably involve op-amps.

As a quick aside, you can make a rudimentary keyboard with just a bunch of push buttons and voltage sources. Indeed, a great device to have around is a set of buttons connected to an equal number of potentiometers that are configured as voltage dividers as we did in the first demo. Being able to tune each key independently makes up for not having very many available, and means you can play in whatever scale you’d like.

Voltage Controlled Sirens

Now let’s do something that we absolutely couldn’t do with a resistor as the control element: control the frequency of the 4046’s oscillator from another oscillator.

vco_vco.schTo do that, we’ll build up an oscillator using our old friend the 40106. Use a nice large value capacitor (10uF is good) so that it’s got a nice slow swing to it. And instead of tapping the output, where there’s a full-range square wave, we’ll tap the input which has an analog triangle wave that bounces handily between the 40106’s hysteresis voltage thresholds.

scope_2This is a simple and perfect combo. The 4046’s voltage input doesn’t draw much current at all, so we can connect it up unbuffered to the 40106’s triangle wave / input without changing the frequency. The triangle wave also doesn’t swing full-range, which is great since the 4046 will stop oscillating entirely below around 1.4V. And with one knob, you can create a slow siren-like effect or ramp the modulating triangle wave up to audio levels, and play around with crazy frequency-modulation (FM) type sounds.

Because continuous voltage sources get monotonous pretty quickly, we add a pushbutton at the end of the video. This also lets us show off the voltage-hold and voltage-decay tricks that we used before. Plus, adding a switch and a capacitor leads directly into sample and hold circuits, and that’s the topic of the next section.

Sample and Hold

 

sample_and_hold.schSample and hold (S&H) is a fancy electronic engineer’s term for putting a capacitor and a switch into a circuit, but its a cool and useful effect to have in your synthesizer arsenal. Indeed, synthesizers going back at least to the original Moog modular had a S&H circuit on board. Why? It’s a cheap and cheerful source of almost-randomness.

So we’ll hook up a second clock-rate oscillator on the 40106 chip, this time using the square wave output. Replacing our pushbutton with a 4066 digital switch puts the S&H under oscillator control. Capacitor C2 charges up to the oscillator when the 4066 switch closes, and holds when it’s open. For now, the time that the circuit samples (the button switch is closed) is the same as the amount of time that the circuit holds (switch is open). For now, we’ll stick to the basics.

There are actually three variants of the circuit here that are interesting. The first is the direct sample and hold circuit. When the sample and hold oscillator is high, and the switch is closed, the VCO tracks the pitch oscillator, and when the S&H oscillator goes low, the pitch holds at its previous level, just as when we were doing it by hand.

Another neat effect is to substitute a pulldown resistor (say, 100K again) for the S&H capacitor (C2). Now when the button isn’t pressed, the voltage gets pulled down and the VCO goes silent. This makes for a nice staccato sound that only plays 50% of the time, wherein the pitch tracks the pitch oscillator.

S&H Behavior

sample_and_hold

If you run the control voltage oscillator pretty fast (as in the first pane) and then sample it relatively slowly, it’s hard to predict what the sampled voltage is going to end up at. This is because the control voltage oscillator changes a lot over the sampling period. Sampling slowly from a quickly-varying clock source like this is a great trick to have.

If you do the opposite, sample frequently from a slowly-moving source voltage, you get this stair-step effect that traces out the general contour of the triangle wave, but holding discrete pitches along the way, as seen in the center pane above.

In the in-between zone, where both oscillators are running at comparable speeds, the sampling takes place at more or less similar places in the control wave. In the third pane above, you can just make out the capacitor moving with the control voltage when the switch is closed, but it all blends together. We’re really big fans of the region between total order and total chaos, so this is where we like to play.

In the real world, the S&H circuitry on things like analog-to-digital converters use very short sample pulses and tiny, low-leakage capacitors that charge up quickly so that it’s more like taking a snapshot of the voltage at a given instant. They also use special digital switches that turn on and off very rapidly and have extremely high impedance when they’re switched off. If you’d like to make something similar with our setup, you can convert the square wave into a pulse wave as we have done with the cymbal and drum circuits before. Play around with different capacitor values to lengthen or shorten the pulse length.

Next Session

We’re having a great time making pitched noises with our VCO. But we’re still not playing scales. To take the next step toward musicality, we’ll need to work on voltage scaling. It’s a lot easier to make music when a fixed voltage increment gives you a fixed scale step. Right now, that’s not the case, and we’ll get into the whole mess next time. It’s worth it.

But for now, enjoy the crazy voltage-controlled tunes / noises.


Filed under: Hackaday Columns

Logic Noise: Playing in Tune with an Exponential VCO

$
0
0

Last session, we use the cheap and cheerful 4046 Phase-locked Loop chip as a simple voltage-controlled oscillator (VCO). It was dead simple, in fact, because the chip has a VCO already built in. There’s one big drawback of the 4046’s VCO; the pitch changes linearly with the control voltage. Ideally, as we’ll discuss in the next sections, we’d like the frequency to be an exponential function of the control voltage (CV), and that’s going to mean a little bit of analog circuitry.

René Schmitz has a fantastic exponential VCO design that’s almost a perfect fit for the Logic Noise series — it’s built with a minimum of parts, it’s a little bit rough around the edges, and at its core is a 4000-series CMOS chip that’s normally used for digital logic applications. The only drawback, from our perspective, is that it uses a dual (positive and negative) power supply. We’ll hack our way around that, and ignore some of René’s otherwise worthwhile refinements in the name of doing something truly quick and dirty. We’ll get 95% of the results with 70% of the work, although it’s easy enough to add on the rest if it strikes your fancy.

Let’s start off with a little scale theory.

Why Exponential Voltage Control?

We humans hear pitches on an exponential scale. All of the musical intervals that we’re used to are based on multiplications and divisions of the fundamental frequency. For instance, we think of the scale repeating every octave, by which time the pitch has doubled. If you multiply the base pitch by 3/2 instead, you’ve got a “perfect fifth”, so-called because it’s the fifth degree of an eight-note major scale based on the initial pitch. To make a (perfect) major chord, you combine the root note with a fifth and a third, which has a frequency that’s 5/4 times the root note’s frequency. It sounds “in tune” because different harmonics that make up the sound line up.

As a concrete example, imagine you’re playing a concert “A” at 440 Hz. You can play an octave up by playing 880 Hz, or an octave down by playing 220 Hz. A fifth up is an “E” at 440 * 3/2 = 660 Hz. The third comes in a 440 * 5/4 = 550 Hz. All this is to say that musical intervals are all about ratios of frequencies.

On the electrical side of things, however, it’s much easier to add and subtract voltages than it is to accurately multiply them. We saw this with our active mixer circuit, for instance. If you simply run two signals through equal-value resistors into the input of an amplifier with feedback, you get the sum of the two input voltages. Multiplying voltages requires a much more complicated amplifier setup. This mismatch between multiplicative frequencies and additive voltages is what makes linear voltage/Hertz scaling awkward. But there’s a second problem that’s even worse.

In our example, if you want to go from an “A” to a “C”, you have to raise the pitch by 440/4 = 110 Hz. You can figure out the corresponding voltage increment and you’re all set. If you started out an octave down, at 220 Hz, however, you’d get a “C” by adding 220/4 = 55 Hz, so you only need to add half of the former voltage. The main problem with linear voltage scaling is this doubling and halving. As you play up and down the keyboard, the voltage increments necessary for any given interval become either tiny or gigantic. Replicating a piano’s range with a half-step at the bottom end represented by 10 mV, which is about the least you could get away with, means that a half-step at the top needs 1.6 V and the total range is just under 27 V. It’s your basic rice and chessboard problem.

We get the VCO to internally exponentiate for us so that we can control the VCO from the outside with nice linear voltages. Following the de facto standard in the synth world, we’ll set up the oscillator so that adding one volt to an input will double the pitch of the output, raising it up by an octave. If you want to play a fifth, you add half a volt, regardless of where you are in the scale. If you want an equal-tempered scale, you only need to reckon down to twelfths of a volt, and the voltage increments are the same no matter where you are on the keyboard.

In short, exponential voltage-to-frequency scaling makes the electronics that corresponds to musical intervals a lot easier. So let’s do it.

Expo Converter

The exponential converter in the VCO takes advantage of the fact that it’s dead easy to get an exponential current to flow through a transistor in response to an input voltage. And once you have exponentially-scaled currents flowing, all that remains is to build an oscillator where the frequency is controlled by a current. That’s the plan, anyway.

The basic model of a bipolar transistor that everyone knows and loves (maybe) is the Ebers-Moll equation:

I_E = I_{ES}\left(e^{\frac{V_{BE}}{V_T}}-1\right)

where IES is a constant that depends on your particular transistor and temperature, VBE is the voltage applied across the base and emitter, and VT is another constant that depends on temperature. For now, think of these constants as being constant, but don’t forget that we just said the word “temperature” twice.

So here’s an exponential voltage-to-current converter: it’s just a transistor. And here’s how the voltage response looks on the scope, with input voltage across the x axis and the current measured by passing it through a resistor and measuring the voltage drop. (As more current flows through the resistor, more voltage is dropped across it, resulting in a proportionally lower voltage at the measurement point.)

transistor_scaling

As you can see, current can’t increase exponentially forever, but stops once it runs almost into the ground supply when the input voltage reaches about 525 mV. And the transistor doesn’t even start to conduct until the base-emitter voltage gets up around 400 mV. But between those two bookends, the current surely does look to be increasing exponentially with input voltage. So the next step is to scale down the input control voltage so that it stays inside this active range where the Ebers-Moll equation holds.

If we have a control voltage range of 5 V, and we want it to fit between (roughly) 400 mV and 525 mV, the entire range fits if we divide by 25, so we’ll need to divide by at least that much. To get one volt per octave scaling, we’ll have to do some math. If we double the frequency by adding \Delta V_{BE} to the initial voltage, and take logs of both sides, we get

\log(2) = \Delta V_{BE} / V_T

scaling.schVT is around 26 mV , so that’s 18 mV per octave on the input to the transistor, suggesting that we divide the input voltage down by 55 (1 / 0.018) to get one volt per octave scaling.

We’ll also need a voltage offset of at least 400 mV, from the look of things. We simply add in a voltage divider tied to the rails and a resistor to combine it with the control voltage through another resistor. Putting all this together, we get this scaling circuit.

Temperature Dependence

When you build this circuit, touch the transistor with your finger. You’ll notice the effect of the temperature dependency of the “constant” IES alluded to above. It’s actually quite dramatic, and removing most of the temperature drift due to IES is a piece of cake, so let’s do that now.

two_transistors_expo.sch

The first transistor, a PNP type, is set up as a common collector voltage follower. The current gain equation in this stage is the same as for the NPN transistor, but with a minus sign in front of the voltage, because current is closed off in a PNP transistor as the base voltage increases. And because of this minus sign, when you solve out for the overall current function, the two IES factors approximately cancel out, removing the main source of temperature dependence along with them.

If you’re feeling particularly fastidious, you can actually tape or glue the two transistors together so they’re at the same temperature which helps the temperature coefficients cancel out. Even if you do so, you’ll find that the circuit drifts around for a little while after turning it on, so give it a minute to warm up.

And notice in René’s design that he’s also included some thermistors (temperature-dependent resistors) in the CV input path. These cancel out the (second-order) dependence on temperature coming from the VT term, making the oscillator even less temperature dependent. If you’ve got 10K NTC thermistors on hand, by all means use them. Otherwise, don’t sweat the details — the circuit is already usably precise as-is.

The Single-Sided Supply Fudge

Hey, what’s up with those two diodes, D1 and D2?

4069vco1In René’s design, the PNP transistor and the offset voltage divider are connected to a negative voltage supply, while the NPN transistor and the input scaling potentiometer are connected to a mid-rail ground. Since we don’t really have a mid-rail ground voltage, we’ll have to fake one. And since we potentially don’t have all that much voltage headroom, for instance the circuit is running on 4xAA batteries, we’ll set up this fake mid-rail at an only slightly higher voltage than our ground reference.

The trick with dual and split-single power supplies is that all voltages are relative. If we call one voltage “ground” or 0 V, then all other voltages are measured with respect to that one. We’ll take the most negative voltage we’ve got (our “ground”) and substitute it wherever we see a negative voltage in René’s circuit. Everywhere we see a “ground” in René’s circuit, we’ll need to raise the voltage up a little bit.

We do this quickly and dirtily with diodes. A diode drops around 0.6 V when conducting, so we’ll put a diode pointing downwards between our ground (the most negative voltage in the circuit) and the scaling potentiometer and collector of the NPN transistor Q1 respectively. The scaling pot is fine as is, but since a diode only drops 0.6 V reliably when current is flowing through it, we need to bias the diode on the NPN transistor so that it’s always conducting by adding a resistor to VCC. Now the “ground” level for the PNP transistor is lower than the NPN transistor, and we get a much better exponential scaling at lower voltages. You’ll still notice that it’s not perfect in the lowest ranges, but it’s better than nothing.

Current Controlled Oscillator

We’ve now got a transistor circuit that pulls an amount of current that’s exponentially related to a reasonable CV range. All we have to do is build up an oscillator to go with it. The oscillator design René uses is only a little bit more theoretically complicated than our usual 40106 oscillator, but it’s rock-solid and exactly what we need. We’ll just copy it straight up.

The overview of the oscillator is that the capacitor C1 is charged and discharged across its inverter section. The left-hand side of the capacitor charges almost immediately through the diode D1 but can only discharge slowly through the exponentiating transistor, and that’s what gives the oscillator its pitch. The oscillator roughly has these two states: slowly discharging the capacitor back out through the transistors, and super-quickly charging the capacitor back up again. The rest of the circuit just supports the speedy charging.

oscillator_alone.sch

The pair of inverters hooked up in feedback on the right-hand side of the circuit (U1F and U1E) form a Schmitt Trigger.

Here’s how it works. If the input of the first inverter is high, its output is low, which means the input of the next inverter is low and its output is high. Viewed as a pair, two inverters make a non-inverter. The high input state of the first inverter is reinforced through the 22K resistor.

When a sort-of low input arrives through the 10K resistor, it’s going to be partially cancelled out by current flowing through the feedback loop. Only when the input is low enough to overcome this feedback does the first inverter turn over, and the input and output of the trigger circuit flip to the low state. The Schmitt trigger in this circuit is simply providing a source of current to quickly charge up the left-hand side of the capacitor while being immune to small amounts of noise in the circuit. Once it’s done its job charging the capacitor up, the output of the Schmitt trigger is effectively blocked from the circuit by the diode D1.

The diode and resistor inline with the capacitor (D2 and R1) can actually be left out and not much changes. The resistor is simply present to provide a current path for the capacitor through which to discharge into the exponentiator. Replacing the resistor with a simple wire results in a small voltage spike on the left-hand side of the capacitor when the inverter switches its output high. The resistor slows down the charging of the right-hand side of the cap just enough to damp out this spike.

On the other hand, we don’t want to slow down the discharge of the right-hand side of the capacitor, because that would slow down the sawtooth wave’s downward drop. The diode D2 provides a path for the speedy discharge of the capacitor when the inverter switches its output low.

Again, the snubber resistor and diode are a refinement, but together they speed up the downward-falling portion of the ramp waveform. This is important because the amount of time that it takes to discharge the capacitor doesn’t change with pitch, which prevents the pitches from tracking perfectly from octave to octave. As built, you can expect four to five octaves to stay in tune. Without the resistor and diode, you get about three octaves in tune. No big deal either way, but it’s a nice touch and only adds two one-cent parts to the design.

Finally, notice that you’ve still got three inverter amplifiers on the 4069UB to play around with. One option is to simply feed the sawtooth output into an inverter and enjoy the quick-and-dirty overdrive effect. Of course, you could go whole-hog and implement an overdrive-to-fuzz circuit, which will give you even more tonal variation.

René’s suggestion is to use the remaining three inverters to create a pulse waveform, adding another input so that you can modulate the pulse width. It’s a nice sound, but adds to the build complexity. Later on, we’ll look into waveform distorter circuits of all kinds, and building the ramp-to-pulse circuit is a great stand-alone option, so don’t be surprised if you see this part of the circuit pop up again in these pages.

Tuning

The best thing about having a one-volt-per-octave oscillator is that now you can play in tune. Or at least, you’ll be able to once you’ve tuned the thing up. Fortunately, this design has only two knobs that you’ll want to tweak to get it in tune. Unfortunately, the scaling knob is ridiculously critical and touchy, and takes a little practice to get just right.

If you’ve got a frequency counter of some kind, or maybe your oscilloscope reads out the frequency of the displayed waveform like mine does, then everything’s pretty simple. Dial in one volt on the CV input, and note the frequency. Then dial in two volts. Is the second frequency twice the first? You’re done. Is it too high? Turn the scaling knob one way. Too low? Turn it the other way. If you don’t have a frequency counter you’re going to have to use your ears, which is more of a challenge. To help out, build up this simple circuit.

octaver.schWhat it does is switch three voltages (determined by the three pots) through the 4051 multiplexer, the output of which is buffered by the transistor. If you’ve been following along, you’ll have all the parts you need sitting around from the second and third sessions. Plug a voltmeter into the output and set each potentiometer until the voltages read (for instance) exactly one, two, and three volts. It’s easiest to disconnect the clock generator and simply tap the signal to VCC and GND until the potentiometer that you need to set is selected. Reconnect the clock once everything’s set.

Now you’ve got a circuit that should play three octaves of the same note up and down. It’s pretty easy to get this into decent tune just with your ears if you know what you’re listening for. Alternatively, as demonstrated in the intro video, you can just tune the circuit up live with whatever you’re intending to play the VCO with. My keyboard puts out a solid 1V/octave, but if yours doesn’t, you’ll need to tune the VCO to match. The nice thing is that you have the flexibility.

Now that the octave scaling is working, you can tune the oscillator to match another musical instrument with the CV offset potentiometer. This one’s a lot easier, and you can do it by ear. You shouldn’t need to re-do the octave scaling again afterwards, but it doesn’t hurt to double-check that as well before you get up on stage with this thing. At worst, you might need to ping-pong between scaling and offset adjustments a couple times before everything’s perfect. That’s the price you pay for wanting to play in tune.

What’s next?

So now that we’ve got a tuned volts-per-octave VCO. Your homework is to wire one of these circuits up on the breadboard and play around with it. See what kind of voltage sources you have lying around and hook them up. Try a string of resistors in a row, like a multi-stage voltage divider, from VCC to GND. You might want to buffer them with a transistor circuit, but then you should be able to play them like a keyboard.

Once you’re convinced that you like the circuit, put it together in solder and wire on perfboard or something similar. It’ll probably behave better than it did on the breadboard because this circuit deals in small voltage differences and low signal voltages. This is a good module to have on hand, anyway. If you haven’t played around with modular synthesizers, this is a great first “real” step. If you have, you already know that you can’t have too many voices (or amplifiers).

Next session, we’ll look at what you can do with voltage control. Specifically, we’ll build up a digital-to-analog converter (DAC) and start playing in-tune scales and then add a shift register into the mix to make something that’s seriously more than the sum of its parts.

And if you’ve been following along, you’re probably scratching your head because I said last time that I’d retrofit the 4046 PLL oscillator for one-volt-per-octave, and then we switched up to an entirely different architecture. What gives? Circuit failure. Where this session’s oscillator has two knobs that are necessary to tune it up, the 4046 exponential converter had three, and it was just a mess getting the thing in tune. But don’t fret, we’ll see the 4046 PLL again after we spend a few sessions playing around with our brand new VCO toy.


Filed under: Featured, Hackaday Columns

Logic Noise: Digital to Analog with an R-2R DAC

$
0
0

Making sound with digital logic usually calls for a Digital to Analog converter. Building one can be very simple, and the sound quality out of an R-2R Ladder is actually pretty good.

In the last edition of Logic Noise, we built up a (relatively) simple VCO — voltage-controlled oscillator — that had roughly one-volt-per-octave response. I even demonstrated it working mostly in tune with another synth’s keyboard. But what if you don’t have a control-voltage keyboard sitting around or you want to combine all of the logic-based circuits that we’ve been building with other circuits under voltage control? That’s where the digital to analog (DAC) voltage converter comes in.

R-2R DAC: Voltage dividers all the way down

In this session, we’re going to be putting together a simple DAC so that later on we can use our logic circuits to put out (analog) control voltages. When we’ve wanted a non-logic voltage in the past, we’ve reverted to connecting up a potentiometer to the two voltage rails and pulling off the intermediate voltage from the center pin, with the output voltage varying as we turn the knob. Maybe given that background, you won’t be surprised that we’ll be using a ton of resistors to build up a DAC that’s capable of making logic-selected intermediate voltage values.

In fact, a potentiometer with either end connected to VCC and GND, is a voltage divider. But they’re more general than that — take two resistors and put them in series. Now put a voltage across them. The voltage in the middle of the two depends on the values of the two resistors like so V_out = R2 / (R1 + R2).

voltage_divider.sch

Say you want to divide a voltage in half? Connecting one side to ground and setting R1 = R2 does the trick nicely, and fits neatly with your intuition. If all of the voltage is dropped across two resistors, and they have equal values, you’d guess that half of the voltage is dropped across each one. Well, it is.

To build a DAC we want each input bit to produce a specific output voltage, and we then sum them up. In particular, if we want to encode the voltage as a binary representation, we just need to make sure that each stage of the ladder contributes half as much voltage to the final output as the stage before it.

That’s exactly what an R-2R DAC does. The R-2R ladder is made up of divide-by-two stages, so that when you apply a logic voltage (we’ll call the levels VCC and GND) to the top rung of the ladder, you get VCC/2 or GND. Add another rung to the ladder, and the top rung still produces VCC/2 or GND, and the rung below it produces VCC/4 and GND. Now the ladder can output four possible values: GND, VCC/4, VCC/2, and 3/4*VCC.

r2r_dac.sch

As we add more and more stages to the ladder, our highest voltage gets closer and closer to VCC and with each new stage the smallest voltage step is divided in half. For instance, with two bits we can represent the numbers 0, 1, 2, and 3, and the minimum voltage step is VCC / 2^2^, so the maximum voltage produced is 3/4*VCC. With eight bits, the minimum voltage step is VCC/256 and the maximum voltage is 255/256*VCC.

Thévenin Equivalent Circuits

If you’re not content with my hand-waving explanation of the circuit above, you’ll need to know a little bit about Thévenin equivalence, but it’s not that bad. The basic logic is that any purely resistive circuit with a voltage source (like we’ve got here) can be treated as if it were just one resistor and a voltage source. And you can do this iteratively, so we can move up the ladder, collapsing everything below it into an equivalent voltage-source-plus-resistor.

In calculating the Thévenin equivalent resistance and voltage, you pretend that the input is shorted to ground and calculate the resistance. Viewed from the first junction (between resistors R1 and R10 in the circuit diagram), we’ve got two resistors of 100k in parallel, so the Thévenin equivalent resistance of the first stage is 50k ohms, and the voltage (V0) at the junction is VCC/2 if D0 is on, and GND if it’s off.

thevenin.sch

Moving up the next rung in the ladder, and doing the Thévenin trick again, we see that we’ve got two 50k resistors in a row (effectively 100k) in parallel with a 100k resistor again. So the equivalent resistance, treating V0 and D1 as if they were grounded, is 50k ohms again. When D0 is off, V0 is GND, and the output voltage is thus GND or VCC/2 depending on D1.

If, on the other hand, D0 is on, V0 is VCC/2. The resulting equivalent voltage when D1 is off is VCC/4 and when D1 is on is halfway between VCC and VCC/2, or 3/4*VCC, as we claimed above. Continue collapsing stages and writing down all the possible voltages, and you’ll get exactly the binary ladder that we discussed before. QED’ed.

And if you need to see it on YouTube to believe it, here’s a nice video explanation of how it works.

The proof of the pudding is in the tasting

And finally, if none of that’s good enough for you, and you share my empirical streak, build your own from the ground up and test each stage with a voltmeter. Or if you share my empirical streak but you’re lazy, just watch this video.

Implementation Details

In principle you can build an R-2R DAC with as many steps as you’d like, but eventually you run into the accuracy of the parts themselves. An 8-bit DAC is just about within reach when using quality 1% tolerance resistors, but going much further doesn’t make much sense without buying higher-quality parts. For generating analog-ish waveforms, you can often get away with even fewer steps, and we’ll be using only five bits here.

We’ve not defined the values of R and 2R yet either, and there’s two different ways to go here, but since it’s hard to find resistors that are precisely factors of two from each other we’re going to make our own. Simply to make the circuit more compact on the breadboard, I’ve chosen R to be 50k, and 2R to be 100k ohms. But you don’t have any accurate 50k ohm resistors? Use two 100k ohm resistors in parallel. That way, you only need one resistor type to get the whole thing done.

Actually, there’s a side benefit to combining two resistors to get another value out: the two values essentially average out. If you’ve got one “100k” resistor that actually measures 101k and another that measures 99k, the series combination of them is exactly 200k, and the parallel combination exactly 50k. In short, as long as the values are right on average, using multiples like this can help.

And finally, note that any of these fixed resistors can be replaced with a potentiometer if you’d like. In particular, substituting a 100k pot for any of the 50k “resistors” gives you an interesting degree of adjustability in the output waveform, as we’ll see below. In principle, one could make a whole R-2R DAC with only potentiometers, dialing them carefully so that one side reads twice as much as the other. In practice, this works with three or four potentiometers, but it breaks down thereafter because potentiometers are usually specified for around 5% accuracy or less. Nonetheless, it’s a fun trick for producing odd, moderately tunable voltages from four binary inputs.

Buffering

But we’re not done yet. If you keep going with this Thévenin equivalent circuit logic until the last stage, you’d discover that it has (like each stage before it) an equivalent resistance of 50k ohms. That’s a lot, and it means that we can’t draw much current out of the DAC without the voltage sagging significantly. So we’ve got to buffer it up before we can use it directly, say to hand it off to your powered speakers.

And while you can totally use a transistor buffer circuit, we’d lose the roughly 0.6 volts needed for the base-emitter bias voltage. And heck, this is Logic Noise. So break out the 4069UB chip that we’ve been using for linear buffering duty since way early on.

quick_buffer.sch

I’ve built up the buffer here with a potentiometer in the feedback loop so that you can vary the output level, and I’ve shown an optional lowpass filter on the output which tames some of the remaining digital character of the waveforms that we’re about to create. As always with the 4069 amplifier circuits, we can get a nice overdrive effect by amplifying the signal until it starts soft clipping.

The Digital Sawtooth

If our R-2R DAC gives us a voltage that’s increasing as we input increasingly large binary numbers, represented by logic high values on the input bits, we can use this to make an accurate sawtooth waveform. In an earlier Logic Noise we built a “sawtooth” waveform from our standard oscillator by adding a diode. But honestly, it was a fairly crappy sawtooth.

old_sawtooth_scopeBecause what’s really going on in the circuit is an exponential decay of a capacitor, it was basically a sway-backed sawtooth. But now that we’re able to convert digital numbers into voltages fairly directly, we can make a very precise sawtooth wave, if that’s your sort of thing.

scope_59The secret is counting, and for that we’ll dig out a 4040 binary counter chip that we’ve used before. As a clock pulse enters the counter, its various outputs represent the number of pulses that have arrived so far. Put this binary number into our DAC and we get a simple rising voltage out. A up-ramp wave.

Now we feed the ramp into our inverting buffer circuit, and we get a beautiful sawtooth out the other side. If you want to filter it, you can. It knocks down some of the high frequency noise that comes from jumping between discrete voltage levels. It’s noticeable, so you should see which way you like it better.

logic_sawtooth.sch

The Digital Madness

There are two complementary ways of thinking of the above circuit. One is that we’re using a counter chip to count up in binary, and feeding this binary numeric value into a DAC. The other, more analog / musical viewpoint, is that we’re sending five square waves, each playing an octave apart from the next, into a voltage divider that reduces the volume of each by half. Stacking these up in the “right” order gives us a ramp waveform.

But switching the different square waves around as they enter the DAC gives us sounds with more high-frequency components in them. Right now, the lowest frequency square wave (the most significant bit) is the loudest. Swap the highest and lowest inputs, and you’ll see what I mean.

illustrative_matrix

What’s fun about this realization is that you’ve got a way to (digitally) change the timbre of the output waveform by scrambling the inputs to the DAC around, or dropping particular DAC inputs altogether. And that’s finally the circuit you see demonstrated in the introduction. A 4066 switch (see Logic Noise: Ping Pong Stereo, halfway through the article) turns the four highest-pitch square wave inputs off and on, triggered by further subdivisions of the clock coming from the 4040 counter.

But there’s other ways to vary the timbre as well. With enough 4051 multiplexer chips, you could re-route multiple square waves to each of the DAC inputs. Or feed the outputs of our shift-register looper into the DAC. How you’re going to drive all of these is up to you.

Conclusion

If you’ve built up this session’s DAC circuit, don’t tear it up just yet. In the next edition we’ll be combining the DAC with the VCOs and tuning them all up. Tuning up circuits like this is tricky, and we may have to bend the only-logic-chip rules a little bit, but it’ll be worth it because I have a fantastic shift-register plus DAC plus VCO circuit to show you.


Filed under: Hackaday Columns, musical hacks

32C3: 20 Oscillators in 20 Minutes

$
0
0

In terms of implausible stand-up comedy, [Darsha]’s “20 Oscillators in 20 Minutes” is pretty far out there. First of all, she’s sitting down, with googly eyes on her multimeter, and five breadboards and a mess of 9V batteries laid out in front of her. “Has anybody built electronics before? Has anybody built electronics in front of this many people before? Yeah, so you’d better f**king be nice.” And she’s off!

twenty_oscillators-shot0012“Square waves are really good for your speakers.” And a few seconds later, a lub-dub beat-frequency oscillator filled the hall. And then there’s the stand-up clichés: “Anyone in the audience from Norway?!” And “Anyone know what chip I’m using here?” (The 555.) A heckler, or participant, shouts up “What are you doing?” She responds “Building this!” and shows a sketch of the basic layout.

She baits the audience — “Do you want to ask me about duty cycles?” — and tells stories: “And then one time the solder fell in my lap and burned through my crappy jeggings. Who knows what jeggings are? Whooo!!” All the while the clicking gets louder and more complicated.

Then there’s the suspense. “11 minutes left? Shit, I dunno if I’m going to make it this time!” She’s visibly panicked. A question: “How do you protect the outputs from overvoltage?” “I don’t. (pause, laughter) I use some filter caps and just, well, hope that you guys have good insurance.”

Nearing the home stretch, there’s this quasi-rhythmic ticking and pulsing slowly building up in the background. She plugs in another capacitor, and the crowd spontaneously applauds. A little bit later, she shouts “Is it loud enough?” over the din and turns it down. At the end, the timing’s getting really tight, and she calls up someone to help from the audience.

We won’t spoil it, naturally. You’ll just have to watch it run to the end. We laughed, we cried. It was better than Schroedinger’s cats.

(We’d use hex inverters.)


Filed under: cons, how-to, musical hacks

Glitchy Synthesizer Meets Honeycomb LED Matrix

$
0
0

Don’t watch [Jason Hotchkiss]’s video if flashing lights or bleepy-bloopy synthesizer noises give you seizures. Do watch, however, if you’re interested in a big honeycomb-shaped LED matrix being driven at audio frequencies through a dedicated square-wave synthesizer that’s built in.

The LED panel in question is housed in a snazzy laser-cut, honeycomb-shaped bezel: a nice change from the standard square in our opinion. The lights are 1/2 watt (whoa!) whites, and the rows and columns are driven by transistor drivers that are in turn controlled by shift registers. We’re not entirely sure how the matrix is driven — we’d love to see a circuit diagram — but it looks like it’s some kind of strange, non-scanning mode where all of the column and row drives are on at once. Whatever, it’s art.

And it’s driven by logic chips making audio-frequency square waves. Two of these are fed into an LFSR and into an R-2R DAC and then into the shift registers. The output is chaos, but the audio and the visuals do seem to influence each other. It’s an audio-visual embodiment of some of my wildest Logic Noise fantasies. Pretty cool. Enjoy the video.


Filed under: musical hacks, video hacks

Friday Hack Chat: Logic Noise

$
0
0

If you like your synthesizers glitchy, squawky, or simply quick-and-dirty, you won’t want to miss this week’s Hack Chat with Hackaday’s own [Elliot Williams], because he’ll be brain-dumping everything he knows about making music with 4000-series CMOS logic chips. Break out your breadboards!

Coaxing sound out of chips intended for digital mathematical operations might sound odd, but there’s a tradition of doing so that dates back to the late 1970s. While the scene is dominated by hackers and artists, would you believe that there was even a commercial synthesizer (the EDP Wasp) based on these techniques?

Even more surprisingly, people are still coming up with novel circuits even in the last few years! Making synths out of logic chips is cheaper, more accessible, and more surprising than building yourself a modular synth, but we’ll be the first to admit that maybe it’s a gateway drug.

If you want to get a jump on the discussion, [Elliot]’s Logic Noise series ran twelve installments and covers a lot of the basics. (Start here, with square-wave oscillators and then skip around if you want.) He also just gave a talk at Hackaday Belgrade, and although it was mostly about the live demos, you can check out the slides here — scroll to the very end for a good bibliography.

Ever wondered:

  • How to get triangle and sawtooth waveforms out of digital logic?
  • Whether a shift register can handle all of your compositional desires?
  • Just exactly what an XOR sounds like?

Don’t miss this week’s hack chat!

You are, of course, encouraged to add your own questions to the discussion. You can do that by leaving a comment on the Hack Chat Event Page and we’ll put that in the queue for the Hack Chat discussion.join-hack-chat

Our Hack Chats are live community events on the Hackaday.io Hack Chat group messaging. This week is just like any other, and we’ll be gathering ’round our video terminals at noon, Pacific, on Friday, June 1st.  Here’s a clock counting down the time until the Hack Chat starts.

Click that speech bubble to the right, and you’ll be taken directly to the Hack Chat group on Hackaday.io.

You don’t have to wait until Friday; join whenever you want and you can see what the community is talking about.

Viewing all 14 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>