GKOS Keyboard PS/2 Interface

The PIC 16F876 microcontroller makes an interface between a GKOS keyboard (QWERTY capabilities with 6 keys!) or a GKOS IR remote control, and the keyboard/mouse connector of the PC.



PIC Microcontroller HEX files
 keyboard functions only
  (Win 95/98/2000/XP)
*** UPDATED 11 Oct 2004,
 an IR reception reliability bug fixed
 gkos20.hex  v.2.0 for replacing a  FIN/SWE PC keyboard, tested on Win98, Win2000 and Windows XP, asm
 keyboard + mouse functions
  (Win 95/98/2000 supported)
  (see below for XP)
 gkpc12.hex  v.1.2 for replacing  a FIN/SWE PC keyboard and mouse, tested on Win98 and Win2000, but NOT compatible with Windows XP yet, asm
 keyboard + mouse functions
  (Win 95/98/2000 supported)
  (see below for XP)
 gkpc12us.hex  v.1.2 for replacing a  US PC keyboard and mouse, tested on Win98 and Win2000, but NOT compatible with Windows XP yet, asm

Test versions of enhanced key polling (keyboard + mouse functions):
- NOTE: these first versions have only been tested using the IR receiver and GKOS IR remote and do not necessarily function with the directly connected GKOS keyboard yet.
gkp17.hex (FIN/SWE) and gkp17us.hex (US kbd version) - 
26 Sept 2003 (overlap allowed)

The recommended enhanced key polling version (for Win 95/98/2000 but not XP yet):
These versions have been adjusted for both IR link and the directly connected GKOS keyboard:
gkp23.hex (FIN/SWE asm) and gkp23us.hex (US kbd version) - 
2 Apr 2004, chordons and chord overlap allowed, LED signals available, US/UK version has word shortcuts (see national character sets at gkos.com), switch between FIN/SWE and US/UK versions by ALT 123-ABC (gkp23 and gkp23us have different defaults only).

**** Windows XP - For full functionality on XP it is recommended that you use the GKOS Serial COM Port Interface. - Here is a test version of the enhanced key polling version of the PS/2 interface that should work on XP, at least the keyboard functions: gkxp24us.hex, asm. It includes a 'quick fix'. A more complete version is planned (Thanks Keithh! Still, the PS/2 handshaking seems to stop after 'Read ID' when kbd has sent the ID 0xAB 0x83.). For now, you have to start the computer with the QWERTY plugged in and afterwards switch over to GKOS. Infrared seems to function too. If you do not connect the mouse pins of the PIC, be sure to have pull up resistors on the pins. Note that this version has the new set of national characters that is planned for all later US layouts with chordon shortcuts, optimized according to word frequencies.

**** For Win 95/98/2000 gkp24us.hex (asm) is now the latest PS/2 interface PIC code (new optimized national character layout).

- Typing chordons (chord chains): If two or more consecutive chords have common keys they need not be released between the characters (for letters and symbols only, not for functions etc.). This works via the infrared link also with no changes at the transmitting side (the GKOS remote control)!

Implementation examples:

The IR receiver, 9-pin connector and the PS/2 interface box

The IR keyboard and the PS/2 interface (no 9-pin connector used, just the IR receiver)

Some notes:


Tested versions of gkosXX.hex and gkpcXX.hex are now available. They operate well at least on laptops Compaq 4210T with Windows 98 operating system and Compaq Evo N600c with Windows 2000. Only gkos19.hex, the keyboard only version, seems to be working with Windows XP! Updates are planned.

Function keys (F1...F12) have not been implemented. All versions have infrared capability. Version gkp23 is the latest and has the most advanced method of polling the keys to allow for normal typing, typing with chord overerlap as well as using chordons technique.


Important: It is not safe to keep connecting/disconnecting the PS/2 connector plug while PC power is on. Having the connector poorly plugged may cause undesired currents or even damage the PC's mouse/keyboard interface card. The latest version of the schematic, however, limits the current by the new 470 ohm resistor in the 5 volt line from the PC to the microcontroller and this should be no problem any more.

Pull-up resistors for mouse lines: The mouse data and clock lines may need to have pull-up resistors because some laptops do not have them even if the lines are otherwise available at the PS/2 connector pins 2 and 6. For example, for the Compaq 4210T laptop, you need to have them. A compromise is to connect 10k resistors from Microcontroller pins 11 and 12 to +5V, so that the same hardware will operate in all cases (pull-ups/no pull-ups on the PC). Anyway, if you do not connect the PS/2 mouse lines at all, they need pull-ups to make the software run (except for version gkos19.hex with no mouse functions).

LEDs for CAPS, 123 and SYMB can be used at pins 4, 5 and 6 (only on versions gkp20.asm  / gkp20us.asm and later). They are active low, so connect the cathodes of the LEDs to the pins and the other ends, via resistors, to +5 volts coming from the PC. The values of the three resistors determine the LED current (470 ohm or so).

The circuit is small enough to fit inside a tiny box as above. The IR receiver can be built inside a D connector case (female connector). There is no need to have a separate power supply because the PC keyboard/mouse connector will provide 5 volts from the PC.

To get a proper PS/2 cable, purchase a PS/2 male/male extension cable and cut it in the middle (you will have two cables then!). A single connector that combines mouse and keyboard signals is suitable for laptops but if you want to connect the interface to two separate PS/2 connectors (mouse and keyboard), as on desktops, you need to make a Y-cable. It seems to be common practice that laptops have both mouse and keyboard pins available on their single PS/2 connector, but desktops use two separate connectors where pins 2 and 6 are not connected on either.

The small 4MHz ceramic resonator (the blue one in the figure, installed under the PIC) does not necessarily require the two 33 pF capacitors. - The clock frequency must be 4MHz to make the IR link functional (Do not use an RC oscillator instead!).

TSOP1736 is a common small compact IR receiver costing  a couple of euros/dollars. Its carrier frequency is 36 kHz and the pins top down are: GND, +5V, data out. It is possible to connect the IR receiver and the 47 uF capacitor directly to a female 9-pin D-type connector pins to have a small unit that is interchangeable with the GKOS keyboard cable connector. The 100 ohm resistor in the 5 volt line is essential for filtering out interference present in the PC power source, improving considerably IR reception.

The IR receiver will provide a reliable infrared connection (36kHz carrier) between this keyboard/mouse interface and the GKOS remote control with or without a mouse. So, if the IR link is used, also mouse functions can be managed. If you plan to use just the IR link (not the wired GKOS keyboard), leave out the 9-pin D-connector, and a very compact IR interface is possible (figure above).


The USART output on pin 17 can be used to monitor both the mouse and keyboard signals sent and recevied at the PS/2 connector. The asynchronous output at pin 17 uses 9600 bits/s, 8 data bits, no parity, one start bit and one stop bit. The voltage levels need to be converted to +/- 12V from 5V/0V before connecting to the PC serial port (e.g. by MAX232 IC). The .asm code will tell what signals are sent to the port. When power is turned on, "GKOS" plus a carriage return is sent, then binary values of parameters.

Page updated: 10 July 2004 (compatibity problems with Win XP); 11 Oct 2004 (gkos20 IR bug fixed);
1 June 2005 (reference to serial port interface added)