Jump to content

Scan matrix for keyboard


John_W._Couvillon
 Share

Recommended Posts

Thorston,

I recently "liberated" a three manual keyboard assembly from a "Saville" electronic organ. In its present form, each of the  three keyboards is wired in an 8x8 matrix with a diode in series with each key (blue band on the diode on the switch side), installed on the opposite side of the key switch from the common bus(row- with 8 switches per row)

Each keyboard is wired to a small pc board with a 74hc151 chip, and there is one pc board receiving feed from the 8 row inputs of each keyboard all connected in parallel. The  row pc board  has a 74C42 chip on it. Needless to say, I don't have a schematic for the keyboards, and don't know what the cabling from the keyboards connected to.  However I would like to use as much of the installation as possible.  Actually, since the keys are attached to pc boards with the diodes just as you show them on your example schematic,  It would be easy to use a core for each keyboard and merge them, or set up a dout and din as per your example and the setup in the referenced website(below), daisy chaining them with one core.

I have reviewed your download examples 1 and 2 for setting up an 8x8 matrix and also found an example using that data on line at "http://www.midibox.org/dokuwiki/doku.php?id=midiboxkb_-_using_a_c64_keyboard_as_input "  which uses your example to encode a C64 keyboard.  I don't see why that method won't work on a keyboard. However, I have 3 keyboards and also a 32 note pedal.  Your example indicated an upcoming example of how to extend the matrix to up to 1024 buttons or switches.  I don't need 1024, but  half that number would be great.

Can this be done with one core, two, three?

My existing system uses two cores with 4 DINs on each, encoding two keyboards, pedal, stops and pistons.  A 32x32 matrix approach would simplify the wiring, reduce the number of DINs and increase the number of switches available.

If anyone reading this post knows of a source for schematics for the "saville" organs, please email me at jwcouvillon@cox.net.

Regards,

Johnc

Link to comment
Share on other sites

Hi, since I spent many time at scan matrix keyboard (and I will ;D) then probably you can check if my solutions are good for you.

The diagram of keyboard you can write yourself by checking each cable and pressing keyboard, but I don`t know how to utilize 74hc151 chip`n`dale ....  ;)

Maybe you can use keyboards without  this chip , and without garlic sauce.... ;)

Just pure keyboard and MIOS hardware. My 88keys keyboard is powered by this way.

If you need more infos about it please write me a priv message.

Link to comment
Share on other sites

Hello QBAS,

Yes you are correct,  I traced out the circuitry and can very easily delete the existing chips and use midibox devices to implement the switch matrix.  However,  the  existing design  looks a all three keyboards in one matrix and scans them all. One chip a 74c42 is a BCD to Decimal decoder. there are 4 inputs to this chip, the connection points to the pc bd are mared c8, c16, c32, c64.  Eight of its ten outputs feed the rows of all three keyboards in parallel. 

Three 74hc151  8 input  multiplexers are used, one for the columns of each keyboard.  There is one output from each multiplexer, and three inputs which are marked c1, c2, c4.  So th 7 inputs and  three outputs.  Since I don't have the rest of the circuitry,  i don't know where the inputs came from or where the outputs went to.  However,  There was probably a processor or clock producing a 8 bit binary number, and the c1.2.4.8.16.32.64 came from it.  The mux output from each of the multiplexers was a serial train that probably was processed by a processor to a specific note, activating an oscillator, etc.  Evidently no midi was involved.

My question is how to configure the matrix, midibox dins and outs with the pic core to scan all three keyboards.

Johnc

Link to comment
Share on other sites

If this keyboards have 61 keys each, then 3x61=183keys one pole.

16x16 matrix give you 256 switches so it is enough to use.

I really don`t know about use egzisting chips, since I always use chips introduced here.

