Keyboard scanner hints
Paul Schreiber
synth1 at airmail.net
Sat Dec 26 00:26:16 CET 1998
Here is an GENERAL overview.
First, you have to figure out which keys are up & which are
down. There are 2 ways of doing this.
The first way is "serially". (this is done on the Synergy, for example).
The keyboard MUST have a common busbar for key DOWN and
individual switches for each key. You attach a 'pullup' resistor to each key
(A 10K SIP pack is perfect for this) and attach the bussbar to GROUND.
Next, you get say 9ea 74HC151 8:1 muxes (about 50 cents each). These parts
act like a 8 position
rotary switch, based on a 3-bit digital input. Assuming a 61-note keyboard,
you
take 8 of the '151s (8x8=64, 3 left over) and attach 1 key to 1 mux input.
All of
the select inputs (A, B, C) are bussed together. Lastly, you take the 8 mux
outputs,
and tied each one of THOSE to the 8 mux inputs of the 9th '151. Whew!!!!
OK, now we are cooking! we have a 2-tier scanner, that needs 6 bits of
"address"
to "look" at each key, ONE AT A TIME. You can scan with a uP, you can scan
with 2ea 74HC161
counters (50 cents each). You connect the 3 LOWER address bits to the 8
bussed selects, and the 3 UPPER
address bits the the 9th '151.
So to "look" at a key, all you have to do is "address" it (000000 is the
leftmost key, 000001 the next one, 111111 the
rightmost) and if the output of the 9th '151 is a LOW, that key is DOWN.
(otherwise, it's a HIGH because
we pulled it up, remember???)
Now, if we want to get REAL clever, we can add velocity sensing in BOTH key
down & key up. How??
What you do is have 2 bussbars: one common for keys UP and 1 common for keys
DOWN. Then you
attach BOTH busbars to ground!!! So, what happens is that the "addressed"
keys start by reading a '1',
then they read a '0' AS THEY ARE TRAVELLING BETWEEN BUSBARS, then they read
a '1' again!!!
So, all your uP or circuitry has to do is TIME how long it read a '0' for
each key. Of course, you have to
assume that on power-up initialization, you don't freak out the logic by
HOLDING KEYS DOWN!! That of
course will read the scans 'backwards' for velocity.
I built a monophonic keyboard with low-note priority (ie Moog) using this
scheme. No uP: about $7 worth of
TTL chips. It used a 6-bit counter, that was latched in a 74LS273 when the
key down signal arrived. A 10-bit
DAC was used to for the CV. The GATE output was a simple flip-flop, and the
TRIGGER was a 555 timer
that "stretched" the key down signal. I scanned EACH key about 28 times a
second with another 555 timer.
The second way (what you would do today, most likely) is use a MARTIX SCAN.
The surplus keyboards
(like the Panasonic rubber dome types) are pre-wired in an 8 x 8 matrix with
blocking diodes.
A uP sets up 1 8-bit OUT port and 1 8-bit IN port. You then output a
"walking 1" pattern
(00000001, 00000010, 00000100, etc) that "scans" a set of 8 common keys. If
a '1' shows up at the IN port,
that key is DOWN.
Again velocity is a matter of keeping a table of "hey, the key changed
states for N scan times, then it stopped".
If you can each "column" every 1ms then you can quantize the velocity in 8ms
steps.
Hope this sheds some light!!
Paul Schreiber
Synthesis Technology
www.synthtech.com
More information about the Synth-diy
mailing list