Figuring Out a Key Matrix (Scan Matrix)

26,643

210

17

Introduction: Figuring Out a Key Matrix (Scan Matrix)

About: www.youtube.com/EvanKale91 === www.facebook.com/EvanKale91 === www.twitter.com/EvanKale91 === www.evankale.blogspot.ca

This is a guide to figuring out how to interface with the cable ribbon of a key matrix.

A thorough run-down of what a key matrix is and how it works can be found in this PCB Heaven article: http://pcbheaven.com/wikipages/How_Key_Matrices_Works/

Here are a few hints to help you determine what keys map to which wires and where a cable ribbon of a key matrix is split into its input and output wires.

Step 1: Count the Number of Wires and Keys

I'll be using an example key matrix here which is actually the keys to a piano keyboard.

So in this example, I have a keyboard with 61 keys, and 17 wires (count the number of solder joints if the wires are too difficult to count).

From this first clue, we can tell that the scan matrix is organized in any one of the following matrices:

  • 6x11 = 66 key combinations max
  • 7x10 = 70 key combinations max
  • 8x9 = 72 key combinations max

Step 2: Find Groups of Keys

By inspecting the board, we can sometimes see groupings of the keys. In this example, we can see groupings of 6 keys per group. The keys of each group are connected together, and a break separates each group.

Counting the groups for this board, there were 10 groups of 6 keys and 1 group of 1 key. So this tells us that the matrix is organized in 6x11.

Step 3: Finding the Split

Now our goal is to find out where the split between the input and output wires are. We start by putting our meter in continuity testing, then attach the two leads to the opposite ends of the ribbon cable.

Hit all the keys to see if we get a reading. If we do, then mark down the one key that causes the reading to occur, and the direction of current (ie, which one is the input wire, and which one is the output wire).

Step 4: If No Reading?

If none of the keys give a reading, then our current needs to flow in the opposite direction (because the diodes used in the matrix limits the current to a single direction). So swap the two leads and try again.

Step 5: Finding the Next Key

Once we have narrowed down our first key, move one of the leads (either left or right) 1 wire inward, then hit all the keys again to narrow down the next key.

If the second key is adjacent or close to the first key, then we are likely moving along the keys of the same row (ie, keys in the same "group" from previous step). Otherwise, we are moving along the columns of the matrix.

In this example, the second key happens to be adjacent to the first key, so we can make a guess that the ribbon is split into 6 output wires on the left and 11 input wires on the right.

On the other hand, if the second key was far apart from first key, then it is likely that the ribbon is split into 11 output wires on the left and 6 input wires on the right.

Step 6: Repeat

Keep moving the leads inward and testing to confirm your observations. Sometimes the ribbons can be scrambled, but with enough testing, a pattern will appear.

That's all! Hope this helps!

You can check out my other projects at: www.evankale.blogspot.ca

