99/4A Keyboard to Serial Chip Code
99/4A Keyboard to Serial Chip Code
This code reads a TI 99/4A keyboard and emits serial ASCII. For some reason, I could not attach it as a .C file, but it is C, for PIC MPLAB Version 8.x. The chip is a fairly cheap 16F883, and you don't need a crystal for it (at least not up to 9600 baud) because the programming system trims the onboard oscillator for you. The draw at +5 or 3.3 is only a very small # of milliamps. As written, it was designed to work with an RS-232 converter but the output could be inverted in port setup, I believe. I mention that it really should have a "transmit buffer empty" interrupt and ring buffer for the serial output, but at fast bauds, this really doesn't matter. The baud is hard-coded, but an enterprising person could use jumpers or better yet, "power on keystrokes" to set the baud and store it into the chip's onboard EEPROM.
The keyboard should handle all common ASCII and control characters, although you may have to do odd things to get to them (note the weird "function" requirement for brackets, for example). Note that I use "alpha lock" for "caps lock". Of course, if you don't like it..you can change it. And, please don't laugh at the code. The only code I've written commercially in 20+ years is PL/SQL.
The keyboard itself is very compact and cramped, but it has a pretty good, old-timey stiff feel. I wonder if they made the keyboard specifically for smaller (kids?) hands. It's pad-printed, but it seems to have held up very well over time.
The way it works is simple; it scans the 8 (+1) x 6 matrix of keys and debounces them by adding /subtracting a threshold counter until it is hit (COUNTLIMIT). A second threshold (REPEATLIMIT) permits auto-repeat. I wouldn't try typing 100WPM (if that's even physically possible) but it shouldn't have ghosting problems, etc.
I don't mention the pinouts and port assignments, but it should be fairly obvious; I used the very nice schematic on the following page to design it.
http://www.mainbyte.com/ti99/keyboard/keyboard.html
If this is a problem, I'll buzz it out for you. I did this as kind of a "one-time-off" project, so, no schematic.
The keyboard is very easy to mount into a box; I used a scroll saw and my woodsman-quality woodworking skills to cut it out.