16

I have a wonderful IBM Model M keyboard, which has the best key action of all keyboards I ever used. The problem is it has the big round 5-pin DIN connector used in AT PCs.

I have some PS/2 to USB converters, and I know they are very 'moody', often only working with keyboards they were shipped with, and sometimes not even that. I do have DIN to PS/2 connector, but - expectably - the double conversion it doesn't work with these PS/2 to USB converters.

How can I use my 'retro' keyboard with modern PCs without PS/2?

  • Do you want to keep using the keyboard LEDs? i.e. bidirectional comms? – Chenmunka Jul 20 '16 at 9:56
  • @Chenmunka: That's not essential, though obviously welcome. – SF. Jul 20 '16 at 10:06
  • 3
    The PS/2 to USB "converters" that come with some keyboards only work if the keyboard itself supports both PS/2 and USB protocols (which are totally different), and the converter just provides an alternative plug by re-wiring the pins. That's why they only work with the keyboard they were shipped with. I don't know of a single XT/AT keyboard that supports USB, which is why any attempt to use those "rewiring converters" will fail. You really need a converter with its own microcontroller, which are never shipped together with a keyboard. – dirkt Jul 20 '16 at 15:24
  • 2
    This will require active circuitry with software-scale internal capability. It would be an interesting project to implement with a USB-capable 5v-tolerant Microcontroller, or perhaps an Arduino Leonardo for which examples covering both USB HID keyboard and legacy PC type keyboard interfaces exist. It should not be too hard to join those, though you may have to put some thought into XT vs. AT signalling and perhaps into mapping key codes. – Chris Stratton Jul 24 '16 at 16:38
  • 3
    An alternative would be to get a brand new Model M keyboard with a USB connection. They are still being manufactured, these days by Unicomp. pckeyboard.com Full disclosure: Just a happy customer. – a CVn Nov 21 '16 at 14:15
14

If the IBM Model M keyboard is one of the ones that uses the AT protocol, you may be able to use a passive 5-pin to PS/2 adapter, chained with an active PS/2 to USB converter such as the Belkin F5U119.

If it uses another protocol (such as XT or 3270 terminal) you will need a custom-made active converter -- https://deskthority.net/wiki/Converter lists several, of which the best known is probably "Soarer's".

  • 6
    To expand on this, most PS/2-to-USB converters are "passive", containing only wires, and depend on the keyboard to detect that it should switch from speaking "PS/2" to speaking "USB". An active converter has a chip in it that speaks "PS/2" on one side and "USB" on the other. – Mark Jul 21 '16 at 18:34
  • 1
    In my experience converters with a single PS2 socket are nearly always passive while those with two PS2 sockets are always active. Unfortunately many active converters, especially cheaper ones seem to be finiky devices. I expect that the vendors are playing fast and loose with the PS2 electrical specs. – Peter Green Mar 2 '17 at 21:04
  • 2
    I discovered today: classic Model M-specific USB cables. USB on one side, and the pre-USB Model M's native port at the other, with the PS/2 -> USB electronics embedded within the cable. Probably the neatest solution. Plentiful on eBay and probably elsewhere, slightly less than US$40. Search for "USB SDL Model M" or similar. – Tommy Jun 20 '17 at 20:31
8

There are two aspects to this. The cable for the physical connection and the driver for the communications protocol.

I suspect with adaptor upon adaptor you are either losing voltage and therefore connectivity or the protocol is getting confused.

Your core problem will lie in the communications protocols. There is a defined USB protocol to which peripherals such as keyboards must comply. The old IBM keyboard clearly doesn't. The host computer will interrogate a USB device using a Setup Token Packet. A USB keyboard will respond, the XT keyboard will not.

PS/2 to USB converters, and other USB converters, usually have a small embedded processor that handles the protocol.

So:
Writing a USB driver on your new PC to bypass the USB protocol is probably impossible as the USB ports are likely to be driven by a dedicated chip.

Cutting the PS/2 connector off your USB-PS/2 adaptor and soldering the wires directly to the DIN plug - in the hope that the voltage loss is reduced and so the flakiness you describe goes away is very risky. Also, the protocol chip may be in the PS/2 plug!
Although the pinouts are not too bad. The IBM DIN and PS/2 sockets have pins as below:

IBM AT-PS2 Pinout

1: Clock
2: Data
3: Reserved (in practice, usually a reset line)
4: Ground
5: +5V

I would suggest: Use a USB-RS232 adaptor and wire the DIN plug to a DB25 or DB9 RS232. The keyboard will then appear to the PC as being on a standard COM port. You then write a keyboard driver for your new PC that converts the data stream from the old keyboard. You may be able to then redirect COM1 to STDIN.

The protocol is summarised as (taken from this description):

Keyboard - PC

When the keyboard has a byte to send to the computer (a keystroke), it shifts 9 bits out to the data line (RxD) with nine clock pulses on the CLK line.
The data format is 1 start bit, followed by 8 data bits.
The baud rate is roughly 2000 bits per second.
The byte sent represents the scan code of the pressed key or a response to a command.

PC to Keyboard:

Commands

