Hacked-apart Casio + AT90USB162 + LUFA = Simple PC Piano
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
Well, if this project wasn't in "hack territory" before – despite an actual hacksaw already having been part of the process ;) – it's definitely there now!
Yesterday, I removed all 32 "anti-ghosting" diodes, and reinstalled them the other way round (except for the one I broke, which I replaced with one from the ol' junk bin). I did this for a couple of reasons:
With the above changes to the hard- and firmware complete, it works great! As for the source, I think I'll skip github and just share an archive of the four files that differ from the LUFA keyboard demo (Demos/Device/ClassDriver/Keyboard in the LUFA package, at time of writing) and the .hex file (although, according to various web searches, I appear to be the only person on the planet still using an AT90USB162 at all, much less this particular carrier board :P).
Since I can't attach (non-image) files to the Hackaday.io project, and I don't want to maintain the file on an external hosting service, and the file is so small, I'm going to include a Base64 encoded version of "usbiano.zip" at the end of this post.
To use it:
UEsDBBQAAAAAAAu+OEUAAAAAAAAAAAAAAAAGAAAAQm9hcmQvUEsDBBQAAAAIAHO+OEV/m4I5agIA
AFMFAAANAAAAQm9hcmQvQm9hcmQuaK1STW/bMAw9x7+CSy9t2ijbsNNObZ1+BEjToWhP7WDIEh1r
VSRDkpcZRf/7KCtBg2DbZRVgSRYfH/lITkYZbNbhpXXQeoS1CjWEGhljRxnsrvnD5RnMVem465Il
t03n1LIOcJgfwRS5gZyv0PET+Pzx0xeWEUzG10cevkNlW7fmWqMUbamERniUlt6FXe0GWq/XTLcV
H2tVMuuW2WiSZZPRCJ4qpTGDEcBT6RRWsLBm7BsUqlICSsudBGUq61Y8KGugRi7RAT0AT+YkzthQ
K7NkiUqQBomBK+3hytm2Kc4jdEZExeL2/nq2uCJgwpInwn2tPMRUwNe21TLyQYkUWuhWogSpHIqg
OwazAITlbbAxJUHauzcY92AQ463sYsGhjwvSqZ/o+nhpSeUbHkS91aOt4AGj1L4jk2nv4Ce9e9pZ
HcVty0Zao659dUmSxCpZ/6IdNuf71j2y/ScNjOkGP2znqbLPJ/GnbEOwxvf3+cU0Xfajnr6k0hyo
ypB4KIrz27O76VZvcV0U2QEZlME/2rLBZASz1ET/NVINBgebpsKQsUlsStpyu1pZszlYPUy+F4aX
GiEHrcwzX2KvMD8+BsI1SqN7Y60gJSIPi0I0uvXxOyLTAH8FdAaG+RBeIhSNVFXi/+awcVag95G3
RvG8S/jhjXG2yOcP04vi8u72ZiP0msgjm3PkO+2LB1ttYTv3uwOebP8YRHL3Ablk+1m2pVaCCEhH
xQVSO294ByVC69NwE3jMm4ZQ/TwkDeRKOOHsVhM9jGiSSis7qNFhHAKiAFHTVKDxjDECpphT5d+h
9K87SrZnTOL0Nfr+BlBLAwQUAAAACABPqUdFyGivrosKAAA+IAAADQAAAERlc2NyaXB0b3JzLmPV
WOluKjcU/n15CutWauGK0qSbql61EgGSohISAeleITNjiNVhPLVnktLl3fsdL3iGadN0+VOUZRif
5Turj/3Oqw6rf2Z3l0M2kxvN9cGtjFRx0HJ3X7LuqMfGgudsxPdC8z579+z8/UEHZCm9/ZaX37Ot
qvQjzzKRJtVGJplg36YK7xO1ryt6fHwcZNWWv53JzUDpXefVO50OYYnqrHRWV8i6z9LTI0S3Qu+l
MVLlrFSsMqLPEkjus71K5Rb/U2lKLTdViRWep8yILGPlvTRgNmpbPnIt7IIsDUtVUu1FXvISAqFb
Y+XAikoXyggmDbsXWmwObKd5Xoq0AwNlea+qkm0F5BdaPchUpJDPS/yB4I16EEAUbM1VKRO8LgrB
NZM5JMA4IpDCQJln3ajyPgppsYMumFBE+2uLMIoQHsj6JOMSXo06mamKQulS5rsOa5psXRQV5wgH
U1tnSQVDNZQAnSBHpx5++iAgy0Aaw3pRbTKZSKgu8JrLnN6XKoYBWrzIegCCG00hErmVSZ89almW
...
Read more »
I know… Thurs was quite a few days ago. I did get the headers then, and I even used them to rig up the new cables the same day. As you can see in the spiffy new photo, I decided to use separate cables for the columns and rows; one 8-pin, and one 4-pin, respectively. This was useful when I moved the rows to port C as a test (which, unfortunately, didn't solve any of my problems). Since this isn't the final resting-place of either the keyboard or the dev. board, it'll also make the reuse of either one much easier.
On the software side, I flipped the keymap the right way round, so that part's working better. I also solved a problem I was having which I didn't mention in the last log entry. Every key was sending a keystroke, but the entire right half of the keyboard was sending the same keystroke. I thought this was just a couple of row lines not making connection, and it would be fixed when I added the new cables/plugs. When I tried it out after the hardware update, it was still happening. I eventually tracked it down to the compiler defaulting to a 16-bit data type, when I need a 32-bit. So, that's fixed, and I get a different keystroke for every key, but the "rotated one column to the left" problem is still there.
Here are some things I've checked:
This leads me to the inevitable conclusion that there is something amiss in the software, but I cannot figure out what it could be. If I'm shifting the wrong number of places, it seems like the "upper" column bit would be lost, not magically wrapped around to the "lower" column! If it was an "off by one" error in the switch-to-keycode map, the whole keyboard would be shifted, not each individual row! It's maddening! (And it's even more maddening knowing that it's something extremely simple that someone with more experience will spot immediately…)
Anyway, that's where I am now. I could start using it now, if I readjusted the key map to compensate for the key rotation, but I really want to know why it's doing that, rather than just cludge a work-around. I'll work on getting the code up on github, ASAP.
Well, I loaded the "alpha" firmware, temporarily connected the keyboard, and fired it up. No magic smoke was lost (not that I was expecting any, since the board worked fine with the LUFA joystick demo), and it enumerated as a keyboard.
I pressed the low "F" key, and… I GOT A KEYSTROKE! Of course, it was the wrong one… but, hey, at least it's something, right?
It turns out I somehow got the key-map "end-for-end", despite drawing a really nice diagram of the rows and columns. Something slightly more odd is the fact that each "row" is rotated one "column" to the… left, I think… yeah, left. I'm assuming this is a software problem, since the matrix is very straight-forward, but I can't figure out why it's happening. Once I get the source posted, I'd appreciate some more eyeballs seeing what I'm missing and letting me know about it.
First, though, I have to get the keys properly connected to the board. I've ordered some single-row, male headers from fleaBay. I'm going to replace the tiny piece of ribbon-cable on the keyboard with a longer one from an old floppy cable, and put some pins on the other end. I'm going to put another set of pins on the AVR board. Then, I'm going to plug both sets of pins into a breadboard socket. Easy-peasy. They're estimating Thurs. for delivery of the headers, so I guess I'm on-hold until then (which will give me time to github-ify my code, and maybe post some pictures).
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates
Why don't you take a look at my USB MIDI project also? It has a similar configuration, but it uses homemade FSRs rather than an hacked keyboard, but again the configuration is pretty similar, although I'm using a multiplexer, a timer interrupt routine which reads a single key at a given time and a Teensy 3.0.
You can find the project on my account
Cheers and keep hacking
Mick