geekhack Projects > Making Stuff Together!

TMK IBM PC Keyboard Converter

(1/44) > >>

hasu:
IBM PC Keyboard Converter

The converter translates IBM PC keyboard protocols into USB to use classic keyboards with modern computer. It supports both IBM XT and AT protocols(including PS/2 and Terminal), and all of scan code set 1, 2 and 3 with one firmware.

Pin configuration is compatible for Soarer's, this firmaware works on existent Soarer's converter hardwares.


You can buy preassembled TMK converter here to support this project.

Thanks


Keyboards that should be supported
- PC XT keyboard of IBM 5150 5160
  - 83-key: 1501100 1501105
- PC AT keyboard of IBM 5170
  - 84-key: 6450200 6450225
- Terminal keyboard of IBM 5271(3270 PC)
  - 122-key: 6110344 6110345 1397000
  - 102-key: 1390680 1395764 1392595
- Other AT and PS/2 keyboards


This project is intended to integrate and supersede existent TMK XT, PS/2 and Terminal converters.
- IBM XT converter: https://geekhack.org/index.php?topic=94649.0
- PS/2 converter: https://geekhack.org/index.php?topic=14618.0
- IBM Terminal converter: http://geekhack.org/index.php?topic=27272.0



REQUEST FOR HELP
Test in the field and feedback from users are needed to improve this converter.
Please report your result and your keyboard model number.
Also debug outputs on hid_listen would be helpful to know how keyboard is recognized.

The converter needs to be tested especially with these keyboards:
- IBM 5576-002/003 - Check and correct Code Set 2 table
- IBM 5576-001 Supported!  2021-06-01
- Zenith Z-150 AT
- Zenith Z-150 XT black label
- IBM PC XT 83-key
- IBM PC AT 84-key
(Let me know if you still have any issue)



Confirmed Keyboards
Let me know if you find any issue with these keyboards using the latest firmware.

XT Keyboards
- IBM PC XT 83-key: 4584656, 2020-06-02
- Leading Edge DC-2014
- KeyTronic E03600 XT/AT (after Timeout error Fix)
- Zenith Z-150 XT, black label, Heath(92-803)
- Chicony KB-5191 in XT mode
- Focus FK-2001
- Siemens F500 XT
- Sanyo N860-2905


AT(PS/2) Keyboards
- IBM PC AT 84-key,
- DS-2001,
- Northgate Omnikey
- KeyTronic E03600 XT/AT
- DTK SPK 101
- FK-8000
- Focus FK-2001
- Siemens S26381-K257-L120
- APC-H410E
- Toshiba JIS AT101
- Dell AT101 - GYI3PVAT101
- Wang 724
- Unicomp Model M
- IBM P70 Keyboard
- Zenith Z-150 AT #661


Terminal Keyboards
- IBM 122-key Terminal: 6110345, 6111070, 6110344
- G80-2551
- IBM 5576-001 (Code Set 3)
- IBM 1394204 101-key(Use 122-key layout on Keymap Editor.)

AT/XT Keyboards
- RT8255c+
- RT-101+
- C260 Enhanced Keyboard (Deyi foam and foil)
- Northgate Omnikey 101
- Zenith ZKB-2
- BTC-5161 - Part number: BTC5339



Issues
Let me know here or on github if you have any problem.





Keymap Editor
You can edit keymap on web browser and download the latest prebuilt firmware here.

http://www.tmk-kbd.com/tmk_keyboard/editor/#ibmpc_usb

Use '83-key XT' layout for IBM PC/XT keyboards and its compatibles.
Use '84-key AT' layout for IBM PC/AT keyboards and its compatibles.
Use '122-key Terminal' laytout for IBM Terminal keyboard and its compatibles.
Use 'Full-key' layout for PS/2 keyboards and others.


Default Keymap
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-Keyboard-Converter#default-mapping

Check this default mapping if your keyboard is ot consistent with Keymap Editor layout.

Use hid_listen to see scan code of questioned key and find it in default mapping table below.

For XT Keyboards: https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-Keyboard-Converter#xt---scan-code-set-1
For AT or PS/2 Keyboards: https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-Keyboard-Converter#at-scan-code-set-2
For Terminal Keyboards: https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-Keyboard-Converter#terminal-scan-code-set-3






Firmware
Source code: https://github.com/tmk/tmk_keyboard/tree/master

Build Firmware
If you are not familiar to these things use Keymap Editor.

    git clone https://github.com/tmk/tmk_keyboard.git
    cd converter/ibmpc_usb
    make -f Makefile.<variant> clean
    make -f Makefile.<variant>

where <variant> is atmega32u2, atmega32u4 or at90usb1286.
You will see firmware hex file in the directory.

Check this page as well. https://github.com/tmk/tmk_keyboard/wiki#build-firmware

Default Prebuilt Firmware
You can download the latest prebuilt firmware with default keymap here.
https://github.com/tmk/tmk_keyboard/tree/master/converter/ibmpc_usb/binary



Debug
Use hid_listen to see debug outputs from the converter.

https://github.com/tmk/tmk_keyboard/wiki#hid_listen