I`m faithful as dog  ;)

But you can simply check datasheet and compare etc.

Since on my keyboard was not known chip I replace all electronic parts by the best hardware under sun: MIOS hardware.

Link to comment
Share on other sites

QBAS , Thorston

You are absolutely correct, and I do intend to use midibox designs for the encoders.  I just didn't want to tear out any components before I knew exactly what to tear out.

I have reviewed Thorston's circuit diagram for the 8x8 matrix and it uses only one 8 bit chip on the DIN (74HC165) and one 8 bit chip on the dout (74HC595) for an 8x8 matrix.

The three manual keyboard stack  is wired as an  8x24,  8 rows and 24 col's.  In terms of midibox, the dout is connected to the rows and the dins are connected to the columns.  So to run an 8x24 matrix, I would need one DOUT chip, and three DIN chips connected as in Thorston's example.  Thorston, will this work with the app examples listed on the website, or is come additional codeing needed.

I would prefer to do the  encoding with one core if possible, rather then three.

Also,  the diodes are in backwards from Thorston's example.  The cathodes are wired  through the key switch to the row bus.  They are not directly connected to the common row bus.

Any help would be appreciated.

Johnc

Link to comment
Share on other sites

QBAS,

If I add all the other things I need to the switch matrix, I think that a 16x16 would cover the ground.  Did you write the code to go from 8x8 to 16x16?  Would it work for me.  I am not sure what the velocity business is, however all my switch inputs are just open close switches. 

What App program do you use with a 16x16 matrix,  midio128?  How do you match up the switch positions with the .ini file?  With the standard DIN and Midio128,  each pin is programmed. Is t here a special .ini format for the 16x16?

Thanks,

Johnc 

Link to comment
Share on other sites

John what help you need?

If I put 16x16 matrix code can you do rest of code alone?

If not please specify more clear about your project.

I know 3 keyboards with only one switch under right?

So it is without velocity. how many more switches you need (like sustain etc...)?

Link to comment
Share on other sites

  • 2 weeks later...

QBAS,

Thanks for your reply.  The devices I want to include on the matrix are dry switches on a pipe organ console, no velocity, or anything like that.

The total count for the keyboards and pedal would be 215  (3 ea at 61, 1 at 32).  It would be good to add the stops, pistons, etc to that number, to bring it up to 256, but  256 won't cover the total.  The three keyboards are idential, actually wired as 8x8 matrixes, with the 8 rows connected together to form a 8x24 matrix.

To get a 16x16 matrix,  I will have to separate the rows.

The pedal board consists of 32 individual  key switches, no matrix, but can be wired that way

I am currently using two midibox cores with 4 DIN modules on each, to encode 2 keyboards, pedal, stops, pistons, swell, and will reuse thecores and DIN's with the matrix.

A matrix covering the three keyboards, plus other switches to get to 256 would be on one core if possible, and the second core would cover the balance in normal DIN fashion with midio128 would work great for me.

To answer your question,  I and not code literate!  I am learning assembly language code, but cannot put a complete package together.

Currently,  the midio128s that encode my keyboards send out "note on/note off" midi messages.  I am familiar with mios, and midio128 i.e., and know how to setup the .ini file, load the programs, etc.  Question:  Does the 16x16 matrix work with a modified midi0128 app?  With a 16x16 matrix,  do you still have a .ini file to set up the type of midi messages sent ont.

thanks much for you willingness to help me,  I appreciate it.

Johnc

Link to comment
Share on other sites

If you would like to add more switches, I suggest use and try 32x32 matrix = 1024 switches, but since I not use it by myself , I`m bot 100% sure of good work code by longer time. OF course you can be tester. :P

I think this 1024 switches-code will work great on your setup becouse you no need velocity counter (who is additional task).

Since codes for bugger  scanmartix are remake TK`s 8x8smatrix code, (1000 x remake) I did not saved clear and good style including possible definitions). This is becouse I`m too small in programming word.

But I can help customize code for you, and write comments where you can define, and change behavior of program.

If I good understand your connectors 8x8 matrixes are connected alerady into one bigger 8x24, so if you don`t wanna destroy this connector 32x32 is an option.

To get a 16x16 matrix,  I will have to separate the rows.

You decide.

Question:  Does the 16x16 matrix work with a modified midi0128 app?

What you mean: work? If you run 2 aplications on 2 cores and connect by MIDI, and set parameters MIDI the same - then yes.

Generally for scan matrix is need (as you know) DINX and DOUX board. Since ports usually used for SRIO are the most standard for these boards, SRIO is go to disable. (I don`t know why TK disable SRIO, but maybe becouse too much proccesing power is go for this SRIO, since we need FASTer scanning matrix than SRIO)

