I’ve been posting about this on slack but figured it’d be better to create a topic here to use as a sort of project log that more people can see. Hopefully some folks find this interesting! I’ll be tearing down an electric piano, figuring out how the keys work, and building the best MIDI controller I can with the parts and a bunch of new stuff.
My family got this Yamaha PSR-170 in 2002 or something. It’s a beginner keyboard with a bunch of built-in samples (including some entertaining ones like a very enthusiastic guy yelling stuff like “DJ!”, “Oh yeah!” and “Dictionary!”). I never used it much myself but years later it ended up in my closet and sat there for a while. I started learning piano last year and it’s been pretty handy for that, but it has no velocity detection, no USB midi, and it’s absolutely massive. But the keys themselves are still decent and it’s nice to have 61 of them. And for various reasons this has ended up being a somewhat sentimental item, so I felt it deserved a new life rather than being replaced and most likely discarded.
So, here’s the guts. It’s got a bunch of stuff in the top including some speakers, amplifiers for said speakers, I/O, some ROM to presumably store all the built-in samples and wave tables, and a YMW728-F “tone generator” to do the actual synthesis. The information I can find online about the chip is sparse and it sounds like kind of a nightmare and isn’t worth salvaging for anything cool, but that’s not super surprising considering the tier of this device.
I cleaned the keys, which come apart easily once unscrewed and are split into separate assemblies for each octave, each with 3 parts.
With the top set aside, I was left with just the key matrix board, ribbon cable, and keybed, which will serve as the base for my new MIDI controller. I connected the ribbon cable to an arduino nano and set about figuring out the key matrix.
It’s a circuit with a bunch of pins (in this case 17) arranged as rows and columns, with each cell representing a single key with a switch connecting the row and column pins. By setting a given row and column pair to LOW and INPUT_PULLUP respectively, the arduino can detect that a key has been pressed when the input reads LOW, indicating that the key press has closed the switch via the conductive pad on the bottom of the rubber dome. Diodes are added to prevent “ghost key presses” from keys interfering with each other. Thanks to this type of circuit you don’t need a wire for every key, which would be a complete nightmare. This is also commonly used in computer keyboards.
After a bit of poking around with a multimeter, I was able to figure out the row and column arrangement for the key matrix (11 rows x 6 columns, with the first 5 cells of the first row empty):
Following a bit of cursing while I tried to figure out why some keys were behaving strangely (pin A6 and A7 on the nano are analog only, so digitalRead always returns 0), I got everything working. Then I swapped out my arduino for a teensy so I could have a proper USB MIDI device and not have to explain to my piano teacher why my piano was in pieces for my next lesson. After adding some delays here and there due to the teensy being so fast the voltage at the input pins couldn’t change quickly enough, it all works perfectly!
After that I moved on to designing the case, which I’m still in the process of doing. I’ll post some more updates soon! I’m really happy with how this is going so far.