Plagiarize Something: Synthesizer Edition

March 20, 2013

IMG_20130317_135057

Welcome to Who Plagiarized It Anyway?, the DIY game show where everything is replicated by following a tutorial and the points don’t matter.

This past week-and-a-half or so, I put almost all my other commitments on hold to build this super great little synthesizer. Why build a synthesizer in a wearable computing-centric course, you might ask? Because synthesizers are cool and 8-bit bleep sounds make me happy. If you’re interested in following along and building your own, you can find the tutorial on Instructables here.

The synth is very simple and easy to use. A power input is featured on the left side of my box, and a 1/4″ audio output jack on the front. In the photo above I’ve used a 1/4″ to 3.5mm adapter to hook it up to my speaker system at home. I will note that, in the event that you get to use my version of this project one-on-one, you should be discouraged from using headphones, as this thing is pumping out a 5v signal that will probably-certainly make your ears bleed.

At the top of the box are a power switch and LED, a tempo knob and orange tempo LED, a frequency knob to control the pitch of your sound, and a big shiny record button for storing sequences of pitches into temporary memory for looping.

The real source of magic (frustration) behind this project is the brain of my synth – the ATtiny45, an 8-pin microcontroller. Although the tutorial has instructions laid out for using the Arduino as well (which I have actually used in the past), I was encouraged to go this route. Although this slowed down my progress very early on thanks to a moderate learning curve, I ultimately gained valuable knowledge and am far less likely to shy away from using it in future projects.

Big thanks to Steve Daniels for supplying me with the ATtiny45 chips I used, the AVRISP mkII programmer to make them do things, and some subtle guidance throughout the process.

IMG_20130315_155124

My proto-synth, a.k.a. my components laid out on a breadboard.

Pictured above is my prototype, laid out only moments after I got the ATtiny45 working for the first time. The reason this took me so long to get off the ground (2 nights worth of troubleshooting to be precise) was because I needed to do more tinkering than I’m used to in order to program the darn thing. Whereas the Arduino is essentially a plug-and-program device, the ATtiny45 required the use of an external programmer (in this case, the AVRISP mkII) and the use of a voltage regulator (a 7805). The ATtiny wants 5v of power and I had 9v, and for some reason I didn’t realize this until the second night. Why? A) because I’ve never used a regulator before, and B) because I brushed over any mention of the 7805 in the tutorial. To be fair, the tutorial assumed a lot of things about my prior experience going into this project. Google was certainly my friend in this journey.

Luckily, the 7805 is very simple to use and after getting over that hurdle the programming process went through fairly smoothly. I followed this tutorial to get the programming ball rolling, adapting any mention of the Arduino to the AVRISP mkII I used.

In the photo above on the right side you can see my AVRISP mkII connections still intact. To program the ATtiny, I laid the chip between those connections in the centre of the breadboard. The programming itself was done through the Arduino IDE, just like programming a regular Arduino.

IMG_20130316_131130

Planning out the holes to-be-drilled on my enclosure.

I’ll use this out-of-context photo to talk about a couple more of my challenges in getting the ATtiny45 to abide by my will. Firstly, although I had successfully programmed the chip after two nights of tinkering, the sound output was sounding like a rapid series of irritating ticks. After doing some research (because of course, the tutorial didn’t make any mention of this possibility), I theorized that I was having a clock speed issue. A virgin ATtiny45 runs at 1 MHz, though bootloaders can be burnt onto it to have it run at 8 MHz (which it is natively capable of) or 20 MHz (which requires an external crystal oscillator hooked up to the chip).

For some reason I thought burning the 20 MHz bootloader onto the chip would be a good idea. It turns out that once this has been done, the ATtiny wants to run at 20 MHz no matter what. As a result, I was unable to program the chip after this point, much less burn the correct 8 MHz bootloader. Luckily, I had two ATtiny45s! Of course the solution was to burn the incorrect bootloader onto both chips! Huzzah!

So now instead of a terrible sounding synth, I had two bricked microcontrollers. It turns out the only way to alleviate the issue (outside of a hard reset) was to give the chips what they wanted. I purchased a 20 MHz crystal and a couple 18 pF capacitors, hooked them up to the ATtiny’s, and upon burning the 8 MHz bootloader was back in business!

IMG_20130316_135344

Drilling holes from my enclosure.

IMG_20130316_143750

A close-up of the box with the components mounted.

IMG_20130316_143859

The underside of my mounted components.

IMG_20130316_152834

(Almost) everything mounted and looking shiny!

IMG_20130317_010735

My circuit board with most of the components soldered on.

Of course the issues didn’t end there. Although I had gotten my ATtiny’s to work once again, the sound output was still poor. I was troubleshooting the issue at school one afternoon and ran into David Bouchard who I am eternally grateful for. Not only did he basically volunteer to help me fix this issue, he stuck around for likely close to two hours until my synth was sounding great.

I won’t get too in-depth here, but I’ll summarize the gist of it:

1) I needed to be designating certain pins on the chip as analog inputs rather than digital (it seems the ATtiny45 is a bit more fiddely in specifying the I/O than Arduino is) — this wasn’t related to the sound issue, but to the potentiometer I was using for my tempo, which it turns out wasn’t actually doing anything.

2) I needed a capacitor (10 µF) on my power rails to address the sound issue. This wasn’t mentioned in the tutorial at all, though he used an Arduino through his process which may explain some of the discrepancies I was having. Nonetheless, this made everything work and brought a smile to my face.

IMG_20130317_014555

The circuit board, components, and enclosure coming together.

If I said those were the last of my issues, I would be lying however. It turns out my enclosure is made of aluminum. Apparently aluminum is a conductive material and you shouldn’t be leaving electronic components on it all willy-nilly. This caused more than a few short circuits, though my sleep-deprived brain presented me with the ingenious solution to tape all of the things! Long story short: I masking taped a lot of the box and some of the component leads, and that made everything work just fine.

You can check out a brief video documenting my fun playing with the synthesizer below.