So I never try run SRIO and scanning matrix parallel because I  rather need speed and many switches, than super usefull of SRIO.

With a 16x16 matrix,  do you still have a .ini file to set up the type of midi messages sent ont.

Are you mean big table with 256 positions for set 256 messages?

I can put thisif if you want. Maybe better is write exacly what you need for your instrument than create many purpose code.

Please tell me like this:

1. keyboard a  (key range C1-C5)

2. keyboard b ( key range the same)

3. foot keyboard (key range from ? - ?)

4. switches (what kind of messages you want for each?)

5. something more? (sustain pedal, potenciometers for pitch or others?)

and please decide witch one size you want for your instrument (256 or 1024 buttons).

Link to comment
Share on other sites

Are you mean big table with 256 positions for set 256 messages?

I can put this if if you want. Maybe better is write exacly what you need for your instrument than create many purpose code..

Thinking out loud here so this may be completely wrong thinking, but...

As I recall, MIDIIO128 uses a .ini file that must be assembled into the resulting executable. Since scan matrix has so far been derived from MIDIIO128 I believe it has inherited this method. I also believe that more recent MidiBox projects have been able to organize their configuration data in a way that permits uploading just the configuration data without the need to reassemble the project.

Undoubtedly it would be a much bigger effort, but perhaps it would be worthwhile to upgrade MIDIIO128 to use a configuration table that can be uploaded without the need to reassemble the project in a way that is consistent with other MidiBox projects and tools. By extension, this same configuration technique would be used for scan matrix as well.

Link to comment
Share on other sites

QBAS

Thanks for the reply.

I will work on the list of questions.

First of all,  forget about pitch blend, velocity and all of that stuff.  The keyboards are pure and simple,  on/off switches.

However,  there is one important point that needs to be made and it didn't occur to me earlier.

the keyboards will be used with virtual Organ Software.  These programs recognize a different midi channel for each keyboard, and all of the other devices i.e.  pistons, stops, swell shoe need to be on different channels also.

with an 8x8 matrix,  the number of points just about consumes the matrix, so it can be on its on midi channel.  The 16x16 or 8x24 or 32x32  won't work with virtual organs unless the encoder program can assign a differen midi channel to each group of switches.

Normally they keyboards and devices are assigned midi channels as follows:

Keyboard        No. of Keys      Midi channel

[table][tr][td]Great                  61                  1

Accompaniment    61                    2

Solo                  61                    3

Pedal                  32                    4

Stops                128                  5

Pistons                33                  6

Swell on Great      12                  7

Swell on  Accomp  12                  8

Swell on Solo        12                  9

Cresendo              12                  10[/table]

Total switches      428

It would be great if the program would be similiar to midio128, and the config of the midi messages could be done in an INI file.

Again, if specific midi channels cannot be made, then the large matrix will not work.

The solution will be to use multiple 8x8 matrixes each on a different midi channel.

Thanks much for the help, I appreciate it.

Johnc

           

Link to comment
Share on other sites

Hi man.

It no matter if you have only one switch or 1000000 switches- every can be assign to any channel.

So if you need 428 , probubly please go to 32x32 and you will save additional core, and will have not delay between cores due to connecting serially.

Of course you can use 8x8scan matrixes - its your decision.

But since it all will be in one instrument you can use 32x32.

