Hi John,
The optical sensing uses Kingbright KM-4457F3C infrared emitters and L-610MP4BT/BD detectors. I chose these because they are relatively cheap (about 30p per pair). I found it best to mount the pairs quite close together with enough space between them to get a slip of the interrupting material between the emitter and detector. For this material I just use thin matt black card.
A typical circuit is here:
With a 6 volt supply, it is satisfactory to chain the IR LEDs in sets of four without any need for series resistors, two such sets are switched on simultaneously by the transistor. I use surface mount devices MMUN2211LT1G which include the two bias resistors in the package. When the sets of 8 LEDs are switched on by the positive pulse from the encoder, any of the detectors that aren't screened from the beam (ie the key has been pressed and the 'flag' of material lifted out of the gap) switch on.
The eight emitters A to H are commoned with the inputs to the encoder, with a further 7 arrays of the same kind, and a 1k resistor to ground on each line. In this way, the whole system behaves electrically just like an 8x8 common anode matrix. One thing to bear in mind is that the emitter/detector combinations don't switch on, and more particularly off, as fast as a signal diode so the scanning encoder has to allow (about 100uS) settling time before and after 'reading' the input lines. My encoders do this, but I can't speak for any others. Also, for a normal compass of 61/58 notes, there will one or two 'orphan' LEDS which will need a series resistor.
Here are some photos showing the key features and which also show the development from the first rather 'Heath Robinson' efforts to my current implementation.
The flags can be placed horizontally or vertically at the tails of the keys as in the second picture, or above the keys just behind the thumper bar.
Interestingly, the detectors specified actually contain two sensors (there are two emitters from each hence the three legs on the detectors) which ought in principle to allow for velocity sensing. I've only made some brief investigation of this so far, but it would overcome one disadvantage of this optical approach which is that there is very little hysteresis compared to reed relays for example. This means that it is just possible to find a point where the note will repeatedly trigger due to small movements of the flag. This is quite difficult to do, and never occurs in normal playing, but is a consideration. Exposing the array to bright direct sunlight produces some interesting (and noisy) effects too.
Nick