The Keyboard Matrix ExplainedOverview
It is common for an electronic device to have a large number of input buttons (or "keys"). The device's microprocessor (MPU) must monitor these inputs. Since any MPU has a limited number of I/O pins, it is often not practical to dedicate a separate pin to each button or keyswitch.
This is especially true in the case of a musical keyboard. If each keyswitch were given a dedicated MPU I/O pin, a keyboard with 32 or 49 keys might not leave any I/O pins for other functions. To make efficient use of MPU I/O, keys are arranged in a matrix. Almost all non-velocity-sensitive musical keyboards use this approach. What follows is a description of the keyboard matrix circuit and its relation to the UMR MIDI retrofit kit. The UMR kit works with many matrix keyboards, but compatibility will all models is not guaranteed. Example Key Matrix
The matrix is connected to the MPU by "select" lines, which are MPU outputs, and "data" lines, which are MPU inputs.
To monitor the keyswitch states, the MPU sends a brief pulse to each select output, one-at-a-time. Each pulse "selects" a group of adjacent keys. Any closed keyswitches in the group will allow the pulse to pass thru to the data lines, which are "read" by the MPU. All of the keys are read continuously, many times per second. This allows the MPU to respond almost instantly to keyswitch state changes. In a "scan high" keyboard, the state of each data line is low (0V) by default. The select signal is a 5V pulse. In a "scan low" keyboard, the state of each data line is high (5V) by default. The select signal is a 0V pulse. Figures 1 & 2 below are examples of simple keyboard matrices. Each is a "2/2" select/data configuration for a 4-key keyboard. In practice, keyboards will have a larger number of select & data lines. Typical 32-key configurations are 4/8, 8/4, or 6/6. 49-key keyboards often use a 9/6 matrix. The maximum number of keys supported by a matrix configuration is governed by the following equation:
Note that each keyswitch is accompanied by a series diode. This diode prevents a potentially damaging short-circuit between select outputs. It also allows the MPU to accurately detect the key states when multiple keyswitches are closed.
Figure 1: "2/2 Scan High" Keyboard Matrix and Select Signals
Figure 2: "2/2 Scan Low" Keyboard Matrix and Select Signals Example Keyswitch States and Data Waveforms
Below are several keyswitch states and the resulting data waveforms for the simple 2/2 matrix. Note that any possible combination of keyswitch states will produce a unique combination of data waveforms.
Figure 3: "2/2 Scan High" Keyboard Matrix, Key A Depressed
Figure 4: "2/2 Scan High" Keyboard Matrix, Key B Depressed
Figure 5: "2/2 Scan High" Keyboard Matrix, Keys C & D Depressed
Figure 6: "2/2 Scan High" Keyboard Matrix, Keys B & D Depressed MIDI Retrofit: "Faking" the Data
To trigger a note, the UMR monitors the select signals of the host keyboard's MPU. When a select pulse occurs, the UMR injects a corresponding "faked" keypress signal into the data lines. To the host MPU, this signal is indistinguishable from a manual keypress.
Installing the UMR therefore involves identifying the select & data lines in the host keyboard, determining which select scheme is used ("scan-high" or "scan-low"), and connecting the UMR accordingly. The UMR has DIP switch settings that allow it to calculate which select/data combinations correspond to which MIDI notes. For many keyboard models, the connections have already been tested and documented. For other models, installation may be possible after a bit of inspection as described below.
Figure 7: UMR Connections to Host Keyboard Matrix Identifying a Keyboard's Matrix Scheme
A keyboard's select & data lines are typically connected from the main PCB to the keyswitch PCB via a ribbon cable. With a help of a continuity tester, the pins of the ribbon cable can be traced to the contacts of the keyswitches. Select lines are typically tied to groups of adjacent keys. Each data line will be connected to one keyswitch in each group. A few keyboard models differ from this convention—these will not be compatible with the UMR.
Note the diodes on the keyswitch PCB. These are the same diodes shown in the schematics above. Their polarity provides a clue to the scanning scheme used: review the connection of the diodes in figures 1 & 2, with respect to the data lines. The keyswitch PCB of the Casio MT-210 is shown in figures 10-13 below. 8 select lines are connected to groups of 6 keys each. The 9th select line is connected to a single key. Note the keyswitch diodes on the underside of the PCB. The anodes are connected to the data lines. This indicates a scan-low configuration. If observed with an oscilloscope, the select waveforms will appear similar to those shown in Figure 2. The UMR is therefore assembled in a "scan low" configuration. The UMR is further configured for the installation via DIP switch SW1. Positions 5-7 specify the number of data lines: "on, off, on" for the MT-210. There is no manual setting for the number of select lines—at power-up, the UMR automatically detects the pulses on its select inputs. SW1 is also used to set the set first note of the UMR's MIDI response to match the first note on the MT-210. The proper UMR "scan speed" setting (SW1 position 8) can be determined through trial-and-error. The "off" setting works well for the MT-210.
Figure 11: Casio MT-210 Keyswitch PCB—Top, Detail
Figure 13: Casio MT-210 Keyswitch PCB—Bottom, Detail |
||
| Site and images copyright 2004-2008 Sonarcana LLC. | ||