Author Topic: Macintosh M0110 USB converter  (Read 10379 times)

0 Members and 1 Guest are viewing this topic.

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« on: Wed, 14 December 2011, 00:43:53 »

This firmware converts the protocol of Apple Macintosh 128K/512K/Plus Keyboard M0110 and M0110A into USB. The retro keyboard can be revived conecting to mordern compter with this converter.




See also:https://github.com/tmk/tmk_keyboard/tree/master/converter/m0110_usb

Changes:
2012/05/26: M0110A is now supported. Thanks for your contribution, skagon!
2013/08: Change port for signals PF to PD
2013/09: Change port again, it uses inversely PD0 for data and PD1 for clock line now.





Keypad M0120 is also supported, even itself without M0110.



Build Hardware
You need 4P4C cable and ATMega32U4 board like Teensy. Port of the MCU PD1 is assigned to CLOCK line and PD0 to DATA by default, you can change pin configuration with editing config.h.


4P4C Plug:
You can find 4P4C plug as phone handset cable if you don't have Mac keyboard cable.
http://en.wikipedia.org/wiki/Modular_connector#4P4C
NOTE: Original cable used with Mac is straight while phone handset cable is crossover.

Socket pinout:
This is Mac side socket but same on keyboard side.
   

Cable colors:
Code: [Select]
    1(Black or Yellow):   GND
    2(Red or Green):     CLOCK
    3(Green or Red):   DATA
    4(Yellow or Black):  +5V
NOTE: phone handset cable is crossover so one end has different color assign(inversed) than the other end.

Close-up pics of handset cable. You can see one end of plug has reverse color codes against the other. Click to enlarge.



Pull-up resistor:
You are strongly recommended to have pull-up resistors on two signal lines though it might work well without them. In particular when you use long or coiled cable you probably need them.



Build Frimware
Optionally edit Makefile and config.h for build options, pin configuration or MCU.

$ git clone git://github.com/tmk/tmk_keyboard.git
$ cd converter/m0110_usb
$ make
and program your Teensy with loader.

Firmware Source: https://github.com/tmk/tmk_keyboard/tree/master


M0110 Protocol - technical resource
- https://github.com/tmk/tmk_keyboard/blob/master/protocol/m0110.c#L404-575
- https://github.com/tmk/tmk_keyboard/blob/master/protocol/m0110.c#L158-200

Technical Info for 128K/512K and Plus
    ftp://ftp.apple.asimov.net/pub/apple_II/documentation/macintosh/Mac%20Hardware%20Info%20-%20Mac%20128K.pdf
    ftp://ftp.apple.asimov.net/pub/apple_II/documentation/macintosh/Mac%20Hardware%20Info%20-%20Mac%20Plus.pdf
Protocol:
    Page 20 of Tech Info for 128K/512K
    http://www.mac.linux-m68k.org/devel/plushw.php
Connector:
    Page 20 of Tech Info for 128K/512K
    http://www.kbdbabel.org/conn/kbd_connector_macplus.png
Signaling:
    http://www.kbdbabel.org/signaling/kbd_signaling_mac.png
    http://typematic.blog.shinobi.jp/Entry/14/
Scan Codes:
    Page 22 of Tech Info for 128K/512K
    Page 07 of Tech Info for Plus
    http://m0115.web.fc2.com/m0110.jpg
    http://m0115.web.fc2.com/m0110a.jpg
« Last Edit: Sat, 21 September 2013, 09:03:37 by hasu »
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
pinout and connection
« Reply #1 on: Sat, 10 March 2012, 15:50:42 »
Hello.
I am jmk, a complete newbie here.
It is odd that I used to see many comments and discussions here, but suddenly they are all gone.
Anyway, inspired by hasu's mod of m0110, I also tried to do the mod in a slightly different but fundamentally the same way.
But I encountered a problem with figuring out pinout and connection between the keyboard and teensy.
I sent hasu a message, and he thinks it is better to discuss it publicly. So here is my question and hasu's answer.

