Introduction: Antique Light Bulb Organ - MIDI/OSC Controlled
12 light bulbs correspond to the 12 notes in an octave (minus the octave note). The rectangular box unfolds to position the light bulbs vertically for display, while at the same time providing a platform for the keyboard in use. Playing a note on the keyboard directly via midi, or through the usb port illuminates the light bulb for a particular key. Releasing the note, releases the key. Pedal presses are also recognized and keep the bulb maintained. The bulbs can be controlled without a computer by using the front mounted midi port, or via computer which allows for remote control via midi or osc messages. More about that later...
The light organ was built for and is currently in use by the band Future Dancing , see the video below to see it in action!
Future Dancing - Telling Stories from Future Dancing on Vimeo.
- 12 MIDI/OSC controlled light bulbs via DIN-5 MIDI port or remotely over USB
- Integrated USB hub providing 2 additional powered usb ports.
- Case unfolds into keyboard platform allowing for mounting on just about any keyboard stand.
- Really annoyingly bright LED that indicates to the player where the control is coming from, as if they didn't know...
Step 1: Overview
I figure there's three significant parts to this project, so I'll split this up into sections in case you're not interested in a particular one.
I. Construction - wooden enclosure etc. (step 2)
II. Electronics - microcontroller circuit and solid state relay control (step 7)
III. Software - avr code as well as virtual midi and osc driver (OSX) (step 11)
Step 2: Construction - Design
This part of the instructable would be a lot better if I hadn't left my drawings at home depot when I bought the wood. Luckily that was after I had cut the wood when I went back to buy some hinges. Either way, the truth is, the box construction wasn't well planned and I think I got pretty lucky that it ended up fitting together properly.
The most important things I wanted to keep in mind when designing this were that it needed to be durable for portability, and not require a lot of assembly, since there's not usually a lot of time setting up on stage. It would have been a lot easier to construct something that didn't contain the actual light bulbs, in other words, if the light bulbs had to be screwed in and removed for each use, it would be able to be a lot smaller. Something to keep in mind if you're building your own.
So, the design process for me basically came down to one thing, the width and height of the light bulbs, as that pretty much determined the size of the box. Once I settled on the idea that the light bulbs would fold down inside the box, the rest sort of came easily.
Step 3: Construction - Outer Frame
Once I settled on the overall dimensions, it was time to start cutting. I got a single sheet of 3/4" plywood from home depot and cut the appropriate pieces out of the wood. For each piece I cut it a little bigger than my actual measurements. By assembling one piece at a time, gluing and screwing in the wood, then sanding down the edges, I was able to get a smoother joint between the various pieces. I don't have the proper tools to make the precision cuts that would be necessary for properly making a box like this, but it works out okay if you're willing to take some time with a sander.
Each piece was individually cut then glued with wood glue, and screwed in using countersunk drill holes to keep the board flush on the sides and top. The corner pieces had additional 3 sided angle brackets to provide more support. I glued and screwed just about everything together with the exception of the top. For the top, I only screwed it in, so that I could sand it down and get the edges smooth, but still be able to remove it for installing the electronics and later on for staining the wood.
Step 4: Construction - Light Bulb Stand
In order to fold the light bulbs into the box, the platform they stand on needed some hinges. There's probably a couple ways I could have done this, but for safety reasons, I felt covering up any route to the mains electrical voltage for the user was a necessity. So the way it works is kind of like an L that can be folded in either direction. There are 3 hinges on the board with the light bulb, which connect to the top of the box for folding down. Another three hinges are on the other side, connected to another board, which acts to prop up the light bulbs when the box is open.
The board that props the light bulbs, and the light bulb platform itself, needed a 45 degree angle cut on side in order for them to bend together properly when the box is closed. I did this using a table router with a 45 degree cutting bit.
Once the boards were cut, I drilled the holes in the main board using a 1 1/4" spade bit. Something to take note of when using these kinds of bits, they are great at cutting nice round holes of an exact size, they are also great at completely tearing up your wood on the reverse side you start on. See the photos below. Fortunately only the top is visible so I didn't really care, although it did make it a little more difficult when mounting the bulb sockets later on.
Step 5: Construction - Plugs/Switches
The two front panels were relatively easy to put together. The left one needed 4 panel mount assemblies, which all had circular cutouts, so that was easy. The right side has the power switch and a secondary USB port which is internally connected to the hub, for a second usb device of any kind.
The left panel has an indicator led at the top, a pushbutton switch for setting the home note position (explained later), a midi input, and a USB input.
The right panel has the main power switch, and a second usb input.
The only difficulty here was the rectangular usb input and power switch. Both were meant for thin metal panel mount systems, and as a result my 3/4" wood posed a problem. However, with a straight cutter on my router I was able to cut out the back of the panel a bit to make the wood thinner in the area where the connectors went, without sacrificing any ugly protruding front panel parts.
The two panels sit back about a quarter inch because the switch on the right panl sticks out a bit, as well as the led indicator. If they were flush, the box wouldn't close flush at the end.
The last picture shows cutting of the power switch, and later on the USB output. I don't have any magic tools to do that with, just a drill and files, It takes a long time, it's boring, and it's frustrating. I guess when they were designing USB ports they didn't consider them being placed in wood enclosures, jerks! Oh if I only I had a laser cutter to help me with those in the future.... :D
Step 6: Construction - Staining and Assembly
Once I had most of the boards put together, before I started to put all the electronics and switches in, I did the staining and lacquering. Couple coats of each was enough. Then I put the hinges back on and was ready to move on.
Step 7: Electronics! - Light Bulb Sockets
Before I talk about the electronics driving the light bulbs, let me first talk about the sockets. You might not guess the most expensive part of the project would be the sockets, but they actually were. The bulbs I was able to get from here for about $1.90 a piece (they were cheaper when I bought them). The sockets I got from grand brass for about $2.50 a piece. Although sockets are a fairly common thing, they're not as cheap as you might guess, and it was difficult finding any that could be mounted in any way to a panel as well as having a fairly low profile. In fact, it wasn't until stumbling across these that I was even able to move forward with the project.
Anyways, the sockets have two connections for the electrical. One side on all the bulbs is connected all the way back to mains connection. The other side is connected to a relay (see next step), which is connected to the other side of the mains. So essentially all the light bulbs are connected in parallel, which is really the only way to do this.
Since the sockets had screw terminals for the connection, I used the obvious choice of crimp connectors to connect to them, which also saved some time on the wiring. (Anytime you can use crimp connectors you should, they're easy and reliable!)
Step 8: Electronics! - Light Bulb Relays
As I mentioned in the previous step, the light bulbs are connected at one side to one side of the mains, the other side is connected to a relay, which is connected to the other side of the mains. Activating the relay closes the connection around the light bulb switching it on. There are a lot of choices for relays, but one obvious bad choice would be a mechanical relay. The last thing you would want when playing music would be the constant click of a mechanical relay (they're actually quite loud). The best alternative is a solid state relay which allows you to control an AC line by simply switching on a low power led (~10-20mA). Any microcontroller/arduino can easily perform this task. The solid state relay (SSR) I used is the PR36MF22NSZF which you can get from digikey or mouser or any place like that. This particular relay, in addition to being small (8 pin dip package) and silent, also allows for control of 240VAC up to 600mA! That corresponds to ~ 70 Watts at 120V. (120V * .6A= 72 W). So technically I could plug in 70 watt bulbs and be okay, although I don't think my eyes or anyone elses would be.
The circuit of what all the relays look like with the bulbs is the last picture above. Because it's so simple, I just picked up a small perf board at radioshack . The resistors leading into them are necessary since the microcontroller is sending out 5V. If you've ever lit up an led with a microcontroller pin, this is the exact same thing, literally. Inside the solid state relay is a small infrared emitting led which sits next to a photo sensitive mosfet. When you light up the led, the mosfet closes. If you check the datasheet, you need 1.2V across the led with 10mA of current. So, from 5V you get: 5V - 1.2V = 3.8V .....3.8V/(10mA) = 380 ohms. Actually anything in this range will work +- about 100 ohms.
The microcontroller connects to the two relay boards with one strip of ribbon cable, explained in the next section.
Step 9: Electronics! - Microcontroller & MIDI
I'll get into the microcontroller code in the next section, for now the important things to know are that I'm using an Atmega324p with an ft232r usb -> serial adapter, and that's about it. I had a bunch of these boards laying around from an old project, in a small form factor that worked out perfectly. That's my only reason for the choice. However, this particular controller had some additional features that really added to the project. Number one, it has two hardware UART ports, that means I can listen and send messages over USB as well as midi at the same time on separate ports. Also, there are many more pins, so driving the 12 pins for the relays was a simple task. In addition to the two ICs (integrated circuits) I also needed an optocoupler to listen to messages coming in from a midi cable. There's a lot of information out there on how to hook this up, I just copied those circuits and had no problems.
The eagle files for the controller board are attached, and you can see the schematic above at the end. Nothing really special going on there. Something to keep in mind if you're thinking of building something like this, an arduino would be able to do all this very easily, even those mini ones, all you really need is the solid state relays, then it's only a matter of controlling 12 leds. Also, since the board was made with a different purpose in mind, the power pin on the USB is not shorted to the power on the uC. I did this with a jumper wire underneath the board, which isn't visible in the pictures.
The last thing that's happening from the microcontroller is the LED control of the indicator. It's an rgb led, so there's three pins for that.
Step 10: Electronics! - Power and Hub
The last part to the electronics is the USB hub and the power supply. Because the hub I bought is powered, I use the USB power to actually power my microcontroller and solid state relays. So I only needed to connect the hub to the power and then connect my controller to the hub. I got a nice thin hub from frys I think? That was kind of a last minute idea, but definitely worth it. I ended up only using three of the 4 ports, but I can live with that. One port connects to the main controller and gives it power, the other two connect from the front panels as expalined in step 5.
Because the power adapter for the hub was meant to be plugged into a wall, I had to pry it apart to get at the wires. I then connected one of the two wires to the mains input, the other to one side of the main power switch on the front. Then from the switch back to mains. That way the main power switch provides power to the controller as well as the light bulbs. Take a note of the third picture, after soldering to the two AC wires, I used shrink wrap to isolate them. That's very important. If it's not obvious at this point, the electrical part of this project is very dangerous if you don't know what you're doing! Using shrink wrap to cover any electrical leads to mains is vital for your own safety.
For the usb output port on the side I used this vertical connector from sparkfun. I then cut the usb cable from the hub to a nice short length and wired it up to the breakout board. (I was starting to run out of space in these corners, so long usb cables had to go.)
Once all the connectors were made, I mounted the power supply and hub to the insides of the case with hot glue and epoxy. Laugh all you want! Hot glue is awesome! No it's not good for long term, but it is great for short term to hold things in place while your long lasting epoxy is able to cure.
Step 11: Software - Microcontroller Firmware
Although the Atmega324p isn't probably the most widely used microcontroller (uC), most of this code will work just fine on the more popular atmega168 series that is used on arduinos. The only major modification would be the implementation of a software UART for the MIDI port since the 168 series only has one UART. However, that feature could easily be left out, as I have to admit, I've never plugged a device in directly through MIDI ever since I finished testing that it worked.
The firmware on the uC is setup to handle either input from the MIDI port, the USB port, or both simultaneously. Switching between modes determines the routing of the messages. In addition, the home note can be set either remotely or locally using the front pushbutton switch. When the switch is pressed, the next note pressed and released on the keyboard will set the first light bulb to be that note. This obviously isn't a necessity, however, I find people are a little less mystified as to what the lights are doing if they see the light bulbs light up in sequence from left to right. When the root note of the key your playing in is the first light bulb, the lights tend to jump around a little less erratically, depending on what you're playing of course. The nice thing is that since this can be controlled remotely, it's easy to set the key of your song so that it automatically updates every time you switch tracks (see the last section on the max4live object using ableton).
When the mode of the unit is switched, the front led lights up a different color, indicating whether the local user has control or whether it is remotely controlled. This goes in the pretty much useless but looks cool category.
The majority of the software is setup to handle the incoming messages (midi/usb). The external crystal drives the uC at 18.423MHz, in order to get 0% error at 115200 baud rate. Aside from going line by line through the code there's not much more to talk about, feel free to ask any questions you have, the codes provided below. The zip file has the entire project inlcluding the avrstudio file (avrstudio5, I recently upgraded and converted all my old projects, you should too! its so much better than avrstudio4!). I left out the individual UART files since they are readily available elsewhere.
Some helpful points when writing for midi. You'll need a UART clock of 31250 baud, which means, for a 0% error, you need a crystal with an integer multiple of that. That works out okay though, since the built in 8Mhz works fine, or 16Mhz, etc. However, a problem arises when combining MIDI UART on the same chip as RS232 UART. The "standard" baud rates, 9600, 112500 etc, don't work well with 8Mhz crystals. So, what to do....well there's two choices IMHO.
1. Use the built-in crystal or similiar frequency (8Mhz...or 16Mhz, 20Mhz etc) and use baud-rate aliasing to correct for the usb.
2. Accept error on one of your lines. Personally, I don't like this option, I know a lot of people run things at 9600 baud with 16Mhz crystals, but I don't like to.
So, here's a bunch of links to aliasing the baud rate using the FT232R driver. I have done this on a PC and a MAC, it works great, and allows you to send data at much much higher transmission rates than RS232 was meant for. For example, instead of peaking at 225kbps, you can go all the way up to 3Mbps (although most atmegas can only do 2Mbps).
How to do it on OSX (follow the steps very carefully, it does actually work, I promise)
And, on a PC
Great article on aliasing the baud rate for using xbee controllers for midi (PC only)
Also, you're going to want to reference this page if you're writing any code for dealing with MIDI messages
Step 12: Software - Virtual MIDI/OSC
Normally, this part of the project would typically be just as time consuming if not more so. However, I've made quite a few devices in the last couple years, and they all talk to the computer using the same routing program for OSC and midi messages. All the code is below, but probably would need an instructable of it's own to make much sense. The main files that are important for this project are the lightOrgan.c and lightOrgan.h files, which are also provided here separately. The midi functionality comes from the RtMidi C++ library , which is fantastic by the way. It allows you to create virtual midi devices and send and receive messages from them, not much else you need! The OSC functionality comes from the liblo osc library.
I worked on this software for a while a long time ago as part of another project which I still currently use , which is why the main program is called polynomeSerial. It is basically a reimplementation of the monomeSerial software, for anyone who uses monomes. Over time I've added more and more hardware to it. Since I have it running while I'm playing, it's an easy way for me to add more and more hardware to my setup without having to do much programming. All of the hardware I make uses the same USB interface, the FT232R usb to serial adapter, and uses the same communication protocol for sending and receiving messages. The same two message protocol that is used by the monome (by no coincidence of course).
Although monomeSerial has a nice GUI to go with it, for whatever reason a while ago I thought it would suit me better to run out of the terminal. So, there's really not much to show. The program runs by opening up a terminal, and using the command:
l for light organ, p for polynome, and a few other pieces of hardware still in the works are in there as well. Again, feel free to ask questions if you go digging through the code.
Step 13: Software - Max4Live
The last bit of software here is a max4live patch, not much to it at all as you can see. Simply allows me to keep the home note saved for each track by designating the key for the song. The real utility is in the polynomeSerial patch which creates the "light bulbs" midi object to send notes to.
Step 14: Completion!
Also, for other projects that haven't made it to instructables...yet, visit here.
And please please vote for me for the Epilog challenge! If I win I'll be able to finish a laundry list of projects still in the design phase, and I promise to post detailed instructables on all of them, including the already finished ones.
Second Prize in the
3rd Epilog Challenge