The Command Matrix Shield is an expansion board for the ChipKit Uno32 that features an 8×8 LED matrix. Its secret superpower is that the Command Matrix is bidirectional – you can display stuff on it, and sense light hitting it, simultaneously*! It’s the world’s tiniest and most adorable touchscreen!
I started this project for the ChipKit Platform Design Contest back in May 2013, but I couldn’t stabilize it in time. The project is now a relentless zombie. I keep telling myself that this thing won’t go anywhere and killing the project, yet it always ends back up on the bench with a taste for brainpower.
SAUCE AND BOARD FILES
The Command Matrix Shield has a repo on my GitHub page. This project was done poorly, barely thought through, and contains many half-assed last-second fixes. It’s fine to build on a breadboard or play with the code, but I wouldn’t recommend building your own yet.
If you’re a masochist who wants one, etch it yourself. The board is laid out for home etching, not fabbing. If Laen wasn’t such a swell chap, OSHPark would laugh at you when you send this to them. It’s got no silkscreen, bad mask relief, and an ambiguous, multi-part layout. Just don’t do it please thanks.
I got some ginormous 5mm 8×8 matrices left over from Ch00f’s QR Clock production, with beautiful crystal-clear lenses and ultra-high-efficiency red dice, that should make a much better Command Matrix than this POS. I should also pull my s**t together and put some op-amps on this low-impedance mess. Totally not in the mood, so bug me on Twitter or the comments if you want me to keep working on this crap.
WAIT A HOT SECOND! READING LED MATRICES?
The basic principle is that an LED ‘goes both ways’***. If you forward-bias it (put a voltage from anode to cathode), it will drop some voltage by converting it to light. If you reverse-bias it, it will create a voltage from cathode to anode when it’s exposed to light****. Something about quantum physics and band gaps, I dunno.
Note: I may have completely mixed up rows, columns, anodes, and cathodes here. Consider everything in this section to be fictional until I get un-lazy and do some testing.
Anyways, each row of the matrix is made of its LEDs’ anodes bussed together, and each column is its cathodes. In my infinite wisdom, I used a bicolor matrix for the project and ignored half the anodes, so pretend they don’t exist here. If we connect the eight anodes to eight analog inputs (One reason I’m using a ChipKit; the Arduino only has six) and set the cathodes high, we can analogRead the rows. Light hitting the LED’s creates a voltage from cathode to anode. Whichever row reads the highest is likely getting the most light.
The columns are trickier. I set the anodes low and the cathodes high for a few microseconds. The LED’s are reverse-biased and no current flows through, but the LEDs’ parasitics***** come into play in a big way – the LEDs’ internal capacitance stores the voltage. I then set the anodes high-impedance low and start digitalRead-ing the cathode pins round-robin. If any of them are hit by light, the voltage generated by the LED opposes the charge stored by the LED and rapidly depletes the capacitor. Long story short, the first column to digitalRead low has the most light on it.
SO WHAT’S UP WITH THAT SHIFT REGISTER THAT I ABSOLUTELY CANNOT SUBSTITUTE?
You’ll notice that there’s a 595 shift register connected to the cathode pins of the matrix. This is because the processor in the ChipKit actually really sucks at driving anything. Its 3.3V I/O claims to be able to source 8mA and sink -12mA, but it sags a lot***. As you approach the maximum I_src, the voltage drops. A lot. I measured it down to 2.2V, which barely scrapes the forward voltage of a red LED. The shift register sources up to 10mA of 5V to each anode. Without it, the PIC would explode if I tried to direct-drive the matrix, and the voltage stored in the parasitic capacitors bleeds below the logic high threshold too rapidly.
Note that the 595 is a 74VHCT595, not the more common 74HC595. The VHCT stands for Very High-Speed CMOS TTL-Compatible, and is the only series being produced that can take 5V input and use 2.2V I/O. The more common HCT won’t accept the ChipKit’s commands because they’re not 3.3V, they’re likely 2.7V. AAAAAAARRRRGHHH!******
Needless to say, you cannot substitute the 74VHCT595 with another kind of 595. The HCT595, HC595, and especially LS595 won’t work at all. They’ll just sit there with a thumb up their silicon ass, completely ignoring input from the ChipKit.
Anyways, writing the display is standard multiplexing. Set cathodes for illuminated columns low, clock 0x1 into the register, set the next row’s columns low, advance the clock, etc. Current-limiting resistors keep the LED’s at 10mA, which is pretty dim but almost within the 74VHCT595’s current source limit of 80mA. It’ll burn up eventually, but YOLO.
WHAT’S UP WITH THAT DAUGHTERBOARD?
It’s a detachable stylus so you can use the Command Matrix like an adorable little graphics tablet.
HOW DO I BUY/MOOCH ONE?
I never want to see this monstrosity again, but I’m known to get beaten down by large bundles of cash. Shoot me a Tweet, email, or comment.
*ish. You can’t actually display and read simultaneously. I’m convinced there is a way to display some pixels and read others at the same time, and solving this problem is part of why I can’t put this goddamned project down.
**This isn’t actually a footnote. I just abuse profanity and feel bad about it when I edit the page.
***Like your mother. ZING!
****The voltage is proportionate to the light hitting the LED die, and maxes out at the forward voltage of the LED. Only light with a wavelength equal to or longer than that of the LED produces this effect – a green LED will sense blue light, but not red light.
*****All components act as though they have resistors, inductors, and capacitors all over the place. Unless the part is, respectively, a resistor, inductor, or capacitor, these almost always have values so tiny that you can just ignore them. Sometimes they’re relevant, which produces extremely tricky circuits.
******This is what caused me to miss the deadline, why I now have a big box of 74VHCT’s in my parts rack, and why I melted all the parts off my first ChipKit with a blowtorch.