I asked about the arrangement of the color of 4p4c because 4p4c is usually crossover-wired. So, for example, yellow can be either +5V or GND (to put is another way, it can be either #4, or #1)

Images below are the messages that I traded with hasu

[ Attachment Invalid Or Does Not Exist ] 43488[/ATTACH]
[ Attachment Invalid Or Does Not Exist ] 43489[/ATTACH]
[ Attachment Invalid Or Does Not Exist ] 43490[/ATTACH]

I hope this helps someone who has the same issue like me.

As I do the mod, I will post my questions and solutions.

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #2 on: Sat, 10 March 2012, 16:26:48 »
I have tried to hand-wire the keyboard and teensy without using handset cable.
Based on the information of kbdbabel, I connected keyboard and teensy (directly from keyboard pcb to teensy).
The result was not very good.
Here is the result:
[ Attachment Invalid Or Does Not Exist ] 43491[/ATTACH]

As I strike each key, each letter is typed twice as shown above. After "\" key stroke, the keyboard stopped working, and I disassemble what I did today so far and reverted the keyboard to its original condition.
As soon as I retrieve an handset cable next week, I will try the mod in the exactly the same way that hasu did and post the result.

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #3 on: Sat, 10 March 2012, 17:44:14 »
JMK, thanks for posting here again to share.

I tried the converter to test just now and it didn't register any keys at all without pull-up resistors.
Though I think it worked well without them last time, but it doesn't work today.

You might need to add two pull-up resistors on DATA and CLOCK lines in Teensy side in particular when you used long cable or coiled cable.
I used 1.5K Ohm resistors but 1K-10K will be OK.

Now I'm typing my M0110 through the converter with pull-up resistors. No problem.
My pull-up resistors is like this:
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
thanks
« Reply #4 on: Sat, 10 March 2012, 22:37:45 »
Thank you hasu
It seems like you plugged both ends of the resistors to clock/data and +5V. So clock and data ports have lines from the 4p4c connector cables and a leg of resistor, and +5V port has two legs of registers from data and clock as well as a line from the 4p4c connector cables.
I don't have resistors. So I think I will have to purchase a bunch of them on ebay or utilize some of the tiny little load resistors on an unused keyboard controller (mx8000, the switches and keycaps of which I used for another project.)
I will keep you updated on this thread.


Quote from: hasu;541592
JMK, thanks for posting here again to share.

I tried the converter to test just now and it didn't register any keys at all without pull-up resistors.
Though I think it worked well without them last time, but it doesn't work today.

You might need to add two pull-up resistors on DATA and CLOCK lines in Teensy side in particular when you used long cable or coiled cable.
I used 1.5K Ohm resistors but 1K-10K will be OK.

Now I'm typing my M0110 through the converter with pull-up resistors. No problem.
My pull-up resistors is like this:
Show Image

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #5 on: Fri, 23 March 2012, 10:09:54 »
Hello.
I finally received a bunch of resistors, and add two to teensy.
[ Attachment Invalid Or Does Not Exist ] 45395[/ATTACH]
[ Attachment Invalid Or Does Not Exist ] 45396[/ATTACH]


I tried two different ways, but it still doesn't work. Maybe, the cord that I use is too long?
Can you identify what problem I have?
It is more difficult that I thought. Thanks though. It is a fun process.
« Last Edit: Fri, 23 March 2012, 10:12:21 by JMK »

Offline JMK

  • Posts: 30
images
« Reply #6 on: Fri, 23 March 2012, 10:20:24 »
I don't know why the images that I uploaded do not appear properly.
Here are the images again. I hope this works.

[ Attachment Invalid Or Does Not Exist ] 45399[/ATTACH]
[ Attachment Invalid Or Does Not Exist ] 45398[/ATTACH]
« Last Edit: Fri, 23 March 2012, 10:31:33 by JMK »

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #7 on: Fri, 23 March 2012, 10:43:25 »
It looks OK.  Hmm, I can't see your problem.
Your RJ plug has same color order as this?  From left yellow, green, red and black.


And you can use PJRC's 'hid_listen' tool to see debug print. This may help you if Teensy already can receive any signal from M0110.
« Last Edit: Sat, 21 September 2013, 01:44:08 by hasu »
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #8 on: Fri, 23 March 2012, 10:48:23 »
Hi, thanks for the prompt response.
The connection is correct. I tested if the electricity flows to the keyboard's connection part.
I guess I need to see the debug print. Everything is new to me, and I don't know what exactly the "debug print" is, but I will just try.
Thanks again.

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #9 on: Fri, 23 March 2012, 11:46:47 »
I guess its over midnight in Japan.
Here is the screen shot of what I got from debug print.
I first did not get any result, and I checked out the connection again. Obviously, the connection was not stable.
Now I got the result that I got when I did not have pull up resistors. Multiple entires are typed at one key stroke.
[ Attachment Invalid Or Does Not Exist ] 45410[/ATTACH]

Any idea?

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #10 on: Fri, 23 March 2012, 11:51:31 »
Congrat!
It seems to be working well and sending keys to PC.
Did you try to just type on editor or other apps?

EDIT: Ah you mean you get two chars per one key press? It is Odd.
« Last Edit: Fri, 23 March 2012, 11:56:38 by hasu »
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #11 on: Fri, 23 March 2012, 15:00:20 »
It does not work properly yet. One of the problems that I had in the process was that the handset cable lines were very weak. They get cut off just too easily. So I had to remove the coat of each line several times. I will try to find a better way to connect the cord/resistor and teensy.

Offline JMK

  • Posts: 30
config.h
« Reply #12 on: Fri, 23 March 2012, 22:45:06 »
hello.
As I was working on teensy, I almost ruined the connecting holes. I tested them and confirmed that they are, strangely, still working, but I think I need a backup plan just in case.
[ Attachment Invalid Or Does Not Exist ] 45492[/ATTACH]

If I want to use the portion that marked in yellow rectangle to connect it with the cables, how should I modify your config.h?
The following is the original configuration:
#define M0110_CLOCK_PORT PORTF
#define M0110_CLOCK_PIN PINF
#define M0110_CLOCK_DDR DDRF
#define M0110_CLOCK_BIT 0
#define M0110_DATA_PORT PORTF
#define M0110_DATA_PIN PINF
#define M0110_DATA_DDR DDRF
#define M0110_DATA_BIT 1


IF I want to use D4 and D5 port along with GND and VCC on the same row, I guess...
#define M0110_CLOCK_PORT PORTD
#define M0110_CLOCK_PIN PIND
#define M0110_CLOCK_DDR DDRD
#define M0110_CLOCK_BIT 4
#define M0110_DATA_PORT PORTD
#define M0110_DATA_PIN PIND
#define M0110_DATA_DDR DDRD
#define M0110_DATA_BIT 5

will this be working?

Thank you again.

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #13 on: Fri, 23 March 2012, 22:59:53 »
You are  right.
It should work.
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #14 on: Sat, 24 March 2012, 15:15:40 »
Thanks.
Let me ask one more question.
Can cables be a problem?

[ Attachment Invalid Or Does Not Exist ] 45546[/ATTACH]

The cord that I use has the type of wire as seen the picture above. However I carefully strip the coat, I failed to strip it perfectly. So the inner fiber-like white thread is always exposed.
When I tried the mod, I just ignore the cable after I check that electric signals flows anyway.
Other than that, I don't know why my mod failed. It is really odd.

Currently, I just ordered 4p4c sockets and stripboards. I will try the mod without cutting the handset cord. Instead, I will solder the 4p4c socket and teensy on the stripboard, and wire them. This way, I can avoid ruining the cable, which I think is the problem of the failure, and probably I can make the mod a little more conveniently and neatly. Maybe I can later make a acrylic case.

Thanks hasu for your support.

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #15 on: Mon, 26 March 2012, 10:37:54 »
I don't know exactly your problem but the white thread can cause bad solder.

What did you see when you press keys on M0110? You got characters doubly? or got nothing?
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
another way
« Reply #16 on: Mon, 26 March 2012, 13:39:21 »
Hi.
The screenshot that I uploaded on 23 Mar 2012, 16:46, is actually the "debug print" if my understanding is correct.
I see multiple characters.
Here it is again.
[ Attachment Invalid Or Does Not Exist ] 45827[/ATTACH]

I am going to do the mod this way as seen in the sketch below. Parts were ordered, but it's going to take several weeks cause it's delivered from hongkong as economy mail.
[ Attachment Invalid Or Does Not Exist ] 45828[/ATTACH]

If you have any comment please let me know.

Offline JMK

  • Posts: 30
my firmware
« Reply #17 on: Fri, 30 March 2012, 23:42:26 »
[ Attachment Invalid Or Does Not Exist ] 46493[/ATTACH]
Hello hasu
I was wondering if you would test my firmware. I see no hardware problem, so I guess there may be a software problem.
I merely changed the keymap suitable for mac (command, L-Alt, and Fn2) and "make" the hex file.
But it was my first time and I am not sure if it is properly done.

I changed the extension of the file as txt to upload it, otherwise the file cannot be uploaded. So I guess you need to simply remove "txt" to make it hex file.
Thank you.
« Last Edit: Fri, 30 March 2012, 23:44:29 by JMK »

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #18 on: Sat, 31 March 2012, 07:23:28 »
JMK,
I tried your binary but it didn't work. Port D4 is for clock and D5 for data in your pin configuration, right?
I can't get any debug print on hid_listen when I pressed a key and don't know why.

You had better not edit codes except for config.h until it works well once.
Try this. This changes pin configuration only.
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #19 on: Sat, 31 March 2012, 17:28:45 »
I am sorry that I gave you misconception. I did not change config.h in my firmware yet. So the pinout is the same with your original code: F0 and F1 for clock and data respectively.
The only thing that I changed in the uploaded firmware here is the keymap.
Thank you for the hex file. I will try it with my next try.

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #20 on: Sat, 31 March 2012, 18:53:47 »
Ah, sorry.
I tried yours with F0 and F1, it works well and also your keymap seems to be OK.
No problem with my M0110. I think your binary should work on your M0110.

Let me know result when you put some parts together.
« Last Edit: Sat, 31 March 2012, 18:56:10 by hasu »
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #21 on: Sat, 31 March 2012, 21:58:27 »
If my firmware works for your m0110, maybe either my keyboard or teensy is the problem.
The parts arrive about ten days later. I will keep you updated.

Is there anyway that I can test my keyboard without the original Macintosh 128k/512k?

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #22 on: Sun, 01 April 2012, 09:16:31 »
Port on your Teensy can become out of order under severe conditions though this will not happen so often.
But still there is possibility of it, if you have suspect of it you can try some other ports by editing config.h.

I can't come up with  a way to test keyboard without Mac.
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #23 on: Sun, 01 April 2012, 15:58:48 »
When my parts arrive, I will just try one last time with the same port. If the same thing happens or the keyboard doesn't work at all, I will try other ports like D4 and D5.
Thank you.

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #24 on: Sun, 15 April 2012, 19:26:57 »
Looks like posts are removed with server incident so I re-post mine here:

JMK,
I found there are two different version of M0110 and they have different signal timing. Let's call them 'old' and 'new', this picture from lowpoly's mod article shows 'old' one at top and 'new' one at bottom.


At this time my firmware  seems to support only 'new' one and can't host 'old' one. Mine is 'new' one.
See this Github issue page for the detail: https://github.com/tmk/tmk_keyboard/issues/6
Github user skagon is working on support of 'old' M0110 and M0110A. It will be done before too long.

I guess your M0110 is 'old' and is not supported in my firmware. In fact which is yours?
I should let you know this before this, sorry. I think my code is problematic and not your M0110 probably.

I will check my M0110 PCB and look into your pic later.

Quote from: JMK
I tried the mod once more using your hex file, and it didn't work at all.
And I did "make" after modifying the config.h file once again and tried the mod again. Nothing happened.
So I opened the keyboard and tested the controller. Please see the image.

(Attachment Link)

As shown in the image, I tested the connection between "1" and the controller part, and I found its direct connection.
But the bx in yellow rectangle are all connected, probably short-circuit. Is it normal? If it's not, I think this is definitely the problem.
I checked some other pins of the controller, and there are more short-circuit.

I think I just need a new controller rather than a converter. Lowpoly's mod will my last option then.
Please let me know your thoughts.
Thanks.
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #25 on: Mon, 16 April 2012, 00:42:29 »
Oh! I see.
Mine is the old one.
Well, there seems to be a problem with geekhack, and I find that my last post was erased.

After I posted my last reply, I have been studying humble hacker's keyboard firmware to use it for my m0110 (old).
If "skagon" comes up with a solution sooner or later, I will just wait and see. But humble hacker's source code is very helpful to make a keyboard controller for other projects.
And don't be sorry for anything. I enjoyed the whole process, though sometimes was frustrated.
Thank you.

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #26 on: Mon, 23 April 2012, 15:18:24 »
The most recent three posts have bee erased again. It is weird.

Anyway, I tried Skagon's code this time without changing anything. My computer recognizes my m0110 but two characters are typed at one key stroke.
First I did not use resistors and second I added resistors, but the result is the same.

Maybe my keyboard is defective.

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #27 on: Mon, 23 April 2012, 17:09:18 »
Here is what I did today.
Instead of cutting an end of the handset cable, I used a socket and a stripboard

[ Attachment Invalid Or Does Not Exist ] 48756[/ATTACH]

As I mentioned in the previous post, I tried both your and Skagon's firmwares. In the case of your firmware, I simply changed the port to use B0 and B1 (which is the default setting of skagon's)
My computer recognizes the keyboard (without resistors with your firmware as well), but two characters are typed at one key stroke.

I ordered m0110a and it is on its way to my place. I will try skagon's firmware with m0110a. If it works, it maybe a proof that my m0110 is defective.

************************
update:
I just received m0110a, installed skagon's firmware (original/no change), plugged in.
The result is the same, two characters at one key stroke.
I assume that it may have something to do with my computer or OS.
« Last Edit: Mon, 23 April 2012, 18:53:56 by JMK »

Offline hasu

  • Thread Starter
  • Posts: 941
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Macintosh M0110 USB converter
« Reply #28 on: Mon, 23 April 2012, 19:00:29 »
Thanks for reporting.

Hmm, it is too bad...
Did you try OS key repetition setting or other OS than OSX?
I've never tried this converter on OSX.
⚠ My Engrish is broken.    tmk keyboard firmware project(ADB,PS/2,X68K,PC98,M0110,HHKB,GH60)

Offline JMK

  • Posts: 30
Macintosh M0110 USB converter
« Reply #29 on: Mon, 23 April 2012, 22:22:42 »
I don't have windows machine. I did try on windows but as a virtual machine, and the result was the same.
What is interesting is that your firmware actually worked without pull up resistors.

Did you not say that you actually updated your code? If you come up with a solution please let me know. Thank you.