Replacing an 8048 CPU with a Teensy

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


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_DisplayWriter.png


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


And finally the kishsaver simply doesn't have many keys, so has fewer strobe lines:

8048_replace_kishsaver2.png


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 09 Oct 2012, 23:52, edited 2 times in total.
Soarer
User avatar

Unread post07 Oct 2012, 03:58

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club 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...

kishsaver_teensy_pins.jpg

kishsaver_teensy_wires.jpg


edit: updated this pic now that I've added a fourth wire to connect to the real Sense Out...

kishsaver_teensy2.jpg


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 09 Oct 2012, 23:48, edited 1 time in total.
Soarer
User avatar

Unread post07 Oct 2012, 04:07

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club 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:

logic-sniff-at-f.png


Scanning the keys on a single column (or row, if you prefer), like this:

logic-sniff-at-f-2.png

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


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     .
Soarer
User avatar

Unread post07 Oct 2012, 06:02

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club member: -
 
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...)
bhtooefr
User avatar

Unread post07 Oct 2012, 11:40

User avatar
X
bhtooefr
 
Posts: 1207
Joined: 09 May 2011, 19:46
Location: Newark, OH, USA
Main keyboard: Matias Tactile Pro 4
Main mouse: ScrollPoint Optical 800dpi
Favorite switch: Matias Click
Club member: 0056
 
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.
Soarer
User avatar

Unread post07 Oct 2012, 13:04

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club 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):

capsense_4channel.png


The 8-channel version (AT schematic):

capsense_8channel.png
Soarer
User avatar

Unread post07 Oct 2012, 13:24

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club member: -
 
Where did you get a Kishsaver?
Icarium
User avatar

Unread post07 Oct 2012, 19:50

User avatar
X
Icarium
 
Posts: 1637
Joined: 11 Jan 2012, 16:22
Location: Germany
Main keyboard: These fields just
Main mouse: opened my eyes
Favorite switch: I need to bring stuff to work
 
Icarium wrote:Where did you get a Kishsaver?

Via another member. The source has dried up.
Soarer
User avatar

Unread post08 Oct 2012, 11:31

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club member: -
 
Interesting! Look forward to seeing what you manage to come up with!
REVENGE

Unread post09 Oct 2012, 07:58

X
REVENGE
 
Posts: 217
Joined: 04 Apr 2012, 20:07
Location:
Club 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).
Soarer
User avatar

Unread post10 Oct 2012, 00:14

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club 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?
dorkvader
User avatar

Unread post12 Oct 2012, 00:09

User avatar
X
dorkvader
 
Posts: 316
Joined: 30 Jun 2012, 06:35
Main keyboard: Unicomp
Main mouse: CST 1550
Favorite switch: Buckling Spring over Capacitave. (Model F)
Club member: -
 
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
webwit
User avatar
Wild Duck

Unread post12 Oct 2012, 01:26

User avatar
X
webwit
Wild Duck
 
Posts: 9860
Joined: 27 Jan 2011, 23:27
Location: The Netherlands
Main keyboard: HHKB Pro II
Favorite switch: IBM beam spring
Club member: 0000
 
 
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?
Soarer
User avatar

Unread post12 Oct 2012, 03:17

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club member: -
 
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.
wcass
User avatar

Unread post12 Oct 2012, 05:11

User avatar
X
wcass
 
Posts: 453
Joined: 27 Nov 2011, 21:18
Location: Fort Lauderdale, FL, USA
Main keyboard: ibm model m
Main mouse: kensington expert mouse
Favorite switch: buckeling spring
Club member: 0185
 
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?
Soarer
User avatar

Unread post12 Oct 2012, 20:22

User avatar
X
Soarer
 
Posts: 999
Joined: 03 Jul 2011, 01:03
Location: UK
Favorite switch: F
Club member: -
 

Who is online

Users browsing this forum: andrea-i, clee and 64 guests