Electronics » the Z80 project » keyboard interface
A computer without a keyboard is about as useful as a.. marshmallow crowbar?
Anyway, as I didn't want to build one from scratch this time the natural
solution was to connect a standard PC PS/2 keyboard.. The internet again obliged
with the necessary specifications for the PS/2 signals/protocol and the
interface itself ended up consisting of another PIC microcontroller, a 74HC245 buffer and a 74HC74 flipflop to act as the "keycode
ready" interrupt line. Minimal code was required for the PIC, it only needed to
read the serial clock and data lines from the keyboard, convert the data to a
scan code byte, present it to the 245 buffer and pulse a line to the 74HC74 to
set the interrupt flag to get the CPU's attention. 16f628 Souce code: Here.
 The PS/2 Keyboard Interface and PSU board |
I didn't need to send any data to the keyboard which simplified the design
drastically (but it does mean the caps lock LED doesn't work - no biggie.) I was
also able to cut down on the traffic from the keyboard interface too - newer
PS/2 keyboards seem to default to "Set 2" scancodes and send extra bytes for
certain keys (at least two bytes are sent when keys are released as well). A bit
of optimizing in the PIC's code and I'd converted all this to a custom system
whereby just a single byte is sent for every key (I care about) that is pressed
or released (in my system, bits 0-6 hold the "set 2 scancode" AND $7F and bit 7
signifies press/release. The only key that could spoon this up is "F7" which has
the "make" scancode $83.. To stop any press / release confusion that code can
be trapped by the PIC's software and converted to some other unused scancode before
output).
The PCB shown on the right was an early version with a 5 volt power 'supply' on the
same board (mainly to use up the space). The keyboard interface is now on the
same PCB as the IDE interface.
|