Author Topic: Reviving an IBM Thinkpad Model M6-1: Part 1 success! Now for the trackpoint...  (Read 5386 times)

0 Members and 1 Guest are viewing this topic.

Offline CarVac

  • Thread Starter
  • Posts: 22
So, I'm new here, and new to mechanical keyboards. Just as an aside, I just ordered a KeyCool 108 white with PBT caps and brown Cherry MX switches after reading various opinions and stuff on the forum. So that's all well and good, but then I remembered about an ancient laptop my dad was about to get rid of, this bad boy from 1995: http://www.thinkwiki.org/wiki/Category:755CV.

Knowing that it is an IBM and hoping it might have a good keyboard I tried it out and I really like it. It has an IBM M6-1, which has membrane switches and an inverted rubber dome mechanism. The force peaks really early, and then once you are past the peak the force drops until the bottom where it activates. It's really quite excellent as far as I can tell. It's very different from the last mechanical keyboard I typed on (a friend's original Das Keyboard with variable key weighting), but it feels good and that's what matters.



And so this brings me to my project: Turn this into a modern combined USB keyboard/pointing device. I took it apart, and reverse engineered the switch matrix (which unfortunately has no diodes; no N-key rollover), took a look at the Trackpoint connection, and put it back together. And had fun typing on it for 15 more minutes.

I saw that there have been some USB devices using Teensy microcontrollers, so that's what I plan on using. It has an 11x18 matrix, and it needs 4 sample points for the Trackpoint so I think I need a Teensy++ 2.0.

For people with experience programming microcontrollers (I only have experience programming desktop apps), do you think that the Teensy 2.0 has enough power to handle the control logic for both the keyboard and Trackpoint at the same time?

How would you program the blocking (a necessary evil, unfortunately)?
« Last Edit: Mon, 04 November 2013, 21:29:23 by CarVac »

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #1 on: Thu, 05 September 2013, 10:58:31 »
Currently, I'm investigating the electrical properties of the Trackpoint.

The active part seems to be a thin square beam, where each side has two little solder contacts, like this:


   ..
  :  :
   ..


From what I'm inferring, each side's two contacts connect to a 5k ohm strain gauge. I suspect that simply by setting up a voltage divider across opposite sides and measuring the voltage with enough precision I can use that for a mouse; that will automatically normalize them to each other.

I need a lot of sensitivity, though: pushing fairly hard on the nub doesn't budge the needle on this old analog multimeter one bit, and I don't think 10 bit precision would be enough. Perhaps I'll need some opamps...

Offline Thimplum

  • * Esteemed Elder
  • Posts: 1101
  • Master of all Ponies
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #2 on: Thu, 05 September 2013, 12:26:08 »
MW's favorite laptop :)
TP4 FOR ADMIN 2013

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #3 on: Thu, 05 September 2013, 16:29:52 »
From what I can tell, the easiest option would be to use an Arduino Due which can be made to trivially act simultaneously as keyboard and mouse, and which has easily enough pins to do what I want.

However, I saw here (http://geekhack.org/index.php?topic=42302.msg985393#msg985393) someone recommending to someone else not to use an Arduino.

Quote
Avoid the Arduino micro-controllers, the bootloader is incompatible with a lot of the firmware's people are using.

What is the reason for this? If it's because existing code doesn't work with Arduino, then that's no obstacle for me; I don't mind (and in fact want to) do my own coding.

Any input?

Offline wcass

  • Posts: 506
  • Location: Fort Lauderdale, FL, USA
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #4 on: Thu, 05 September 2013, 20:22:27 »
hasu has done most of the programming for you.

do a search on TMK_keyboard.
http://geekhack.org/index.php?topic=41989.0
« Last Edit: Thu, 05 September 2013, 20:24:39 by wcass »

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #5 on: Thu, 05 September 2013, 21:01:03 »
So basically, the reason is that it would take unnecessary work to adapt existing code to Arduino?


I want to code it myself for the learning experience, so I guess that point isn't valid, and Arduino seems easier to set up the compilation environment for. Am I mistaken here?

Thanks for the link, though. The inductive [in the way it assumes the previous state was valid] anti-ghosting code is clever; I hadn't thought of that method.

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #6 on: Wed, 23 October 2013, 15:52:09 »
It's been a while, but here we are:


IMG_5652-output by CarVac, on Flickr

Evidently, steady hands are able to obviate the need for flux or solder wick or any of that fancy high-teck mumbo-jumbo.

AKA, I used a regular old soldering iron and rosin-core flux to do this, including the surface-mount connectors.

It works, though, and I tested some examples of the keyboard matrix to make sure. (that works too)

Next is to figure out the Teensy, figure out the TrackPoint, and figure how to get them all working together.

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #7 on: Fri, 25 October 2013, 11:00:46 »
I've now wired the digital portions of the adapter up to the Teensy (via a birdsnest of wires on the breadboard), and I'm programming the matrix into Hasu's TMK firmware.

Because it doesn't have diodes, whoever designed the matrix made it huge: 11x18. Fortunately, since so much of it is empty, (198 spaces, 87 keys), I could do a lot of copy-pasting.


Now I have a question, though perhaps it's better asked on Hasu's firmware thread.

The mouse buttons are in the keyboard matrix (though actually they each have their own row and share an exclusive column).

If in keymap.c I just use 'BTN1' and 'BTN3', does that get me fulltime mouse button functionality, so long as I have mousekey enabled? And then I can modify mousekey.c later on to deal with whatever analog data the TrackPoint output ends up being?


Thanks for any input,
CarVac

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #8 on: Sun, 27 October 2013, 16:35:35 »
I got it partially working, but there are some mysteries. (not enough to stop me from writing this post on it, though).

There are some keys that don't work, like the right mouse button, the alt's, and pgup/pgdn. I attribute this to errors in my matrix.

However, the more baffling one is that backspace and backslash are switched. I checked several times, and I cannot tell why that is.

Code: [Select]
#define KEYMAP( \
    KAA,                                         KFM, KCM, KGQ, KDP, KDQ, KDR, \
    KDC, KDB, KBB, KAB, KAK, KAG, KBH, KDH, KDK, KFK, KFL, KFP, KDL, KFQ, KFR, \
    KDA, KFA, KFC, KFB, KFE, KDE, KDF, KFF, KFG, KFH, KFI, KDI, KDG, KBK, \
    KBA, KCA, KCC, KCB, KCE, KBE, KBF, KCF, KCG, KCH, KCI, KBI, KBG, KEK, \
    KBC, KEA, KEC, KEB, KEE, KAE, KAF, KEF, KEG, KEH, KEI, KAI, KGK, \
    KBJ, KGA, KGC, KGB, KGE, KHE, KHF, KGF, KGG, KGH, KHI, KGJ, \
    KKN, KDD, KAM,           KHK,           KHM, KGD,           KAQ, \
                        KIO, KJO,                          KHQ, KHL, KHP \
) { \
/*        0         1         2         3         4         5         6         7         8         9         10        11        12        13        14        15        16        17 */ \
/* 0 */ { KC_##KAA, KC_##KAB, KC_NO,    KC_NO,    KC_##KAE, KC_##KAF, KC_##KAG, KC_NO,    KC_##KAI, KC_NO,    KC_##KAK, KC_NO,    KC_##KAM, KC_NO,    KC_NO,    KC_NO,    KC_##KAQ, KC_NO }, \
/* 1 */ { KC_##KBA, KC_##KBB, KC_##KBC, KC_NO,    KC_##KBE, KC_##KBF, KC_##KBG, KC_##KBH, KC_##KBI, KC_##KBJ, KC_##KBK, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \
/* 2 */ { KC_##KCA, KC_##KCB, KC_##KCC, KC_NO,    KC_##KCE, KC_##KCF, KC_##KCG, KC_##KCH, KC_##KCI, KC_NO,    KC_NO,    KC_NO,    KC_##KCM, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \
/* 3 */ { KC_##KDA, KC_##KDB, KC_##KDC, KC_##KDD, KC_##KDE, KC_##KDF, KC_##KDG, KC_##KDH, KC_##KDI, KC_NO,    KC_##KDK, KC_##KDL, KC_NO,    KC_NO,    KC_NO,    KC_##KDP, KC_##KDQ, KC_##KDR }, \
/* 4 */ { KC_##KEA, KC_##KEB, KC_##KEC, KC_NO,    KC_##KEE, KC_##KEF, KC_##KEG, KC_##KEH, KC_##KEI, KC_NO,    KC_##KEK, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO }, \
/* 5 */ { KC_##KFA, KC_##KFB, KC_##KFC, KC_NO,    KC_##KFE, KC_##KFF, KC_##KFG, KC_##KFH, KC_##KFI, KC_NO,    KC_##KFK, KC_##KFL, KC_##KFM, KC_NO,    KC_NO,    KC_##KFP, KC_##KFQ, KC_##KFR }, \
/* 6 */ { KC_##KGA, KC_##KGB, KC_##KGC, KC_##KGD, KC_##KGE, KC_##KGF, KC_##KGG, KC_##KGH, KC_NO,    KC_##KGJ, KC_##KGK, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##KGQ, KC_NO }, \
/* 7 */ { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##KHE, KC_##KHF, KC_NO,    KC_NO,    KC_##KHI, KC_NO,    KC_##KHK, KC_##KHL, KC_##KHM, KC_NO,    KC_NO,    KC_##KHP, KC_##KHQ, KC_NO }, \
/* 8 */ { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##KIO, KC_NO,    KC_NO,    KC_NO }, \
/* 9 */ { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##KJO, KC_NO,    KC_NO,    KC_NO }, \
/* 10*/ { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##KKN, KC_NO,    KC_NO,    KC_NO,    KC_NO } \
}

#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))

static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* Layer 0: Default Layer
     * ,---.                               ,-----------------------.
     * |GUI|                               |Psc|Fn1|Pau|Ins|Hom|PUp|
     * |-----------------------------------------------------------|
     * |F1 |F2 |F3 |F4 |F5 |F6 |F7 |F8 |F9 |F10|F11|F12|Del|End|PDn|
     * |-----------------------------------------------------------|
     * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = |Backsp |
     * |-----------------------------------------------------------|
     * |Tab  | Q | W | E | R | T | Y | U | I | O | P | [ | ] |  \  |
     * |-----------------------------------------------------------|
     * |Escape | A | S | D | F | G | H | J | K | L | ; | ' |Return |
     * |-----------------------------------------------------------|
     * |Shift    | Z | X | C | V | B | N | M | , | . | / |Shift    |
     * |-----------------------------------------------------------'
     * |Fn0|Ctrl |Alt  |Space               |Alt  |Ctrl |    |^ |
     * `------------------------------------------------' ,--------.
     *                     | MB1  | MB2  |                |< |v |> |
     *                     `-====---====-'                `--------'
     */
    KEYMAP(LGUI,                                        PSCR,FN1, PAUS,INS, HOME,PGUP, \
           F1,  F2,  F3,  F4,  F5,  F6,  F7,  F8,  F9,  F10, F11, F12, DEL, END, PGDN, \
           GRV, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL, BSPC, \
           TAB, Q,   W,   E,   R,   T,   Y,   U,   I,   O,   P,   LBRC,RBRC,BSLS, \
           ESC, A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,ENT, \
           LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT, \
           FN0, LCTL,LALT,          SPC,           RALT,RCTL,          UP,\
                               BTN1,BTN2,                         LEFT,DOWN,RGHT),

It's relatively easy to find where they should be in the code for the matrix (backspace is BK and backslash is EK), (and I did look at the physical circuit itself to confirm), so I can't help to think that there's some software library issue somewhere... Nothing else sharing those rows or columns are mixed up, either.

Offline hasu

  • Posts: 3475
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #9 on: Mon, 28 October 2013, 19:17:35 »
Interesting project!
And interfacing analog signal of Trackpoint is so excited and challenging.

In Japan keyboard of ThinkPad 600 is known as a master piece among many of Thinkpad series. That era launched out good quality ThinkPad keyboards, yours is also likely one of them.

Can you open your code repositry on Github?  Codes will be also so helpful for us to see your problem. Code snipet is not enough sometime.

At least I'd see your matrix.c in this case. You can use a service like gist or pastebin to share a few files.

Offline hasu

  • Posts: 3475
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #10 on: Mon, 28 October 2013, 19:32:46 »
The mouse buttons are in the keyboard matrix (though actually they each have their own row and share an exclusive column).

If in keymap.c I just use 'BTN1' and 'BTN3', does that get me fulltime mouse button functionality, so long as I have mousekey enabled? And then I can modify mousekey.c later on to deal with whatever analog data the TrackPoint output ends up being?

BTN1 and BTN3 are resistered via HID mouse report you need to define MOUSE_ENABLE macro to enable it. This macro is define indirectly in common.mk when you use mousekey or ps2 mouse support(MOUSEKEY_ENABLE or PS2_MOUSE_ENABLE).
But I think you don't need both of them in your keyboard so you need to define MOUSE_ENABLE yourself with adding line like below in your Makefile.

    OPT_DEFS += -DMOUSE_ENABLE
« Last Edit: Mon, 28 October 2013, 19:36:41 by hasu »

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #11 on: Mon, 28 October 2013, 21:42:24 »
Interesting project!
And interfacing analog signal of Trackpoint is so excited and challenging.

In Japan keyboard of ThinkPad 600 is known as a master piece among many of Thinkpad series. That era launched out good quality ThinkPad keyboards, yours is also likely one of them.

Can you open your code repositry on Github?  Codes will be also so helpful for us to see your problem. Code snipet is not enough sometime.

At least I'd see your matrix.c in this case. You can use a service like gist or pastebin to share a few files.


The 755 presumably has at least a similar keyboard to the 600 series. This keyboard is plainly and simply a joy to use: far better than my MX Brown keyboard (which is otherwise excellent), and of course infinitely better than normal rubber-domes with their wiggly, jam-prone mechanisms. I do like the firmer mechanism; perhaps I would have been better off with Blues on the full-sized keyboard.

I'll put a repo up on GitHub probably tomorrow. I had to use quite a few of your and others' (the 1-button one was really useful) code examples to piece together the necessary functions to get the keyboard functioning at all, so I certainly could be still missing some necessary functions. I still can't get the bootmagic to work, even though both shift keys work, so I'll need some help with that.

The mouse buttons are in the keyboard matrix (though actually they each have their own row and share an exclusive column).

If in keymap.c I just use 'BTN1' and 'BTN3', does that get me fulltime mouse button functionality, so long as I have mousekey enabled? And then I can modify mousekey.c later on to deal with whatever analog data the TrackPoint output ends up being?

BTN1 and BTN3 are resistered via HID mouse report you need to define MOUSE_ENABLE macro to enable it. This macro is define indirectly in common.mk when you use mousekey or ps2 mouse support(MOUSEKEY_ENABLE or PS2_MOUSE_ENABLE).
But I think you don't need both of them in your keyboard so you need to define MOUSE_ENABLE yourself with adding line like below in your Makefile.

    OPT_DEFS += -DMOUSE_ENABLE

I figured out the mouse buttons; they're among the few non-alphanumeric buttons that aren't misplaced in some manner or another.

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #12 on: Sun, 03 November 2013, 13:01:39 »
I figured out one of my problems: all of the dip-switch-emulation commands were all on, switching backspace and backslash, switching escape and grave, switching alt and gui, and then disabling gui. I just commented out the code that lets those happen, since I plan on having any layout variations be coded into the layers.

Now all that's left typing-wise is determining exactly why certain rows don't work. I've determined that anything past column index 15 simply doesn't work, and if you hit the key for something in column 15, it applies itself and all of the keys to the right of that in sequence.

For example, the right arrow is [7][15] and the left arrow is [7][16] so the left key doesn't work, and the right key hits 'rightleft' in a single frame.
Likewise, F12 [5][15] key transmits itself, end [5][16], and pgdn[5][17] in quick succession, and neither of those two keys work.

I saw that another keyboard has a matrix which has 8 columns and 18 rows, so I tried to swap rows and columns to put the 18 dimension of my matrix in rows, but it's mostly garbled up for some reason.

The other mystery is the fn key in the bottom left...it simply doesn't do anything even if I assign it to another key. While it's row index 10, the mouse buttons which are 8 and 9 work fine, so an 8-row limit wouldn't explain it.

Offline hasu

  • Posts: 3475
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #13 on: Sun, 03 November 2013, 19:03:47 »
I'm probably sure your problem is about integer size of matrix column. your column size is more than 16 so you need uint32_t integer to retain column status.

make sure your code uses 32bit integer and avoid unintentional use of automatic conversion of the language specification. to see assembly code output may be helpful to debug.

note that lager size matrix code is not tested well in specific when uint32_t is used.

Offline CarVac

  • Thread Starter
  • Posts: 22
Re: Reviving an IBM Thinkpad Model M6-1
« Reply #14 on: Mon, 04 November 2013, 11:06:43 »
Turns out I did the matrix transpose incorrectly before.

This time I did it correctly and it works fine. Now I have every key working.

I also have layers working, though it's kinda hackish:
Layer 0: normal
Layer 1: normal (it was always defaulting to layer 1 on bootup no matter what)
Layer 2: dvorak
Layer 3: qwerty on software-mapped dvorak
Layer 4: num lock
Layer 5: fn layer

I don't know if there's a more elegant way to do this, but I'm okay with it as is.

The only issue I have on the keyboard side right now is that the KC_MENU keycode doesn't do the same thing as the menu key on my other keyboards: it seems to map as the Sun Props key (0x1005ff70) instead of menu (0xff67) according to xev. Anyone know why? I'd really like to have it back because I have it set to toggle maximization state of windows, something I do fairly often.