Highly Liquid Forum facebook twitter google plus rss feed
  #1  
Old 02-08-2011, 08:48 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default Switch Matrix Setup

This thread is intended as a discussion of the "theory" of how to set up a switch matrix for use with the MIDI CPU. Specific examples can be found in other threads.

The first step is to understand how switch matrices work. (Whether or not a MIDI CPU is involved.) Here is a detailed article:

http://forum.highlyliquid.com/showthread.php?t=1133

It should be clear from the above article that select lines are MIDI CPU outputs, and that data lines are MIDI CPU inputs.

For the purposes of MIDI CPU config, all of the "meat" of the configuration is done at the select line. The data lines are configured to be "dumb"--they just take a logic input but don't "know" anything about what the select lines are doing. That's why mode 7Fh is used for the data lines.

For example, if control terminal #0 is a matrix data line, we want to use these two configuration chunks for its config:

00 00 7F 00 00 00
00 01 7F 00 00 00

...in other words, CT #0 will be a logic input, but it will do nothing when its state changes from both high-to-low and from low-to-high.

The select line is where the "interesting stuff" happens. The select line configuration includes several pieces of information:

1. What type of MIDI message to generate from activity on the matrix switches. (And what MIDI channel to use.)
2. Where to "look" for the switch state data when the select pulse is generated.
3. What range of MIDI values are generated from this particular group of switches in the matrix.

More detail follows:

1. What type of MIDI message to generate from activity on the matrix switches. (And what MIDI channel to use.)

This is very similar to other control terminal configurations. Here is a control terminal configuration chunk with the relevant bytes bolded:

08 00 2C 00 3C 00

The 2Ch is the control terminal mode. "Logic Output Matrix Select Modes" in the MIDI CPU firmware user manual. Mode 2Ch is for sending MIDI notes in an application similar to a piano keyboard.

The bolded 00h is the MIDI channel setting. 00h here means that the MIDI CPU uses the channel jumper to determine what MIDI channel on which to send the notes. We could also use 01h to 10h to explicitly specify channels 1-16, independent of the channel jumper.

2. Where to "look" for the switch state data when the select pulse is generated.

Again, a sample configuration chunk with relevant bytes in bold:

08 00 2C 00 3C 00

Take a look at the "Logic Output Matrix Select Modes" in the MIDI CPU firmware user manual. For a typical "piano keyboard" (note on/off) type application, we have modes 2Ch, 2Dh, and 2Eh. These three modes only differ by their "Switch State Data Register".

Mode 2Ch uses data register 00h, mode 2Dh uses register 01h, and mode 2Eh uses register 02h. Take a look at the "Logic Input Data" section of the manual. Here you will see a description of each of these data registers.

Each register 00h-02h contains the current states of certain control terminals, if those control terminals happen to be configured for logic input. Register 00h is for CT 0-7, register 01h is for CT 8-15, and register 02h is for CT 16-23.

So, if our matrix select line is configured with mode 2Ch, then the MIDI CPU will "read" the matrix data from control terminals 0-7 when the select pulse is generated.

This works perfectly when our matrix has 8 data lines, but of course, there are different matrix configurations. The MIDI CPU looks for switch data from groups of 8 control terminals, but some configurations have fewer than 8 data lines. If, for example our switch matrix has only 4 data lines, we must tell the MIDI CPU to "read" just 4 of those terminals and ignore the other 4. This is where the matrix data bitmask is useful.

