From: cgordon@vpnet.chi.il.us (gordon hlavenka)
Subject: Re: IBM Keyboard Info
Organization: Vpnet Public Access
Date: Thu, 01 Oct 1992 16:23:58 GMT

 rob@dexter.psych.umn.edu (Robert Stephens) writes:
>I need some technical info on the circuitry,
>and pinouts for a standard IBM keyboard.\
>
>Could someone please E-mail some info to me?

I'm posting it also, since there's probably sufficient interest...

Here is a module out of some code I recently wrote for a Signetics
87C751  (Intel MCS-51 core)  The comments pretty much cover it...

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                       ;
;       Keyboard Interface              ;
;                                       ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;                                       ;
; This is where we make like an XT      ;
; keyboard.  The scancode to send is    ;
; passed in A, and this routine drives  ;
; a KCK and KDA line.                   ;
;                                       ;
; I characterized a BTC-53 keyboard,    ;
; and discovered the following:         ;
;                                       ;
; - KCK rests high                      ;
; - KDA rests low                       ;
; - There are 10 KCK pulses per scancode;
; - KCK goes low for 23 uS              ;
; - During this time, KDA goes high     ;
; - KCK goes high for 513 uS            ;
; - KCK pulses 9 times                  ;
; - The pulses go low for 32uS          ;
; - The pulses go high for 50 uS        ;
; - KDA is NRZ, LSB first               ;
; - The first KDA bit is always a 1     ;
;                                       ;
; The following code seems to work,     ;
; even though the timings don't match   ;
; the above data.  The importantest     ;
; part seems to be that initial 513uS   ;
; "front porch" -- it works with at     ;
; least 2 different generic XTs.        ;
;                                       ;
; Compatibility with other XTs is not   ;
; assured.                              ;
;                                       ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                                        ;
KB_SEND:                                ;
        PUSH    ACC                     ; Save the ACC, in case we want it lat
                                        ;
        CLR     KCK                     ; Generate
        SETB    KDA                     ;          the first
        SETB    KCK                     ;                    KCK pulse
                                        ;
        MOV     R0,#75                  ; Now do the 513 uS delay
        DJNZ    R0,$                    ; (This is approximate, and assumes
                                        ;  a 3.579545 MHz crystal)
                                        ;
        SETB    C                       ; Prime the pump
        MOV     R2,#009                 ;
KB_LOOP:                                ;
        MOV     KDA,C                   ; Data valid
        SETB    KCK                     ; Clock high
        CLR     KCK                     ; Clock low
        RRC     A                       ; Position next bit
        DJNZ    R2,KB_LOOP              ;
                                        ;
        SETB    KCK                     ; This should be left high...
        CLR     KDA                     ; ...and this should be left low
        POP     ACC                     ; Restore ACC
        RET                             ; All done

Also, (depending on your budget) you may want to look into "PC
Keyboard Design" by Gary J. Koznak.  It's $249 (!) (with diskette)
from Annabooks at 1 (800) 462-1042 or 1 (619) 673-0870


Oh, yeah -- pinouts.

Pin 1 Keyboard Clock
Pin 2 Keyboard Data
Pin 3 Keyboard Reset (not used in the XT, I believe)
Pin 4 Ground
Pin 5 +5 volts

The connector is a 5-pin (120 degree) DIN.  The PC gets a female
connector, and the keyboard is male.

PS2 keyboards are left as an exercise :-)


-- 
----------------------------------------------------
Gordon S. Hlavenka           cgordon@vpnet.chi.il.us
  Don't forget:  Dave Barry/Joe Walsh in November!