Governor Technology recently took some time out to build their first Raspberry Pi experiment - a musical robot which can be played remotely via the internet. Here we talk about how we put the experiment together.
It started as a vague concept - we had been keen to experiment with a Raspberry Pi for a while, so we started to form an idea around creating a robot to play a musical instrument. Lots of suggestions were put forward including a robot that plays a set of minature doll's drums, but we settled on the idea of using a set of metalic chimes because they were easier to get hold of, and it meant we could create a robot to play some simple musical notes.
We figured that in order to hit the chimes and produce a note we would need to drive some solenoids from the Pi. Solenoids are essentially magnetic coils with a metal plunger in the middle designed so that activating the coil causes the plunger to push or pull something. By activating a push solenoid briefly we felt we could make it strike a chime and then retract leaving it to ring out a note!
To drive the solenoids from the Raspberry Pi we needed some kind of breakout board, so we purchased a PicoBorg (see here for more details). The PicoBorg plugs into the Raspberry Pi allowing it to drive four servos, or in our case solenoids. Four is a bit of a limitation in terms of playing musical notes, but it's good enough for a proof of concept!
Once we had all the bits together we set about soldering the solenoids onto the PicoBorg. We also needed a 12V DC power supply to power the solenoids, so we cut the end off an old laptop power adapter and soldered that onto the PicoBorg as well.
We powered up the Raspberry Pi, installed the PicoBorg software, switched on the power to the solenoids and tried some of the test scripts. To our pleasant suprise everything worked first time - we could activate and deactivate the solenoids using python scripts running on the Pi.
The next problem was how to suspend the solenoids over the chimes accurately so that a brief activation would strike the chime below. We played about with a few ideas but ended up making a simple rig out of wood with a glue gun, which did the job. So we glued the solenoids onto the rig and positioned that over the chimes.
Then we needed a server application on the Raspberry Pi that would accept incoming requests and play a sequence of notes. We knocked together a simple python script using Flask for this, which takes a text string containing the notes to play and the durations, and strikes the chimes in the right order with a delay between each note.
The final step was to put a web page together to host a live stream of the robot and to allow external users to send requests to the Pi. We used ustream.tv to host the live video stream, and created a very simple page with a form to send the requests to the Pi.
The Next Step From Here
As a first effort I think it is a pretty good proof of concept. Of course there are loads of ways we could improve it: add more notes, have a more sophisticated user interface for entering the tunes, add some sort of queuing system to handle larger numbers of users, add beaters to the robot to make the process of striking the chimes more visual and perhaps get clearer sound.
Let us know what you think via twitter, and we will think about building version two of the Raspberry Pi-ano incorporating the most popular ideas!
We made some improvements to the original pi-ano. Read about the upgraded version here...