You will see debug ouputs like this.

--- Code: ---Waiting for new device:...
Listening:


TMK:95aba6dd/LUFA


USB configured.

Keyboard start.
rAA rBF rBF wF5 rFA wF2 rFA rBF rBF wF4 rFA ID: BFBF
kbd: Terminal
wF8 rFA 

--- End code ---



Hardware
The firmware supports ATmega32u4, ATmega32u2, AT90USB128 by default, Teensy2/2++ or Pro Micro can be used.

Wiring
Wire controller pins below to keyboard signals, besides VCC and GND. This pin configuration is compatible for Soarer's converter.
- Data    PD0
- Clock   PD1
- Reset   PB7(or PB6 for Pro Micro)  (For some of XT keyboards. Not needed for AT, PS/2 and Terminal)
Pull up resistors of 1-4.7K Ohm on both Data and Clock line are strongly recommended, without them it won't work in some cases.

Reset pin
Old Type-1 IBM XT keyboard and some of XT clones need Reset pin to initialize its controller on startup. Also some clones such as Zenith Z-150 XT and  Leading Edge DC-2014 are known to need this. Type-2 IBM XT keyboard and other XT clones don't need the reset pin. But you better have wiring for Reset if you want to support XT keyobards. See this for difference between XT Type-1 and Type-2.
AT, PS/2 and Terminal keyboards don't require the Reset pin. The Reset pin won't harm AT keyboards you can make converter to support both AT and XT keyboards.

Connector pinouts
MoreXT
DIN 5P 180

- https://web.archive.org/web/20191117093845if_/http://www.kbdbabel.org/conn/kbd_connector_ibmpc.png
- https://allpinouts.org/pinouts/connectors/input_device/keyboard-xt-5-pin/
For Pin 3: Reset see above for the details.

AT, PS/2
DIN 5P 180, Mini-DIN 6P, SDL

- http://www.kbdbabel.org/conn/kbd_connector_ps2.png
- https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#connector
- https://old.pinouts.ru/InputCables/KeyboardPC5_pinout.shtml
- https://pinouts.ru/InputCables/KeyboardPC6_pinout.shtml

Terminal
DIN 5P 240, RJ-45 8P5C

- http://www.kbdbabel.org/conn/kbd_connector_ibm3179_318x_319x.png
- http://www.kbdbabel.org/conn/kbd_connector_ibmterm.png
- http://www.kbdbabel.org/conn/kbd_connector_ibmrt.png (IBM RT)


Pro Micro Caveat
Pro Micro is not recommended unless you are already familiar or have skill and time enough.
Don't ask Pro Micro specific question/help here like which pins to be used and how to flash.
MoreYou have to use VCC pin to power your keyboard, not RAW pin.
RAW pin is not for 5V power supply directly from USB line. The name may be confusing but it is used for external power input, not output. You get only around 4.6V due to protection diode(D2 in schematic) forward voltage drop(0.4V typically) on RAW pin.
And you have to make J1 solder bridged, without this you will get same voltage as RAW pin or lower.
With J1 solder bridge you can get raw power(possibly 5V) directly from USB line on VCC pin. Note that RAW pin doesn't give 5V even with the solder bridge.
Check this wiki for detail. https://github.com/tmk/tmk_keyboard/wiki/Pro-Micro#j1-solder-bridge

PD0, PD1 and PB6 are maked on Pro Micro PCB as 3, 2 and 10 respectively.

https://github.com/tmk/tmk_keyboard/wiki/Pro-Micro#pinout






Protocol Considerations
- https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol
- https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol

Keyboard discrimination
This section explains how the converter determines proper protocol and scan code set for keyboard. The converter need to do that before starting to receive and translate scan codes from keyboard.
MoreProtocol
This converter can recognize both XT and AT protocol *dynamically* accoding to bit sequence received on signal line.
https://github.com/tmk/tmk_keyboard/blob/f80601db962384146eb80705aaa3057a1b3848b4/tmk_core/protocol/ibmpc.c#L272-L303

Keyboard ID
After startup the converter sends 0xF2 command to get keyboard ID and sees how the keyboard responds to the command.
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#keyboard-id

Response from keyboard:

- XT keyboard doesn't support any command and returns no response.
- AT keyboard should respond with 0xFA to the command but returns no keyboard ID.
- PS/2 keyboard should respond with 0xFA to the command, followd by keyboard ID, such as 0xAB83.
- Terminal keyboard should respond with 0xFA to the command, followed by keyboard ID, such as 0xBFBF.

Now we can dscriminate the keyboard and determine suitable protocol and scan code set as described below.

Scan code Set
- Scan codes from XT keyboard are handled as CodeSet1.
- Scan codes from AT and PS/2 keyboard are handled as CodeSet2.
- Scan codes from Terminal keyhboard are handled as CodeSet3.




