Squareinator - a SN76489 Monosynth
by uhclem in Circuits > Electronics
8993 Views, 25 Favorites, 0 Comments
Squareinator - a SN76489 Monosynth
It all began a few years back, when a friend handed me an old RadioShack blister pack from the early 1980's he'd gotten at a hamfest - a SN76489 soundchip. Some research showed it had been used in early home computers and video game systems. Could it be used as a synthesizer?
The SN76489 is a four-operator programmable divider. You feed it a high-frequency clock signal (0.5 to 4.0 mHz) and binary counters divide the clock down to an audible frequency. It is capable of three independent squarewave waveforms based on a 10-bit divisor. It also contains a 15-bit shift register with feedback, which produces a pseudo-random squarewave output resembling white noise. Each "channel" has its own 4-bit attenuator, and is mixed to a single audio output. Communication with the chip is via an 8-bit data bus - wasteful of microcontroller pins but common for the era of 8-bit computers with an 8-bit data bus.
Inspiration
Previous projects existed based on the SN76489 sound chip.
http://little-scale.blogspot.com/2013/02/how-to-bu... used the chip for polyphonic output of "tracker" files and other 8-bit-era-inspired MIDI music.
This is cool, but the sound palette is limited by the nature of the chip to squarewave output. I'd get bored of just squarewaves pretty quickly. What if all three squarewaves were mixed, along with the noise? That could sound a lot more interesting. What if we added a cheap, nasty resonant multimode filter? Even better!
The Squareinator was born!
Hardware Design - SN76489 Clock
We of course knew we would be using the SN76489. How to control it? Other SN76489 users made use of the Teensy 2.0 microcontroller platform - a good choice, since it can enumerate a USB MIDI device.
I wanted regular serial MIDI, along with a 1/4" audio jack. Further, I'd be limited by the 100x80mm board size of freeware Eagle Cadsoft. Space on the board would be limited. Was there a way to not have a 2.0 mHz crystal for the SN76489 clock?
In fact, the ATMEGA32U4 used in the Teensy 2.0 has a hardware PLL capable of mutiplying one of the counters to a high frequency. The following website demonstrated this:
http://harizanov.com/2013/04/crazy-high-frequency-...
The Teensy 2.0 can easily output a 2 mHz clock using this method.
Hardware Design - Power Supply
The Teensy 2.0 and the SN76489 run on 5.0v DC. However, if you want a Voltage Controlled Filter (VCF), you're going to need a bipolar (positive and negative) supply. This can be handed by a split winding secondary transformer supply, but only the filter needs a negative supply, so the current requirements are very low and can be handled fine by a voltage inverter chip. I chose the LT1054 chip. It has a 100 mA capability, which is plenty for the design. Mutable Instruments (www.mutable-instruments.net) has an excellent bipolar supply based on this chip. The LT1054 produces a slightly lower negative voltage than the positive input provided, so the design feeds in 9V and then regulates both sides with linear regulators of the 780x and 790x type.
You can see a small heatsink on the 7805 regulator. It's not really necessary, but I like to keep things not more than warm. The 7905 never gets warm, as very little current is drawn on the negative rail.
Note the absolute maximum for the LT1054 is 15v. I would not use an unregulated supply of more than 9v, since a lightly-loaded unregulated 12v supply might provide more than 15v.
Hardware Design - VCF
As stated, I wanted a VCF for my synth. Further, I wanted a multi-mode design capable of lowpass, bandpass, and highpass outputs. Again, mutable-instruments.net had an excellent-sounding circuit of low parts count for their Anushri monosynth. With space at a premium on my board, low-parts count was ideal. The good and bad of this design is it uses the V2146D Voltage Controlled Amplifier (VCA) chip, which provides excellent results but is somewhat hard to find and is somewhat expensive. However, I think it was better than the alternatives.
The filter is a two-pole design, meaning it produces a 12db/octave response in lowpass mode. It is capable of self-oscillation in all modes. In my design, I save parts by using the attenuators in the SN76489 to generate the loudness envelope (VCA). Normally an analog synth puts the VCA after the VCF to silence the filter when no notes are playing if the filter is at self-oscillation, and to tame the filter output at self-oscillation, since in this design it tends to be quite a bit louder than the input. Since I have software control over the resonance, I can silence the filter by simply turning down the resonance when there is a note-off.
The filter design has voltage control over the filter cutoff. It does not have voltage control over the resonance, but it is adjustable with a variable resistance. This is handled by a MCP4131 100K 128-step digital pot. Control voltage (CV) for the cutoff is provided by a MCP4921 12-bit, single-channel DAC. 12-bits provides for a very smooth envelope. Both parts are SPI, which helps to conserve pins. Each chip has its own chip-select line.
Filter modes are selected by a CD4051BE 8-to-1 analog mutiplexer.
Software Design
The synth code was written in Arduino, which as I write is basically plain C code. MIDI and SPI libraries were used as a convenience. The code is written as a single file. There are no includes other than the referenced libraries.
Coding a synth is all about loops. There's the main loop, whose job it is to spin around checking if notes have arrived via MIDI or if it is time to service one of the envelopes. There are envelopes for VCA and VCF, as well as a simple on-off LFO for the VCA. There is also a loop for servicing the glide function. The SN76489 outputs a signal on its own once set, so other than MIDI there is nothing very timing-critical. So, everything is handled by polling and interrupts are not used (other than MIDI).
If we were playing back samples and needed to maintain a bitrate, then yes, interrupts would be necessary.
The code can be found here:
https://github.com/quarterturn/squareinator
You can use "git clone https://github.com/quarterturn/squareinator.git" to get a copy, or just use the web interface on github.
The code is licensed under GPL v2.
Hardware Design - Saving Space
To save space and cram everything in on the board, the SN76489 was placed underneath the Teensy 2.0. This worked out well, since it kept the data lines very short. Noise from the CPU does not seem to be getting into the SN76489 output at all.
How Does It Sound?
Here's a quick youtube video of me playing it badly while twisting MIDI controller knobs to demonstrate the various sound possibilities.
https://www.youtube.com/watch?v=b5AoeZAc0gg&feature=youtu.be
Conclusion
It was fun to bring back to life an old chip like the SN76489. There's nothing unique anymore about the chip - you can easily generate three independent squarewaves using the hardware timers in an ATMEGA chip and do the shift-register noise in software to a regular pin. It's mostly a nostalgia thing.
I will not be producing a kit, but boards will be available and a BOM will be posted on github so you can order the exact parts needed. The Teensy 2.0 is from pjrc.com and the V2164D is available in the USA from Small Bear Electronics. The SN76489 is available on ebay cheaply and in quantity from Chinese suppliers. I find it interesting there is that much NOS of this chip. Possibly these are new copies. I have tested the chips from a Chinese supplier and they work just like the original, so I guess it does not matter.