Be the First to Share

    Recommendations

    • The 1000th Contest

      The 1000th Contest
    • Battery Powered Contest

      Battery Powered Contest
    • Hand Tools Only Challenge

      Hand Tools Only Challenge

    17 Discussions

    0
    dibyendub96412
    dibyendub96412

    2 months ago

    I have a 32 key casio SA-11 KEYBOARD. with 12 pin ribbon cable. i think scan matrix should be 8*4. but cant find split of input and output cable as mentioned in the above project. multimeter shows no value. help needed. thanks.

    IMG_20200817_220228.jpgIMG_20200817_220240.jpgIMG_20200817_220303.jpg
    0
    JohnPark
    JohnPark

    6 months ago

    If you aren't getting any continuity readings, try switching your multimeter to diode reading mode. You may have a diode matrix keyboard like I did!

    0
    goomboxaudio
    goomboxaudio

    1 year ago on Step 2

    Im having trouble getting this to work. I have a Casio with 61 keys and 17 wires for the matrix. I can't seem to get continuity at all. I assumed I could snip the 17 wires going into the main board but was that a mistake? Do I need power? I assumed that the keys work like switches plugged in or not.

    0
    Np Vishwajith
    Np Vishwajith

    1 year ago

    I tried doing it and instead of giving a sound the multimeter showed some kind of value and by doing this I figured out that on going right to left
    1st wire 1st key
    2nd wire 6th key
    3rd wire 2nd key
    4th wire 7th.... Key
    And so one
    But after 9th wire (5th key)
    I couldn't record any continuity.... Can someone plz help..

    0
    AlexTsani
    AlexTsani

    Question 1 year ago

    Hellow !! I want to replace a broken clavier (61 keys) with a new one (61 keys). The problem is that the old one has 19 pins in the ribbon wire and the new one has only 17 pins in the ribbon wire. How I should plug in the 17 pin wire to an 19 pin socket? Thank you!

    0
    gauravb79
    gauravb79

    Question 2 years ago on Introduction

    my keyboard has 16 wires

    What would be its scan matrix?

    0
    DummoH
    DummoH

    Answer 2 years ago

    8x8 seems obvious, how many keys does it have? 61?

    0
    JanM200
    JanM200

    Question 2 years ago

    So, I have an "Weinberger Elektronics Music 54 Key" keyboard. In this case, the keyboard have 2 connectors and the positiv and negativ wire to the keypad. My question is: how looks the matrix for the keyboard
    Thanks,
    Jan Metasch

    IMG_20180720_161007.jpgIMG_20180720_160952.jpgIMG_20180720_160945.jpgIMG_20180720_160934.jpg
    0
    Nesemis
    Nesemis

    Question 2 years ago on Step 3

    This doesn't work at all as it should. I've tried pressing one key at once, but 20 spent and I was done, I just plugged it like that and assumed at least one will give continuity, none gave, so I don't know what to do really...

    15318636941941121028083.jpg
    0
    Nesemis
    Nesemis

    Answer 2 years ago

    Ok, I'm working on it, here are my thoughs:
    I screwed out every screw I could and followed the path on PCB. I found out the path in my keyboard is: from 6th wire to button, then if I press it goes to diode kathote, anode goes to wire 1(the red one).Knowing that I plugged COM to red wire and that red from multimeter to 6th wire, set up a DIODE MESURE and it showed me, as it should, of course when I pressed the button. Nice, we got progress.
    Btw When I tried to mesure it with normal continuity test it showed nothing, so there are some tips for you, who are newbies to electronics.
    Brb

    0
    JoséS344
    JoséS344

    Question 2 years ago on Step 2

    My keyboard have a different cables, and dont have break, what do i have to do?

    WIN_20180126_13_07_50_Pro.jpgWIN_20180126_13_07_52_Pro.jpg
    0
    JoséS344
    JoséS344

    Question 2 years ago on Step 2

    what i have to do if it dot have a break?

    0
    DaleF22
    DaleF22

    3 years ago

    Im struggling with this! When i get to step 5 it all goes wrong. Ive attached photos of my old yamaha keyboard matrix ive located all the inputs to the keys (eg, from left to right, in ribon cable;
    Wire 1 goes to c#, g
    Wire 2 i get no continuity
    Wire 3 goes to d, g#
    Wire 4 no continuety
    Wire 5 d#, a
    Wire 6 no continuety
    Wire 7 goes to e, a#
    Wire 8 no continuity
    Wire 9 f, b
    Wire 10 no continuity
    Wire 11 goes to c, f#

    And so on up to wire 17.

    I assume even numbers are outputs but i get no continuity when searching for outputs. Ive switched polarity aswell incase current was reversed because of the diodes but still nothing when i push the keys. In fact on even numbers i get no continuity on any solderd joint.

    The part under rubber key is in groups of 6 and 61 keys.
    Im at the point of rippin my hair out. Any help??

    1488139216644277618655.jpg14881392568641243242722.jpg1488139281803-1946232372.jpg
    0
    Examper
    Examper

    Reply 2 years ago

    DaleF22 For me the wires that didn't have connectivity were 1-5 and 12-17. What I did was have the red clip on 1-5 & 12-17 and the black on 6-11 and tested enough of them until I found the pattern. Your pattern could probably be Wire 1 = c#,g for all of the c#,g and so on for the keys that you got on each wire.

    0
    FedericoA12
    FedericoA12

    3 years ago

    Is it easy to construct a scan matrix from scratch?

    0
    polikarpa
    polikarpa

    4 years ago

    Hi Man!

    I'm just proving a broken piano toy keyboard, and I can't understand how to connect it to an Arduino board.

    I've proved the connections as in the image 2 but it don't works.

    Must I use output pins in the four lines P30-P40?

    Do I need this 8 analog inputs to connect it?

    Can you help me, please? I'm too confused with it.....

    Thank you very much!

    arduinoxino@gmail.com

    Teclat_Imaginarium_Esquema.pngTeclat_Imaginarium_Conexio_Arduino.png
    0
    tomatoskins
    tomatoskins

    5 years ago on Introduction

    Key matrices are awesome! I've gutted my fair share of keyboards. Thanks for your thorough explanation!