Wednesday, January 9, 2013

Apollo 13: What is the Matrix?


Seriously. Who else did not see this joke coming a mile away?


Welp. It's the post I know a lot of you have been waiting for as it deals with one of the more advancing wiring techniques of the project. Perhaps the one I've been the most vague on? The one I've mentioned here and there but always put off. But fear not! I am going to do everything within my writing capacity to ensure you finish this article knowing exactly what I did and more importantly how you can replicate it.

Plus! Take solace in this - this is close to actually completing wrapping the project because the faders and knobs are ready to be connected to the Livid Builder Brain. "But of course they are, the builder brain has all those analog inputs. You just connect all the ground terminal together and wire them to a ground on the Brain. You do the same for the 5V high pins. Then annoyingly enough, you wire all the wipers interdependently to each analog input on the builder brain. But you have at the very least 36 buttons dedicated to clip launch!


The Button Matrix
So the problem is the Brain has a limited number of input pins. You require a lot more than what's available. The solution is wiring these buttons in matrix. Any chefs out there? We're about to create an electronic button weave.

Now, as some information worth sharing - wiring in matrix is not a new concept, it's not foreign to electronics, and it's especially the "norm" when it comes to musical instruments. So don't be scared! Matrices also exist in electronic pianos. Because it's really just crazy stupid easier to wire. Seriously. Again, electronic button weave. That's what we're doing.


The LP15 has 4 pins for the button, and 2 pins for the led. The builder brain supports an LED matrix AND button matrix. So stew on this for second, because if you think it means we are going to wire two matrices you are 100% correct. We'll do the "button" aspect first and leave the powering the LED thing as the last remainder of the project.





In the post where I outline the parts list for this (specifically drawing attention to the LP15 and it's four gold "fangs") we're going to be focusing on those. The four gold fangs, truthfully - are the four pins that make this button work. A button is actually a type of switch. When the switch is "closed" the electrical connection is made. When it is "open" there will be no flow of electricity. That being said, if you are choosing to deviate from my choice in buttons, take special note here. I am using Normally Open buttons, with the shorthand as "NO". Could you imagine if you picked normally closed? Ableton probably wouldn't work out so well for you as 36 clips are going to attempt to all fire at the same time!!! Better yet, think about this like a doorbell. The doorbell is a Normally Open switch (it's a pushbutton) and when you push the button - the electrical connection is made. When released it stops ringing. Alright, so now imagine a Normally Closed doorbell!

But the question is, "I have four pins on the button and I really only need two to make the electrical connection...so uhh, what about these other ones?" I used fangs as the choice word because these things are going to snap/clip into the perf board. Once snapped in, we can solder and secure these things in place.

Pins 1 and 2 are on the same "rail" that is to say they are internally connected inside of the switch. The same thing goes for pins 3 and 4, they are also on the same rail. So to make the button work we need solder to pin 1 or 2 AND pin 3 or 4. So why four pins? I'll be honest I have no idea. So the button can clip into a board? Maybe it's a fail-safe of some sort in case one pin goes bad? Perhaps you want to wire the button to two identical functions? I'll be honest, I have no idea. Anyway, picture time.


Alright so the above photo, assuming you are looking at the LP15's underside has a pin layout identical to what you see above. Four "fangs" flanked by two long leads. The flanking leads are the two pins responsible for powering the LED. As I've said, this is wired a in a "matrix" configuration and I've been putting off that explanation up until now. Not to mention, you need 2 matrices - 1 for data and 1 for LED power. But, once you wire one matrix wiring the other will make perfect sense.

So in the above sketch of mine, I've laid out 36 buttons in a 6 by 6 grid. I have 25 individual wires connecting all the "positive" leads of the buttons. They connect a single column of 6 buttons (going up and down). So yes - lots of soldering here. For the sake of following along (assuming you yourself have embarked on this identical journey, and are currently holding a LP15 in your hand) position the button in your hand so that it matches the above layout in the photo with pins 3 and 1 on the top; and pins 4 and 2 on the bottom. You may need to get a magnifying glass but rest assured the pin numbers are marked on these things just in crazy tiny print. Holding it correctly you will in in fact see 3 and 1 on the top, with 4 and 2 on the bottom.

Again, to reiterate - a single column of these I've connected all pin 3's together running top to bottom. You could alternatively connect pins 4 top to bottom if you wanted as these pins are once again on the same rail.


Diodes. Yes, you need more stuff to continue.
These things are an interesting electrical solution to a problem you have probably never even considered.

All of our inputs thus far (knobs/faders) each have their own unique data pin running to them. The Builder Brain can uniquely identify them. But the button matrix - lot of inputs on a very selective number of pins. How does anything know you pushed the button you did? It's almost as though you need to know where the power "dies" out. The inherit problem is that looking at a 6x6 grid, if you push button 4 in column 4 (looking left to right) you are effectively cancelling out the power/data to the buttons that make up the grid to that button. A 4x4 grid is now dim and you've now just pushed all of those buttons. Something you definitely don't want to do in the middle of your next Ableton set.

So how can we signal which button is pressed with electricity? Fortunately, diodes solve this problem. How do they do this? They only allow current to flow in a single direction! The matrix (and more importantly Brain) can identify where in the matrix the button has been depressed. With that said, you're going to need 36 diodes (conveniently available from Livid Instruments store front). Let's look at the next photo for what part of this has to happen next.

