The circuit

On the face of it the design of a Sound Square is simple, all you need are several Infra red beams across an opening and when ever you place your hand in it you break one of the beams. Simply detect which beam is broken and you know where about the square your hand is, then convert that position into a note.  However, within that simple remit is a lot of design and construction, not only because of the number of components in the system but also trying to minimise the hardware required.

I decided to mount my components on a frame made of angle aluminium, it was an asymmetrical piece with the two sides being 1" by 2.5". I didn't use anything more fancy than a saw and a drill. The whole thing is held together by 4BA nuts and bolts although you can use metric ones if you want.

Having constructed a mount for the components now came time to design the electronics. The first problem was knowing how far apart I could put the beams. Too far and there would not be much resolution, too close together and the light from one beam would spread out and interfere with the next detector. I tackled this on three fronts, first of all I scoured the component catalogues for a narrow angled Infra red emitter. I found one in the OP298B, this has a half angle beam width of 25 degrees and a high light output, 4.8mW at 100mA. A matching detector BPV11F was found with a half angle of 30 degrees. This is a photo transistor and has enough sensitivity to detect the beam without needing further amplification, further more it has a built in filter to minimise interference from visible light. In order to reduce the stray light further I then fitted 1" long tubes over the emitters and detectors. I made these from black art paper rolled twice round a pencil the same diameter as the sensor. The ends of the roll were fixed with a little double sided sticky tape.

The final way to reduce the effects on adjacent sensors is to alternate sensor and emitter, in this way the sensors can be twice as close, as if you had a row of emitters and a row of sensors. This sounds quite complex but is quite simple, the basic idea is shown in Figure I below.


Note that the space is surrounded on all four sides with emitters and sensors, each column is labelled V for vertical and each row H for horizontal. I managed to squeeze eight beams in each direction but this can be modified for your convenience. Still, having eight sensors enabled me to split the space into 64 different sensing areas, enough for two independent banks of sounds.

This design works well but it can still suffer from light interference either from adjacent beams or from stray day, or room light. I minimised this problem by putting infra red filters over each photo transistor. If only one photo transistor is triggered from stray light then nothing on that side will work. If you are making this hardware specifically for this project then you can space the beams further apart, this will also help to minimise spillage. I originally had them at 3.5 mm intervals but this could easily be doubled.

Now when it comes to the interface you can usually trade extra hardware for computer input and outputs and this is no exception. On the face of it having 16 emitters and 16 detectors would require 32 computer I/O lines, my design reduces this to four! I could have gone for three but that would have needed much more logic circuitry and not have been worth while. So how is this trick performed?

Well, if you switch the emitters on one at a time you only need to see if any of the detectors has seen a beam. This is because if you know what light is on there is only one detector that can possibly have seen it. In fact in this design I decided to turn two emitters on at once, one  vertical and the other horizontal. Then I only need to know if I have a detection on the horizontal or vertical axis. So that cuts down the number of computer inputs from 16 to two. However, even turning two emitters on at a time would take 8 computer outputs. The way round this is to use a counter, you see you always want to turn them on in sequence so all you need is one output to clock the counter and another to reset it. You need a reset so that you know the initial condition of the counter.

This requirement of two inputs and two outputs can be met from any number of interfaces, however I found the Create USB interface offered me more than enough signal lines.

Figure II shows the circuit diagram of the emitter side of the touch screen system.


The interface outputs are fed into the clock and reset inputs of a 4 bit counter. This is then fed to a decimal decoder, this will put to a logic zero the output who's number is being addressed on the input lines. In other words if we feed it a binary count each output will go low in turn. Note here that output zero is not connected to anything as we do not want an emitter on when the counter is reset. From here we need to boost the signal to drive two LEDs quite hard, in fact we require a drive of 300mA. The LM18293 will provide this quite comfortably and so will other drivers, the push pull output of this device is not really needed but I had them to hand, so I used them. Finally you will see that each LED requires its own current limiting resistor, these should be rated at 1 watt, however as they are only on for a short length of time you could get away with using half or even quarter watt resistors here.

Figure III shows the receive side of the system,





















note that here you need to make two of these but the circuit is so much the same that it is only printed once. The second circuit should use the pin numbers for the NOR gate shown in brackets. I said that the detector could register the beam without further amplification but I found the output impedance was too high to drive a logic gate therefore, each detector is buffered with an emitter follower before being fed into a 4 input gate. This has a Schmitt input to remove any noise jitter. The two 4 input gates are combined so that the output will go low when any detector sees a beam.

Construction of these circuits is a little tricky simply because of the number of components involved. I mounted the emitters and resistors along with the detectors and transistors on thin strips of veroboard mounted to the inside of the frame, this is shown in Figure IV.


 

The Sound Square