ED <byte> Set LEDs depending on byte
          bit 0 is Scroll lock
          bit 1 is Num lock
          bit 2 is Caps lock

EE          Echo EE
F0 <mode>   Select mode 1, 2 or 3
F2          Send keyboard I.D.
F3 <byte>   Set repeat delay and rate
            byte is: 0ddbbaaa
                 delay is (dd+1)*250 msec
                 rate is (8+aaa)*2^bb*4 msec

F4          Clear buffer
F5          Restore default settings and wait for enable
F6          Restore default settings
FA          Acknowledge
FE          Error- please retransmit
FF          Reset keyboard

I have heard of people trying to achieve this feat by putting a Raspberry Pi or Arduino between the keyboard and PC as a protocol converter. But I don't know of any "How To" guide for this.

The upshot of this is that it isn't trivial. Good luck.

  • 2
    Unfortunately it's even worse than that. On both the DIN and PS/2 connectors, see the pin marked "Clock"? That's a ~2,000 Hz signal sourced from the PC to the peripheral, which a normal RS-232 port simply doesn't offer. You'd need a USART rather than a UART, which is hardly a standard COM port... – John Burger Jul 20 '16 at 12:55
  • Indeed, this posting is seriously mistaken and confuses the issues far more than in contributes. Please consider removing it. – Chris Stratton Jul 24 '16 at 16:37
7

The easiest (PnP) approach is definely using two adapters. The first one should be a USB to PS/2 (miniDIN) adapter; This one needs to be an active adapter, such as this one: active ps/2 adapter

Avoid using weird smaller adapters like the one below - they probably won't work because they're designed for motherboards that have a PS/2 host, which allows them to be passive (motherboard will be in charge of changing D+ and D- from the USB port to Clock and Data signal from PS/2). If you have one lying around, you can always try it - your PC will be fine even if the keyboard won't work with this one. passive ps/2 adapter

The second adapter should be a passive one; You can either make one yourself (working schematic on the last picture) or buy one like the picture below online.

passive din>ps/2 adapter a WORKING schematic

One last thing; If you're going to make an adapter yourself, you should not connect the same colored cables from the DIN cable to the same colored cables from the miniDIN cable; Always verify what cables you're connecting to what pins and double check if the polarization is OK (ie. that you haven't connected + from the miniDIN to a - on the DIN)

  • heh +1 for the Czech circuit images :) btw it works also in reverse I got USB keyboard connected to DIN5 Oscilloscope this way. – Spektre Dec 16 '17 at 9:42
  • A silly question, but is this schematics drawn as seen from the "back" (where the wires come in), or from the front (the pins)? – Violet Giraffe Sep 10 at 20:19
  • 1
    @VioletGiraffe From what I have experienced most of the wiring diagrams I have used show the pins as you look at the object, for a plug it's as you look at the pins as if you were 'plugging it into your eye' and for a socket it's shown as you look into the socket from the outside or 'down a well' so to speak. You just have to make sure the pins are numbered and so far all of the plugs I've ripped open had a small mark on pin 1 to show me which one that was, once you know which pin is which it doesn't matter what side you look from as the numbers for each pin are fixed. Sorry if that confuses a – Paddy Brett Nov 9 at 17:51
  • @PaddyBrett, thanks for replying and that's a very good point that it doesn't matter if the diagram is mirrored as long as you know where to count from. – Violet Giraffe Nov 9 at 20:54
  • Actually, I've never seen a host that accepted PS/2 protocol input on a USB connector. However, keyboards that do both PS/2 and USB protocol, and come with an adapter like the one you show to allow the PS/2 connector (doing USB protocol) to be wired to a USB port, are common. – Curt J. Sampson Nov 10 at 1:42
0

have some PS/2 to USB converters, and I know they are very 'moody', often only working with keyboards they were shipped with, and sometimes not even that.

There are two very different types of converters you might be dealing with in this situation.

Wire Converter

One simply connects the wires, changing the connection from a mini-DIN to a USB connector, with no protocol changes at all. These work only with modern keyboards that know how to do both AT (more often called "PS/2") and USB keyboard protocols, and automatically switch depending on what they're plugged into. In other words, what's happening with these is that the protocols is already USB at the PS/2 connector, and the adapter is just changing the connector shape. They typically look like this:

mini-DIN to USB type A

Typically if an adapter is supplied with a keyboard, it will be one of these "wired through" connectors because it's much cheaper to build a keyboard that speaks both protocols than it is to build a keyboard that speaks just one and an entirely separate electronic system to convert the protocols.

PS/2 to USB Converter

The second type talks the AT protocol on one side and the USB protocol on the other, being essentially itself a small computer that converts between the two. These will often look a little bit larger, but not always:

PS/2 to USB protocol converter

What You Need

Because your old AT keyboard talks the AT (PS/2) protocol only, you must use the second type of adapter. Anything that came with a keyboard is most likely the first type of adapter. Anything without a second connector for a mouse is probably the first type of adapter, unless you have some evidence otherwise.

You'll also probably need a connector to convert from your larger DIN connector used by AT keyboards to the smaller mini-DIN connector used by PS/2 keyboards, but the protocol is exactly the same for both AT and PS/2, so these will simply be wired through.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.