electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Arduino
The Casioduino Project - Understanding the Keyboard Matrix
Post new topic   Reply to topic
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
MusicMan11712



Joined: Aug 08, 2009
Posts: 720
Location: Upstate New York USA
Audio files: 148

PostPosted: Tue Jul 17, 2012 6:15 am    Post subject: The Casioduino Project - Understanding the Keyboard Matrix Reply with quote  Mark this post and the followings unread

Last summer I started getting into Arduino midi programming with some simple midi in and midi out sketches.

This summer, I was throwing out a dead Casio CT-615 [non-midi] keyboard which my sons had talked me into buying at a neighborhood sale. After I took it apart, I noticed that the insides looked like something had been spilt on it. I had no desire to try to fix it, but began to take it apart just to see how it worked. Thus, the idea of the Casioduino was born.

The first task was to figure out how 61 keys came out of 17 leads on a ribbon cable. So I learned about keyboard matrixing (there are 10 groups of 6 keys each plus one group with the top C) and adapted an Arduino sketch written using a KeyPad library from Wiring.

Here are some of the resources on understanding the keyboard matrix I found useful.

1. http://www.rtbot.net/Keyboard_matrix_circuit [brief, easy-to-understand overview]
2. http://www.dribin.org/dave/keyboard/one_html/ [detailed, easy-to-understand explanation; includes explanation of the use of diodes]
3. http://arduino.cc/playground/Code/Keypad [Arduino Keypad Library; link to tutorial]
4. http://home.roadrunner.com/~jgglatt/hardware/key.htm [using PIC16C84; includes schematic; uses 74LS138 (mux)]
5. http://wiring.org.co/learning/ [host site for KeyPad and other libraries and sketches]
6. http://weltenschule.de/TableHooters/Casio_MT-540.html [circuit-bending resource for MT-540 (tone bank) with comments about many other Casio models]
7. http://weltenschule.de/TableHooters/ [host site for "warranty void" with circuit-bending details for a number of keyboards]
8. http://generror.wordpress.com/2010/07/08/history-of-casio-keyboards-2/ [non-tech historical explanation of Casio keyboards & features]
9. http://arduino.cc/forum/forums.html/topic,60248.0.html [Arduino Forum discussion; has some insights]

Highly Liquid has their own MIDI CPU board (among other products). Their explanations, schematics, etc. can be applied to Arduinos and others.
10. http://highlyliquid.com/hl2012/blog/52 [“The Keyboard Matrix Explained”]
11. http://forum.highlyliquid.com/showthread.php?t=724&goto=nextnewest [connection for using 1 MIDI CPU with 2 61-key matrices]
12. http://forum.highlyliquid.com/showthread.php?t=716&goto=nextnewest [connection for using 1 MIDI CPU with 128 switches]
13. http://highlyliquid.com/support/docs/pdf/MIDI-CPU-Hardware-Rev-K.pdf [also shows hookups for rotary encoders among others]

I hope these links are helpful. Thanks to PHOBoS and Cyno for pointing me to a number of these links.

Steve

PS: I have numbered the links. If you find that any of them no longer seem to work, send me a PM with the number of the link(s) and either the name of this thread or a link to it. Thanks.

PPS: Here is another insightful link posted by richardc64 in another DYI thread.
14. http://pcbheaven.com/wikipages/How_Key_Matrices_Works/ from "Cheap Keyboard --> sequencer" - http://www.electro-music.com/forum/post-365817.html#365817

Last edited by MusicMan11712 on Sun Jul 22, 2012 5:58 am; edited 4 times in total
Back to top
View user's profile Send private message
elmegil



Joined: Mar 20, 2012
Posts: 1472
Location: Chicago
Audio files: 14

PostPosted: Tue Jul 17, 2012 12:12 pm    Post subject: Reply with quote  Mark this post and the followings unread

Do you have a link to the sketch or your project? This sounds very interesting, and that set of links very useful.

Thanks!
Back to top
View user's profile Send private message
MusicMan11712



Joined: Aug 08, 2009
Posts: 720
Location: Upstate New York USA
Audio files: 148

PostPosted: Tue Jul 17, 2012 8:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

elmegil wrote:
Do you have a link to the sketch or your project? This sounds very interesting, and that set of links very useful. Thanks!

