STYLOPHONE MIDI CONTROLLERTo use a Stylophone as a MIDI controller, we need to be able to work out which pad on the keyboard the stylus is touching, convert this to a MIDI note value and send a MIDI "note on" message to a sound module (or to the MIDI interface of a PC running synthesizer software like Propellerheads Reason). When the stylus is no longer touching the same pad on the keyboard we need to send a MIDI "note off" value for that same note value, to stop the note ringing on. The pads on the stylophone "keyboard" are connected to each other through the resistors you can see on the top of the board. The first note (A) is connected to the second note (A#) through a resistor, which is connected to B through another resistor and so on. Therefore the further you are down the keyboard, the more resistors you are connected through. The total resistance between the stylus and one end of the keyboard depends on the pad the styus is touching. This arrangement is called a resistor ladder... by measuring the resistance you know how far you are "up the ladder". The resistors in the stylophone have specially chosen values that will make the synthesiser circuit sound the right note, but for our purpose we just need a predictable resistance for each note. To measure the resistance and convert it to MIDI we'll use a microcontroller (a small computer on a single chip) board. A good choice is an Arduino compatible board, as you can download free software for programming it and there are loads of projects out there to try. Here I am using a Miduino board (http://tomscarff.110mb.com/miduino/miduino.htm). This as a couple of special adaptations for MIDI and also makes a nice general purpose Arduino clone, but any Arduino or compatible clone will do for this project. OK, first we need to get into the guts of the Stylophone and hook up some wires that will allow us to hijack its keyboard. Mine is an "original" 1980s one which is pretty easy to take apart, just be careful not to break any wires or bend components... I've not seen inside the "reissue" Stylophone but I guess its much the same. You need to attach a wire to the point (Connection 4) at which the stylus joins the PCB - this is the brown wire in my pictures - and a wire to the "bottom" of the keyboard (Connection 1) - this is the orange wire in my pics. Now you need to attach a wire to the top end of the keyboard (Connection 2).. on my Stylophone this joins to the synthesiser circuitry and I thought the circuitry between this point and the stylus might cause problems.. especially when putting a voltage across the keyboard.. so I cut the PCB track at this point and added a wire (Connection 3) to the other side of the break so that the wires can be joined together to play the Stylophone normally. The pic does not show the break too well.. it is on the track which joins Connections 2 and 3... the top one of the pair of tracks there. I scraped a break with a small screwdriver. Now reassemble everything. Connect the wires from Connection 1 and Connection 2 to GND and +5V output of the Microcontroller board and connect the wire coming from Connection 4 to one of the analog input pins of the Microcontroller board. One additional thing is that we need to add a "pull up" resistor to our analog input. Without this, the voltage coming from the stylus will be changing randomly all over the place and will give us all kinds of false readings when the stylus is not touching the keypad. I added a 1 Megaohm resistor, which I placed between the analog input and the +5V power pin. The idea is that when the stylus is not touching the keyboard, it will be "pulled up" to 5 volts through the resistor, so we will read a predictable value for "stylus not touching keyboard" but when we do touch the keyboard, the resistor has sufficiently high resistance to not affect the voltage we pick up from the keyboard. Its a crazy plan but it just works... Here is the Microcontroller board with the wires and resistor in place. On my board the analog inputs are marked A0, A1 etc (I am using A0) and the power outputs are marked +5V and GND. My board has header pins sticking out the bottom so I can pop it in a breadboard for easy tinkering! Note that for now the wire from Connection 3 is not connected to anything. The Stylophone should be switched off and does not even require a battery for this.
In order to program an Arduino microcontroller board, you usually use a serial cable. I have a USB to TTL adaptor cable which connects to header pins on the board (coming in on the left in pic) OK... now we need to find out what reading we get from our analog input pin when we touch each key pad on the Stylophone. To do this we can use the Arduino development environment (free download from http://www.arduino.cc/) to compile, and upload to the board, the simple program below void setup(){ To see the output from the program (with the serial cable connected to the board), open Arduino's Serial Monitor window using the toolbar button Ensure that 9600 baud is selected. Touch the stylus to each keypad in turn and note the value that is shown You will see the values vary a bit, but try to get an "average" value of each note. You shoudl find the values across the keyboard range from 0 at the bottom to something like 1000 at the top. When the stylus is not touching the keyboard you should see a value around 1020. Make a note of the value for each note, and then edit the following Arduino program to use your values (which might be different to mine). The numbers you need to change are in the scale array... #define LedPin 13 // MIDI Functions from Tom Scarff's MIDIUNO projects // Send a MIDI note-on message. // Send a MIDI note-off message. // Send a general MIDI message #define NOTES 21
int getNote(int input) void setup(){ You can change the values of MIDI_CHANNEL and MIDI_VELOCITY. MIDI_A is the bottom note value (for the low A on the stylophone). You can shift octaves by adding or subtracting multiples of 12. OK now the exciting bit! You'll need a MIDI lead and a MIDI socket. Solder a couple of wires to the socket as shown below (it will help to use 2 colours, since MIDI DOES care about polarity). In case its not clear below, the black wire goes to the second pin from the left.
Now take the other ends of the wire and connect them to the serial port OUTPUT of your Arduino board (My Miduino board has a dedicated MIDI out header, but this duplicates the serial output) Compile and upload the above program to your board (disconnect any MIDI hardware first... the serial interface is shared with MIDI a lot of non-MIDI garbage goes out during program uploads... this has a tendency to crash most MIDI software!) Once the upload is complete you should see the pin 13 diagnostic LED flash when you touch notes on the Stylophone.. this indicates outgoing MIDI traffic. If you use a program like MIDI-OX (http://www.midiox.com/) you should be able to see the MIDI events (if you can't, first thing to try is to reverse the wires of your MIDI out connection in case you have them back to front) Now connect up your favorite soft syth or sound module and enjoy!! To get your Stylophone back in working order you need to join the wires from Connection 2 and Connection 3 together. I've put a 3.5mm stereo jack socket on mine to run the 3-wire Arduino connection (when you pull the plug out the connection to restore working order is made automatically) What Next...
Since the stylus is measuring a voltage not a resistance, I think it should be possible to run multiple styluses on the same keypad and read their voltages individually... you could assign them to different MIDI channels and sounds and get polyphonic multi instrument thing going on.. a whole orchestra coming out of one stylophone... imagine the possibilities :) The Arduino has 6 analog inputs so getting 6 styluses working together should be possible, if you can find a way to hold them all.
You could hide the microcontroller PCB inside the stylophone case and put the MIDI output socket on the outside. The Miduino can run off a PP3 battery so the whole thing could be made self contained. This would obviously be much easier if you ripped out some of the guts of the stylophone to make space, but I think it should be possible to squeeze everything inside without resorting to such destructive measures and still leaving a working stylophone.
Now if you DID rip out the guts of your stylophone.. there are a few other things you could try... Arduino has total 6 analog inputs and (depending on your flavour of clone board) up to 12 usable digital I/O pins. There are all kinds of possibilities for adding extra switches and knobs to the stylophone and using the Arduino to send MIDI messages based on analog or digital states. For example you could add "mod wheel" and pitchbend potentiometers and maybe a rack of accordion style bass buttons.... if you do anything like this be sure to share it! Likewise if I get round to this I will post some info up here
Cheers/Jason
|



