Connecting A Keyboard To A Vintage PC-XT, The Hard Way

We’re not sure if there’s any single characteristic that qualifies someone as a hacker. After all, we’re a pretty eclectic bunch, with skills that range all over the map, and what one person feels is trivial, others would look upon as black magic. But there’s one thing we’re sure of: if you find yourself reading the original POST code for the PC-XT motherboard just to get a keyboard working, you’re pretty much our kind of people.

That was the position [Anders Nielsen] found himself in as work progresses on his “PC-XT from Scratch” project, which seeks to build a working mid-80s vintage IBM Model 5160 using as many period-correct parts as possible. The first installment of the series featured the delicate process of bringing the motherboard up, lest the magic smoke was released. After seeing some life out of the old board, [Anders] needed a little IO, specifically video and keyboard. The video side of the equation was relatively trivial, with an early-90s VGA card from eBay — not exactly period correct, but good enough to get something to display.

The keyboard was another matter entirely. It’s not too much of a chore to find a keyboard that’ll talk to a PC-AT, but the PC-XT had an entirely different protocol, not to mention that chunky 5-pin DIN connector. As with many things, the solution involved building an adapter out of an Arduino, but the process was not exactly low-friction. First, there was the question of dealing with the open-collector outputs on the keyboard, which required code changes. Next, [Anders] broke out the oscilloscope to check waveforms, and found a weird 9-Hz square wave on top of the keyboard clock signal. That ended up being a sign that the keyboard was stuck in a manufacturing test mode, according to a read-through of the power on self-test (POST) source code. A tiny tweak of the Arduino code got everything working.

We’ve got to say that we’re loving this deep dive into the internals of a piece of computer history. [Anders] teased the next step, which will use an empty ROM socket on an old network card to load some assembly code onto the XT. We’re very much looking forward to that exploit.

15 thoughts on “Connecting A Keyboard To A Vintage PC-XT, The Hard Way

  1. Great deep dive, thank you!

    Back in the day I needed print some code I wrote on my [Spectravideo SVI-328](, so I made it “type” the code into the keyboard input of my dad’s IBM-XT using a similar method to that described here, and then printed it from the XT. Had to open a document on the XT before the “typing” was started (might have been EDLIN), and then save it afterwards and print. Used the joystick input on the SVI-328 configured as an output to send the pulses to the XT’s keyboard input to simulate the “typing”. On the SVI-328, the joystick input sockets use some I/O pins on it’s AY-3 8910 programmable sound generator chip, and those can be reconfigured as output as well. Too much experimentation eventually led me to blow one of those pins so the joystick is stuck pointing to the left now :) Good thing I have two SVI-328s in the cupboard. Now if only I could find those old cassette tapes with my programs on!

  2. I suspect it might be worth knowing that an awful lot of PS/2 wired keyboards will auto switch to XT mode if they are plugged in to one.

    Of course it may well be that the intention was to build everything and I applaud that effort. I’m already impressed someone has made so much effort to recreate the XT anyway.

    1. I did mention that in the video. I suspect XT mode prevalence has dropped in keyboards over the last decade – for any cheap USB keyboard even PS/2 has been rare over the last 5 years.
      But I bet you can still get a lot of PS/2 keyboards cheap on eBay – maybe.

      1. Do you have a copy of How to Repair and Maintain Your IBM PC (Chilton’s Computing Series)? IIRC that book is extremely in-depth detailed about the Model 5150. It’s all about the PC, no XT or anything else.

      2. Ah the perils of watching videos between snatched lunchbreaks, I miss important bits like that.

        I was mildly surprised a few years ago when I tried a USB keyboard with an ugly USB to PS/2 to AT adapter “chain” and it worked with an ancient PIC project that very definitely needed XT mode, not sure if would still work now though.

    1. Are you sure? I thought there were differences.
      Maybe you’re thinking of the DIN connector on AT mainboards and the PS/2 connector?
      Yes, they carry same protocol. The PS/2 version may also carry PS/2 mouse signals in addition.

      The XT keyboard protocol, the old one, I mean – not a newer hybrid version, if there’s one, is different to the AT keyboard protocol.

      – To my understanding, the XT keyboard was merely sending out scan codes to PC.

      – Keys didn’t need to be registered/un-registered: The AT version is much more complicated.

      Some people say the XT version was elegant due to its simplicity and that IBM was foolish for switching to AT protocol.

      1. One difference in the keyboard workings on the PC-AT is the Gate A20 control, which for some reason IBM put into the keyboard controller.

        ISTR some 80286 computers that wouldn’t boot without a keyboard. Having a BIOS setting for fast A20 was a thing for quite a while. Early on the BIOS default was always normal, slow, etc to use the keyboard controller. By the later 90’s most motherboard manufacturers were setting the default option to fast.

    2. Incorrect. PS/2 is identical to the AT protocol – less the connector. XT uses only two (10bit) packets for make/break – the AT and PS/2 use three (11bit) packets.. and of course different scan codes.
      I’ve taken the time to explain it very thoroughly in the video :)

  3. It’s worth noting that there are still PC/XT keyboards to be found, with some searching, from pack-rat hoards.

    At some point I should try bringing up my Luggable and see if it still runs. Any pointers to best practice would be welcome. (I presume people would tell me not to just plug it in and turn it on, for fear that capacitors have frotzed…?)

    1. I would tell you to go through the same procedure I did in part 1 – though it is a bit harder with a 5155 still in its case.
      If you don’t find shorts you can try.. though some caps still might blow. PSU should save you tho.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.