Memorex telex keyboard on the serial port.
A friend of mine bought a really old 122 key Memorex telex keyboard at
somewhat of a mysterious place, it was really dirty and probably used a
lot but it looked very cool.
He cleaned it very thoroughly up to the point where it looked almost
brand new, hooked it up to his computer and....... nothing. This
was somewhat disappointing.
He asked if I could take a look at it because people seem to think I know a lot about electronics, but he wasn't expecting much.
I had a hunch that the keyboard used the old XT keyboard protocol, which doesn't work on modern AT style computers.
So I hooked the keyboard up to a 5 volts power supply and pressed
numlock, this turned on the numlock light, which makes sense because
the XT keyboard protocol only goes one way, the pc has no way of
commonicating with the keyboard, so the keyboard has to turn on the
lights by itself.
Next I hooked up the data pin to the scope and lo and behold, it actually did something:
The protocol looked somewhat like 9600 bps rs232, but it has two start
bits and no stop bits, so I hooked it up to the rx pin of the serial
port and wrote a little program to show on screen what data the
keyboard was sending.
This worked somewhat but not to my satisfaction, the timing was
slightly off so I was unable to properly read the most significant bit,
which represents whether a key is pressed or released.
The solution was to use a 16F84A microcontroller to translate the data
to proper rs232, since the keyboard works with ttl levels I could hook
up the data and clock pins directly to the microcontroller's ports.
This looks surprisingly simple, and it is, the keyboard's data pin
connects directly to pin B1 which is programmed to be an input, the
clock pin connects to pin B0 with a pull-up resistor and pin B2
connects directly to the rs232 rx pin, no level shifter is used for
rs232 since most (probably all) rs232 ports can handle ttl levels (and
I didn't feel like soldering).
Also the keyboard is connected to 5 volts and ground, which I forgot to include in the schematic.
I soldered the parts on some veroboard:
Next I wrote some code for the microcontroller in JAL:
The microcontroller sits in an endless loop, first it makes pin B0 an
input to signal the keyboard that it can send data, it then waits for
pin B1 to become high, and when it does it waits about 2,5 bits, the
reason for this is so it reads the data in the middle of the bits.
It then reads the first databit, waits one bit, reads the second databit etc.
I tried using the clock pin as a clock source, but I saw very strange
behaviour when I did that, so I decided to use normal delays in the
This of course makes the controller incompatible with other XT protocol keyboards.
After the keyboard has sent an entire byte, the microcontroller pulls
the clock pin low to signal the keyboard it can't send any data.
The controller then sends the received byte out via rs232.
Now the loop starts from the beginning.
You can download the code here.
Now I needed a way to use the keyboard in linux, so I wrote a little
program that converts the keyboard scancodes into keycodes for linux
and sends them to an uinput node.
This worked perfectly.
I really like this keyboard, too bad I have to give it back.
You can download the sources here.
Just compile it with ./configure && make. If you have any
problems compiling make sure you have the kernel headers installed.
Install it with make install.
Run it with memorex_telex <serial_port> <uinput_node>
Example: memorex_telex /dev/ttyS0 /dev/input/uinput.
Make sure you have the uinput kernel module loaded, you can load it
with modprobe uinput or put it in /etc/modules to load it at boot.
If you have any questions you can mail me at email@example.com (remove the _ and n0sp4m parts).