The idea for this project was born when a recently bought , old Infinium oscilloscope booted up showing a dreaded message from the past : "Keyboard error . Press F1 to continue" . Of course the scope does not have an USB connector , and buying a PC/AT keyboard only to change one BIOS setting and poke the scope system from time to time , seemed to be a waste of space.  Some older USB keyboards were able to be used in PS/2 mode with a simple converter , but unfortunately none of my keyboards  have this feature. Using the Raspberry Pi as a converter may look like an overkill , but is much simpler than the alternative - programming the USB host HID  on the microcontroller.


The GPIO ports of the Raspberry Pi use a 3.3V logic , while the PC needs 5V TTL signals. Whats more , the Pi is known to be easily damaged with voltages higher than 3.3V.  The logic level shifter uses NPN transistors in  common-base configuration to turn the low voltage signals into 5V TTL signals while the GPIO input voltage is clamped with diodes.


The software reads keyboard events form system /dev/input/event0 device. The events contain XT compatible scancodes , which are translated  into AT scancodes and then bit-banged  onto GPIO pins.  Since the timing of the signals is critical , the timing function from the WiringPi library is used instead of the system usleep or nanosleep . The emulator software also listens to the keyboard interface in order to capture the commands send from the computer to the keyboard and acknowledge them . Without this function the computer won't recognize the emulated keyboard.


1) Install wiringPi library :

         sudo apt-get install wiringpi

2) Compile and install software :

        gcc pskbd.c -lwiringPi -o pskbd

        sudo cp ./pskbd /usr/local/bin

3) Add following line to the /etc/rc.local file before the "exit 0" line  :

        /usr/local/bin/pskbd & > /dev/null