Highly Liquid Forum facebook twitter google plus rss feed
  #1  
Old 09-03-2013, 07:24 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default The Keyboard Matrix Explained

Overview

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 UMR2 MIDI retrofit. The UMR2 works with many matrix keyboards, but compatibility with all models is not guaranteed.

Example Key Matrix

The matrix is connected to the MPU by “select” or “common” 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 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.

There are two categories of key matrix distinguished by the polarity of the select signal. In an “active-high select” keyboard, the state of each data line is low (0V) by default. The select signal is a 5V pulse. In a “active-low select” keyboard, the state of each data line is high (5V) by default. The select signal is a 0V pulse. Figures 1 and 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:

k = s * d

Where k is the maximum number of keys, s is the number of select lines, and d is the number of data lines. 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 Active-High Select” Keyboard Matrix and Select Signals


Figure 2: “2/2 Active-Low Select” Keyboard Matrix and Select Signals
Reply With Quote
  #2  
Old 09-03-2013, 07:26 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

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 Active- High Select” Keyboard Matrix, Key A Depressed


Figure 4: “2/2 Active-High Select” Keyboard Matrix, Key B Depressed


Figure 5: “2/2 Active-High Select” Keyboard Matrix, Keys C & D Depressed


Figure 6: “2/2 Active-High Select” Keyboard Matrix, Keys B & D Depressed
Reply With Quote
  #3  
Old 09-03-2013, 07:28 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

MIDI Retrofit: “Faking” the Data

To trigger a note, the UMR2 monitors the select signals of the host keyboard’s MPU. When a select pulse occurs, the UMR2 injects a corresponding “faked” keypress signal into the data lines. To the host MPU, this signal is indistinguishable from a manual keypress. Installing the UMR2 therefore involves identifying the select and data lines in the host keyboard, determining which select scheme is used (“active-high” or “active-low”), and connecting the UMR2 accordingly. 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. Please browse the rest of this forum for more information.

Figure 7: UMR2 Connections to Host Keyboard Matrix
Reply With Quote
  #4  
Old 09-03-2013, 07:31 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

Identifying a Keyboard’s Matrix Scheme

A keyboard’s select and 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. When in doubt, it is wise to use an oscilloscope to identify the select and data lines with certainty.

The keyswitch PCB of the Casio MT-210 is used as an example below. The diodes in Figure 9 serve the same function as the diodes in the schematics above. Their polarity provides a clue to the polarity of the select pulse used: review the connection of the diodes in figures 1 and 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 an active-low select configuration. If observed with an oscilloscope, the select waveforms will appear similar to those shown in Figure 2. The UMR2 is configured accordingly.

Figure 8: Casio MT-210 Keyboard Matrix Schematic


Figure 9: Casio MT-210 Keyswitch PCB—Top


Figure 10: Casio MT-210 Keyswitch PCB—Top, Detail


Figure 11: Casio MT-210 Keyswitch PCB—Bottom


Figure 12: Casio MT-210 Keyswitch PCB—Bottom, Detail
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:32 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.