Final Project

files

final code (ideal)
final code (working)

inspiration

high-low tech

initial conception

I've always been interested in electronic musical instruments; a theremin seemed like a great way to incorporate lots of different fabrication methods.

The theremin is a sound-synthesizing electronic instrument that is controlled by moving one’s hands around two metal sensors, usually antennae, aligned perpendicular to each other on opposite sides of the instrument, which is usually box-shaped and enclosed in wooden casing. The instrument converts a measurement of the hand’s closeness into an electronic signal that modifies a tone; typically, the right hand controls the volume of the tone while the left controls its pitch. It may contain an on-board speaker or send a signal to a separate speaker module or computer. I intend to make the standard right-handed configuration with a small onboard speaker.

input devices

The input signals are created by sensing capacitance to ground: a square wave is sent to the sensor and the retention of charge is measured. As a grounded electrolyte such as a human hand moves closer to the sensor, less charge is retained. I based my design off of Neil’s hello-load board, which also measures capacitance to ground but is programmed to then send data to a display. In my circuit, the capacitance measurement of the pitch antenna is used to set the value of one of the attiny's registers that defines the upper value of a steadily incrementing counter. The counter restarts from its lower limit once it reaches this top value; the duration of its count describes the period of a square wave generated by Timer/Counter 0 in CTC mode. This input is sampled frequently enough that the pitch (frequency) of the generated wave seems to respond instantaneously to the motion of a hand near the sensor. The volume antenna measures input using same method and defines the top value of an incrementing counter, but the resultant square wave is used instead to define the duty cycle of the generated pitch - the fraction of its period during which it is high. When this fraction increases, the generated sound seems louder.

The input device I used on the final music box, after failing to make my programmed attiny respond to capacitive inputs, is a simple 100k potentiometer with its poles attached to 5V and ground. It provides a variable voltage to be read on one of the input pins of the micrcontroller.

using the attiny44

Using the potentiometer as a variable input voltage, I used arduino's analogRead command and skipped the ADC resgister assignments in my final code. The code I wrote for the theremin with capacitance sensing uses the chip's ADC on the input pins to convert an incoming analog signal (calculated as the average of signals read during the square wave's high and low). I took a lot of the initial bit assignments from neil's codes for the tiny44 and did not need to thoroughly research how each bit in the ADC resgisters function. However, I did thoroughly research the timer/counter register functions so that I could get the exact functionality I wanted. The Atmel microcontroller datasheets seemed more and more like treasure troves the deeper I got into this project, and I came to understand the different timer/counter modes and decided on setting T/C0 to CTC mode, which allows a variable input voltage to control the frequency of the generated square wave. I set timer/counter 1 to fast PWM mode, which allows a variable input voltage signal to control the duty cycle of a second square wave, which them modulates the first.

hardware and housing

The outer casing of the speaker can be made of wood, plastic, metal, or composite - I am hoping to make a simple wooden case on the ShopBot. I am hoping to make speaker cones out of a fiber/epoxy composite during wildcard week, and potentially to use the coil-winding machine in the Harvard machine shop to wind speaker coils. During molding and casting week, I created a mold around a small tree branch in Oomoo with the hope of casting a Cerro-tru branch to use as a sensing antenna. Unfortunately, this mold shape is very difficult to cast in as the metal cools before it can reach the end of a long cavity. While this would be a visually interesting direction in which to take the project eventually, for now I’ve milled two straight steel antennae to use in the interim. I got to take the basic training course at the Harvard machine shop and used their bandsaw, grinders, and sanders to create the antennae. (update 12/12: I've decided to use copper sheets as sensors, since the metal antennae were not so responsive to a hand unless I touched them. I've cut leaf shapes out of copper on the vinyl cutter to use as sensors; these will read more similarly to the copper sheets used as sensors during input devices week.)

output devices

The output value OC0A is read on pin 5 (PB2) of the ATtiny44 and is connected to the gate of a surface-mount transistor, which drives the speaker. The output of the volume control pin drives the gate of a transistor that pulls current from the pitch fet's gate to ground.

failures, trials, tribulations

The first four or five boards I designed and made were so finicky that I redesigned rather than refined them. This is partly due to my stubbornness - I always opted to solder on wire connections manually instead of learning how to mill a double-sided board. I did try using drill holes and routing wires underneath the board, but this was no more convenient than routing wires over the top and make the board harder to handle on the tabletop. I burned several attiny44 chips as a result of faulty wiring, or routing, or occasionally for no discernible reason.

On day t-2, I set a potentiometer on fire (visible orange flames) by accidentally shorting 5V through it; the faulty setup attached the power supply and pot to the same two pins, which allows too much current to pass through the pot when the wiper is set all the way high. The pot now seems to respond to touch; the pitch generated by the music box does vary as you move your hand closer to the pot and touch it. I am nor sure that this would have happened with a brand new pot or if it is a result of the abuse this one suffered. I didn't replace it because we didn't have any in the lab with similarly sized tactile knobs.

Dim LEDs: Throughout the trial stages of my final project board, I noticed that the power and signal lights would turn on, but very faintly. I always had bigger problems to deal with until the final week of the class, when I tried replacing my 10k current-limiting resistors with 1k resistors. This seemed to fix the brightness issue; the LEDs seemed to glow with full brightness when they were on.