I can help you with this preparing code, but since I don`t know midio128 aplication, please tell me what important

tips you need include in code. I mean: I can prepare code and inform you how connect gear to DINX and DOUTX boards for this:

Keyboard        No. of Keys      Midi channel

Great                  61                  1

Accompaniment    61                    2

Solo                  61                    3

Pedal                  32                    4

Stops                128                  5

Pistons                33                  6

Swell on Great      12                  7

Swell on  Accomp  12                  8

Swell on Solo        12                  9

Cresendo              12                  10

but what you need more?

For me is also important to specify ranges for note on/off messages, and kind and numbers for messages of Pistons , swells, Cresendo. :)

Link to comment
Share on other sites

QBAS,

Ok,  a 32x32 matrix would do nicely.  NOt sure what you mean by ranges of note on/note off.

Midibox should seed note on note off message as in the ini file for the midio128. You will note that i changed up the table below somewhat, less channels.  If you are not famliliar with the midio128, you should take a look at it.  I agree with Jim Henry in his post above.  If what I have provided is not what you are asking for, please let me know.

Device            Number of keys    Channel      Note range    Midi note

Main                  61                  1              C2  to  C7        36  to  97

Accompaniment    61                    2            C2  to  C7        36  to  97

Solo                  61                    3              C2  to  C7        36  to  97

Pedal                  32                    4              C1 to  C4        24  to 71

Stops                  64                  5              C1  to  D#5      24  to  75

Stops                  64                  6              same

Pistons                36                  7              C1 to  B3        24 to  59

Swell on Great      12                  8              C1 to B1          24 to 35

Swell on  Accomp  12                  8              C2 to B2          36 to 47

Swell on Solo        12                  8              C3 to  B3        48 to 59

Cresendo              12                  9                C1 to B1        24 to  35

* Middle C is C4

Johnc

Link to comment
Share on other sites

As I recall, MIDIIO128 uses a .ini file that must be assembled into the resulting executable. Since scan matrix has so far been derived from MIDIIO128 I believe it has inherited this method. I also believe that more recent MidiBox projects have been able to organize their configuration data in a way that permits uploading just the configuration data without the need to reassemble the project.

Hi Jim,

It’s not necessary to assemble the INI into the executable. From the very beginning you could upload the INI file via MIDI as often as you wanted without reassemble. The only thing needed is to convert the INI, which is a simple text file to a SYX file.

In my opinion this is one of the best features of the MIDIO128, total flexibility and you can reconfigure with just a few mouseclicks.

Link to comment
Share on other sites

QBAS,

Be advised that there are two errors in the data I posted:

The Pedal  has 32 notes, the correct range is C2 (Midi 36) to  G4 (midi  67).

Also, note  C7 is show as midi note 97 on all the keyboards,  the correct entry should be midi note 96.

Sorry about the mess up,

Best Regards,

Johnc

Link to comment
Share on other sites

Have you ready for tests core + DOUTx4 + DINx4 modules?

Of course you can use smaller DOUTx and DINx.

please upload 32x32 from this page

http://www.midibox.org/dokuwiki/doku.php?id=qbas

program will send for checking sysex string (F0 #ROW  #COLUMN #VALUE F7).

Rows go to DINX and counting same like pins on the board. http://www.ucapps.de/mbhp/mbhp_dinx4.pdf

Counting on DOUTX4 is here:

first      SR pins 7 - 0  =  our  24 - 31

second  SR pins 7 - 0  =  our 16 - 23

third      SR pins 7 - 0  =  our  8 - 15

fourth    SR pins 7 - 0  =  our  0 - 7

Firstly will try to find good connection way for your keyboards.

For better understanding (due to my poor english) lets say that you have 8a * 8b matrix on each keyboard.

Since I`m not sure which one have anode or cathode, please try both options:

-8a to DOUTx4 SR#4 , and 8b to DINx4 SR#1

-8b to DOUTx4 SR#4 , and 8a to DINx4 SR#1.

When you find connection which send out sysex string please check that numbers in string are proportionally higher when you play on higher octaves. The best is when for example F0 00 00 F7 is on C2,  F0 07 00 F7 is on G2,  F0 00 01 F7 is on G#2....

or  F0 00 00 F7 on C2,  F0 00 07 F7 is on G2,  F0 01 00 F7 on G#2....

Link to comment
Share on other sites

QBAS,

I am reviewing your last post, and have many questions.

Please email me at jwcouvillon@cox.net with your email address so that I can send you photos, schematics, etc., of the keyboard pcb's.

Questions:

1.  The code you provided is loaded as an application on top of mios? 

