BMOW title
Floppy Emu banner

Keyboarding

Last night I rigged up a system to read keypress data from a standard PS/2 style PC keyboard. I bought the necessary parts weeks ago, but I assumed it would be complicated to get working, and never made any progress on it until yesterday. It turned out to be incredibly easy– from soldering and wiring up the required connectors to reading out scan codes on the logic analyzer only took about an hour! Now I should be able to get a direct keyboard connection for BMOW, providing an alternative to the USB connection to a PC terminal program.

It turns out that only four of the pins on the PS/2 connector are used by the keyboard, and two of those are power and ground. The other two are data outputs generated by the keyboard when a key is pressed. No data needs to be sent to the keyboard, so the interface is very simple. The two data outputs from the keyboard are clock and data, both normally high. When a key is pressed, the clock signal pulses low 11 times, and the data signal sends 11 bits of data in sync with the clock. Bits 1-8 are the scan code data byte. Bits 0, 9, and 10 are start, parity, and stop bits, and can be ignored. More data details can be found in this write-up of interfacing a PC keyboard to a microcontroller. 

My only remaining question is how to best join together the bits into a byte, and generate an interrupt. The format of the data is clearly intended to be used with a UART, with its start, parity, and stop bits. However, a UART is a fairly complicated component to add to the BMOW system, and it would be overkill for this purpose. At first I thought I could build a customized solution from a single GAL, but I don’t think I can fit 8 data bits and the necessary bit counting and interrupt logic in one GAL. One GAL combined with a 4-bit counter should do the trick, I think, although I haven’t yet worked out the exact details. Those two chips together are still about the same physical size as a single UART, and will be much easier to control, so it feels like a good solution.

Be the first to comment! 

No comments yet. Be the first.

Leave a reply. For customer support issues, please use the Customer Support link instead of writing comments.