After struggling with various methods of level shifting to convert the TTL 5v logic of the keyboard to the 3.3v logic of the Teensy, I decided to take a step back and wonder exactly why I was struggling with level shifting. Did I really need to use a 3.3v device? Things were so much simpler when everything was 5v logic!
A quick investigation showed that there is an Arduino that is 5v logic and also supports HID – the Arduino Micro. After waiting a few days for my order to show up, I was away to the races with 5v logic. About an hour later, I had the keyboard interfaced to the Arduino Micro, and my logic probe showed that I could scan the matrix and detect key presses.
There’s 6 outputs to scan the keyboard matrix, and 2 inputs – one for Control, Shift, Break, and one for the rest of the keyboard.
Now that the hardware side is locked down, I now need to write a lookup table to convert the POKEY scancodes into HID key presses.
I took on the project of a keyboard adapter for this RetroChallenge because I’m a bit pressed for time, and I though that this was simple enough that I could whip it together from stuff in my junk box.
First, I need a microcontroller that has HID built-in, to simplify the process of emulating a PC keyboard over USB. Digging around in my collection, I found a few Teensy 3.0 Arduino clones that I got from a Kickstarter a few years ago. These offer HID, and a quick test sketch proved it.
Ahh, but this micro controller is 3.3v only. The Atari XEGS keyboard has a couple of 4051 ICs inside, and operates off of 5v. More digging, and I find an Adafruit 8-channel logic level converter.
I’ll post my reverse engineering findings soon, but I’ve determined that I need 6 output lines to scan the keyboard, and two input lines to return the results (1 for control, shift, and break; and the second for the rest of the keys). This 8-port device should be fine.
However, after wiring it up, I wasn’t getting anything. Hooking up a logic analyzer showed that the outputs were all over the place. After some head-scratching, I determined that the fancy auto-direction-detect of this level converter was getting confused by the voltage levels and pull-ups/pulldowns that were in the keyboard.
Back to the drawing board. I don’t need anything with auto direction detection – each of my signals is unidirectional. Some 74AHCT125 ICs should give me the level shifting I need, but I don’t have any here. So my once-easy project is now waiting for parts to arrive.