2.  There is no .ini file to configure the inputs and outputs.  Its hard coded in the program? The configuration data youi used is same as in my post, with changes?

3.  Hardware will require 1 MBHP core, one DINX module(32 pins) and on DOUTX module(32 pins). The DINXs and DOUTXS are wired to the core as in midio128 app. by interconnecting J8 and J9 to the I/O PCB's? I understand the pin order for the DINX, but the pin order for the DOUTX is confusing.  Is  "SR", "Shift Register"?  So looking at the DOUTX  Schematic, counting from the J1 end of the board, the SRs  (74H595) are numbered 1 through 4. The pin numbers for SRs are:

  SR PIn #      New Pin#SR1  New Pin# SR2  New Pin # SR3  New Pin# SR4

      0                31                    23                      15                  7

      1                30                    22                      14                  6

      2                29                    21                      13                  5

      3                28                    20                      12                  4

      4                27                    19                      11                  3 

      5                26                    18                      10                  2 

      6                25                    17                      9                  1

      7                24                    16                      8                  0

Is this correct?

Do the column numbers of the matrix correspond to the pin numbering, ie. col#1 is DOUTX SR4, pin 0?

QBAS,  I appreciate your hard work and speed with which you have come up with the code, however,  This is a beginning project to assemble a new complete console, including fabrication of a  true theatre organ cabinet with horseshoe stop tab rail, three manuals, etc. All of the devices are included in the matrix and it will take me some time to complete the project.  Since you have hardcoded the configuration, I will need a table to identify switch assignments withing the matrix (row, col) so I know how to wire from the DINs and DOUTs.

Please review my questions and answer as best possible. Considering the potential length of future posts, I feel it best that we go to email to continue.

Best Regards,

Johnc

Link to comment
Share on other sites

Considering the potential length of future posts, I feel it best that we go to email to continue.

Please keep the posts on the Forum. This project should result in a major addition to the inventory of general purpose MidiBox projects. We need the record of the development publicly archived if that is to happen.

I am planning to make a portable organ console by assembling two or three inexpensive MIDI keyboards into a single case with proper inter-keyboard spacing. It will be a good test vehicle for this project but I won't be able to get to the project for a few months. So it looks like hardware for thorough testing is going to be the tall nail.

Link to comment
Share on other sites

Please keep the posts on the Forum. This project should result in a major addition to the inventory of general purpose MidiBox projects. We need the record of the development publicly archived if that is to happen.

Yeh please keep it on the forum :)

Link to comment
Share on other sites

to TK, jimhenry and stryd_one:

I know that get working application is first good step, but write good documentation is great milestone. Unfortunately I don`t know how to write documentation for that simple scan matrix extension. If this is needed I will try do this in future if no other man do this first.

I can send you photos, schematics, etc., of the keyboard pcb's.
Why you would like to send me this?

I said that we start from connect one keyboard (16 pin connector split to say "8a" and "8b"). I wrote the way for test if this work,  what is no understandable?

Questions:

1.  The code you provided is loaded as an application on top of mios? 

This is for 18f452, but if you have another probably is is easy to change this, and any MIOS> v.1.7

2.  There is no .ini file to configure the inputs and outputs.  Its hard coded in the program? The configuration data youi used is same as in my post, with changes?

Take easy. We just start - first get working hardware. Look: there is no documentation (I`m to small for this now), if documentation will specify how to connect, then only customize parameters will left. But we must have sure that you connected right.

3.  Hardware will require 1 MBHP core, one DINX module(32 pins) and on DOUTX module(32 pins). The DINXs and DOUTXS are wired to the core as in midio128 app. by interconnecting J8 and J9 to the I/O PCB's? I understand the pin order for the DINX, but the pin order for the DOUTX is confusing.  Is  "SR", "Shift Register"?  So looking at the DOUTX  Schematic, counting from the J1 end of the board, the SRs  (74H595) are numbered 1 through 4. The pin numbers for SRs are:

  SR PIn #      New Pin#SR1  New Pin# SR2  New Pin # SR3  New Pin# SR4

      0                31                    23                      15                  7

      1                30                    22                      14                  6

      2                29                    21                      13                  5

      3                28                    20                      12                  4

      4                27                    19                      11                  3 

      5                26                    18                      10                  2

      6                25                    17                      9                  1

      7                24                    16                      8                  0