For what its worth, here's the code so far. When I get around to putting in a midi out (or two), I will simply change the text going to the console to midi out data. The Casio has a volume slider. Since the keyboard is not velocity sensitive (the keys are just switches), I might try using the volume slider to set velocity of note ons.

Steve

Code:
// Based on the KeyPad library (See CustomKeypad.pde.)

// Mods for testing Casioduino by Dr. Steve 9 July 2012
// His son Avi also contributed.

/* Coded for Casio CT-815 keyboard using 10 sets [rows] of 6 keys [columns] each.
C, C# D, Eb, E, F
F#, G, G#, A, Bb
etc.

The keyboard matrix comes out via 17 leads
(10 rows + 6 columns, plus 1 row for top C --not used here)
See RowPins and ColPins for connection of the Casio keyboard matrix
leads into the Arduino. For this test of the connection,
I started with pin 31 of the Mega 2560 and used the Casio leads
in order (from 1 to 16).

*/

#include <Keypad.h>

const byte ROWS = 10; //ten rows
const byte COLS = 6; //6 columns

char keys[ROWS][COLS] = {
  {1,2,3,4,5,6},
  {7,8,9,10,11,12},
  {13,14,15,16,17,18},
  {19,20,21,22,23,24},
  {25,26,27,28,29,30},
  {31,32,33,34,35,36},
  {37,38,39,40,41,42},
  {43,44,45,46,47,48},
  {49,50,51,52,53,54},
  {55,56,57,58,59,60},
};

byte rowPins[ROWS] = {31, 32, 33, 34, 35, 42, 43, 44, 45, 46 }; //connect to the row pinouts of the keypad
byte colPins[COLS] = {36, 37, 38, 39, 40, 41}; //connect to the column pinouts of the keypad
byte CasioduinoKey = 0;
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  Serial.begin(9600);
  keypad.setDebounceTime(0);
  keypad.setHoldTime(100000);
  Serial.println("You may now start.");
}

void loop(){
  keypad.getKeys();
  if(1)
  {
    for(int n=0;n<LIST_MAX;n++)
    {
      char key = keypad.key[n].kchar;
      CasioduinoKey = byte(key);
      if(key != NO_KEY && keypad.key[n].stateChanged)
      if((keypad.key[n].kstate!=IDLE) && (keypad.key[n].kstate!=HOLD))
//    if (key != NO_KEY)
      {
//        Serial.print(key);
        Serial.print("Casioduino Key # ");
        Serial.print(CasioduinoKey);
       
          if(keypad.key[n].kstate==PRESSED)Serial.println(" was pressed");
          if(keypad.key[n].kstate==RELEASED)Serial.println(" was released");
                   
          delay(10);
         
      }
    }
  }
}

Back to top
View user's profile Send private message
MusicMan11712



Joined: Aug 08, 2009
Posts: 720
Location: Upstate New York USA
Audio files: 148

PostPosted: Tue Jul 17, 2012 8:41 pm    Post subject: Reply with quote  Mark this post and the followings unread

Here's a sample of the output that is sent as text. Thanks to help from Jan and Scott, I used PuTTY instead of the Arduino IDE's built-in serial monitor.


CasioduinoKeyReadSampleOutput.JPG
 Description:
 Filesize:  29.3 KB
 Viewed:  3442 Time(s)

CasioduinoKeyReadSampleOutput.JPG


Back to top
View user's profile Send private message
Cynosure
Site Admin


Joined: Dec 11, 2010
Posts: 666
Location: Toronto, Ontario - Canada
Audio files: 34

PostPosted: Wed Jul 18, 2012 6:14 pm    Post subject: Reply with quote  Mark this post and the followings unread

Thanks for putting all the links in one place Steve. This will help when i get around to doing something similar.
Back to top
View user's profile Send private message
Cynosure
Site Admin


Joined: Dec 11, 2010
Posts: 666
Location: Toronto, Ontario - Canada
Audio files: 34

PostPosted: Tue Jul 31, 2012 6:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hi Steve. I just came across this and thought it might be useful to you.

http://arduino.cc/forum/forums.html/topic,57211.0.html
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1 [6 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Arduino
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use