Note: This photo does not have all pin 3's connected, photo was 
taken before that solder task to emphasize the diodes.

You can see that I've soldered diodes to all pin 1's. Now, based on my photo (and my memory now that I'm thinking about it). I soldered all the diodes first. Then I soldered all of pin 3's together with individual wires. K, now we're back on track.

Oh! Before I forget and you ask - diodes do have a wrong and right wiring! Unlike the entire rest of this project if you got wires flipped backwards it would just result in an opposite expected effect, with diodes, direction is everything! However, assuming someone would see this picture and think "I'm going to replicate what Adam did step by step, picture by picture" Then good news. Those diodes are positioned 100% correctly. While you can easily find this on a quick Google search, I've been told there is something reassuring about hearing it from a real person (as opposed to fake ones). The black ring (it may just be any color ring) around the diode represents the - negative side of the diode or where power is coming out of

So at this point, the 3rd pin on every button is connected top to bottom and the 1st pin merely has a diode soldered to it. Better yet, here's a picture!


Now you'll notice one other thing near the top. I didn't just stop on the 6 button panel I created. I actually kept wiring "up" for the Record and Cue buttons. Given the Builder Brain can support a 48 button matrix, i might as well make use of this fact and keep on wiring. Plus - it's simple. Just keep connecting pin 3 top to bottom. If anything, it may help visualizing this not as a 6x6 matrix, but a 6x8 matrix. But it's not complicated. if you can wire a 6x6, you can do 6x8 or any combination thereof. It may take some thought, it may take some failure, but you can do it!

When the red wire finally reaches the top of the column, it connects into a ribbon cable that is in turn connected to the Brain's button matrix pins.

Note: I'd click on the photo if I were you.

Alright so the above photo completes the first matrix! The matrix that allow you to to actually push buttons and have them send MIDI signals.

boom.

To provide a bit more detail (and ease for the sake of following) you'll notice I changed color for the rows. The black wire now connects the rows (pin 1) to each other, left to right. On the right hand side if you look closely, you'll notice some really funky wiring on my behalf. But I think it makes the most sense when you are new to electronics. There is a junction of the diode, a resistor that connects to ground (pick any ground cable you have running back to the board), and a black wire running to the matrix cable (which plugs into the Brain). This junction is absolutely necessary. The resistor is killing off/absorbing any excess voltage in the matrix when a button (or several) are pressed (and then is grounded) and the black wire running off to the matrix cable is obviously conveying data as to the location of what button was pushed.

If you don't believe this junction is necessary (e.g. you are looking to experiment to see what happens and by all means. Do it. That's how you learn things!) and you either are wondering what happens or worse decide to not wire it - button presses will generate RANDOM midi data. Maybe you turned a knob? Pushed another button...or 7. This is the result of excess electricity in the circuit incorrectly signaling back to the Brain.



The LED Matrix
Here's the good news. YOU ALREADY KNOW HOW TO DO THIS! Seriously, just repeat the above steps but use the silver pins jutting out that connect power to the LED's and then back to the cable that connects to the LED matrix on the Brain.

Not feeling confident about wiring another matrix, let alone on top of your already existing one? That's ok. Unlike the button matrix where you'll have to constantly be testing to ensure signals and proper secure wiring, the LED matrix is as simple as connecting power and just making sure the LED (inside the button) lights up.

Looking at the below pictures, my color coded wire is set to match + and - alike. Red is + and black is -. Pin 5 is positive and Pin 6 is negative. So in my LED matrix I've connected a 120oHm resistor to pin 5, pin 5 to the next pin 5 and then repeated the process on another two buttons. The buttons were then connected pin 6 to pin 6 on adjacent column. Pin 6 then runs out of the circuit to ground.

Grab a 9V battery. You have a perfect test awaiting.




I think I got excited in my wiring, because I can't find a lit up version of a 2x2 matrix. I think I just saw two other buttons and kept going. Below you'll see a 2x3 matrix powered by a 9V battery.


I genuinely hope no one is offended when I say I don't have a thorough process photo documenting the LED matrix wiring as when i was doing it - completely took it for granted that if I had successfully wired my data matrix - that getting the buttons to light correctly was a plus. But, it was one that I immediately had the knowledge for given I'd only minutes before completed the data matrix.

The only thing worth mentioning is the 120ohm resistor at the start of each column for the LED matrix. I remember when I first received the demo package of 5 of these things and I very eagerly and stupidly wired one directly to a battery. It was the brightest green I'd ever seen until it instantly turned red, popped, and made an unexpectedly loud noise. So - don't do that.



Wasn't perfect the first time around. Seriously. I got the whole thing lit except two buttons!? Are you kidding me??!!!! Oh well, "back to the soldering table" I told myself. Until I realized "Oh yeah, the whole thing pretty much works. I should maybe just play around on it for 1 or 18 hours."


And so...
Wire a few more buttons for data and lighting. Touch up the paint a little bit. Maybe drop it from 1 foot off the ground...start writing a blog about how I built this thing.

Come to think of it, I've been looking back and at my notes. I may only have 2 if not only a single ONE remaining post left. I have to type out loud here to double check.

Build the box.
Cut the faceplate.
Ordered the parts.
Connected the knobs, faders.
Wired a button matrix.
Wired an led matrix.
Put the thing together.
Started a blog that highlighted all of my notes and thoughts of the build process.


Hrm.
Well. I probably should tell everybody about what happened in October of 2012 then...


No comments: