MIDI Glockenspiel

Striker

Arduino & Shield

Arduino Shield

Drive Electronics

Using an Arduino make a computer controller MIDI Glockenspiel

Introduction

This project first saw the light of day at Christmas 1993 as my 124th constructional article in “The Micro User” magazine for the Acorn Archimedes or BBC computer. It was easy in those days to get an output from a computer, as these two computers had “User Ports” dedicated input / output ports brought out to a connector. Nowadays it is much more difficult to set a bit accurately timed as the operating system gets in the way. Therefore I decide to move the intelligence away from the controlling computer into an Arduino controller board and have the instrument driven from a MIDI signal that could be derived from computer, controller or instrument.


A Computer Controlled Glockenspiel or Quasimodo's revenge

The idea was to take a child's toy xylophone and get the computer to play it. Now I know that the computer is capable of making noises electronically but it is much more interesting to watch an instrument being automatically played. I am sure you have all seen crowds around fair ground steam organs, whereas tapes of the same hardly sell at all.

Now I found it impossible to find a toy xylophone but relatively easy to find a toy glockenspiel, a quick trip to the dictionary soon put me right. A xylophone is an instrument with wooden bars and a glockenspiel has metal ones. Therefore the shops were full of glockenspiels, don't you just love the trade descriptions act?

The one I have decided to use is from the “Early Learning” shops and seems superior to others. It has eight notes, a good computer number, and each bar is electronically tuned. This process involves removing some metal from the back of the bar until it rang at the right tone. The result is a tuned instrument with a pleasant tone, unlike some of the other toys available.

Now to decide how to strike the bars. The commercial bells use small clappers attached to a coil rather like a relay. I considered using this approach at first. You take a small relay and glue a thin but stiff wire on the moving part. To the end of the wire you attach a plastic striker and mount the whole thing on a frame. Well despite the low cost of this approach it did seem to be rather messy and involve a lot of mechanical work, so I thought again.

An electrical component designed to produce a striking movement is the solenoid, the problem is that they are quite expensive especially when you consider how many we will need. However, I found that they fitted particularly well on my glockenspiel. Underneath the instrument I fitted a perspex (that’s plexiglass for those of a U.S. persuasion) plate and drilled holes under each bar, to mount the solenoid. Then I placed a small screw metal block, taken from connection block, over the end of each solenoid plunger to stop it falling out. I found this arrangement did produce a bit of clatter when the solenoid was released. This was solved by pushing a small amount of foam rubber under each stopper. With the bars removed from the glockenspiel the solenoids did tend to stick in the up position but once the bars were in place they prevented this from happening.

In fact the glockenspiel and the solenoids fitted so well together you would have though that they were designed to do just that. So next I had to decide how to drive the solenoids. In this incarnation of the design I used an Arduino board to take in MIDI signals and use the MIDI protocol to determine what solenoid to energise. The output pins of an Arduino are only 5 volts so to convert the logic signals up to the 12 volt levels needed to drive the solenoids I used an LM18293 driver chip. These have the added advantage of having an enable input as well as a drive signal. Now it should be easy to have the Arduino simply turn on the solenoid and after a short time turn it off. Unfortunately this is a fine adjustment and is best made while listening to the instrument. So I used some hardware to determine the length of time the solenoid was driven. The Arduino can be programmed to provide a very short pulse whenever any new note is to be sounded, this I use to fire a mono-stable. Now a mono-stable is not a dwelling for an unmarried horse, but a circuit that will produce a fixed pulse output in response to an input logic edge. The pulse width is determined by an external resistor and capacitor and so we can adjust it to match our glockenspiel. Too short and the plunger does not have time to travel to strike the bar, too long and it is held against the bar stopping it from ringing. Note that this is a polyphonic arrangement, that is, we can play as many notes at the same time as we wish -  what the musical boys call chords !

The circuit diagram of the drivers is on this page and it is designed to turn the solenoid on with a logic one. The mono-stable drives the enable input of all the drivers so we only have to write a bit pattern once and then forget about it until next time. Note that the driver chip needs to be fed with both 5 volts, for the logic and 12 volts needed for the solenoids. You can drive the solenoids from a single supply and have the Arduino regulate it provide the 5 volts for the logic and the Arduino.

Now the program that has to be put into the Arduino can be downloaded here:- MIDI_Glock.pde. It basically takes the MIDI “Note On” message and transfers it to the appropriate output pin. Note here that not all the MIDI not numbers are used to activate a solenoid, as well as restricting the notes to the octave the instrument can play we must also filter out all the sharps and flats because we have not got any on this toy.

To do this I use an array that either contains the Pin number of the required output or a zero. A zero is used to signify that this note corresponds to a sharp or flat (or a black key on the keyboard) as this instrument strictly in the key of C. It is relatively easy to map what octave the instrument will respond to by setting the “baseNote” variable.

When setting up the system remember to swap the link on the Arduino to allow it to be powered from the external power socket rather than, as normal, the USB cable. This caught me out on several occasions.

If you are using a Mac then you will have Garage Band, unfortunately this does not have any MIDI output capability but there is a free ware utility called midiO to give it one. Unfortunately it does eat up processing time and with a Power PC mac mini, it stalls with even one other MIDI track saying their are too many tracks. It faired much better no my Mac Book Pro. There are other music packages with MIDI output capacity but you have to purchase them.

This link shows you a “You Tube” video of the project with a sample of two tunes.