Tuesday, August 12, 2014

Raspberry Pi NES Hack

I recently picked up one of these sexy bastards:


It's the Raspberry Pi -- a fully functional miniature computer about the size of an index card.

I decided to build a stand-alone classic console emulator: plug it into a TV, plug some controllers into the USB ports, and choose from a list of hundreds of games from the NES, SNES, Atari, Sega, or GBA (all in one). One thing that's awesome about the games on those early 3-4th generation consoles is that they took up so little memory that now you can pack thousands onto the same small console.

So that I won't have to deal with the bare circuit board, my plan's to install a UNIX-based operating system like RetroPie onto the Pi, hollow out a broken NES, rig the Pi into it, connect the NES's power/reset buttons, and alter all of the case's ports to support USB controllers, HDMI output, etc.

I'll be uploading photos of my progress onto this same post.

20140812: Got an old NES from my bud Ryan; sexy but it's no longer amongst the living



20140812: Took out its electronics, save the power and reset buttons which I plan to splice with the Pi

20140812: Spray-painted the upper case -- few coats of jet blue and a few coats of clear acrylic. Jet blue's becoming my signature, apparently.


20140812: Downloaded (entirely legally, of course) a few hundred Nintendo and GBA games to load onto the hard disk.




Wrapped up the electronics. Rigged some HDMI and USB extenders to plug the monitor and controls onto the old ports. A separate circuit let me integrate the original power and reset buttons. Liberal use of hot glue.


The original operating system is Raspbian (UNIX-based). Had to do lots of configuring to get everything working smoothly.



Now, all you need to do is press the power button on the NES, and the emulation software boots up asking which gaming system you want to play. I have 1,000 NES games loaded and am working on adding some SNES and Atari!

Glamor shot.



Sunday, August 10, 2014

Compressor Pedal

My next DIY's going to be a compressor effects pedal, because they're awesome and the sound manipulation's damned interesting.

Before going into the schematics, here's essentially what they do: given an input voltage from a guitar pickup, the compressor limits the output voltage below a preset value. It doesn't do that by just clipping any voltage above a certain value (like distortion pedals do) but instead by progressively decreasing the amplification of the incoming signal. The total dynamic range of the sound is "compressed" by limiting high voltage signals while maintaining low voltage signals, which results in a crisper sound with high sustain. Here's a clip of someone using an MXR Dyna Comp pedal, for example, and here's the sound you can get by combining a fuzzbox and a compressor.

The dynamics of the voltage manipulation break down into several aspects: the attack is the time until the compression effect kicks in after an input voltage is detected, the release time is how long it takes for the compression effect to diminish; the threshold is the voltage amplitude higher than which the compression effect takes place; the compression ratio is the amount by which the gain is reduced (this can be set such that any given input amplitude will leave the pedal with a constant output amplitude, giving you loud harmonics); finally you may need to increase the overall output amplitude to make up for the selective damping, with a level control.

This can all be accomplished with a few integrated circuits and passive electronics, which is what I'll be building over the next couple of weeks. To pick up some more intuition about the effect of compressors, though, I've been playing around with the audio manipulation software Audacity. Here's the spectrum of a distorted guitar lick without compression.


Audio sample, no compression


Now going into the compression settings:



The basic controls that will be available on the physical pedal are here, too. If I lower the threshold to its minimum value and max out the compression ratio, it applies a significant compression effect to sounds of every amplitude in the clip.


You can see based on the spectrum that the difference between the smallest and largest amplitudes has decreased -- in other words, we've compressed the dynamic range of the sound. That's what it's all about!

Another way to look at the effect is by plotting the absolute value of the output voltage amplitude as a function of the corresponding input:


 The degree of compression in this plot is quantified in units of a potentiometer's resistance setting -- 0 Ohms corresponds to no compression effect (the purple line), which is linear since any V(in) gets mapped to itself; as the value of the resistance is increased, every V(in) gets mapped to the same V(out), and in this case the dynamic range of the sound is completely compressed. Note that the frequency of the sound isn't being altered in any of this, just the amplitude -- so you'll still get distinct notes.

As for the electronics, here's the circuit diagram I'll be using:

http://www.valvewizard.co.uk/engineersthumb.pdf


It uses two op-amp integrated circuits and four current-controled transconductance amplifiers, along with potentiometers to vary the level and compression factor and passive electronics to vary everything else. In my next post I'll describe the circuit in detail and post some design plans!