Introduction

This project has a long gneiss. It started in 1994 as a project to make a touch screen for an Acorn Computer. Then two years later it transmuted into the sound square again for an Acorn. In those days I used to write for an Acorn magazine and produce a hardware project every month. Late in 2007 I again dragged out the hardware this time for a Macintosh running the Leopard operating system. Things have changed a lot since those days and now it is much more of a struggle to get digital signals in and out of a computer. So in this incarnation my project has much more hardware. Basically the Sound Square electronics feed into a Create USB interface. This attaches to the Macintosh via the USB port and looks like a HID (Human Interface Device) class. This is read by a patch in the language Quartz Composer and displays the screen graphics. It then passes the input information to an Objective C, Cocoa application which generates the appropriate MIDI signals. This is then fed out of the computer through a USB / MIDI interface into a MU10 tone generator. The MIDI data can, however be fed into any virtual instrument like Garage Band. One more piece of software completes the system, the XG voice changer. This basically sends the three bytes of data to the MU10 that define its voice. This is mainly a huge menu system and again is written in Objective C.

I doubt you will want to reproduce the whole set up but if you do all the information is contained here.

USB / MIDI interface

The Hardware

CUI - Interface

This is a project to convert hand position into music through the magic of MIDI

MU10 - Tone Generator

IR receptors and emitters

Interface

In order to attach this sensor to the Macintosh I used a CUI (Creative USB Interface), this is a configurable USB interface and it allows some of the driving software to be transferred from the Macintosh into the interface. This is the software that clocks the counters, delays until the infer red sensors settle down and read the state of the horizontal and vertical sensors. This is done for the whole array and presents just two bytes to the Macintosh, one for the horizontal beams and the other for the vertical ones. These have a 1 in the positions where the beam is blocked and a 0 when there is no blocking. The two custom files are contained in this link CUI_Files.zip and should be used to replace the files of the same name in the CUI software. Alternatively their is also the pre compiled code to download directly to the CUI. These files implement a state machine, details of which can be found in this article. Using the CUI with slow sensors.doc I built up the CUI on a small piece of circuit board as shown below. These are the connections to the Sound Square hardware.

PortB6 - Horizontal data in

PortB7 - Vertical data in

PortD0 - Clock

PortD1 - Reset





The rest of the electronics was on a board attached to the top of the frame. With so many wires carrying quite large pulses of current you have to be careful about the earths. For a start I earthed ( connected to zero volts ) the aluminium frame and ran separate 5 volt lines for the emitters and detectors. This caused a bit of extra wiring but I had no problem with interference. I used flat ribbon cable to run wires between these side strips and the main circuit which was mounted rather un-aesthetically on top of the frame. It is essential to get the emitters and detectors pointing directly at one an other, so a bit of judicious pushing when testing is in order. Finally the emitters and sensors were boxed in with polystyrene sheets held together with hot melt glue and then sprayed black. This helps shield the sensors from stray light. Strong daylight or fluorescent light directly onto the sensors can  make them think there is no obstruction and not register anything inside the square. To further improve matters I put a small square of infer red filter over each sensor tube.

Software

Now we need some software to receive the data from the CUI and process it into a screen display showing what beam have been broken and also identifying the crossing points. In addition I split the space into two, an upper and lower space and wanted a different marker on the screen to indicate it was being sent to a different channel. The lower on looks like a jammy dodge. Then the software needs to identify the beam crossing points and map a point to a MIDI note then transmit the MIDI. This MIDI stream can be picked up either from an internal instrument like Garage Band or some virtual instrument or sent out through a MIDI interface to a synthesiser or tone generator like the MU10. These external tone generators are becoming rare nowadays but they do a good job of generating a good sound while not loading the main CPU at all.

To handle the graphics and input side I used Quartz Composer, I generated a composition that read the CUI as a USB HID using the built in patch, generated the lines for each sensor and changed the colour depending on if it were blocked or not and placed a graphic at the crossing points of the beam. In addition it also outputted the data from the CUI. This output was read by a Cocoa application written in Objective-C by binding it to a routine that only activated when the values change. It then calculated the crossing point and performed the mapping to the required note. This mapping dependent upon what key has been selected and what octave range has been selected. These choices also affect the window around the Quartz Composer composition. The full Leopard only application can be down loaded from this link. Sound Square.zip.

MU10 Support

In order to support voice changing on the MU10 I wrote XG Voice changer. This is required because the MU10 has several hundred voices arranged in a number of banks. So for each voice it sends three defining data bytes to the output MIDI stream. If you have an MU10 or compatible tone generator it will do the job. However note it has to be XG MIDI compatible. The screen shot shows the menus and you can download the application here. XG Voice Changer.zip


See a movie of the Sound Square in action