Update
2021-06-03 Add support for Zenith Z-150 AT, IBM 5576-001(ID:AB92) and IBM 1394204(ID:7F7F)
2020-11-22 Add adhoc Z-150 AT support(Let me know your result)
2020-11-22 Fix Pause key for enhanced XT keyboard
2020-07-05 Fix for Timeout error(ERR:20)
2020-07-02 Add support for hidden keys of IBM AT 84-key to Editor
2020-06-03 Improvement for XT protocol and keyboard error recovery
2020-05-11 Add handler for keyboard buffer full to prevent key stuck
2020-05-11 Add adhoc start bit error recovery for XT keyboards
2020-04-28 Add support G80-2551 and possibly other terminal keyboards(whose id is AB86)
2020-04-11 Keymap Editor is available
2020-03-02 firmware update for XT protocol handling and many other fixes



TODO
* Reset method for rescue
For converter without accesible reset button when magickey combo doesn't work.
Check pin status at powerup:
- if Data and/or Clock are pull down to GND
* Force protocol and scan code set
Keyboard discrimination may fail and you have to configure them by hand.




Solved Issues:
MoreIBM PC XT 83-key:
- Random issues show up.
https://geekhack.org/index.php?topic=103648.msg2898287#msg2898287
https://github.com/tmk/tmk_keyboard/issues/635#issuecomment-626363659
https://github.com/tmk/tmk_keyboard/issues/635#issuecomment-626346945
It was hardware issue probably. 2020-05-14

- miss start bit(0) and register wrong key
https://github.com/tmk/tmk_keyboard/issues/635#issuecomment-626249036
https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-XT-Keyboard-Protocol#note-for-start0

https://github.com/tmk/tmk_keyboard/commit/7c3b669e6f7f449fa4ae58e028fcd07182cafa99
https://github.com/tmk/tmk_keyboard/issues/635#issuecomment-627397611
Updated firmware and solved. Use the latest firmware. 2020-05-14

https://github.com/tmk/tmk_keyboard/issues/635#issuecomment-636972917
Updated firmware for further improvemtn. 2020-06-03


Zenith Z-150 AT:
- Start bit and ACK when sedinging data

Detailed Issue Description:
- https://github.com/tmk/tmk_keyboard/issues/661
- https://github.com/tmk/tmk_keyboard/wiki/IBM-PC-AT-Keyboard-Protocol#zenith-z-150-at

hasu:
anyone? please check first post.



--- Quote ---REQUEST FOR HELP: Try and report your result.
Post your keyboard model number here, also debug outputs on hid_listen would be helpful.

--- End quote ---

Maledicted:
I have a few ATMega32u4s sitting around waiting to be turned into Soarer's Converters, and probably the necessary resistors. I have both the standard IBM Model F XT, and AT. I also have some AT/XT switchable Uniteks and a DC-2014, although it already currently has a Soarer's converter I built inside of it. I know a guy that has an old RJ11 Wyse too (among other old weird things), if any of that may be helpful for testing.

What exactly is it that you wish to accomplish? An open-source alternative to Soarer's Converter? I would think that the AT/PS2 keyboards should all work just about the same, right? My F AT works with modern systems with a 5 pin din to PS2 adapter. There's certainly no shortage of random old PS2 boards that must be available to you.

hasu:

--- Quote from: Maledicted on Mon, 06 January 2020, 12:00:47 ---I have a few ATMega32u4s sitting around waiting to be turned into Soarer's Converters, and probably the necessary resistors. I have both the standard IBM Model F XT, and AT. I also have some AT/XT switchable Uniteks and a DC-2014, although it already currently has a Soarer's converter I built inside of it. I know a guy that has an old RJ11 Wyse too (among other old weird things), if any of that may be helpful for testing.

--- End quote ---
Report on those keyobards would be definitely helpful. As for DC-2014 this firmware is compatible to Soarer's hardware you can just program it to test. This doesn't break your existent keymap settings of in eeprom, so you just need to program Soarer's firmware again to restore.

I really want to know my firmware with the IBM model F AT and XT(I don't own any unfortunately), they are very original and legitimate test samples for the keyboard  protocols.

I don't know much about RJ11 Wyse but I guess some of them uses Wyse specific protocol, not AT or XT.


--- Quote ---What exactly is it that you wish to accomplish? An open-source alternative to Soarer's Converter? I would think that the AT/PS2 keyboards should all work just about the same, right? My F AT works with modern systems with a 5 pin din to PS2 adapter. There's certainly no shortage of random old PS2 boards that must be available to you.

--- End quote ---

Yes, I like to make this useful open-source converter and I will have to improve it.
I believe that there are still unexpected behaviours of keyboards and bugs on my code that cuases problems. It is difficult to find them without testing with real keyboards.

hasu:
I tested with IBM 122-key Terminal 6110345 and it worked well.

The converter recognizes like below.

--- Quote ---Waiting for new device:.......
Listening:


TMK:5a759850/LUFA


USB configured.

Keyboard start.
err: 2A
rAA rBF rBF wF5 rFA wF2 rFA rBF rBF wF4 rFA ID: BFBF
kbd: Terminal
wF8 rFA r3B rF0 r3B r3B rF0 r3B r3B rF0 r3B

--- End quote ---

Navigation

[0] Message Index

[#] Next page

Go to full version