geekhack

geekhack Projects => Making Stuff Together! => Topic started by: hasu on Wed, 12 February 2014, 18:38:39

Title: IBM 4704 Keyboard Converter
Post by: hasu on Wed, 12 February 2014, 18:38:39
Acknowledgement
Without generous big help from 002 this would never happened. He helped me to obtain this keyboard, gave me one as a gift or donation more precisely. Thank you 002!

And without Soarer's help I would have given up this work at early stage of reverse eng.

Disclaimer
This converter is mainly for 'proof of concept' purpose. It may or not work for your everyday use. (I'm very confident of this converter now. It works well enough. :D)
Won't offer step by step tutorial and support. But feel free to tinker it yourself. Your improvements and new discoveries are welcomed, let me know. Enjoy!

Post your question here, DON'T PM/EMAIL ME unless you really need.

(http://i.imgur.com/o852pMMl.jpg)

Converter
Source code:
https://github.com/tmk/tmk_keyboard/tree/master/converter/ibm4704_usb

PCB Design files:
TMK keyboard converter:
https://github.com/tmk/keyboard_converter
D-sub 9pin Adapter:
https://github.com/tmk/keyboard_converter_adapter_ibm4704

My album:
http://imgur.com/a/LaABs



Supported Keyboard
These keyboards are expected to be supported.

IBM capacitive switch models:
- 6019273 Model 100 50-key (grid layout)      http://kishy.ca/?p=894
- 6019284 Model 200 62-key Alpha(60% layout)  http://kishy.ca/?p=894 https://geekhack.org/index.php?topic=63267.0
- 6019303 Model 300 77-key Expanded Alpha     http://kbtalking.cool3c.com/article/23272
- 6020218 Model 400 107-key Full key          http://kishy.ca/?p=894 https://www.flickr.com/photos/triplehaata/sets/72157647943972746/comments/
 
Alps switch(vintage Green) models:
- 5954339 Japanese 102-key    http://deskthority.net/post87127.html#p87127
- 6112883 Japanese 102-key    http://geekhack.org/index.php?topic=52888.msg1194489#msg1194489
- 6112884 Japanese 102-key    http://geekhack.org/index.php?topic=50437.msg1193047#msg1193047                                       
- 6341739 Chinese 102-key     http://geekhack.org/index.php?topic=52888.msg1176566#msg1176566
- 6113442 Chinese 102-key    https://geekhack.org/index.php?topic=62628.0 https://imgur.com/gallery/ljxUiev (identical to above one)


IBM 4704 Keyboard Protocol
ibm4704.txt:
See the latest version at:
https://github.com/tmk/tmk_keyboard/blob/master/converter/ibm4704_usb/ibm4704.txt


NOTE
Audible Clicker
- With Alps models the converter cannot control clicker at all but you can change sound volume with dial on bottom.
- With capacitive models the converter doesn't support  clicker by default. You will hear beep while startup after plugin but no clicker at all when typing. See this post (https://geekhack.org/index.php?topic=54706.msg2785969#msg2785969) to enable key click.(2019-07-12)

Alt keys
Both keys next to space bar send identical scan code. You can remap the two keys but always they work as same key. For example, with default keymap both work as Left Alt key.


Preassembled TMK Converter for IBM4704
You can buy it here.
https://geekhack.org/index.php?topic=72052.0

TMK IBM4704 converter
(https://i.imgur.com/lnyRjFjh.jpg)

Precompiled  Firmware
You can use TMK keymap editor to remap keys fortunately.
http://www.tmk-kbd.com/tmk_keyboard/editor/

Use this link for 50-key: https://goo.gl/95HRna

Title: Re: IBM 4704 Keyboard Converter
Post by: E TwentyNine on Wed, 12 February 2014, 18:56:07
Waiting for first post to be filled in.  When it is if this point isn't covered, here's what I must ask:

Did you get this working with the stock controller? 
Title: Re: IBM 4704 Keyboard Converter
Post by: JPG on Wed, 12 February 2014, 19:17:48
I don't have one of these, but this is so much good news for those that have one!


I already see people bragging about using their Kishsaver!


Great work man!
Title: Re: IBM 4704 Keyboard Converter
Post by: dorkvader on Thu, 13 February 2014, 19:41:12
Awesome! I have another teensy-size project box. I think instead of a panel mount dsub connector, I'll just chop up a serial cable and use that.
Title: Re: IBM 4704 Keyboard Converter
Post by: Soarer on Fri, 14 February 2014, 17:00:13
Hasu succeeded where I failed; his reverse engineering was masterful :D

I've been playing with the protocol as well, following hasu's notes above. The FD command just seems to make the keyboard emit a short beep, presumably so the terminal can emit a BEL code.

The Chinese/Japanese IBMs with vintage Alps (http://deskthority.net/post87127.html#p87127) use the same protocol, and the same command sequence (FC, 80 .. F6, FF) enables release codes for all keys. Scan codes output are different to the KS for most keys. On powering up, both the 6113442 and the 6112884 send A6 as an ident code.

Title: Re: IBM 4704 Keyboard Converter
Post by: rindorbrot on Sat, 15 February 2014, 15:01:46
Well, I gotta get myself a Teensy I guess...
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sat, 15 February 2014, 19:24:01
Thank you, Soarer. I'll fix my document later.


And...
For those who are interested, my converter has some limitations:
1. Keyboard(6019284) has only *3-byte* key buffer.
2. Keyboard has same scancode on both Alt key. You can't use different scancodes on those.
3. My converter is naively *polling* at not so fast speed.
Due to 1. and 3. you probably will see missing keys and transposing keys at very fast typing.(my wpm is less than 60 and I don't have a problem) To solve or mitigate this problem we can use *interrupt* method instead of polling.

Replacing controller board doesn't have these limitations. It is still very intriguig option to squeeze every last drop of its power out of this keyboard.


EDIT: 1. and 3. are no longer problem as of Mar 2015, see this post.
https://geekhack.org/index.php?topic=54706.msg2638926#msg2638926
Title: Re: IBM 4704 Keyboard Converter
Post by: Soarer on Sun, 16 February 2014, 08:19:38
I can also confirm that the 50-key outputs A2 as its ID. (I didn't see it output it on startup, only after sending a reset command (FA) to the keyboard, but that might be because I'm sending commands before it has time to output it).

IDs so far...
A2 = 50-key
A3 = 62-key
A4 = 77-key (unconfirmed)
?? = 107-key
A6 = the vintage Alps CN/JP

The 107-key surely uses this protocol, but we don't know if it uses the same ROM image. It has no ID pads on the PCB -
http://kishy.dyndns.org/?attachment_id=1045 - if it does use the same ROM then the ID would A0, but A5 fits the sequence better!

Not that I would recommend it, but cutting the track to the ID pads ought to make the keyboard output raw matrix position codes rather than scan codes, which would then distinguish between the left and right alt keys.
Title: Re: IBM 4704 Keyboard Converter
Post by: rindorbrot on Tue, 18 February 2014, 23:59:25
Got my teensy yesterday and now the keyboard is alive. Thanks guys! but the missing scancode for the right alt really is a big loss for me, as I use it very frequently.

But it is definitely a good interim solution until the complete replacement controllers are here.
Title: Re: IBM 4704 Keyboard Converter
Post by: dorkvader on Wed, 19 February 2014, 01:20:54
Got my teensy yesterday and now the keyboard is alive. Thanks guys! but the missing scancode for the right alt really is a big loss for me, as I use it very frequently.

But it is definitely a good interim solution until the complete replacement controllers are here.
Unfortunately no HHKB layout model F until the controller project is done.
Title: Re: IBM 4704 Keyboard Converter
Post by: bcg on Thu, 20 February 2014, 21:42:44
Wow great work hasu!

Do you think this would work with my 3178?  It is like the top one here:

(http://deskthority.net/w/images/1/17/C1_and_c2.jpg)

Here's a picture of the guts:

(http://geekhack.org/index.php?action=dlattach;topic=50437.0;attach=47196;image)

I just a couple Teensy 3.1 boards and was going to see if I could drive the matrix myself using the touch pins ... I'm probably not smart enough to pull it off so this looks great!
Title: Re: IBM 4704 Keyboard Converter
Post by: vivalarevolución on Thu, 27 February 2014, 17:00:44
Hey, I'm a little confused about how I should load this onto the teensy.  Are the instructions somewhere in the files in that github link?
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Thu, 27 February 2014, 19:01:20
bcg, I don't know much about IBM keyboard models, though, I guess it uses diffrent protocol than 4704. It doesn't seem it is part of 4704 banking system.

prdlm2009, README didn't help you? You won't be able to find more detailed instructions in tmk repository. Maybe you need Googling of AVR and gcc toolchain, I guess.

EDIT: Note that tmk_firmware has also README file in root directory in addition to in each project directories. You need to read both README files.
https://github.com/tmk/tmk_keyboard
https://github.com/tmk/tmk_keyboard/tree/master/converter/ibm4704_usb
Title: Re: IBM 4704 Keyboard Converter
Post by: vivalarevolución on Thu, 27 February 2014, 19:19:08
bcg, I don't know much about IBM keyboard models, though, I guess it uses diffrent protocol than 4704. It doesn't seem it is part of 4704 banking system.

prdlm2009, README didn't help you? You won't be able to find more detailed instructions in tmk repository. Maybe you need Googling of AVR and gcc toolchain, I guess.

EDIT: Note that tmk_firmware has also README file in root directory in addition to in each project directories. You need to read both README files.
https://github.com/tmk/tmk_keyboard
https://github.com/tmk/tmk_keyboard/tree/master/converter/ibm4704_usb

Thanks, that's what I needed, I should be able to figure it out with that information.  This is my first time using any of your converter firmware.
Title: Re: IBM 4704 Keyboard Converter
Post by: bcg on Mon, 03 March 2014, 22:30:37
bcg, I don't know much about IBM keyboard models, though, I guess it uses diffrent protocol than 4704. It doesn't seem it is part of 4704 banking system.

Thanks hasu, you're probably right.  Guess I've got some hacking to do now :)
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sun, 02 November 2014, 21:51:50
On Deskthority TMK thread Ellipse and I were working on 107-key keyboard and it kind of work but still iffy and some problems remain. Check it out if your are interested.

http://deskthority.net/workshop-f7/tmk-keyboard-firmware-collection-t4478-90.html#p190725
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 18 May 2015, 11:10:22
Recently added keymaps for 77-key and 107-key. Thanks orihalcon.

And protocol handling bug was fixed today, it seems like this solves key stuck and drop problem.
https://github.com/tmk/tmk_keyboard/commit/81137b7a61ef11df023e1f542840a80bfc1ca090
Title: Re: IBM 4704 Keyboard Converter
Post by: PicklesKill on Mon, 06 July 2015, 20:04:46
With your firmware does it matter what chipset the keyboard is running? I cracked open the 6112884 an my board is running a TI SN74159N. I was under the impression they had the intel 8048 or did I just misread other posts.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 06 July 2015, 20:13:04
No, keyboard controller itself does not matter but keyboard protocol matters.

SN74159N is just one of 74 series IC - demuxer, not controller :D
http://www.ti.com/lit/ds/sdls059/sdls059.pdf

I think you can find other IC package of controller on the board, probably 8048 or compatibles.
Title: Re: IBM 4704 Keyboard Converter
Post by: PicklesKill on Mon, 06 July 2015, 20:17:47
Awesome thats the same doc I pulled down.
Title: Re: IBM 4704 Keyboard Converter
Post by: PicklesKill on Mon, 06 July 2015, 20:30:30
PM'd you as well
Title: Re: IBM 4704 Keyboard Converter
Post by: PicklesKill on Mon, 06 July 2015, 20:41:21
With the Blanks on the 6112884 do you have any recommendations on the best way to go about starting to map those keys? IE. what did you use to find the hex for the original layout. My second question as I have never used a teensy how do you load your code on to that d**n thing.  :D
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 06 July 2015, 20:57:26
You can use 6020218 107-key keymap for start and I guess it works also on 6112884 probably. If it does not work or has wrong keymap you will have to change keymap file. I can tell the detail of investigation/debug in that case.

At first you need converter hardware, its wiring is explained in README on github.
https://github.com/tmk/tmk_keyboard/tree/master/converter/ibm4704_usb

Next compile firmware to get binary hex file and load the hex to Teensy.
https://github.com/tmk/tmk_keyboard/blob/master/doc/build.md

As for loading hex to you can find PJRC instruction on their site.
Title: Re: IBM 4704 Keyboard Converter
Post by: PicklesKill on Mon, 06 July 2015, 21:17:03
Thanks Hasu from what I have seen you and Soarer have done an amazing job of helping everyone on this forum, I really appreciate it.
Title: Re: IBM 4704 Keyboard Converter
Post by: Coin-op Adjutant on Mon, 27 July 2015, 19:34:45
Going to resurrect this thread since I'm having issues with my own converter for a 6112883 keyboard.

I was able to make and load the hex file for the plain layout onto a Teensy.  When I run hid_listen, all the keys respond to presses (there are one or two blanks on the far right cluster that are giving errors, but that's it)...but the keyboard won't actually function in Windows.  No Start Menu search results, no Notepad results, etc...but hid_listen works.

Am I missing some sort of step in this process?
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 27 July 2015, 20:04:27
The plain keymap is for capacitive switch models, your Alps switch model probably use different scancodes and you need to define keymap for the keyboard.

First, look into scan codes of all keys and make table like below. You'll see scan code on hid_listen when pressing or releasing a key.

Quote

    6019284 62-key:
    ,-----------------------------------------------------------.
    |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|???|BS |
    |-----------------------------------------------------------|
    |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P| ¢|  \|  PD2|
    |-----------------------------------------------------------|
    |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '| {}| PD3|
    |-----------------------------------------------------------|
    |Shif| <>|  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /|???|Shift |
    |-----------------------------------------------------------|
    |Reset|blk|Alt  |         Space             |Alt  |blk|Enter|
    `-----------------------------------------------------------'
    +----------+---------------------+----------+----------+
    |`       00|PD1     04|Caps    20|LShift  30|Reset   31|
    |1       18|q       05|a       21|<>      3E|Rblank  41|
    |2       19|w       06|s       22|z       32|Alt     3F|
    |3       1A|e       13|d       23|x       33|Space   40|
    |4       10|r       14|f       24|c       34|Alt     3F|
    |5       11|t       15|g       25|v       35|Lblank  42|
    |6       12|y       16|h       26|b       36|Enter   2F|
    |7       08|u       17|j       27|n       37|          |
    |8       09|i       01|k       28|m       38|          |
    |9       0A|o       02|l       29|,       39|          |
    |0       0F|p       03|;       2A|.       3A|          |
    |-       1F|¢      1B|'       2B|/       3B|          |
    |=       0D|\       1C|{}      2C|???     3C|          |
    |???     0C|PD2     1D|PD3     2D|RShift  3D|          |
    |BS      0E|          |          |          |          |
    +----------+---------------------+----------+----------+
    Bit7 is 'press flag' which set 1 on press and 0 on release when break code is enabled.
Title: Re: IBM 4704 Keyboard Converter
Post by: Coin-op Adjutant on Fri, 28 August 2015, 12:44:11
So, late response, but I have yet another question, Hasu:

I've been looking through your codes for the keymaps, and I'm wondering if I just overlooked it:  Is there a code for turning off a keyboard's solenoid/beeper?  (The IBM 6112883 has a speaker in it, and while it's cool to have on to show it off, I don't think I could stand to have it on all the time.  It's either this, or I'll need to desolder the blasted thing.)

I did notice "Volume up/down/mute" codes, but those are for media controls, not the keyboard itself, correct?

EDIT:  I can't read the Japanese characters on the keyboard, either, so if there was originally a designated key for doing this, I have no idea.  :x
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 28 August 2015, 15:09:58
At least my 6019284 stops beep after sending FF at end of initialization. The code is located at enable_break,
() in  matrix.c
https://github.com/tmk/tmk_keyboard/blob/master/converter/ibm4704_usb/ibm4704.txt


Mine has no solenoid. If your keyboard has solenoid I think it has a command. But I don't know that.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 28 August 2015, 15:14:40
Post pics of your keyboard and manual. I can read them for you.

Title: Re: IBM 4704 Keyboard Converter
Post by: tai on Fri, 04 September 2015, 15:11:19
Thread Res!

I have an IBM 4704 (6112884) version.
I've played around with the firmware, and I've put it on the teensy several times.
I will also dump the break codes below. I get scan codes in hid_listen on keypress for all keys except one of the macro keys.
I'm lost as to how to get this working as a keyboard. Any help from anyone would be super appreciated!

The scan code table will be below as well. They are in the order of how the keyboard is laid out.

Break Codes:
------------------------------------------------
Waiting for new device:...
Listening:
Keyboard ID: A6
Enable break: s00:rFD s01:rFD s02:rFD s03:rFD s04:rFD s05:rFD s06:rFD s07:rFD s08:rFD s09:rFD s0A:rFD s0B:rFD s0C:rFD s0D:rFD s0E:rFD s0F:rFD s10:rFD s11:rFD s12:rFD s13:rFD s14:rFD s15:rFD s16:rFD s17:rFD s18:rFD s19:rFD s1A:rFD s1B:rFD s1C:rFD s1D:rFD s1E:rFD s1F:rFD s20:rFD s21:rFD s22:rFD s23:rFD s24:rFD s25:rFD s26:rFD s27:rFD s28:rFD s29:rFD s2A:rFD s2B:rFD s2C:rFD s2D:rFD s2E:rFD s2F:rFD s30:rFD s31:rFD s32:rFD s33:rFD s34:rFD s35:rFD s36:rFD s37:rFD s38:rFD s39:rFD s3A:rFD s3B:rFD s3C:rFD s3D:rFD s3E:rFD s3F:rFD s40:rFD s41:rFD s42:rFD s43:rFD s44:rFD s45:rFD s46:rFD s47:rFD s48:rFD s49:rFD s4A:rFD s4B:rFD s4C:rFD s4D:rFD s4E:rFD s4F:rFD s50:rFD s51:rFD s52:rFD s53:rFD s54:rFD s55:rFD s56:rFD s57:rFD s58:rFD s59:rFD s5A:rFD s5B:rFD s5C:rFD s5D:rFD s5E:rFD s5F:rFD s60:rFD s61:rFD s62:rFD s63:rFD s64:rFD s65:rFD s66:rFD s67:rFD s68:rFD s69:rFD s6A:rFD s6B:rFD s6C:rFD s6D:rFD s6E:rFD s6F:rFD s70:rFD s71:rFD s72:rFD s73:rFD s74:rFD s75:rFD s76:rFD s77:rFD s78:rFD s79:rFD End
Keyboard start.

--------

Scan Codes:
------------------------------
00 0F 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 44 45 46 43 41 42 4A
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 54 55 56 50 51 52 5A
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 64 65 66 60 61 62 6B
30 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 74 75 76 70 71 72 (Error: 7B)
31 47 (BF 3F) 40 4F 48 2F 77 67 57 73 63 53 4E
---------------


-
Tai
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 04 September 2015, 18:08:29
hmm, all of 'enable break' commands are not accepted with your keyboard.
For example, this displays that the keyboard responds erroer FD(out of bound) when send the command for scan code '00'.
Code: [Select]
s00:rFD


Those Alps switch models probably work a little differently than cpacitive switch models. My code has depended largely on my 6019284 behaviour and it does not work your keyboard well.

I found Soarer mentioned earlier that your 6112884 accepts 'enable break' commands. You probably have to send 'FC' to start sending the commands.
Quote
The Chinese/Japanese IBMs with vintage Alps use the same protocol, and the same command sequence (FC, 80 .. F6, FF) enables release codes for all keys. Scan codes output are different to the KS for most keys. On powering up, both the 6113442 and the 6112884 send A6 as an ident code.



Try this patch to add 'FC' on top of commands. And this will fix the one bad key(7B).
Code: [Select]
diff --git a/converter/ibm4704_usb/matrix.c b/converter/ibm4704_usb/matrix.c
index 155df9c..5b91d49 100644
--- a/converter/ibm4704_usb/matrix.c
+++ b/converter/ibm4704_usb/matrix.c
@@ -68,8 +68,9 @@ uint8_t matrix_cols(void)
 static void enable_break(void)
 {
     print("Enable break: ");
+    while (ibm4704_send(0xFC)) { _delay_ms(10); }
     // valid scancode: 00-79h
-    for (uint8_t code = 0; code < 0x7A; code++) {
+    for (uint8_t code = 0; code < 0x7F; code++) {
         while (ibm4704_send(0x80|code)) _delay_ms(10);
         _delay_ms(5);   // wait for response
         // No response(FF) when ok, FD when out of bound
Title: Re: IBM 4704 Keyboard Converter
Post by: tai on Fri, 04 September 2015, 18:44:37
Fantastic! We're in business.

The new break codes are as follows:

------
Waiting for new device:...
Listening:
Keyboard ID: A6
Enable break: s00:rFF s01:rFF s02:rFF s03:rFF s04:rFF s05:rFF s06:rFF s07:rFF s08:rFF s09:rFF s0A:rFF s0B:rFF s0C:rFF s0D:rFF s0E:rFF s0F:rFF s10:rFF s11:rFF s12:rFF s13:rFF s14:rFF s15:rFF s16:rFF s17:rFF s18:rFF s19:rFF s1A:rFF s1B:rFF s1C:rFF s1D:rFF s1E:rFF s1F:rFF s20:rFF s21:rFF s22:rFF s23:rFF s24:rFF s25:rFF s26:rFF s27:rFF s28:rFF s29:rFF s2A:rFF s2B:rFF s2C:rFF s2D:rFF s2E:rFF s2F:rFF s30:rFF s31:rFF s32:rFF s33:rFF s34:rFF s35:rFF s36:rFF s37:rFF s38:rFF s39:rFF s3A:rFF s3B:rFF s3C:rFF s3D:rFF s3E:rFF s3F:rFF s40:rFF s41:rFF s42:rFF s43:rFF s44:rFF s45:rFF s46:rFF s47:rFF s48:rFF s49:rFF s4A:rFF s4B:rFF s4C:rFF s4D:rFF s4E:rFF s4F:rFF s50:rFF s51:rFF s52:rFF s53:rFF s54:rFF s55:rFF s56:rFF s57:rFF s58:rFF s59:rFF s5A:rFF s5B:rFF s5C:rFF s5D:rFF s5E:rFF s5F:rFF s60:rFF s61:rFF s62:rFF s63:rFF s64:rFF s65:rFF s66:rFF s67:rFF s68:rFF s69:rFF s6A:rFF s6B:rFF s6C:rFF s6D:rFF s6E:rFF s6F:rFF s70:rFF s71:rFF s72:rFF s73:rFF s74:rFF s75:rFF s76:rFF s77:rFF s78:rFF s79:rFF s7A:rFF s7B:rFF s7C:rFF s7D:rFF s7E:r00 End
Keyboard start.
-----

The scan codes that are actually mapped to keys function properly. Now all I have left is to make a keymap for the 102 layout!!!
Thanks so much Hasu, couldn't have done it without you. I'll also post or PM you a good default 102-key keymap if you'd like to add it to the configs.

--
Tai
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 04 September 2015, 19:01:36
Great. Thanks for the report back.

I confirmed that fix works also on my keybaord and pushed the fix to github now.
Title: Re: IBM 4704 Keyboard Converter
Post by: tai on Sat, 05 September 2015, 00:39:48
Alright, I've run into a few more issues. I've got a keymap, but the keys laid out in keymap_plain (for example) don't line up with the scan code values. For example, here's my keycode config in keymap_common.h

Code: [Select]
#define KEYMAP( \
    K00, K0F, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E,   K44, K45, K46,   K43, K41, K42, K4A, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D,      K1E,   K54, K55, K56,   K50, K51, K52, K5A, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D,      K2E,   K64, K65, K66,   K60, K61, K62, K6B, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D,           K3E,   K74, K75, K76,   K70, K71, K72, K7B, \
    K31, K47, KBF,                 K40,               K4F, K48,                K2F,   K77, K67, K57,   K73, K63, K53, K4E  \
) { \
    { KC_##K00, KC_##K0F, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07, KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K44, KC_##K45, KC_##K46, KC_##K43, KC_##K41, KC_##K42, KC_##K4A }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17, KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_##K54, KC_##K55, KC_##K56, KC_##K50, KC_##K51, KC_##K52, KC_##K5A }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27, KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K64, KC_##K65, KC_##K66, KC_##K60, KC_##K61, KC_##K62, KC_##K6B }, \
    { KC_##K30, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37, KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K74, KC_##K75, KC_##K76, KC_##K70, KC_##K71, KC_##K72, KC_##K7B }, \
    { KC_##K31, KC_##K47, KC_##KBF,                                                          KC_##K40,               KC_##K4F, KC_##K48,                KC_##K2F,   KC_##K77, KC_##K67, KC_##K57,   KC_##K73, KC_##K63, KC_##K53, KC_##K4E }  \

I have both an 8x16 matrix table and that one right there that matches exactly the keys on the keyboard.

What's weird is that even after I changed the keys in keymap_plain to match that layout, they don't match up. For example, where it should be the "1" key, it's printing the character "u". and where the character should be "2" it's printing "1".

I found that if I changed the key where it would normally say "u" to be "1" (reversing the process), the "1" key does indeed display "1", but that's not what I should be doing to fix this.

Any ideas guys? Any help is appreciated!!

--
Tai

Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sat, 05 September 2015, 04:02:23
You have to define keymap macro for your Alps keyboard like definition for 107-key. Note that the latter part of the definition should be an array 16x8(keymap[16][8]) containing sequence of scan codes from KC_##K00 to 7F basically, but use KC_NO for scan codes not used in the frist part. The first part of your definition seems to be correct at a glance.
https://github.com/tmk/tmk_keyboard/blob/master/converter/ibm4704_usb/keymap_common.h#L44-L61

Code: [Select]
/* 107-key */
#define KEYMAP( \
    K46,K64,     K00,K18,K19,K1A,K10,K11,K12,K08,K09,K0A,K0F,K1F,K0D,K0C,K0E,   K6A,K6B,K6C,    K47,K48,K49,K4A, \
    K56,K66,     K04,K05,K06,K13,K14,K15,K16,K17,K01,K02,K03,K1B,K1C,K1D,       K6D,K6E,K6F,    K4B,K4C,K4D,K4E, \
    K71,K77,     K20,K21,K22,K23,K24,K25,K26,K27,K28,K29,K2A,K2B,K2C,K2D,       K70,K65,K72,    K50,K51,K52,K53, \
    K44,K45,     K30,K3E,K32,K33,K34,K35,K36,K37,K38,K39,K3A,K3B,K3C,K3D,       K74,K75,K76,    K5E,K58,K59,K5A, \
    K54,K55,     K31,K41,K3F,        K40,                        K42,K2F,       K78,K67,K79,    K5B,K5C,K5D,K57  \
) { \
    { KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_NO    }, \
    { KC_##K08, KC_##K09, KC_##K0A, KC_NO,    KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \
    { KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
    { KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_NO,    KC_##K1F }, \
    { KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
    { KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_NO,    KC_##K2F }, \
    { KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
    { KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \
    { KC_##K40, KC_##K41, KC_##K42, KC_NO,    KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
    { KC_##K48, KC_##K49, KC_##K4A, KC_##K4B, KC_##K4C, KC_##K4D, KC_##K4E, KC_NO    }, \
    { KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
    { KC_##K58, KC_##K59, KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_NO    }, \
    { KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
    { KC_NO,    KC_NO,    KC_##K6A, KC_##K6B, KC_##K6C, KC_##K6D, KC_##K6E, KC_##K6F }, \
    { KC_##K70, KC_##K71, KC_##K72, KC_NO,    KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
    { KC_##K78, KC_##K79, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO    }  \
}
Title: Re: IBM 4704 Keyboard Converter
Post by: tai on Sun, 06 September 2015, 13:35:55
Alright! It's completely done! Thanks Hasu!

I'll post more stuff later, I actually made a script to make the scan code grid for you, but I have a few little things I want to fix with it first.

Below are the scan code matrix and key layout for the IBM 4704 6112884 (finally!) this may also work  with the CN model, but I'm not sure.

Code: [Select]
#define KEYMAP( \
    K00, K0F, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, K0E,   K44, K45, K46,   K43, K41, K42, K4A, \
    K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D,      K1E,   K54, K55, K56,   K50, K51, K52, K5A, \
    K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D,      K2E,   K64, K65, K66,   K60, K61, K62, K6B, \
    K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, K3D,           K3E,   K74, K75, K76,   K70, K71, K72, K7B, \
    K31, K47, K3F,                 K40,               K4F, K48,                K2F,   K77, K67, K57,   K73, K63, K53, K4E  \
) { \
{ KC_##K00, KC_##K01, KC_##K02, KC_##K03, KC_##K04, KC_##K05, KC_##K06, KC_##K07 }, \
{ KC_##K08, KC_##K09, KC_##K0A, KC_##K0B, KC_##K0C, KC_##K0D, KC_##K0E, KC_##K0F }, \
{ KC_##K10, KC_##K11, KC_##K12, KC_##K13, KC_##K14, KC_##K15, KC_##K16, KC_##K17 }, \
{ KC_##K18, KC_##K19, KC_##K1A, KC_##K1B, KC_##K1C, KC_##K1D, KC_##K1E, KC_NO,   }, \
{ KC_##K20, KC_##K21, KC_##K22, KC_##K23, KC_##K24, KC_##K25, KC_##K26, KC_##K27 }, \
{ KC_##K28, KC_##K29, KC_##K2A, KC_##K2B, KC_##K2C, KC_##K2D, KC_##K2E, KC_##K2F }, \
{ KC_##K30, KC_##K31, KC_##K32, KC_##K33, KC_##K34, KC_##K35, KC_##K36, KC_##K37 }, \
{ KC_##K38, KC_##K39, KC_##K3A, KC_##K3B, KC_##K3C, KC_##K3D, KC_##K3E, KC_##K3F }, \
{ KC_##K40, KC_##K41, KC_##K42, KC_##K43, KC_##K44, KC_##K45, KC_##K46, KC_##K47 }, \
{ KC_##K48, KC_NO,    KC_##K4A, KC_NO,    KC_NO,    KC_NO,    KC_##K4E, KC_##K4F }, \
{ KC_##K50, KC_##K51, KC_##K52, KC_##K53, KC_##K54, KC_##K55, KC_##K56, KC_##K57 }, \
{ KC_NO,    KC_NO,    KC_##K5A, KC_NO,    KC_NO,    KC_NO,    KC_NO,    KC_NO,   }, \
{ KC_##K60, KC_##K61, KC_##K62, KC_##K63, KC_##K64, KC_##K65, KC_##K66, KC_##K67 }, \
{ KC_NO,    KC_NO,    KC_NO,    KC_##K6B, KC_NO,    KC_NO,    KC_NO,    KC_NO,   }, \
{ KC_##K70, KC_##K71, KC_##K72, KC_##K73, KC_##K74, KC_##K75, KC_##K76, KC_##K77 }, \
{ KC_NO,    KC_NO,    KC_NO,    KC_##K7B, KC_NO,    KC_NO,    KC_NO,    KC_NO,   }  \
}


Thanks again to all the help from Hasu, I'll post my actual key layout (it has a mouse!) and the script to automagically make your scan code matrix later today.
Have a fantastic day! Happy Hacking!

--
Tai
Title: Re: IBM 4704 Keyboard Converter
Post by: PicklesKill on Sun, 06 September 2015, 13:42:00
I'm stoked for you this will make it easier for us allow kids ;D hopefully your hard work pushes more people into picking one up.
Title: Re: IBM 4704 Keyboard Converter
Post by: tai on Tue, 15 September 2015, 14:26:15
Alright! I want to go a bit farther in this project.
I started thinking about making the keyboard wireless, and I saw that you actually had some bluefruit support in the firmware.

I want to pick up a bluefruit so that I can do the whole bluetooth thing (I wish I could just use RF, but beggars can't be choosers)

Does any significant code need to be modified to get the firmware working with a bluefruit? Or can I just wire it in and go? I have to power it of course.

I saw this article: https://learn.adafruit.com/convert-your-model-m-keyboard-to-bluetooth-with-bluefruit-ez-key-hid/use-it

where someone converted an IBM Model M using your firmware with an arduino micro (gross) and a bluefruit for the bluetooth part, but I didn't quite grock what he changed in the code for that part. Since I already have the working code for the 6112884 is it just plug and play?

Thanks for the help, and I'll keep everyone updated as I receive advice / make changes!

P.S. I also have the RF module from an old membrane keyboard, I don't see how I could get that to work with the current setup though, it has an 8x15 matrix (and the pins for it) on the PCB, but I just wanted to transmit the data through it....oh well..


--
Tai
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 15 September 2015, 21:30:59
Including protocol/bluefruit.mk instead of lufa.mk should work basically. Not so tedious job.
But I don't thave the module and haven't maintained it, I'm not sure it works with the latest code base.

BTW, I added keymap of Alps 102-key and update repository!
https://github.com/tmk/tmk_keyboard/commit/dc04983fd7905048c94366bce70f1288b323bfc9
Title: Re: IBM 4704 Keyboard Converter
Post by: tai on Tue, 15 September 2015, 22:58:28
Oh awesome! Thanks for the mention! It means a lot. I'll pick up a bluefruit soon and play around with it, I'll post the results here of course.

I never expected there to be actual community for old keyboards lmao


--
Tai
Title: Re: IBM 4704 Keyboard Converter
Post by: __red__ on Sat, 06 February 2016, 00:03:25
Quick thread necromancy... anyone modified the code to send the correct (0xFD?) code to the keyboard controller to make the buzzer / bleeper inside buzz/bleep after every keypress?
Title: Re: IBM 4704 Keyboard Converter
Post by: Dernubenfrieken on Sat, 06 February 2016, 08:39:20
Quick thread necromancy... anyone modified the code to send the correct (0xFD?) code to the keyboard controller to make the buzzer / bleeper inside buzz/bleep after every keypress?

On my 6112884 Japanese 102-key the buzzer worked perfectly
Title: Re: IBM 4704 Keyboard Converter
Post by: __red__ on Sat, 06 February 2016, 09:44:01
Quick thread necromancy... anyone modified the code to send the correct (0xFD?) code to the keyboard controller to make the buzzer / bleeper inside buzz/bleep after every keypress?

On my 6112884 Japanese 102-key the buzzer worked perfectly
Do you recall which keyboard / converter you compiled with?
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sat, 06 February 2016, 10:32:38
Quick thread necromancy... anyone modified the code to send the correct (0xFD?) code to the keyboard controller to make the buzzer / bleeper inside buzz/bleep after every keypress?

I think Soarer did that and confirmed FD command works on his capacitive model keyboard.
https://geekhack.org/index.php?topic=54706.msg1228052#msg1228052

Vintage Alps models works differently, they emit beep themselves without FD command from converter.
Title: Re: IBM 4704 Keyboard Converter
Post by: __red__ on Sat, 06 February 2016, 11:14:42
Quick thread necromancy... anyone modified the code to send the correct (0xFD?) code to the keyboard controller to make the buzzer / bleeper inside buzz/bleep after every keypress?

I think Soarer did that and confirmed FD command works on his capacitive model keyboard.
https://geekhack.org/index.php?topic=54706.msg1228052#msg1228052

Vintage Alps models works differently, they emit beep themselves without FD command from converter.
I guess I'm looking for the correct location to insert the send function call.

My first attempt was in the initialization section and it beeped a few times.  Last attempt I pot it in the debug util function and it didn't work at all.

I'll work it out eventually...
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Tue, 09 February 2016, 16:42:39
Do forgive me if this is a stupid question; I've been looking over the documentation for a while now but I'm still trying to wrap my head around it; I received my Hasu's Converter today; it's lovely and I'm typing on my 6112884 right now; I'm thrilled to have spherical keycaps like the old VT100 I first used at age 4!  What I'm after now is the ability to re-map the keys.  I know this is something that is possible with this unit but I'm on Windows and I'm no programmer, so I'm afraid a lot of the information is lost on me.  I see that there is a keymap file on github which corresponds to the functions of the keys, and I gather that I'm supposed to be able to make my own version of this and somehow upload it to the microcontroller's RAM, but I simply don't know how to go about doing that.  If someone could be so kind to spell it out for someone who hasn't touched a Unix command prompt for ten years, I'd be quite appreciative. 

I feel that I should say that I'm exceptionally pleased with the converter; the only thing like a complaint I could raise is that the DE9 plug on it has the wrong type of locking screws for the mating connector on the keyboard, but this is easily overcome and shouldn't be anything like a major issue as I intend to put the whole board into a small box to keep it from damage and dust (does it get hot in operation?  Should I put vent holes in the box?)  Also, what is the purpose of the small button on the board?
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 09 February 2016, 22:16:59
Read these document if you didn't yet.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md

Procedure of remap looks like the below. I'm not usually on Windows, so I may pass by something improtant, though.

1. First, you need to install Toolchain to compile firmware(.hex) file from source code and Programmer app(FLIP) to download firmware into MCU(ATMeaga32u2) on converter.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/build.md#1-install-tools

2. Then open Cygwin terminal and compile firmware. You will see firmware file 'ibm4704_usb.hex'.
Quote
$ cd tmk_keyboard/converter/ibm4704_usb
$ make -f Makefile.tmk_rev2 clean
$ make -f Makefile.tmk_rev2

3. Open FLIP to program MCU(ATMega32u2) with the firmware.
Push small button on converter before run FLIP. The button on converter is program button, you have to push it when program it.

I dont think the MCU needs ventilation.
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Thu, 11 February 2016, 16:42:30
Alright, I think I know what I've got to do; I've got all the tools and I've edited the keymap file; I'll post it at the end and hopefully someone with more experience at this than I can tell me if I've stuffed up before I go flashing ROMs or whatever it is that happens when the microcontroller is programmed.  Do I need to hold down the button while it programs or do I just press it once to put it into programming mode? If a single press, do I need to press again to return to normal operation?  Again, sorry if these are stupid questions, but in spite of spending a lifetime around computers, this is the first time I've done something like this.

Anyway, this is what keymap_alps102key.c looks like in the specified directory for me right now:
Code: [Select]
#include "keymap_common.h"


const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
    /* Layer 0:
   

  * ,---------------------------------------------------------------.  ,-----------. ,---------------.
   

  * |  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|BS |BS |DEL|  |PSC|SLK|PAU| |F1 |F2 |F3 |F4 |
   

  * |---------------------------------------------------------------|  |-----------| |---------------|
   

  * |Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|INS|  |KP7|KP8|KP9| |F5 |F6 |F7 |F8 |
   

  * |---------------------------------------------------------------|  |-----------| |---------------|
   

  * |Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Ret|Ret |CTL|  |KP4|KP5|KP6| |F9 |F10|F11|F12|
   

  * |---------------------------------------------------------------|  |-----------| |---------------|
   

  * |Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /|Shf|Shift |CAP|  |KP1|KP2|KP3| |HOM|UP |END|PUP|
   

  * |---------------------------------------------------------------|  |-----------| |---------------|
   

  * |Fn0  |Gui|Alt  |         Space             |Alt* |Gui|KPENTER  |  |KP0|000|KP.| |LFT|DWN|RGH|PDN|
   

  * `---------------------------------------------------------------'  `-----------' `---------------'
   

  */
    KEYMAP_ALPS102(
    ESC, 1,   2,   3,   4,   5,   6,   7,   8,   9,   0,   MINS,EQL,

BSPC,BSPC,KC_DELETE,      PSCR,SLCK,PAUS,     F1,  F2,  F3,  F4,  \
    TAB, Q,   W,   E,   R,   T,   Y, 

 U,   I,   O,   P,   LBRC,RBRC,BSLS,     INS,      KC_P7, KC_P8,KC_P9,     F5,  F6,  F7,  F8,  \
   

LCTL,A,   S,   D,   F,   G,   H,   J,   K,   L,   SCLN,QUOT,GRV, ENT,      KC_RCTL,      KC_P4, KC_P5,

KC_P6,     F9,  F10, F11, F12, \
    LSFT,Z,   X,   C,   V,   B,   N,   M,   COMM,DOT, SLSH,RSFT,RSFT,   

      KC_CAPS,      KC_P1,  KC_P2,  KC_P3,       KC_HOME, KC_UP, KC_END, KC_PGUP, \
    FN0, LGUI,LALT,   

       SPC,                     RALT,RGUI,               KC_PENT,      KC_P0,MACRO( (T)KC_P0, (T)KC_P0,

(T)KC_P0, END),KC_PDOT,     KC_LEFT, KC_DOWN, KC_RIGHT, KC_PGDN  \
    ),

    /* Layer 1:
     *

,---------------------------------------------------------------.  ,-----------. ,---------------.
     *

|  `|  1|  2|  3|  4|  5|  6|  7|  8|  9|  0|  -|  =|BS |BS |F21|  |VoD|VoU|Mut| |F1 |F2 |F3 |F4 |
     *

|---------------------------------------------------------------|  |-----------| |---------------|
     *

|Tab  |  Q|  W|  E|  R|  T|  Y|  U|  I|  O|  P|  [|  ]|    \|F22|  |Ins|Hom|PgU| |F5 |F6 |F7 |F8 |
     *

|---------------------------------------------------------------|  |-----------| |---------------|
     *

|Ctrl  |  A|  S|  D|  F|  G|  H|  J|  K|  L|  ;|  '|Ret|Ret |F23|  |Del|End|PgD| |F9 |F10|F11|F12|
     *

|---------------------------------------------------------------|  |-----------| |---------------|
     *

|Shift   |  Z|  X|  C|  V|  B|  N|  M|  ,|  ,|  /|Shf|Shift |F24|  |   |PgU|   | |F13|F14|F15|F16|
     *

|---------------------------------------------------------------|  |-----------| |---------------|
     *

|Fn0  |Gui|Alt  |         Space             |Alt* |Gui|Fn0      |  |Hom|PgD|End| |F17|F18|F19|F20|
     *

`---------------------------------------------------------------'  `-----------' `---------------'
     

*/
    KEYMAP_ALPS102(
   

TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     VOLD,VOLU,MUTE,     

TRNS,TRNS,TRNS,TRNS, \
    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     

TRNS,     TRNS,TRNS,TRNS,     TRNS,TRNS,TRNS,TRNS, \
   

TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,     TRNS,     TRNS,TRNS,TRNS,     

TRNS,TRNS,TRNS,TRNS, \
    TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,         

TRNS,     TRNS,TRNS,TRNS,     TRNS,TRNS,TRNS,TRNS, \
    TRNS,TRNS,TRNS,          TRNS,                   

 TRNS,TRNS,               TRNS,     TRNS,TRNS,TRNS,      TRNS,TRNS,TRNS,TRNS  \
    ),
};

const uint16_t

PROGMEM fn_actions[] = {
    [0] = ACTION_LAYER_MOMENTARY(1),
};
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Thu, 11 February 2016, 18:19:44
Yes, you need to push a button just once before programming, pressing the button turns MCU into programming mode. No, you don't need to push the button to return normal mode, it usually works as a keyboard after programming but if not just replug.

'MACRO' doesn't work as you defined, except for it it looks good to me.
Unfortunately no document of 'MACRO' action is located around, you have to learn someone's keymaps or from trial and error.
This is my macro definition in my keymap, for example.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/keymap_hasu.c#L233

You cannot break your hardware with programming mess up keymap, try it at ease!

EDIT:
If you mess up your converter program with this firmware with default keymap to recover it.
[attachurl=1]
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Thu, 11 February 2016, 22:16:06
Yes, you need to push a button just once before programming, pressing the button turns MCU into programming mode. No, you don't need to push the button to return normal mode, it usually works as a keyboard after programming but if not just replug.

'MACRO' doesn't work as you defined, except for it it looks good to me.
Unfortunately no document of 'MACRO' action is located around, you have to learn someone's keymaps or from trial and error.
This is my macro definition in my keymap, for example.
https://github.com/tmk/tmk_keyboard/blob/master/keyboard/hhkb/keymap_hasu.c#L233

You cannot break your hardware with programming mess up keymap, try it at ease!

EDIT:
If you mess up your converter program with this firmware with default keymap to recover it.
(Attachment Link)

Thank you again for all your help with this;
This:
Quote
You cannot break your hardware with programming mess up keymap, try it at ease!

Reminds me of an old joke about a computer salesman who tells his worrisome client that "Nothing he can enter at the console can harm the system in any way".  The client, re-assured, buys the system.  A few weeks later, the salesman gets a call from the client, saying that he has indeed entered something at the console that damaged the system.  "what was it?"  the salesman asks.  "A can of coke..."
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Fri, 12 February 2016, 17:00:25
I'm running into trouble compiling the firmware.  I think it's got something to do with the toolchain system; I see that it is necessary and I have downloaded it, but I can't figure out how to actually *use* it.  I enter the "make" commands into Cygwin's console and get the following:
$ make -f Makefile.tmk_rev2 clean
Makefile:90: ../../tmk_core/protocol.mk: No such file or directory
Makefile:91: ../../tmk_core/protocol/lufa.mk: No such file or directory
Makefile:92: ../../tmk_core/common.mk: No such file or directory
Makefile:93: ../../tmk_core/rules.mk: No such file or directory
make: *** No rule to make target '../../tmk_core/rules.mk'.  Stop.

I think I need to get Cygwin somehow to work together with the toolchain but I don't know how.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 12 February 2016, 17:43:29
hmm,
It seems you don't have files under tmk_core/ directory for some reason.

Did you download TMK source code from this link?
https://github.com/tmk/tmk_keyboard/archive/master.zip

You shoud have directories like this at least. In paticular do you have tmk_core directory?
Code: [Select]
tmk_keyboard-master/
├── converter
│   ├── adb_usb
│   ├── ascii_usb
│   ├── ibm4704_usb
│   ├── m0110_usb
│   ├── news_usb
│   ├── next_usb
│   ├── pc98_usb
│   ├── ps2_usb
│   ├── serialmouse_usb
│   ├── sun_usb
│   ├── terminal_bluefruit
│   ├── terminal_usb
│   ├── usb_usb
│   └── x68k_usb
├── keyboard
│   ├── alps64
│   ├── gh60
│   ├── ghost_squid
│   ├── hbkb
... snip ...
│   ├── stm32_f072_onekey
│   ├── stm32_f103_onekey
│   └── teensy_lc_onekey
├── README.md
└── tmk_core
    ├── common
    ├── common.mk
    ├── doc
    ├── ldscript_keymap_avr35.x
    ├── ldscript_keymap_avr5.x
    ├── protocol
    ├── protocol.mk
    ├── README.md
    ├── ring_buffer.h
    ├── rules.mk
    └── tool

42 directories, 8 files
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Fri, 12 February 2016, 23:41:30
hmm,
It seems you don't have files under tmk_core/ directory for some reason.

Did you download TMK source code from this link?
https://github.com/tmk/tmk_keyboard/archive/master.zip

You shoud have directories like this at least. In paticular do you have tmk_core directory?
Code: [Select]
tmk_keyboard-master/
├── converter
│   ├── adb_usb
│   ├── ascii_usb
│   ├── ibm4704_usb
│   ├── m0110_usb
│   ├── news_usb
│   ├── next_usb
│   ├── pc98_usb
│   ├── ps2_usb
│   ├── serialmouse_usb
│   ├── sun_usb
│   ├── terminal_bluefruit
│   ├── terminal_usb
│   ├── usb_usb
│   └── x68k_usb
├── keyboard
│   ├── alps64
│   ├── gh60
│   ├── ghost_squid
│   ├── hbkb
... snip ...
│   ├── stm32_f072_onekey
│   ├── stm32_f103_onekey
│   └── teensy_lc_onekey
├── README.md
└── tmk_core
    ├── common
    ├── common.mk
    ├── doc
    ├── ldscript_keymap_avr35.x
    ├── ldscript_keymap_avr5.x
    ├── protocol
    ├── protocol.mk
    ├── README.md
    ├── ring_buffer.h
    ├── rules.mk
    └── tool

42 directories, 8 files


I put the whole package in the working directory, but now I'm getting a new set of errors. 
$ make -f Makefile.tmk_rev2 clean
gives
sh: dfu-programmer: command not found
sh: dfu-programmer: command not found

and proceeds to remove a bunch of files.
The non-"clean" command just fails with:
sh: dfu-programmer: command not found
sh: dfu-programmer: command not found

-------- begin --------
sh: avr-gcc: command not found
../../tmk_core/rules.mk:406: recipe for target 'gccversion' failed
make: *** [gccversion] Error 127

I think I haven't got Cygwin linked with the toolchain.  I'm not sure how to do this and suspect that it's got something to do with me being on Windows. 
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sat, 13 February 2016, 15:09:13
You need to add toolchain location to PATH. In my case location of toolchain is '/cygdrive/c/avr8-gnu-toolchain/bin', so added this line in .bashrc file. YOu will have to open new terminal to get this PATH effective.
Code: [Select]
PATH=$PATH:/cygdrive/c/avr8-gnu-toolchain/bin


YOu can ignore this warn or just install dfu-programmer and add its path too.
Quote
sh: dfu-programmer: command not found
sh: dfu-programmer: command not found
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Sun, 14 February 2016, 00:16:37
You need to add toolchain location to PATH. In my case location of toolchain is '/cygdrive/c/avr8-gnu-toolchain/bin', so added this line in .bashrc file. YOu will have to open new terminal to get this PATH effective.
Code: [Select]
PATH=$PATH:/cygdrive/c/avr8-gnu-toolchain/bin


YOu can ignore this warn or just install dfu-programmer and add its path too.
Quote
sh: dfu-programmer: command not found
sh: dfu-programmer: command not found


I added the line to every .bashrc file I could find in Cygwin's directories (good ol` shotgun approach); well in my case I made it avr32 because that is what I have, which now makes me wonder if I got the wrong software.  I still get the same errors as before.  Is it simply a matter of adding the line
Code: [Select]
PATH=$PATH:/cygdrive/c/avr8-gnu-toolchain/bin
to the end of the .bashrc file (and which one should I be editing?) or does it have to be in a certain place or preceded by a special character of some kind; opening the file with notepad doesn't seem to display it exactly right and I can't tell what is commented out and what is not. 
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sun, 14 February 2016, 18:02:44
Use avr8 instead of avr32 because MCU on this controller is 8bit chip. (I had to add this clearly on document.)

Yes, you can just add the line to end of .bashrc file located in your home directory. To add just run this two commands line by line. You need this just once.

Code: [Select]
cd
echo 'PATH=$PATH:/cygdrive/c/avr8-gnu-toolchain/bin' >> .bashrc
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Sun, 14 February 2016, 22:51:38
I must be a total idiot when it comes to this.  I got rid of the 32-bit toolchain and replaced it with the 8-bit toolchain.  I changed all the references in .bashrc files from 32-bit to 8.  I still get the same errors:

$ make -f Makefile.tmk_rev2
sh: dfu-programmer: command not found
sh: dfu-programmer: command not found

-------- begin --------
sh: avr-gcc: command not found
../../tmk_core/rules.mk:406: recipe for target 'gccversion' failed
make: *** [gccversion] Error 127

I am terribly confused by this. 

EDIT: Progress has been made.  As I suspected, this is a problem to do with Windows and Cygwin keeping relevant files in different places.  I found that windows keeps PATH variables in a window off of the advanced system settings menu under "System" in the control panel.  There is a button, "Environmental variables", to which Flip had already written a PATH entry. 
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Sun, 14 February 2016, 23:44:10
One more update; I got it all working except that my keymap was somehow messed up and it seems like my changes weren't applied correctly.  I got it back to default with the file from earlier in the thread, though, so the programming is going smoothly, I just somehow goofed up the actual keymap, because keys I didn't change were working (all of the alpha keys, for example), but others seemed to be shifted around.  Also worth noting is that the keymap it came with seems to differ slightly from the one in the source files; I left mappings I was OK with alone, and discovered that the top-left key came mapped to ESC but in the source file it is defined as ` (grave accent/tilde).  This shouldn't be too hard to overcome, though.  Thanks again to Hasu for all the help and for offering an excellent product to begin with!
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Tue, 16 February 2016, 16:24:51
Well, I'm having another problem.  Hopefully this one will be easier than the last to sort out.  I still cannot get the keymap to program correctly.  Here is the real strange thing:  I thought, perhaps I have put some incorrect data into the keymap, and this is why it is functioning strangely.  So I re-downloaded the source file, and, without editing anything, created the hex file with Cygwin, and loaded it with Flip.  It still did not program correctly.  Most of the second and third row of keys (asdf... zxcv...) work, but the first row and the number row do not work as expected.  "1" instead types "0", some keys don't seem to send anything at all.  More curiously, when I did change the programming of the keymap, some of the keys actually stayed the same: for instance the keys in the keyboard's numpad, which are assigned to the arrow keys by default, were still working as arrow keys even though I changed their mapping to be numpad numbers.  Changing the numlock state on the PS/2 keyboard plugged into the system (via a regular old PS/2 port) didn't change anything in regards to those keys. 
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 16 February 2016, 18:11:48
Hmm, I think you are compiling wrong keymap file. I assume your keyboard is 102-key Alps, so you have to use and edit keymap_alps102key.c. To compile with the keymap file use following commands.

Code: [Select]
$ make -f Makefile.tmk_rev2 KEYMAP=alps102key clean
$ make -f Makefile.tmk_rev2 KEYMAP=alps102key


What's your os? how to handle numlock state depends on OS implementation, I think.
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Tue, 16 February 2016, 18:28:28
Hmm, I think you are compiling wrong keymap file. I assume your keyboard is 102-key Alps, so you have to use and edit keymap_alps102key.c. To compile with the keymap file use following commands.

Code: [Select]
$ make -f Makefile.tmk_rev2 KEYMAP=alps102key clean
$ make -f Makefile.tmk_rev2 KEYMAP=alps102key


What's your os? how to handle numlock state depends on OS implementation, I think.

This looks like it'll do the trick.  I'm busy tonight for a while but I'll try it when I get back in.  My OS is Windows 7.  I never use numlock functionality and am perfectly content to leave it to the board plugged into the PS/2 port, but don't mind learning how to do it as I have other oddball keyboards around and am always looking for new ones.  Also, of the commands listed in the keycode.h file, will they all do something meaningful on Windows?  For instance, KC_CLEAR, KC_PRIOR, KC_OUT, KC_OPER?  Do the FN* codes do something different to the regular F* codes?  Any idea how to make the Three Zeroes key actually type three zeroes?
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 16 February 2016, 20:27:57
I have Windows10 on Thinkpad which has interanal PS/2 keyboard and confirmed the internal keyboard and my HHKB with tmk_keyboard share capslock sate in sync. Not sure about numlock but guess same as capslock.

Windows doesn't recognize all keycodes, some is only for Mac or Unix and usage of some codes are unknown in general. You can see pp53 of this doc for the detail. I guess those keys cannot be used unless you use tools like autohotkey.
http://www.usb.org/developers/hidpage/Hut1_12v2.pdf

You can register '000' with macro in TMK but no good documentation unfortunately. You will have find examples in repository and read source code.
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Wed, 17 February 2016, 02:28:41
Just posting quickly to say that it's working perfectly now.  I've got the programming of the keymap all squared away and I can upload it successfully to the microcontroller.  My next task is to make some legends for the relengendable keys. 
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Wed, 17 February 2016, 02:34:26
Just posting quickly to say that it's working perfectly now.  I've got the programming of the keymap all squared away and I can upload it successfully to the microcontroller.  My next task is to make some legends for the relengendable keys. 

Great to hear that. Enjoy! ;D
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Fri, 19 February 2016, 15:22:23
Well I'm back with a strange problem (Hasu, it doesn't seem to be with your software!); the key one row up from the bottom-right corner of the board (has no legend by default, default programming is F16) doesn't seem to work.  It beeps like all the others on the keyboard, but I programmed it to Page Up, and it doesn't work.  I've tried changing the programming of that key and it doesn't want to send a plain "up" code either, so I'm just confused here.  I've tried re-plugging the USB, which fixes it when other keys decide to stop working at random (yesterday it was "4", and just as I was typing this it was Comma (whose programming I didn't change at all), but that doesn't change anything.  It's just that one key, so it's not a huge problem, but perhaps its something unforeseen with these keyboards, or perhaps mine is faulty?
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 19 February 2016, 16:53:50
I updated for the "F16" key try the latest repo. scan code of the key was not handled in matrix.c.
https://github.com/tmk/tmk_keyboard/commit/75ca495c010621699866a042e6a85061280177a7

I think this fixes "F16" key but not sure other problems. You can see some debug info with hid_listen, it may help you.
https://www.pjrc.com/teensy/hid_listen.html
Title: Re: IBM 4704 Keyboard Converter
Post by: Red October on Fri, 19 February 2016, 17:27:47
I updated for the "F16" key try the latest repo. scan code of the key was not handled in matrix.c.
https://github.com/tmk/tmk_keyboard/commit/75ca495c010621699866a042e6a85061280177a7

I think this fixes "F16" key but not sure other problems. You can see some debug info with hid_listen, it may help you.
https://www.pjrc.com/teensy/hid_listen.html

One more compile-flash sequence and it's working!  Hasu, you are honorable and friendly! 
Title: Re: IBM 4704 Keyboard Converter
Post by: __red__ on Sun, 28 February 2016, 16:21:45
Yes he is <3
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Thu, 17 March 2016, 23:35:58
I could installed converter inside case using 0.1"(2.54mm)pitch 10pin(2x5) female socket to connect  with a bit filing.
(http://i.imgur.com/ptQv6p0.jpg?1)

Original socket is 14pin(2x7) but  you will be able to use 10pin with flatcable available normally in store by a bit filing.

Code: [Select]
Femal socket connector
2x7            2x5
|xRxWKYx|      |RxWKY|
|xxxxxxx|      |xxxxx|
x = no connection
R = red wire/VCC
W = white wire/GND
K = black/DATA
Y = yellow/CLOCK

(http://i.imgur.com/C1UACtoh.jpg)

EDIT: [ad] I'm offering assembly service here :D [/ad]
https://geekhack.org/index.php?topic=72052.0
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 06 May 2016, 22:14:44
I designed Dsub 9pin adapter PCB for my TMK converter, IBM4704 converter looks like this now.
(http://i.imgur.com/xLhm8aSh.jpg)

PCB design files of the adapter PCB is available here:
https://github.com/tmk/keyboard_converter_adapter_ibm4704
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 30 September 2016, 06:47:30
I added Online Keymap Editor support for IBM4704 converter.

http://www.tmk-kbd.com/tmk_keyboard/editor/

Enjoy!
Title: Re: IBM 4704 Keyboard Converter
Post by: lemur on Wed, 23 November 2016, 19:07:19
Hey folks!

I recently got two of the Alps switch IBM boards this converter/firmware works with...

For one of the keyboards I've already ordered a controller made by hasu to use with it.

For the 2nd keyboard I'd like to start learning some things I've not yet learned, such as some basic electronics stuff, like soldering, using a breadboard, etc..

If I am reading the docs hasu has nicely provided to us correctly, I am wondering the following:

If I had a teensy 2.0 with pins already in it, a breadboard, maybe some wiring, and some wire strippers/cutters, I should be able to use this firmware to get a converter to work by connecting the wires coming from the keyboard to the proper pin locations on a teensy mentioned in the 'Connection' section of the page below without any other components needed ?

https://github.com/tmk/tmk_keyboard/tree/master/converter/ibm4704_usb

for example.. run the proper wires from the keyboard cable and connect them via soldering or breadboard to the 4 pins mentioned in the docs to a teensy 2.0 (vcc, gnd, pd0, pd1) without needing extra components such as resistors or anything?

I am already familiar with building and loading firmware onto a ATMega32U2 based board (bpiphany frosty flake), so that is well understood how it works.

If I do need other components to make this work, such as resistors or anything else, that's fine, more stuff to learn, but as for right now I'm just looking to get started with this first project and want to be sure I have everything I need.

Thanks!
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Thu, 24 November 2016, 11:18:51
I think you understand it correctly. Do it! :) Pull up resistors are recommended btw.

Tapatalk を使用して私の Nexus 5X から送信

Title: Re: IBM 4704 Keyboard Converter
Post by: lemur on Thu, 24 November 2016, 12:40:11
Great, thanks for the reply!

Another thing to be sure I'm understanding the basics..

Am I looking for a result like this diagram where A and B would be the Data and Clock and R the 1kohm resistors..... and 5v is from the VCC?

[attachimg=1]
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Thu, 24 November 2016, 12:46:57
Yes, the diagram is correct and I use 1KOhm.
Title: Re: IBM 4704 Keyboard Converter
Post by: lemur on Thu, 24 November 2016, 22:40:32
thanks again, hasu.

also..

As reference, this is what the internal cable connector on the Alps 6341739 Chinese 102-key version looks like.

I cannot speak to what the other Alps variants look like inside but it does seem that the internal converter shown elsewhere in the thread is not compatible with the Alps switch models due to a different internal connection.

I am not sure if that information is already known or not, but now it is at least in one place!

[attachimg=1]
Title: Re: IBM 4704 Keyboard Converter
Post by: lemur on Tue, 29 November 2016, 15:50:58
yay I got it working.

thanks for the tiny encouragement to "do it", hasu, and the great work at working on the converter for this thing.

Only had one problem and it was my own fault... was telling it to use the wrong atmega device in the makefile.. fixed it all up and worked the first time.

man does it beep!  i am glad it has a volume knob.

now i just need to learn to solder and figure out whether or not i will be putting it inside the board, or outside.

fun times!

[attachimg=1]
Title: Re: IBM 4704 Keyboard Converter
Post by: Ail on Mon, 19 December 2016, 19:42:40
I'm officially lost and confused, my brain doesn't work the way it did when I was 18 I guess. My converter arrived today and I used Bash on Ubuntu Windows to make the firmware, now I tried to go in to Flip and load the hexfile for the keymap, and I get the .dll error when trying to set the connection to USB. Okay no big deal I just install the .dll manually, except for one problem, my device doesn't show up in the device manager as ATmega32U2. It doesn't show up at all. What am I forgetting? The keyboard is plugged in. I tried pressing the button on the converter, clearly I have forgotten something. I ran make for the rev2 make file and that all seemed to work fine.

Edit: Seems I never got the install new hardware wizard for the chip, like it will not go in to bootloader or something?

Edit 2: False alarm I got it working, it was my micro USB cable.

LOL how do I turn off this god awful beeping noise, hahahah. This is awesome and terrible all at once.

Edit 3: Nevermind it has a volume wheel, whew that was scary for a few minutes there.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 19 December 2016, 23:45:55
I'm officially lost and confused, my brain doesn't work the way it did when I was 18 I guess. My converter arrived today and I used Bash on Ubuntu Windows to make the firmware, now I tried to go in to Flip and load the hexfile for the keymap, and I get the .dll error when trying to set the connection to USB. Okay no big deal I just install the .dll manually, except for one problem, my device doesn't show up in the device manager as ATmega32U2. It doesn't show up at all. What am I forgetting? The keyboard is plugged in. I tried pressing the button on the converter, clearly I have forgotten something. I ran make for the rev2 make file and that all seemed to work fine.

I heard from you via PM that you already resolved it yourself, so this is just future reference.

Just plugin the converter and press the button, bootloader should come up on your computer. Its name on device manager should be  'ATmega32U2' and located under 'LibUSB-Win32Devices' node, If you don't see the device you will have to re-install driver.

https://github.com/tmk/tmk_keyboard/wiki/Driver-install-on-Windows




Title: Re: IBM 4704 Keyboard Converter
Post by: seantingwong on Tue, 31 January 2017, 22:23:11
After reading through your documentation, I'm still confused on how create custom a custom Unimap. I have the 6341739 model. I am mostly confused about making a custom layout, figuring out layers, and macros.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 31 January 2017, 23:03:24
After reading through your documentation, I'm still confused on how create custom a custom Unimap. I have the 6341739 model. I am mostly confused about making a custom layout, figuring out layers, and macros.

No documentation for unimap yet, and it is mainly useful to make fimware binary for online keymap editor.   
You can use keymap_alps102key.c instead if unimap doesn't work for you. It is documented better.
Title: Re: IBM 4704 Keyboard Converter
Post by: seantingwong on Wed, 01 February 2017, 00:39:08
How do you get keymap to work with the teensy? I tried it a compiling it with the Makefile prompt but after flashing it to the teensy, my computer isn't registering keypresses even when I use the hid_listener?
Title: Re: IBM 4704 Keyboard Converter
Post by: seantingwong on Wed, 01 February 2017, 01:20:34
Nevermind, i got it figured out. My pull up resistor came loose. I flashed my keymap using Makefile.rev1 and it worked!
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Thu, 27 April 2017, 18:29:05
Added note for audible clicker in first post.

Quote
NOTE
Audible Clicker
The converter doesn't control the clicker/speaker.
- With Alps models the converter cannot control clicker at all but you can change sound volume with dial on bottom.
- With capacitive models the converter can control/use the clicker theoretically but doesn't support. You will hear beep while startup after plugin but no clicker at all when typing.
Title: Re: IBM 4704 Keyboard Converter
Post by: alh84001 on Fri, 23 June 2017, 03:46:30
Are pull-ups necessary for F107?

I got a F107 which came with xwhatsit already installed, and loose original controller. I decided to take out the xwhatsit and put the original controller back in. I used a Pro Micro to make a converter, but I don't get anything out of it. Perhaps original controller is not working, but I'm looking at what else can be at fault. I built the firmware with
Code: [Select]
make -f Makefile.rev1 and I wired the data line to PD2 and made a corresponding change in config.h.

P.S. Regarding buzzer, I thought it was under control of the controller, and converter had nothing to do with it.


Edit: I added 1k pull-ups but it's still not working :/
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sun, 25 June 2017, 05:58:10
Yes, you need pull up resisters in fact. Buzzer should stop after converter initializes.
Title: Re: IBM 4704 Keyboard Converter
Post by: Wingklip on Sun, 23 July 2017, 17:38:40
The buzzer on my 6113442 works perfectly fine after the initialisation stage

The only issue is that it does not have NKRO? Is that a controller limitation? Does it exist on your adb controller too?

Just some questions I would like to ask :)
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 24 July 2017, 01:05:58
The buzzer on my 6113442 works perfectly fine after the initialisation stage

The only issue is that it does not have NKRO? Is that a controller limitation? Does it exist on your adb controller too?

Just some questions I would like to ask :)

Are you sure your keyboard is ghost free?
Both TMK firmware and 4704 protocol itself support NKRO. I know that with Capacitive switch models you can do NKRO.


Seeing pics of its pcb it seems to be 2KRO because it doesn't have diodes. shame :(
https://deskthority.net/workshop-f7/p77-the-tkl-pingmaster-t16419.html#p368463
Title: Re: IBM 4704 Keyboard Converter
Post by: Daniel Beardsmore on Mon, 24 July 2017, 02:13:36
Are you sure? It looks to me like it has diodes.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 24 July 2017, 02:22:38
Are you sure? It looks to me like it has diodes.

Not sure. Did you trace some routes on pcb?
I don't have time to trace pcb, it seems to me they are jumpers at a glance. I may be wrong.
Title: Re: IBM 4704 Keyboard Converter
Post by: Daniel Beardsmore on Mon, 24 July 2017, 02:28:12
You'd never have that many jumpers (the one-per-switch regularity is a strong indicator of diodes, and that's a very Alps-like diode arrangement), and there are photos on the same page showing components that appear to be diodes.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 24 July 2017, 02:46:52
ah you are right. other post has pic of to side of PCB which displays diodes.

Alps models can support Nkro.
Title: Re: IBM 4704 Keyboard Converter
Post by: alh84001 on Tue, 03 October 2017, 16:09:49
Hasu, any idea how I could test if my F107 OG controller is working?

I actually have two controllers, but I had no luck with getting either one to work with my self-made converters (first pro micro one, then teensy one, both with pull-up resistors).

I'm at my wits ends, so I guess I'll just need to get a pingmaster so I could test that at least converters are working.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 03 October 2017, 18:31:54
Hasu, any idea how I could test if my F107 OG controller is working?

I actually have two controllers, but I had no luck with getting either one to work with my self-made converters (first pro micro one, then teensy one, both with pull-up resistors).

I'm at my wits ends, so I guess I'll just need to get a pingmaster so I could test that at least converters are working.

Hmm, I think it should work, though I don't have 107-key model.
Why don't you buy my TMK converter instead of the keyboard ? :D
https://geekhack.org/index.php?topic=72052.0

EDIT: Wait, what is "F107 OG controller"?
Title: Re: IBM 4704 Keyboard Converter
Post by: alh84001 on Tue, 03 October 2017, 19:26:18
It's a controller that came with my F107. When that one didn't work, I got another one from orihalcon, which I tried today, with the same result.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 03 October 2017, 19:36:47
ah, OG means original, TIL. Urban dictionary is always good reference. We usually use it as "old girls" here in Japan :facepalm:
http://www.urbandictionary.com/define.php?term=OG
https://japanese.stackexchange.com/questions/6778/what-do-the-words-og-and-ob-mean

Title: Re: IBM 4704 Keyboard Converter
Post by: alh84001 on Tue, 03 October 2017, 19:41:56
Well, F107 is definitely an old girl, so it even made some sense :)
Title: Re: IBM 4704 Keyboard Converter
Post by: rich1051414 on Thu, 25 January 2018, 07:01:33
Thanks man, works great!

I ended up just unscrewing the end cap on the Serial connector, gutting it, and putting the pro-micro inside, didn't even have to open the keyboard and preserved it's originality as much as possible, best of both worlds. However, how anyone can deal with the clicker turned on is beyond me... Thank god there is a volume wheel on it :D
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 27 April 2018, 03:37:13
Added IBM4704 50-key(6019273) support on keymap editor.

http://www.tmk-kbd.com/tmk_keyboard/editor/
https://goo.gl/95HRna
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sun, 15 July 2018, 17:36:23
Thank you, Soarer. I'll fix my document later.


And...
For those who are interested, my converter has some limitations:
1. Keyboard(6019284) has only *3-byte* key buffer.
2. Keyboard has same scancode on both Alt key. You can't use different scancodes on those.
3. My converter is naively *polling* at not so fast speed.
Due to 1. and 3. you probably will see missing keys and transposing keys at very fast typing.(my wpm is less than 60 and I don't have a problem) To solve or mitigate this problem we can use *interrupt* method instead of polling.

Replacing controller board doesn't have these limitations. It is still very intriguig option to squeeze every last drop of its power out of this keyboard.

Some user asked me about this post and "polling" rate issue, so I'll answer it here.

This post describes issue of the converter firmware in initial development at that time.
Current firmware implementation uses "interrupt" and there are no longer slow "polling" issue.  Neither transposing nor droping key problem should happen with the current converter firmware any more.

So, you have to notice that 2. is only limitation at this time, which is exactly keyboard limitation decided by IBM and the converter cannot solve this.
Title: Re: IBM 4704 Keyboard Converter
Post by: jeff_c on Tue, 17 July 2018, 01:56:22
ah you are right. other post has pic of to side of PCB which displays diodes.

Alps models can support Nkro.

I read about how the alps 4704 boards can support NKRO, but I only get 2-key rollover with my keyboard connected to the Hasu controller. Is that a result of buffer limitation on my particular 4704? The model number for my board is 5954339

In other words, should I expect the magic key function to enable NKRO to work on this converter like it does on the HHKB alternate controller?
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 20 July 2018, 17:30:51
ah you are right. other post has pic of to side of PCB which displays diodes.

Alps models can support Nkro.

I read about how the alps 4704 boards can support NKRO, but I only get 2-key rollover with my keyboard connected to the Hasu controller. Is that a result of buffer limitation on my particular 4704? The model number for my board is 5954339

In other words, should I expect the magic key function to enable NKRO to work on this converter like it does on the HHKB alternate controller?

I saw diodes in pics on this post so I thought the Alps model should be NKRO if its keyboard firmware supoorts it. I don't see reason it doesn't support, but NKRO depends totally on the 4704 Alps firmware implementation.
https://deskthority.net/workshop-f7/p77-the-tkl-pingmaster-t16419.html#p368597

This converter supports 6KRO on USB by default you can send up to 6 keys plus modifiers if you keyboard supports NKRO. No converter limitation there.
(If you need NKRO on USB you can configure and build firmware yourself, but it is not your problem in this case.)

If you get only 2 keys with this converter your keyboard is 2KRO.
Title: Re: IBM 4704 Keyboard Converter
Post by: laxfan91 on Sun, 26 August 2018, 01:09:38
For the alps board, what is the fn key mapped to in the default firmware in your converter? I`m curious.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Sun, 26 August 2018, 01:21:52
Right bottom key of main alpha part. See keymap editor, L1 means the key turns layer 1 on.



Sent from my WAS-LX2J using Tapatalk

Title: Re: IBM 4704 Keyboard Converter
Post by: kankurou1010 on Tue, 11 September 2018, 18:03:47
Hey so I bought your converter and I'm using it on the 6112883 Japanese 102-key. However, I'm a total noob and I don't know what to do  :confused:
How do I get the keyboard to be able to type? I plug it in and it beeps but I can't type on it. Thanks.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 11 September 2018, 19:51:09
Hey so I bought your converter and I'm using it on the 6112883 Japanese 102-key. However, I'm a total noob and I don't know what to do  :confused:
How do I get the keyboard to be able to type? I plug it in and it beeps but I can't type on it. Thanks.


I think the converter should work with it out of the box. It is programmed with default firmware when shipped.
DId you try other port or computer? What are your OS?

Use hid_listen to see debug info and could you post it here?
https://github.com/tmk/tmk_keyboard/wiki#debug
Title: Re: IBM 4704 Keyboard Converter
Post by: kankurou1010 on Wed, 12 September 2018, 01:26:49

I think the converter should work with it out of the box. It is programmed with default firmware when shipped.
DId you try other port or computer? What are your OS?

Use hid_listen to see debug info and could you post it here?
https://github.com/tmk/tmk_keyboard/wiki#debug

So turns out it was because I was using a crappy micro usb cable. Plugged in a different one and now it works. However, some keys aren't typing letters, such as: d s q w z x c. hid_listen is picking them up though. How do I get those to work? I don't understand how to use the tmk editor... I tried both "alps 102 key" editors, but I don't get what I'm supposed to be doing. OS is windows 10 btw.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Wed, 12 September 2018, 01:52:18

I think the converter should work with it out of the box. It is programmed with default firmware when shipped.
DId you try other port or computer? What are your OS?

Use hid_listen to see debug info and could you post it here?
https://github.com/tmk/tmk_keyboard/wiki#debug

So turns out it was because I was using a crappy micro usb cable. Plugged in a different one and now it works. However, some keys aren't typing letters, such as: d s q w z x c. hid_listen is picking them up though. How do I get those to work? I don't understand how to use the tmk editor... I tried both "alps 102 key" editors, but I don't get what I'm supposed to be doing. OS is windows 10 btw.

OK. yeah, reliable usb cable is a must have.
Try to download firmware from this page without any change and flash it. I guess you flashed wrong firmware.
http://www.tmk-kbd.com/tmk_keyboard/editor/unimap/?ibm4704_usb_alps
Title: Re: IBM 4704 Keyboard Converter
Post by: kankurou1010 on Wed, 12 September 2018, 02:58:12
Am I doing this right? Open page, download "Firmware Hex File Download," select file under "Base Firmware File:" select the downloaded hex, then press "Load Keymap from firmware"?


Didn't fix it. Now, some of the keys that were working aren't.  :confused:
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Wed, 12 September 2018, 08:57:11
Am I doing this right? Open page, download "Firmware Hex File Download," select file under "Base Firmware File:" select the downloaded hex, then press "Load Keymap from firmware"?


Didn't fix it. Now, some of the keys that were working aren't.  :confused:


Open the link and just click 'Download' button without touching anything to download default firmware.
Title: Re: IBM 4704 Keyboard Converter
Post by: kankurou1010 on Wed, 12 September 2018, 14:33:17
Am I doing this right? Open page, download "Firmware Hex File Download," select file under "Base Firmware File:" select the downloaded hex, then press "Load Keymap from firmware"?


Didn't fix it. Now, some of the keys that were working aren't.  :confused:


Open the link and just click 'Download' button without touching anything to download default firmware.

Got it. All is working. Thanks for the help!  :thumb:
Title: Re: IBM 4704 Keyboard Converter
Post by: fr08 on Mon, 08 October 2018, 13:36:42
I'm having a weird issue, been using a Pingmaster (6112883) with this controller for like a week without any problems. In fact it was much easier than I thought.

But earlier today my up, down, left and right keys started outputting 8, 2, 4 and 6 instead. I've tried reflashing multiple times, even with old .hex files and with the "preset" that's on http://www.tmk-kbd.com/tmk_keyboard/editor/unimap/?ibm4704_usb_alps

But nothing changes. Even if I put "no" on those keys, they still gives me 8, 2, 4 and 6.

What could be wrong? Have I messed up somehow? :(
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Mon, 08 October 2018, 17:22:14
If you are using TMK preassebled covnerter URL you linked is correct and it should work.
Open browser with the URL and try reloading the page again before download firmware without editing.

I guess you flashed wrong firmware which is for IBM Capacitive models.
Title: Re: IBM 4704 Keyboard Converter
Post by: N6NG on Tue, 30 October 2018, 16:29:36
Hi
I had been using this converter on the IBM 6113442 for many months with a slightly edited version of the default Alps 102 key firmware until recently, when the keyboard suddenly stopped working. No key presses register and the beeper doesn't work.
Here is the readout from hidlisten:
Code: [Select]
Waiting for device:
Listening:
Keyboard ID: FF
Enable break: S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48 S:48
etc.
It simply repeats S:48 until I unplug it.
I tried reflashing my firmware and then tried flashing the original firmware, all to no avail.
I am completely lost  :confused:
Any help is appreciated, thanks!
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 30 October 2018, 17:10:09
Seeing the log(Keyboard ID: FF) the converter restarts? and doesn't recognize keyboard at all.
I guess connecton/power was lost  temporalily for some reason? Check USB cable or keyboard cable.

Do you have hid_listen log lines before the ones you post?
I'm curious what hid_listen speaks just when the problem occurs.

I'm thinking this is related to your hardware(converter, keyboard  or cables) at this time because I haven't heard here this problem from any other users so far.
Does anyone here have similar problem to this?
Title: Re: IBM 4704 Keyboard Converter
Post by: N6NG on Tue, 30 October 2018, 17:56:46
I thought it might be the cable, so I tried multiple USB cables and tried unplugging and plugging everything in again earlier, all with the same results.
Unfortunately, I don't have any log lines from before this. I don't have any from when it was working and this is the first thing that happens when I plug it in.
Is there any way if I could test whether it's the keyboard itself?
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 30 October 2018, 19:28:25
I thought it might be the cable, so I tried multiple USB cables and tried unplugging and plugging everything in again earlier, all with the same results.
Unfortunately, I don't have any log lines from before this. I don't have any from when it was working and this is the first thing that happens when I plug it in.
Is there any way if I could test whether it's the keyboard itself?



Wait, it seems I misread this probably due to my weak language skills.
I thought wrongly: you can type on keyboard usually but it suddenly stops sometime and you have had this problem for months.

Quote
I had been using this converter on the IBM 6113442 for many months with a slightly edited version of the default Alps 102 key firmware until recently, when the keyboard suddenly stopped working. No key presses register and the beeper doesn't work.


After I read several times I think I got it. Your converter and keyboard stoped recently and they don't work at all at this time, right? If so, yes, keyboard cable/connector is primary suspect in addition to connector on converter. And USB cable is not the cause here because the converter can communicate with hid_listen program.

If you have DMM you can do continuity test with the keyboard cable.
Title: Re: IBM 4704 Keyboard Converter
Post by: N6NG on Tue, 30 October 2018, 21:31:18
Yes, that is correct, there is has been no response whatsoever from the keyboard since that point.
That's a good idea, I actually don't own a multimeter, but I will see if I can buy or borrow one.
Thanks!
Title: Re: IBM 4704 Keyboard Converter
Post by: fcoury on Tue, 20 November 2018, 18:56:33
Is the converter TMK hex supposed to work on a Pro Micro? I have flashed the hex and have it wired like this:

(https://i.imgur.com/tcvVjSs.jpg)

(https://i.imgur.com/fd8ndZx.jpg)

But it doesn't seem to be working. Did I get this all wrong?

Thanks!
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Tue, 20 November 2018, 20:03:27
I think HEX file should be used on Pro Micro. I don't know its pinout. Check Pro Micro schematics, github README and the first post for wiring again and take time for trials and errors. You won't break your keyboard even if you connect wires wrongly unless you are extremly unlucky.

https://github.com/tmk/tmk_keyboard/tree/master/converter/ibm4704_usb

EDIT: I hope someone can help.
Title: Re: IBM 4704 Keyboard Converter
Post by: fcoury on Wed, 05 December 2018, 21:17:52
Thank you so much hasu! I not only made it work, but ended up creating a video tutorial if anyone else wants to do it:


Hopefully this will help others :)
Title: Re: IBM 4704 Keyboard Converter
Post by: ErgoMacros on Thu, 06 December 2018, 14:21:15
Nice video! Makes the whole thing seem so accessible. (Easy to do.)

I haven't done this myself (yet), but have 2, purely aesthetic, suggestions.
  a. You may be able to make the wires shorter, and
  b. you could run them all through one piece of heat-shrink tubing.

Hope you're enjoying your new keyboard! and thank you.
Title: Re: IBM 4704 Keyboard Converter
Post by: rezene on Tue, 30 April 2019, 17:56:41
I have made a converter for the pingmaster and watched fcoury's video about it + talked to him on discord. He has looked everything over and can not see any thing wrong with it. The controller gets flashed and the computer recognizes it as a 4704 converter, but when I try typing on it nothing happens. this has some images I can add more if needed https://imgur.com/a/1C8IEl8
Title: Re: IBM 4704 Keyboard Converter
Post by: karlmartin95 on Wed, 10 July 2019, 22:11:01
I need help with my F77, the keyboard works good with an Arduino Pro Micro but I can't hear the beeps. I only hear one beep when I connect the keyboard to the computer but nothing more.

Please, I want to make the beeper work. I moved the knob to both sides but nothing...

What can I do? We should find the way to send the command from the Arduino to the logic board in order to get a beep in every key press.

This is my baby, recently restored:
(https://i.imgur.com/d6Z2VNP.jpg)
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Wed, 10 July 2019, 23:15:49
As first post says, current firmware doesn't support the beeper/buzzer on 'capacitive switch models'. I'm just not interested in enabling beeper on my keyboard usually and I haven't look into the feature back in the day.

I think you can emit a shot beep with sending command 0xFC to keyboard.

ibm4704_send() can be used to send the command. You can check its code here but you won't change this.
https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/protocol/ibm4704.c#L49

You may want to add it here to emit a beep on every key press.
https://github.com/tmk/tmk_keyboard/blob/master/converter/ibm4704_usb/matrix.c#L103

Refer this for 4704 keyboard protocol and commands.
https://github.com/tmk/tmk_keyboard/blob/master/converter/ibm4704_usb/ibm4704.txt

Try it anyway and keep us updated!



By the way, the beep/buzzer on 'Alps switch(SKCC) models' are used by keyboard itself each key press automatically, not controlled by the converter. You can use its volume knob to remove tones from the beeper.
Title: Re: IBM 4704 Keyboard Converter
Post by: hasu on Fri, 12 July 2019, 02:01:52
I tried ibm4704_send(0xFD) on my Model 200 62-key and found it didn't work.
After tesing and debuging I could fix it and got annoying key clicks :p

More
Try this patch.

Code: [Select]
diff --git a/converter/ibm4704_usb/matrix.c b/converter/ibm4704_usb/matrix.c
index acba17dc..648c1ff4 100644
--- a/converter/ibm4704_usb/matrix.c
+++ b/converter/ibm4704_usb/matrix.c
@@ -102,6 +102,7 @@ uint8_t matrix_scan(void)
     } else if (code&0x80) {
         dprintf("%02X\n", code);
         matrix_make(code);
+        ibm4704_send(0xFD);
     } else {
         dprintf("%02X\n", code);
         matrix_break(code);
diff --git a/tmk_core/protocol/ibm4704.c b/tmk_core/protocol/ibm4704.c
index 6a03cd44..75e7db12 100644
--- a/tmk_core/protocol/ibm4704.c
+++ b/tmk_core/protocol/ibm4704.c
@@ -39,7 +39,7 @@ Data    ____|__/    X____X____X____X____X____X____X____X____X____X   \___
             |  Start   0    1    2    3    4    5    6    7    P   Stop
             Request by host
 
-Start bit:  can be long as 300-350us.
+Start bit:  can be long as 300-350us during start up and upto 2500us while key scanning
 Request:    Host pulls Clock line down to request to send a command.
 Timing:     After Request keyboard pull up Data and down Clock line to low for start bit.
             After request host release Clock line once Data line becomes hi.
@@ -58,7 +58,7 @@ uint8_t ibm4704_send(uint8_t data)
     clock_lo();
 
     /* wait for Start bit(Clock:lo/Data:hi) */
-    WAIT(data_hi, 300, 0x30);
+    WAIT(data_hi, 5000, 0x30);
 
     /* Data bit */
     for (uint8_t i = 0; i < 8; i++) {
@@ -89,7 +89,7 @@ uint8_t ibm4704_send(uint8_t data)
     return 0;
 ERROR:
     idle();
-    if (ibm4704_error > 0x30) {
+    if (ibm4704_error >= 0x30) {
         xprintf("S:%02X ", ibm4704_error);
     }
     IBM4704_INT_ON();


EDIT: Updated main repo. Just use new patch below to enable key click on IBM capacitive switch keyboards.
Code: [Select]
diff --git a/converter/ibm4704_usb/matrix.c b/converter/ibm4704_usb/matrix.c
index acba17dc..648c1ff4 100644
--- a/converter/ibm4704_usb/matrix.c
+++ b/converter/ibm4704_usb/matrix.c
@@ -102,6 +102,7 @@ uint8_t matrix_scan(void)
     } else if (code&0x80) {
         dprintf("%02X\n", code);
         matrix_make(code);
+        ibm4704_send(0xFD);
     } else {
         dprintf("%02X\n", code);
         matrix_break(code);
Title: Re: IBM 4704 Keyboard Converter
Post by: karlmartin95 on Sat, 13 July 2019, 00:57:18
Thank you very much Hasu! I'll try it and keep you in touch.