Is this correct?

all yes. You explain this better than me. Can you help me with create documentation after we finish? Like you see I have big problem with sentences other than I meet in manuals for synths. :)

Do the column numbers of the matrix correspond to the pin numbering, ie. col#1 is DOUTX SR4, pin 0?

Yes I think so. I have no free set (core + dinx, doux) for test again , but if you can please check it and tell us:

simply connect first pin on DINx4 and last pin on DOUTx4 (SR#4:D0)  and check if sysex is F0 00 07 F7.

Since you have hardcoded the configuration, I will need a table to identify switch assignments withing the matrix (row, col) so I know how to wire from the DINs and DOUTs.

I don`t understand (this sentence was never at all in my Ensoniq`s manual >:( )

Please don worry aboput table - we will create one in next days - I hope...  :P

Table is good place for your setup , and must be - I know this and OK lets go with this

Please review my questions and answer as best possible.

yes sir!

Considering the potential length of future posts, I feel it best that we go to email to continue.

psssst. we cannot now ... you know ... What will think they other?

its joke

Go on please go with test and connect first keyboard

Link to comment
Share on other sites

QBAS,

OK, my friend, I will take it easy. The reason I want to send you the photo is that the matrix is a PCB attached to the keyboard switches. I thought you would want to see what we are working with.  As for a test,  I don't have a core and DINX and DOUTX to use for a test. I will order kits from SMASH and get back with you when they are complete.  I would include photos in my post, but I do not have a website on which to locate the photos. If there is a way to do that by direct insertion into the post, somebody please give me some input.

As regards, documentation,  yes I will be happy to do what is necessary, and yes, your text is hard to follow. Forgive me for feeding back my understanding of what you put in your post in my own words, but if i don't understand, thats the only way for me to confirm.

For all interested, I agree, best we keep this on the forum.

I'll get back with you as soon as I have hardware to use for the test.

Johnc

Link to comment
Share on other sites

The reason I want to send you the photo is that the matrix is a PCB attached to the keyboard switches. I thought you would want to see what we are working with.
I have 2 keyboards powered by MIOS at home, both look similar, also I seen many keyboards parts at service.

Of course it is any time very interested, but now I need speed up this our process so I no please for pictures.

You said: 8x8 matrix are on keyboard, and I go with this. This is simple.

For me the important is to find good connection configure, and keep it until we finish main program, after this you will can change everything with table.

I would include photos in my post, but I do not have a website on which to locate the photos. If there is a way to do that by direct insertion into the post, somebody please give me some input.

OK I see: you think that I will do test virtually with photos? Its impossible. So we will wait for your working MB hardware set.

About your question with photos, I have the same problem all time. Usually I put photos and files at shitty servers, who delete them after period.

I never seek for better place, since always is to do some other things.

see you later!

Link to comment
Share on other sites

  • 2 months later...

I have a bit of a question regarding reading a key matrix. To add fuel to the current fire

I'm wondering if it's possible to scan a matrix but sensing a variable voltage at each

crosspoint. In older keyboards, velocity was sensed by timing the crossover from a normally

closed contact to a normally open contact on each key. Thus the quicker the change over

the higher the velocity.

Recent keyboards use a dynamic rubber button arrangement. On closure, the voltage output

depends on the resistance at the time of closure. It works on the principle the harder the

key is pressed the lower the contact resistance and therefore the higher the voltage at the time

of reading. As an aside to this principle, it also allows aftertouch to be applied as well.

On each scan, new key voltages are read and a midi note and velocity value sent. If a key scanned

is already "flagged" as being on, the current voltage is read and sent as an aftertouch value.

I hope my rough description is enough for someone to answer whether it is viable to use this approach with MIOS. I have a number of keyboard assemblies that use dynamic rubber contacts

I could use if this could be achieved.  :)

Link to comment
Share on other sites

  • 4 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...