Hi, I need to build a simple/cheap MIDI controller for the old but still=20 good keyboard (49 keys). The keyboard switches are organized as follows (ASCII art - use fixed=20 width font to see it): Global rail A ---o \____ individual key pin Global rail B ---o To implement the dynamic keyboard, I have to detect three states: a) Idle state - key pin connected to rail A b) Intermediate state - key pin not connected at all c) Pressed state - key pin connected to rail B The key press velocity will be measured as inverse of time when the key is in the (b) state. I can see two ways to simply detect those states 1. With switched rails Both rails are pulled-up to Vcc via 1k resistors. Each key pin is connected to the input of microcontroller or PISO register (like 74HC165) which is also pulled-up via e.g. 20k resistor. The readout is performed as follows in two steps: 1.1. - rail A is actively shorted to GND (via open-drain output). I read all inputs - '0' state informs that particular key is released 1.2. - rail B is actively shorted to GND (via open-drain output). I read all inputs - '0' state informs that particular key is pressed If '1' is read in both steps, than the particular key is in the intermediate position. This solution is very simple (e.g. I can read a series of 6 74HC165 PISO registers with single SPI), but may lead to increased RF radiation from switched rails. 2. With rails connected to GND and VCC The rail A is constantly connected to VCC, while rail B is constantly connected to GND. The key pins are connected in a following way: rail A --o R1 1k \---+=3D=3D+---+-----+-------- X uC input (one per key) rail B --o | | -+- | R2 20k C1 100p -+- +--+=3D=3D+-- Y uC output (one per a few keys) | -+- In this solution the rails are connected to constant voltages so RF radiation is much lower. The software works as follows: 2.1. Y is set to '1' and after 10us all inputs are read if X remains '0', it means, that key is pressed 2.2. Y is set to '0' and after 10us all inputs are read if X is '1', it means, that key is released If key is neither pressed nor released, it is in the intermediate state. In the second approach I can use small microcontrollers like e.g. ATmega8A to service groups of 17 keys. Then the Y output is loaded with 20k/17 > 1k which is quite acceptable. Those microcontrollers may calculate key velocities in parallel and communicate with the=20 central uC via I2C (TWI) or USART in 9-bit mode. The central uC will send MIDI commands via USB-MIDI or serial MIDI. Do you think, that there is any more efficient way to implement controller for such keyboard? I'll appreciate any remarks and suggestions. --=20 Regards, Wojtek Zabolotny (wzabise.pw.edu.pl) Do you need to sort data stream in FPGA? Get free, BSD-licensed sources at: http://groups.google.com/group/alt.sources/msg/aba5ae202bdaecd8? --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .