Replacing an 8048 CPU with a Teensy
- Soarer
- Location: UK
- Favorite switch: F
- DT Pro Member: -
My goal for this project is to get a DisplayWriter keyboard (beam spring) and the kishsaver (a Model F) converted to USB and usable. They don't have protocols that are usefully convertible, because they don't send release codes (or rather, they only send them for one or two keys).
Fully replacing the controller is an option - dfj has done so with a 122-key F, and it works well. But I fancied taking a different route, preferring to drive the IBM capacitive sensing chip by replacing the CPU. This means desoldering the original CPU, which naturally carries some risk of damage, but I've been lucky so far!
Some of the information here could of course be useful for replacing the 8048 in other, non-IBM, keyboards. The 8048 pins that might be used to scan a switch matrix are marked in green on this pinout:
They are never all used just for reading the matrix. Some will be driving the external interface, and some may be driving LEDs. So a Teensy should have enough pins for any case, just! OTOH, something like a Teensy++ would make it easier to make a logical mapping between the 8048's three 8-bit ports, since the Teensy++ has four full ports (and/or might make physically mounting it in place easier, but more of that later).
Of the IBM controllers, there's a distinct similarity in pin use between the PC/XT and DisplayWriter (although of course there are big differences in pin use for the external interface):
The AT uses a multiplexer for driving the strobe lines, so it doesn't use many pins at all. This same arrangement is also used in at least some of the 122-key terminal controllers:
And finally the kishsaver simply doesn't have many keys, so has fewer strobe lines:
edit: updated kishsaver pinout, having discovered that there is a buffer between Sense Out Clamp and Sense Out (unlike the other boards).
Fully replacing the controller is an option - dfj has done so with a 122-key F, and it works well. But I fancied taking a different route, preferring to drive the IBM capacitive sensing chip by replacing the CPU. This means desoldering the original CPU, which naturally carries some risk of damage, but I've been lucky so far!
Some of the information here could of course be useful for replacing the 8048 in other, non-IBM, keyboards. The 8048 pins that might be used to scan a switch matrix are marked in green on this pinout:
They are never all used just for reading the matrix. Some will be driving the external interface, and some may be driving LEDs. So a Teensy should have enough pins for any case, just! OTOH, something like a Teensy++ would make it easier to make a logical mapping between the 8048's three 8-bit ports, since the Teensy++ has four full ports (and/or might make physically mounting it in place easier, but more of that later).
Of the IBM controllers, there's a distinct similarity in pin use between the PC/XT and DisplayWriter (although of course there are big differences in pin use for the external interface):
The AT uses a multiplexer for driving the strobe lines, so it doesn't use many pins at all. This same arrangement is also used in at least some of the 122-key terminal controllers:
And finally the kishsaver simply doesn't have many keys, so has fewer strobe lines:
edit: updated kishsaver pinout, having discovered that there is a buffer between Sense Out Clamp and Sense Out (unlike the other boards).
Last edited by Soarer on 10 Oct 2012, 00:52, edited 2 times in total.
- Soarer
- Location: UK
- Favorite switch: F
- DT Pro Member: -
I've started with the kishsaver. Its CPU has been removed and an IC socket soldered in its place. I've fitted the Teensy with some pins made from solid core wire, and some solid core wires for power, ground and the final strobe...
edit: updated this pic now that I've added a fourth wire to connect to the real Sense Out...
Of course, I'll trim the wires a bit more when I'm happy with it!
I picked that position for the Teensy because it covers most of the used 8048 pins, and specifically it lines up PD0 to PD2 with Sense D0 to D2 - those three want to be changed together, so they at least need to be on the same Teensy port. The rest of connections will be read/written individually, so it doesn't matter if they're on different ports.
edit: updated this pic now that I've added a fourth wire to connect to the real Sense Out...
Of course, I'll trim the wires a bit more when I'm happy with it!
I picked that position for the Teensy because it covers most of the used 8048 pins, and specifically it lines up PD0 to PD2 with Sense D0 to D2 - those three want to be changed together, so they at least need to be on the same Teensy port. The rest of connections will be read/written individually, so it doesn't matter if they're on different ports.
Last edited by Soarer on 10 Oct 2012, 00:48, edited 1 time in total.
- Soarer
- Location: UK
- Favorite switch: F
- DT Pro Member: -
To sniff the logic of the capacitive sensing chip, the AT is good because of the multiplexer - less probes to attach!
A full scan of the entire matrix looks like this:
Scanning the keys on a single column (or row, if you prefer), like this:
Note that the Sense D0 to D2 lines (DB0 to DB2) serve a dual purpose - first, they select which key to read, and second, they set a sensitivity level (for which there is a table in the ROM).
When a key is pressed, the sense chip output (Out) goes low, when gated by the G line going high. The fifth key read in this scan is pressed:
This subroutine from the AT's firmware reads a column of 8 keys:
A full scan of the entire matrix looks like this:
Scanning the keys on a single column (or row, if you prefer), like this:
Note that the Sense D0 to D2 lines (DB0 to DB2) serve a dual purpose - first, they select which key to read, and second, they set a sensitivity level (for which there is a table in the ROM).
When a key is pressed, the sense chip output (Out) goes low, when gated by the G line going high. The fifth key read in this scan is pressed:
This subroutine from the AT's firmware reads a column of 8 keys:
Code: Select all
X0251: clr c ; 0251 - 97 .
mov r0,#8 ; 0252 - b8 08 8.
mov r6,#0 ; 0254 - be 00 >.
mov a,r2 ; 0256 - fa z
dec a ; 0257 - 07 .
anl a,#0f8h ; 0258 - 53 f8 Sx
mov r7,a ; 025a - af /
X025b: dec r2 ; 025b - ca J
anl p1,#0fch ; 025c - 99 fc .|
mov a,r2 ; 025e - fa z
outl bus,a ; 025f - 02 .
orl p1,#2 ; 0260 - 89 02 ..
rrc a ; 0262 - 67 g
movp3 a,@a ; 0263 - e3 c
jc X0267 ; 0264 - f6 67 vg
swap a ; 0266 - 47 G
X0267: anl a,#7 ; 0267 - 53 07 S.
orl a,r7 ; 0269 - 4f O
outl bus,a ; 026a - 02 .
clr c ; 026b - 97 .
nop ; 026c - 00 .
nop ; 026d - 00 .
nop ; 026e - 00 .
orl p1,#1 ; 026f - 89 01 ..
orl bus,#80h ; 0271 - 88 80 ..
jt1 X0276 ; 0273 - 56 76 Vv
inc r6 ; 0275 - 1e .
X0276: mov a,r6 ; 0276 - fe ~
rr a ; 0277 - 77 w
mov r6,a ; 0278 - ae .
djnz r0,X025b ; 0279 - e8 5b h[
ret ; 027b - 83 .
- bhtooefr
- Location: Newark, OH, USA
- Main keyboard: TEX Shinobi
- Main mouse: TrackPoint IV
- Favorite switch: IBM Selectric (not a switch, I know)
- DT Pro Member: 0056
- Contact:
Also, this method (but with different pinouts) will be useful for getting other beam springs going. (I'm looking over kbdbabel's 5251 schematic right now, at the AMI chip that I believe is the microcontroller. Unfortunately, the pinout doesn't match any kind of AMI microcontroller that I can find...)
- Soarer
- Location: UK
- Favorite switch: F
- DT Pro Member: -
True... the CPU details aren't really as relevant as the peripherals around it, although it helps to cheat by looking at the code!
That 5251 uses the 4-channel version of the capsense chip - I would guess it's mostly driven in a similar fashion, but the 8-channel version doesn't have the U1 connection, so no idea what that's doing.
This thread could do with a more appropriate title. At first I was thinking of wiring a Teensy++ up to a DIL plug, so I could use it to replace the 8048 in any controller, but then I decided to just focus on one board first and make the simpler drop-in.
That 5251 uses the 4-channel version of the capsense chip - I would guess it's mostly driven in a similar fashion, but the 8-channel version doesn't have the U1 connection, so no idea what that's doing.
This thread could do with a more appropriate title. At first I was thinking of wiring a Teensy++ up to a DIL plug, so I could use it to replace the 8048 in any controller, but then I decided to just focus on one board first and make the simpler drop-in.
- Soarer
- Location: UK
- Favorite switch: F
- DT Pro Member: -
For local reference, here are symbols for the capacitive sensing chips that akurz has used in the kbdbabel schematics.
The 4-channel version (5251 schematic):
The 8-channel version (AT schematic):
The 4-channel version (5251 schematic):
The 8-channel version (AT schematic):
- Soarer
- Location: UK
- Favorite switch: F
- DT Pro Member: -
Well I managed to get the matrix scan code basically working last night, but it will take a lot of trial and error to get it fully reliable!
I've updated a couple of the pics in the earlier posts because the kishsaver has a buffer connected to the pin it uses to clamp the Sense Out line low. None of the other controllers have a buffer there! Sense Out is the output from the capacitive sensing chip, and is normally connected to two pins on the CPU - one for reading it, and one for clamping it to ground. From the timing, this clamping could be an acknowledge back to the sensing chip - it appears to clear the previous output back to the unpressed state (high).
I've updated a couple of the pics in the earlier posts because the kishsaver has a buffer connected to the pin it uses to clamp the Sense Out line low. None of the other controllers have a buffer there! Sense Out is the output from the capacitive sensing chip, and is normally connected to two pins on the CPU - one for reading it, and one for clamping it to ground. From the timing, this clamping could be an acknowledge back to the sensing chip - it appears to clear the previous output back to the unpressed state (high).
- dorkvader
- Main keyboard: Unicomp
- Main mouse: CST 1550
- Favorite switch: Buckling Spring over Capacitave. (Model F)
- DT Pro Member: -
This is some very good and in-depth work! Would it be possible to adapt this project with some other components (like, reverse engineering the PCB) to make a teensy directly drive an IBM Model F, like Wcass's XTant project?
- webwit
- Wild Duck
- Location: The Netherlands
- Main keyboard: Model F62
- Favorite switch: IBM beam spring
- DT Pro Member: 0000
- Contact:
Cool project. Making a beam spring keyboard work on a modern computer is a prize to be won! Also, I need you to convert my beam spring mini, so I finally have the Ultimate Keyboard.
Spoiler:
- Soarer
- Location: UK
- Favorite switch: F
- DT Pro Member: -
This thing is pissing me off today! I've made all the delays match the original ROM's timings, and it still doesn't read reliably when more than a few keys on two sense lines are pressed at the same time. OTOH, it works perfectly up to having all 16 keys on two strobe lines pressed. Also, I'm having to set the lowest sensitivity (7) when the original ROM happily uses 2 (this one self calibrates at startup), otherwise I get random keypresses registered. I must be missing something.
It's the mysterious square silver capacitive sensing chip that's hard to replicate, if trying to completely replace the controller PCB.dorkvader wrote:This is some very good and in-depth work! Would it be possible to adapt this project with some other components (like, reverse engineering the PCB) to make a teensy directly drive an IBM Model F, like Wcass's XTant project?
So... do we know which sense chip that has? I haven't got anything with the 4-channel version, yet. Got any pics of the controller PCB?webwit wrote:Cool project. Making a beam spring keyboard work on a modern computer is a prize to be won! Also, I need you to convert my beam spring mini, so I finally have the Ultimate Keyboard.
- wcass
- Location: Columbus, OH, USA
- Main keyboard: ibm model m
- Main mouse: kensington expert mouse
- Favorite switch: buckeling spring
- DT Pro Member: 0185
would it help to have a few XT controllers? i would be happy to ship them to someone with the skills to use them.Soarer wrote:It's the mysterious square silver capacitive sensing chip that's hard to replicate, if trying to completely replace the controller PCB.dorkvader wrote:This is some very good and in-depth work! Would it be possible to adapt this project with some other components (like, reverse engineering the PCB) to make a teensy directly drive an IBM Model F, like Wcass's XTant project?
- Soarer
- Location: UK
- Favorite switch: F
- DT Pro Member: -
Probably not much, if I'm honest, but having a spare or two would allow me to try a few things that I'm too scared to do at the moment in case I kill onewcass wrote: would it help to have a few XT controllers? i would be happy to ship them to someone with the skills to use them.
