Replacing an 8048 CPU with a Teensy

User avatar
Soarer

07 Oct 2012, 04:58

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:
8048_replace.png
8048_replace.png (56.45 KiB) Viewed 8303 times
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):
8048_replace_PCXT.png
8048_replace_PCXT.png (82.71 KiB) Viewed 8303 times
8048_replace_DisplayWriter.png
8048_replace_DisplayWriter.png (84.2 KiB) Viewed 8303 times
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:
8048_replace_AT.png
8048_replace_AT.png (78.69 KiB) Viewed 8303 times
And finally the kishsaver simply doesn't have many keys, so has fewer strobe lines:
8048_replace_kishsaver2.png
8048_replace_kishsaver2.png (81.44 KiB) Viewed 8126 times
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.

User avatar
Soarer

07 Oct 2012, 05:07

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...
kishsaver_teensy_pins.jpg
kishsaver_teensy_pins.jpg (218.85 KiB) Viewed 8299 times
kishsaver_teensy_wires.jpg
kishsaver_teensy_wires.jpg (263.67 KiB) Viewed 8299 times
edit: updated this pic now that I've added a fourth wire to connect to the real Sense Out...
kishsaver_teensy2.jpg
kishsaver_teensy2.jpg (258.07 KiB) Viewed 8121 times
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.

User avatar
Soarer

07 Oct 2012, 07:02

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:
logic-sniff-at-f.png
logic-sniff-at-f.png (6.17 KiB) Viewed 8285 times
Scanning the keys on a single column (or row, if you prefer), like this:
logic-sniff-at-f-2.png
logic-sniff-at-f-2.png (6.83 KiB) Viewed 8285 times
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:
logic-sniff-at-f-f1-down.png
logic-sniff-at-f-f1-down.png (4.69 KiB) Viewed 8285 times
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     .

User avatar
bhtooefr

07 Oct 2012, 12:40

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...)

User avatar
Soarer

07 Oct 2012, 14:04

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.

User avatar
Soarer

07 Oct 2012, 14:24

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):
capsense_4channel.png
capsense_4channel.png (5.53 KiB) Viewed 8256 times
The 8-channel version (AT schematic):
capsense_8channel.png
capsense_8channel.png (7.38 KiB) Viewed 8256 times

User avatar
Icarium

07 Oct 2012, 20:50

Where did you get a Kishsaver?

User avatar
Soarer

08 Oct 2012, 12:31

Icarium wrote:Where did you get a Kishsaver?
Via another member. The source has dried up.

REVENGE

09 Oct 2012, 08:58

Interesting! Look forward to seeing what you manage to come up with!

User avatar
Soarer

10 Oct 2012, 01:14

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).

User avatar
dorkvader

12 Oct 2012, 01:09

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?

User avatar
webwit
Wild Duck

12 Oct 2012, 02:26

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:
Image

User avatar
Soarer

12 Oct 2012, 04:17

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.

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?
It's the mysterious square silver capacitive sensing chip that's hard to replicate, if trying to completely replace 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.
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?

User avatar
wcass

12 Oct 2012, 06:11

Soarer wrote:
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?
It's the mysterious square silver capacitive sensing chip that's hard to replicate, if trying to completely replace the controller PCB.
would it help to have a few XT controllers? i would be happy to ship them to someone with the skills to use them.

User avatar
Soarer

12 Oct 2012, 21:22

wcass 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.
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 one :twisted: (Using direct 5V for a 'high' signal for example. That would only remove the need for external pull-up resistors though). Are they looking for a home?

Post Reply

Return to “Workshop”