For matrix select modes, the final byte in the configuration specifies the bitmask. (That's the sixth byte--the bolded 00h in the chunk above.)

Check out the "Matrix Data Bitmask" section in the MIDI CPU firmware user manual. For a matrix select control terminal, each value 00h-0Eh of d1 in the configuration chunk (that's the sixth byte) corresponds to a pattern of bits that tells the MIDI CPU which bits of matrix data (and thus, which control terminals) to "read", and which to ignore.

Let's say our matrix has 6 data lines, connected to MIDI CPU CT #0-5. In this case, we want to use switch data register 00h, and we want to use only bits 0-5 for matrix data (ignoring bits 6-7). So we want the bitmask pattern "00111111", which is specified by the d1 value 09h. Our select line CT config could look like this:

08 00 2C 00 3C 09

The value of using the bitmask is that, in the example above, CT 6 and 7 are now free to be used for other functions. Since they are not used for switch matrix data, their state will not be interpreted as such by the MIDI CPU. They can be used as matrix select outputs, or something completely unrelated to the switch matrix.

In theory, we could design the MIDI CPU so that it could ignore any possible pattern of bits in the data register. The trouble is that this would require 256 different values for the bitmask (all on/off combinations of the 8 bits). This would make configuration more difficult, since a MIDI data byte (and thus, any byte in the control terminal configuration) contains only 7 bits. So instead, only the most useful bit patterns are provided--this means that the bitmask setting "fits" into a single byte of the configuration chunk.

3. What range of MIDI values are generated from this particular group of switches in the matrix.

Relevant byte in bold:

08 00 2C 00 3C 00

For matrix select outputs, the fifth byte of the chunk (d0) tells the MIDI CPU which MIDI number (note number, or CC number, or program number) to use for bit 0 in the matrix data.

For example, given the chunk above, for the group of switches connected to CT 8, the MIDI CPU will generate note 3Ch (#60--"Middle C") from bit 0 in the switch state register. The next 7 bits will generate the next 7 notes in sequence (#61-67), with the exception of any bits that are ignored because of the bitmask.

If we want CT 9 to generate the next 8 notes #68-75, we can use the configuration chunk:

09 00 2C 00 44 00

Here's a handy table with all of the notes in both hex and decimal:

http://forum.highlyliquid.com/showthread.php?t=1125

Will be happy to add clarifications or more detail...

Last edited by John; 09-03-2013 at 04:02 PM.
Reply With Quote
  #2  
Old 06-15-2011, 12:55 AM
ross3117 ross3117 is offline
Junior Member
 
Join Date: May 2010
Posts: 22
Default

Thanks for posting this John!

I'm about to start the programming for my 25 note midi bass pedal project and this helped clear up some things for me.

One question...

On the last page of the 1.2 firmware guide (page 55), CT# 8 is configured thus:

08 00 2C 00 24 0E

And the description says "Control Terminal 8 Matrix Select Output: Data Register 00h, note number 36"

Given your explanation in the post above, I'm not sure I understand the last byte. If I'm interpreting it correctly, it would seem that this CT is masking all but the first data line.

All the other matrix select CTs have 00 in this byte address.

Is this correct? If so, why?

Thanks!

Last edited by ross3117; 06-15-2011 at 12:57 AM.
Reply With Quote
  #3  
Old 06-20-2011, 08:55 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

Hi Ross,

If you take a look at the MIDI CPU wiring diagram for the same example (V1.2 page 53), I think it will make more sense. The select line connected to CT #8 has only a single switch connected to it.

In this particular application, it's actually not necessary to mask the other 7 data bits for that select line, but I put it in there anyway for illustration.

Please let me know if this helps.
Reply With Quote
  #4  
Old 11-29-2011, 02:13 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default Diodes for a switch matrix...

For a switch matrix, just about any regular (not zener) small signal or rectifier diode will work fine. I like to use 1N4148 or 1N4004.

For off-pcb work, 1N4004 are nice because the DO-41 package has heavy leads that are easy to work with. About $0.06 apiece.

The "cut tape" packaging is cheaper, but for a few extra bucks you can get "bulk" packaging so you won't have to bother with pulling the diodes from the tape.

http://www.mouser.com/ProductDetail/...VA%2fNo6VSc%3d

http://www.mouser.com/ProductDetail/...vYzJHIVjDdM%3d
Reply With Quote
  #5  
Old 06-17-2012, 02:44 PM
Synthetech's Avatar
Synthetech Synthetech is offline
Moderator
 
Join Date: May 2012
Location: USA
Posts: 711
Default

I thought maybe this simple explanation of a switch matrix might be helpful here...

http://www.dribin.org/dave/keyboard/one_html/


Made it very clear for me on how the columns and rows work together, what ghosting/masking is and why the diodes are put in place to avoid them.
Reply With Quote
  #6  
Old 09-12-2012, 03:30 PM
Genecyll Genecyll is offline
Junior Member
 
Join Date: Sep 2012
Posts: 8
Default LEDs as diodes

A question about the diodes:
Can I also use LEDs as diodes, because LEDs are in fact diodes, or does this affect switch time or something else?
Reply With Quote
  #7  
Old 09-15-2012, 05:21 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

Quote:
Originally Posted by Genecyll View Post
A question about the diodes:
Can I also use LEDs as diodes, because LEDs are in fact diodes, or does this affect switch time or something else?
Yes, LEDs can work as diodes for the switch matrix, but there is not much reason to use them instead of regular diodes. Very little current passes through the switch matrix, so the result will be disappointing if you are expecting the LEDs to light when a switch is closed.

Aside from emitting light, LEDs in general are more expensive, less mechanically robust, and less tolerant of reverse voltage than regular diodes. So they are not typically used for purposes other than generating light.
Reply With Quote
  #8  
Old 01-24-2013, 03:22 PM
theorganloft theorganloft is offline
Junior Member
 
Join Date: Jan 2013
Posts: 7
Default Diode Placement in the matrix

Quote:
Originally Posted by John View Post
For a switch matrix, just about any regular (not zener) small signal or rectifier diode will work fine. I like to use 1N4148 or 1N4004.

For off-pcb work, 1N4004 are nice because the DO-41 package has heavy leads that are easy to work with. About $0.06 apiece.

The "cut tape" packaging is cheaper, but for a few extra bucks you can get "bulk" packaging so you won't have to bother with pulling the diodes from the tape.

http://www.mouser.com/ProductDetail/...VA%2fNo6VSc%3d

http://www.mouser.com/ProductDetail/...vYzJHIVjDdM%3d
================================================== ======

I built this matrix on a set of 32 contact Allen Organ pedals.

I fired up my CpU for the first time yesterday. Power light is on and the Led on the board flashes red but I get no activity on the activity LED or transmitting over the output port. I am using a MIDISPRT 1X1 connected to a usb port on my Ubuntu Studio v12.x workstation. I know that the Midisport works becasuse I attached it to my drum machine and plays my software synths through the JACK interface.

The one thing that I think may be causing a problem is the way that I wired the matrix. I put the diode on the Data Lines instead of the select lines. Check out the images. I used a stiff wire to hold the reed switches and put the magnets on the pedals. The stiff wire holds the switches in place. The switches are soldered to the wire. There are 4 select lines and 32 data lines.

Is this keeping the CPU from transmitting? Or is there more programming that I need to do?
THanks

Reply With Quote
  #9  
Old 01-25-2013, 01:41 AM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

Quote:
Originally Posted by theorganloft View Post
================================================== ======

I built this matrix on a set of 32 contact Allen Organ pedals.

I fired up my CpU for the first time yesterday. Power light is on and the Led on the board flashes red but I get no activity on the activity LED or transmitting over the output port. I am using a MIDISPRT 1X1 connected to a usb port on my Ubuntu Studio v12.x workstation. I know that the Midisport works becasuse I attached it to my drum machine and plays my software synths through the JACK interface.

The one thing that I think may be causing a problem is the way that I wired the matrix. I put the diode on the Data Lines instead of the select lines. Check out the images. I used a stiff wire to hold the reed switches and put the magnets on the pedals. The stiff wire holds the switches in place. The switches are soldered to the wire. There are 4 select lines and 32 data lines.

Is this keeping the CPU from transmitting? Or is there more programming that I need to do?
THanks

Hi Theorganloft, welcome to the forum.

Before continuing with the project, I would disconnect the switch matrix from the MIDI CPU and perform the basic tests from the new user orientation in this thread:

http://forum.highlyliquid.com/showthread.php?t=267

Once the MIDI i/o is tested and working, we can continue with the project discussion.

Have you sent a sysex configuration file to the MIDI CPU yet? It will be required to get the switch matrix working.

Please create new thread for your project. Include a list of MIDI CPU control terminals 0-23 and the function you'd like to assign to each. From there, we will work on getting everything working.

I look forward to continuing the discussion.
Reply With Quote
  #10  
Old 01-25-2013, 04:48 AM
theorganloft theorganloft is offline
Junior Member
 
Join Date: Jan 2013
Posts: 7
Default

Quote:
Originally Posted by John View Post
Hi Theorganloft, welcome to the forum.

Before continuing with the project, I would disconnect the switch matrix from the MIDI CPU and perform the basic tests from the new user orientation in this thread:

http://forum.highlyliquid.com/showthread.php?t=267

Once the MIDI i/o is tested and working, we can continue with the project discussion.

Have you sent a sysex configuration file to the MIDI CPU yet? It will be required to get the switch matrix working.

Please create new thread for your project. Include a list of MIDI CPU control terminals 0-23 and the function you'd like to assign to each. From there, we will work on getting everything working.

I look forward to continuing the discussion.

Thank you John for responding. Received your email

I will run the tests and get right back to you.

Thanks,
Abe
Reply With Quote
  #11  
Old 02-26-2013, 01:04 AM
toomany toomany is offline
Junior Member
 
Join Date: Feb 2013
Posts: 12
Default Switch Matrix Sysex Sending

So, if i am reading correctly, you cannot generate SysEx messages with a switch matrix setup? Nor can one generate them from analog input, ie: potentiometer?

Last edited by toomany; 02-26-2013 at 01:38 AM.
Reply With Quote
  #12  
Old 02-26-2013, 02:37 AM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

Hi toomany, welcome to the forum.

Quote:
Originally Posted by toomany View Post
So, if i am reading correctly, you cannot generate SysEx messages with a switch matrix setup? Nor can one generate them from analog input, ie: potentiometer?
Correct. As of firmware version 1.3, only MIDI CPU logic inputs can be used to trigger sysex output from the MIDI CPU.

That said, it is clear that it would be useful if a user could "sandwich" fixed sysex data on either side of a byte whose value is determined by an analog input. Is that what you are looking for? Maybe in version 1.4...

I do not foresee a method for generating sysex with a switch matrix in the next release.

If you can describe your application in more detail, I'd be glad to continue the conversation. (It is probably worthy of its own thread. Please create one, if you like.)
Reply With Quote
  #13  
Old 03-06-2013, 01:28 AM
toomany toomany is offline
Junior Member
 
Join Date: Feb 2013
Posts: 12
Default note on?

With a switch matrix, I read from p. 25 of your firmware manual that there are 1k cycles that constantly "monitor" or define the switch positions. Under either the "Note On/Note Off" or "Toggle" configurations, is the CPU constantly re-sending a note on message for the switches left on?
Reply With Quote
  #14  
Old 03-12-2013, 06:35 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

Quote:
Originally Posted by toomany View Post
With a switch matrix, I read from p. 25 of your firmware manual that there are 1k cycles that constantly "monitor" or define the switch positions. Under either the "Note On/Note Off" or "Toggle" configurations, is the CPU constantly re-sending a note on message for the switches left on?
The 1k/s is a description of the "sample rate" the MIDI CPU uses to monitor switch input.

The MIDI CPU only sends MIDI messages when the state of the connected switch changes.

So in other words, in a typical configuration, the MIDI CPU will send a single note-on message when the switch is closed, and then send a corresponding note-off when the switch changes back. There are lots of possible variations on this, depending on configuration.

For a receiving device, when a MIDI note-on message is received, the note is sustained until the matching note-off message is received.

Not sure if that answers your question. If not, please let me know. You can find all the details of MIDI messaging here:

http://home.roadrunner.com/~jgglatt/tech/midispec.htm
Reply With Quote
  #15  
Old 03-14-2013, 03:09 AM
toomany toomany is offline
Junior Member
 
Join Date: Feb 2013
Posts: 12
Default

yes indeed, thank you.
Reply With Quote
  #16  
Old 09-03-2013, 05:06 PM
Girts23 Girts23 is offline
Junior Member
 
Join Date: Sep 2013
Posts: 2
Default Switch Matrix - initial setup

Hi there!
I've got 25 key keyboard with diode matrix, and want to make a midi keyboard. But how EXACTLY should I configure the MIDI CPU in order to switch to Switch Matrix Mode. I checked MIDI CPU with a synth - everything works well in basic switch input configuration, it generates midi notes, but I do not succeed with going into Switch Matrix Mode.

Thank you!

Girts
Reply With Quote
  #17  
Old 09-05-2013, 08:04 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

Quote:
Originally Posted by Girts23 View Post
Hi there!
I've got 25 key keyboard with diode matrix, and want to make a midi keyboard. But how EXACTLY should I configure the MIDI CPU in order to switch to Switch Matrix Mode. I checked MIDI CPU with a synth - everything works well in basic switch input configuration, it generates midi notes, but I do not succeed with going into Switch Matrix Mode.

Thank you!

Girts
Hi Girts, welcome to the forum. Did you read the first post in this thread?

Please create a new thread for your project, and include a sketch of your keyboard's switch matrix. I can help you from there.

You can also check out some configuration examples, like:

http://forum.highlyliquid.com/showthread.php?t=691
http://forum.highlyliquid.com/showthread.php?t=268
http://forum.highlyliquid.com/showthread.php?t=278
Reply With Quote
  #18  
Old 09-06-2013, 07:33 AM
Girts23 Girts23 is offline
Junior Member
 
Join Date: Sep 2013
Posts: 2
Default

Thanx, John!
I've made a lot of DIY music stuff, but haven't come across midi much. So basically you answered the question, that in order to configure MIDI CPU, I need to send the code like in example to the device. I'll try this.

But there's another question on the hardware - the keyboard comes from defective Edirol and diodes in the switch matrix are reversed - in MIDI CPU connection examples anodes are connected to data lines through keyboard switches, Edirol has exactly opposite. Should I resolder diodes to reverse them?
Reply With Quote
  #19  
Old 10-11-2013, 06:26 PM
John's Avatar
John John is offline
Moderator
 
Join Date: Jan 2009
Posts: 3,007
Default

Quote:
Originally Posted by Girts23 View Post
Thanx, John!
I've made a lot of DIY music stuff, but haven't come across midi much. So basically you answered the question, that in order to configure MIDI CPU, I need to send the code like in example to the device. I'll try this.

But there's another question on the hardware - the keyboard comes from defective Edirol and diodes in the switch matrix are reversed - in MIDI CPU connection examples anodes are connected to data lines through keyboard switches, Edirol has exactly opposite. Should I resolder diodes to reverse them?
Hi Girts, sorry for missing this message.

The position of the diodes (on which side of the switch) in the matrix is not consequential.

However, the polarity does make a difference. For me to give a specific recommendation for your project, I need to see a sketch of the matrix schematic.
Reply With Quote
  #20  
Old 09-12-2014, 09:15 PM
Steamrocks Steamrocks is offline
Junior Member
 
Join Date: Sep 2014
Posts: 2
Default Matrix to handle full 128 note encoding

I have built a VirTual Theater Pipe Organ with three manuals, 117 stops, pedals, and a full Theater Pipe Organ console controlling the virtual equivalent of 23 ranks (Sets) of pipes and six tuned percussion instruments. The MIDIfied 1920's vintage console drives a large sample player through a utility called jOrgan.

I am rebuilding the console MIDI electronics after an electrical surge accident, and need the Highly Liquid MIDI CPUs to be able to scan a full 128 key and switch closures for each of the 4 boards I am incorporating.

I have reviewed all the material on matrix switching I could find, including the very informative posts on this thread. I have tried many configurations, but the most I can achieve is 120 switches since terminal 19 is not capable of being a logic output.

I have found by extensive experiment that I can't reverse the order of Data Inputs and Outputs, since the Data Inputs must be the lowest terminal numbers, and all be continuous, and the Outputs must be the highest terminal numbers, again, all continuous.

While a 128 note encoder may not be very commonly used in other music applications, those of use who build virtual organs find it very handy. A full Highly Liquid console encoder system would cost an order of magnitude less than other available systems, and additionally take up much less space in the console.

If anyone has found a way to program the unit so that it can handle all 128 notes and switches, I'm all ears! I've tried a lot of alternatives, and haven't found one yet.

By the way, the long explanation that John put up at the beginning of this thread is very clear and helpful. NOW, if he could only tell us how to turn terminal 19 into a Logic Output!
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 02:38 AM.


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