Keyboardin’ Part 3
The keyboard hardware interface works! I’m now a happy key-tapping fool, because with its own keyboard and LCD display, BMOW can operate completely independently from any host PC. The 4×20 LCD is certainly a very cramped workspace, so a Hyperterminal connection over USB from a PC is still the most practical solution for any serious BMOW interaction. But for the sheer cool factor, a stand-alone BMOW with its own I/O beats a USB tether to a Wintel box hands down.
Of course I can’t actually type anything useful with the keyboard interface yet, that would be too easy. You might think that the keyboard sends ASCII bytes to the computer as you type them, similar to a terminal connection, but in fact it’s a totally different interface. Each keypress sends a scan code to the computer, which is normally a single byte but can sometimes be two or three bytes. Then when the key is released, the keyboard sends a “break” scan code, followed by another scan code for the released key, which is usually but not always the same as the keypress scan code. Even the shift key works this way. So to tell if the user typed a capital “A”, you’ve got to keep track of the current state of the shift key by listening for its keypress and key release scan codes, then translate the scan code byte 0x1C to the “a” key, then finally convert that to the character “A” when the shift key state is factored in. I haven’t written any of the key state and scan code conversion software yet, so while it’s true that my hardware interface works, all it does currently is display scan codes.
My original hardware design for the keyboard interface almost worked on the first try. The only problem I ran into was with the clock signal generated by the keyboard, which is used to synchronize the data it sends to the computer. The rise time on the clock signal was mind-numbingly slow: about 1.2 microseconds to go from 0 to 5 volts. Compare that to BMOW’s main system clock, which rises in about 15 nanoseconds. The slow keyboard clock was causing trouble, because the different BMOW chips connected to it sensed a low-to-high clock transition at slightly different voltages, which equated to substantially different transition times due to the slow rise time. My solution was to feed the keyboard clock signal through a Schmitt trigger inverter, which turns a slowly-changing input like this one into a nice clean, quick low-to-high step.
5 Comments so far
Leave a reply. For customer support issues, please use the Customer Support link instead of writing comments.
cheap pic/atmel microcontrollers with lookup tables that put out ascii bytes!!
😀 That is… if you want to use ps/2 keyboards. Then again, I can’t imagine homemade being much better
I wonder, if, with some cad experience, someone COULD make a keyboard which outputs certain bytes based on keys pressed, with some switches.
Translating the scan codes isn’t too tough, really… I just haven’t gotten around to writing software to do it yet. A separate microcontroller could do it too, but BMOW already has everything needed to do the job. I plan to write an interrupt routine that processes incoming scan codes, and turns them into character data for whatever program is running.
Where are we going to get the secure local fileserver complete with cyptographic authentication and redundant error-checking, all maintained with an insanely complex system of rodents and wire wrapping?
“BMOW already has everything needed to do the job.”
Now retailing for only $5,699! YOU TOO can become part of the wide sweeping computer craze!
Two years later, I realized that the cause of the “mind-numbly slow” rise time on the clock is that the clock line is not actively driven high from the keyboard. The keyboard drives it actively low, then releases it, and the voltage is pulled up from a pull-up resistor. The greater the resistor value, the slower the rise time. You’re supposed to read the incoming keyboard data at the falling edge of the clock, not the rising edge.