PC/XT and AT Keyboards - How Are They Different?

IBM PC and XT Keyboard

When IBM designed the Model 5150 (IBM PC), the keyboard communication was one-way (from the keyboard to the keyboard controller on the motherboard). The first keyboard was the Model F which had 83 keys including 10 function keys down the left-hand side. The Model F was a full travel mechanical keyboard. The same keyboard was carried over for the Model 5160 (IBM PC-XT).


IBM Model F XT Keyboard (1981)

It used a 5-pin DIN connector consisting of a clock and data line, with the idle state being clock high (+5V) and data low (0V).

The pinouts look like this:

When a key is pressed, the clock line goes low (0V) for 36us (microseconds). This is followed by 9 clock pulses, each of which is 12.5us low and 20us high (32.5us each). On the 10th rising edge the clock then stays high (+5V) until the next sequence. The data line meanwhile changes on the rising edge of the clock. There are 7 data bits (the last 2 are always low). This 32.5us clock period gives us approximately a 31 kHz bit rate.

IBM PC/AT Keyboard

The AT version of the Model F came with the IBM 5170 (PC/AT) in 1984, and was designed to overcome some of the limitations of the PC/XT keyboard. Keeping the function keys down the left, but it added a SysRq (System Request) button, the numeric keypad was pushed out to be away from the main keys, the Return and Backspace keys were made much larger, and it got 3 status LEDs for Caps Lock, Num Lock and Scroll Lock.


IBM Model F AT Keyboard (1984)

 

This design was updated in 1986 with the introduction of the IBM "Model M" keyboard, a design which remains relatively unchanged even today. The function keys were moved to the top and F11 and F12 added, and depending on your country's layout had anywhere from 101 to 106 keys. The UK keyboard layout got 102 keys.


IBM Model M AT Keyboard (1986)

AT keyboards used the same 5-pin DIN connector as before, complete with identical pinouts. The key difference however (mind the pun), is that the AT keyboard can send and receive data - it's bidirectional - whereas the PC/XT keyboard can only send data (unidirectional).

Unlike the PC/XT keyboard, the idle state on the AT is both clock and data lines high (+5V).

The keyboard sends data by bits, each synchronised with a clock signal. It starts to send by setting both the clock line and data line high (+5V). It uses 11 bits for a transmission: 1 start bit, 8 data bits, 1 parity bit and 1 stop bit. After these 11 bits are sent, the keyboard controller sends the clock signal low (0V) to tell the keyboard not to send anything more until the clock line goes high again (+5V).

When the computer needs to send a command to the keyboard it sets the clock signal high (+5V) and the data line low (0V) When the keyboard sees this, it starts clocking pulsed on the data line. Once it's received its 10th bit (there is no 'start bit' when the computer's keyboard controller sends data to the keyboard) it sets the data line low (0V) and sends out an extra low clock pulse. It then waits to receive a handshaking 'clock line low' from the keyboard controller.

The primary advantage of this two-way communication on the AT keyboard was to be able to set the keyboard status LEDs off or on, but it also allows the controller to have the keyboard run a self-test.

Here are the special commands the keyboard can send to a keyboard controller:

00      Keyboard buffer overflowed  
AA      Selftest passed - this always occurs after initial power-on
FA      The command sent was received correctly  
FE      The command sent was received poorly. Please resend.

 

And here are the commands the keyboard controller can send to a keyboard:

ED      Set the LEDs according to next byte I send          
        bit 0=Scroll lock 1=on
        bit 1=Num lock          
        bit 2=Caps lock          
        bits 3-7 must be 0  
F4      clear the key buffer and start scanning  
F6      restore default values  
FE      retransmit last character, please  
FF      Reset keyboard

 

Switchable Keyboards

The only way an XT keyboard would work on an AT is if the motherboard's keyboard controller and the BIOS supported it, which is very rare. Between around 1988 and 1992 XT-compatibles were still available to buy new alongside the faster AT 286, 386 and 486 systems. At this time, most XT-compatible PCs came bundled with an "Enhanced" 101 or 102-key keyboard, but still used the XT unidirectional protocol. Some however, came with a switchable keyboard that had an XT/AT switch on the bottom or rear, allowing the same keyboard to be bundled across the manufacturer's entire range - these work because they have the circuitry to support both unidirectional (PC or XT) and bidirectional (AT) protocols. I have never seen an 83-key keyboard with one of these switches.

   

 

PS/2

With IBM's launch of the PS/2 range in 1987 they also introduced the use of the 6-pin mini-DIN for keyboard and mouse connectivity. These offered no material benefit to the end user since they were electrically identical to the older 5-pin DIN. These connectors were used long after IBM left the PC scene since motherboard manufacturers and OEM PC manufacturers soon adopted their use. They also kept the name, so these are usually referred to as "PS/2 ports" after the original IBM PS/2 range of computers.

One interesting side note... the IBM PS/2 Model 30 is an XT-compatible machine, yet came with PS/2 ports for keyboard and mouse just as its faster siblings did (Modesl 50, 60 and 80). This is at odds with my understanding that PS/2 ports were only used on AT-class systems, making the Model 30 possibly the only XT-based PC that used the PS/2 port.

In most cases the use of a PS/2 to AT adapter works just fine if you only have a PS/2 keyboard but want to use it with an AT-compatible PC that has the older 5-pin DIN. These adapters were prevalent from 1986 until well into the 90s to allow a more modern keyboard to work with an older AT computer.

         
PS/2 to AT Adapters

If you find the use of an adapter doesn't work, the usual cause of this is down to whether your keyboard supports "Fast Gate A20" mode. This was a BIOS option that appeared on 286/386/486 motherboards that allowed it to switch between the standard Gate A20 that used the motherboard's keyboard controller chip, to the fast Gate A20 somewhere else on the motherboard. At some point, PC manufacturers stopped implementing the original 'slow' A20 emulation through the keyboard interface and had the "Fast Gate A20" option fixed to 'on'. On these systems, the keyboard circuitry was modified also to not bother with Gate A20.