Currently available for freelance and full-time roles in the experiential media space!
Jason Webb

DIY synthesizer boards using ATMega328s and Auduino

September 2011

As part of a large series of projects for an upcoming art show, I have created a set of five custom synthesizers that use ATMega328s with custom firmware (using the Arduino framework) that each convert data from a different type of sensor into musical notes. The idea was to create a series of objects and gadgets that are similar enough to be recognizable, yet different enough to convey different thoughts and concepts.

Each synth was originally intended to utilize a different sensor, but I ended up using three distance sensors for time considerations. Therefore, this post will document the design and construction of the synth in general, with notes at the end about what to do to make a board unique once it is completely built.

Schematic

In this project, an ATMega328P microcontroller is the brains of the operation, and is configured to run whatever is in its memory core as soon as power is supplied, with a 16 MHz external clock.

Initially, I wanted to burn the Arduino bootloader onto these chips myself, but had some difficulties. Of course, as soon as I admitted temporary defeat doing so, Lady Ada posted a fantastic tutorial on burning bootloaders to these chips that might be of use.

Instead, I opted to buy five ATMega328 chips from SparkFun that come with the Arduino Uno Optiboot bootloader pre-loaded. Call me lazy, but it worked like a dream!

Technical note The real reason that made it difficult for me to program the ATMega328P chips that I had ordered from DigiKey was that I had actually ordered ATMega328-PU-ND chips, which have a slightly different device signature than plain ATMega328P chips expected by the Arduino IDE. Some hacking of the boards.txt and avrdude.conf files would be necessary to add support for this chip, but since I was short on time (or thought I was), I opted to order the chips from SparkFun just to be safe!

The rest of the schematic is pretty self-explanatory, so glance over it and take a look at the bill of materials that follows.

I was expecting to install these synths in an environment that had 12V lighting rails throughout the room, so it made sense to me to create a 12V->5V regulator section for the schematic to obtain 5V power without need for external AC wall warts. Obviously, you don’t need to do this if you have 5V power already.

Bill of Materials

1 – ATMega328P w/ Optiboot bootloader (microcontroller)
1 – 28 pin IC socket (microcontroller)
1 – SPDT slide switch (on/off switch)
1 – LM7805 voltage regulator (power supply)
1 – .33uF capacitor (power supply)
2 – .1uF capacitor (power supply)
2 – 20pF capacitor (external clock)
1 – 16 MHz crystal (external oscillator)
1 – 10k resistor (reset pull-up)
5 – 10k trimpot (four for the synth, one for the amplifier)
1 – 3mm green LED (power indicator)
1 – 1.8k resistor (power indicator)
1 – 10uF capacitor (decoupling)
1 – 25k resistor (amplifier)
1 – TIP120 Darlington transistor (amplifier)
1 – 8ohm .5W speaker (amplifier)

Circuit board design

To help me plan my soldering and wiring, I jumped over to Eagle’s PCB tool to route all the connections. If you had the means, you could absolutely etch this out yourself (might be a fun future project for me), but I executed this board on perfboard.

The yellow lines indicate unrouted connections, but I found them helpful to imagine as jumper wires. These yellow lines were simply used to indicate where wires should be placed.

Perfboard wiring

Since I didn’t have the materials or skills required to etch these circuit boards myself, I opted to follow the PCB layout as a guide for wiring up these synths on perfboard.

And here is what that PCB design looks like executed on perfboard:

Sensor calibration

Although most sensors are designed to operate (and output) between 0-5V, you will find that every sensor will be most sensitive or most active within a certain band of voltages. For example, a photocell, set up in a voltage divider, would theoretically result in 0V when no light is falling on it, and 5V when a lot of light is falling on it. But what happens when you are placing the sensor in a dimly lit room – can you expect to see its full range of voltage? As you can see, each synth could be tweaked to account for each sensors individual characteristics so that it creates a pleasant range of musical notes under specific conditions.

I chose to add every sensor I planned to use onto a single breadboard, then loaded Firmata onto single Arduino Duemilanove board so that I could access sensor data through it using Processing. In about 20 minutes, I had whipped up a simple Processing sketch that graphs voltage measured at one analog input as a function of time (yes, analog fanatics, I basically wrote an oscilloscope, but hey, it was free this way!).

With this Processing sketch loaded, I simply moved the Arduino analog pin connection to different sensors and observed the effect it had on the rolling graph. I outputted the current exact value to the console, and made diligent notes about the effective ranges and behaviors of each of the sensors I had. This provided me with a reasonable maximum and minimum value for each of the sensors, so I could scale the input data in the Auduino sketch appropriately.

An interesting result of this experiment was to see the relative stability of each of the sensors. In other words, how stable the signal is from reading to reading. CdS photocells have a relatively stable signal, due to their relatively slow reaction time to stimuli, whereas infrared rangefinders have a noticably higher amount of noise. What this ‘fuzziness’ translates into in musical terms is the degree of a spastic tremolo effect. In other words, it is easier to maintain a single note intentionally with a less noisy sensor than with a more noisy sensor.

Load the Auduino sketch onto the ATMega328

Once a board has been created, the hardware can be brought to life using a sketch on the ATMega328. I based this synth on my prior experience with the Auduino synthesizer sketch.

What is Auduino?

Auduino is a two-channel, granular FM synthesizer that takes input from five variable analog voltage sources (like potentiometers) and creates an awesome musical output. In project, four trimpots are used for four of the voltage sources (controlling decay and pitch for the two channels), but the frequency of the synth is determined by an infrared rangefinder.

Auduino converts an analog voltage signal (represented as digital values in the range 0-1023) to a notes that belong in the pentatonic scale. In other words, regardless of the sensor used, the tones produced will ‘snap’ to notes found in the pentatonic scale, which is commonly used in rock and folk music.

Programming the ATMega328s

Loading the Auduino sketch onto the ATMega328 is a relatively trivial process, once the bootloader is loaded onto the target chip. Simply follow the instructions from the official Arduino website here:

Upload Using an Arduino Board

Once loaded, you can drop the ATMega328 into the 28-pin IC socket of your synth!

Assembly

Using the schematic I created earlier, I tested out the synthesizer on perfboard to see how it sounds and works. Next, I used the PCB design to wire up all of the electronic components on an appropriately sized perfboard. I created five identical boards this way, but planned to use different sensors for each one. At the top of the perfboards (above the LED and resistor) you’ll see a slide switch and a 1N4007 diode, which are simply used to cut power to the board and protect the 7805 against reverse polarity respectively.

Installation at the Artist in Residence show

These synths were specifically meant to be installed in a collaborative art show on the UNK campus called Artist in Residence. While I did have all five synthesizer boards completed, I didn’t work out interactions planned out to utilize five unique sensors. So, in the interest of time, I simply made three synths that all used long-range infrared rangefinders from Sparkfun. I modified the code for each synth slightly so that they each made somewhat unique noises, which is demonstrated in the video below.

The synths are hanging from two concentric rings of anchor wire fastened to wooden fixture hanging from the ceiling. The rings of anchor wire are connected to a power supply’s +12V and GND lines respectively, so that the synths also receive power from the wires they are hanging from.