Author Topic: AMIGA 2000 + Arduino Leonardo = PC Compatible  (Read 4129 times)

0 Members and 1 Guest are viewing this topic.

Offline fl0w3n

  • Thread Starter
  • Posts: 269
AMIGA 2000 + Arduino Leonardo = PC Compatible
« on: Mon, 17 March 2014, 01:12:13 »
Thought I'd finally take the time to document a little of what I've done since I picked this Amiga up. 

Ever since I saw the Amiga I loved its vintage style and looks, and thought that just robbing it of the keys and switches would do it no justice.  So, based off this thread - http://forum.arduino.cc/index.php?topic=139358.0 - I went ahead and picked it up from a member on here.  I had never worked with Arduino before, but it seemed pretty straight forward.

Well, took me some time messing with the Arduino IDE to finally get the code uploaded.  There was some tricks to get the drivers to install, such as renaming/force installing Arduino drivers. 
Anyways, after that, you need to make sure the Arduino IDE is set to Leonardo mode, and bingo a copy-pasta of the code from the linked thread uploaded fine. 

The Arduino forum listed some pinouts that didn't quite make sense based off what I was seeing on my Amiga (see my picture clarifying which revision I had) so I found this reference: http://www.amibay.com/showthread.php?t=17871
Here's the pinout that I was able to partially successfully reference


So far, I've been able to properly identify the 5v power and the ground, but the rest I have not been able to successfully figure out which wire is which.  The keyboard turns on, LED's light up, and I can toggle the CAPS LOCK led on/off like normal, but I see no input with my PC nor do the Rx and Tx lights look to show promising indications on the Leonardo. 

The pinout has been where I'm stuck at

It seems like there were different revisions of the Amiga 2000, and I found ones that looked different in this area - this is what mine looked like:


So, for now, it's sitting waiting until I either find an answer in google, or figure it out on my own.  I think I may just have to leave the 5v and Ground properly hooked up, and then just start guessing with every combo possible for the rest of the wires. 

Offline Shayde

  • Posts: 88
  • Location: Auckland, New Zealand
Re: AMIGA 2000 + Arduino Leonardo = PC Compatible
« Reply #1 on: Mon, 17 March 2014, 21:29:19 »
Does this help?

The data transfer is unidirectional.  It always runs from the keyboard to the computer.  The keyboard places the individual data bits on the data line (KDAT),  accompanied by 20 microsecond-long low pulses on the clock line (KCLK).  40-microsecond pauses are placed between the individual clock pulses.  This means that the transfer time for each bit is 60 micro-seconds.  This yields a 480-microsecond transfer time for one byte, or a transfer rate of 16666 baud (bits/second).

After the last bit has been sent, the keyboard waits for a handshake pulse from the computer.  This Amiga sends this signal by pulling the KDAT line low for at least 75 microseconds.

The bits are not sent in the usual order 7-6-5-4-3-2-1-0, but rotated one bit position to the left: 6-5-4-3-2-1-0-7.  The key up/down flag is always the last bit sent.

The data line is active low.  This means that a 0 is represented by a high signal and a 1 by a low.

After each byte is sent, the keyboard waits a maximum of 145 milliseconds for the handshake signal.  If it does not occur in this time, the keyboard processor assumes that a transfer error occurred and enters a special mode in which it tries to restore the lost synchronisation.  It sends a 1 on the KDAT line together with a clock pulse and waits another 145ms for the synchronisation signal.  It repeats this until it receives a handshake signal from the Amiga.  Synchronisation is now restored.

The keyboard can also generate a reset on the Amiga.  If the two Amiga keys and the Ctrl key are pressed simultaneously, the keyboard processor pulls the KCLK line low for about 0.5 seconds.  This tells the reset circuit of the Amiga to generate a processor reset.  After at least one of these keys has been released, the keyboard also resets itself.  This can be seen by the flashing of the Caps Lock LED.

Source: Amiga System Programmer's Guide.
Collector-of-switches.  Cherry: red, brown, blue, black, grey (linear), green.  Alps: simp./comp. white, comp. blue, Matias.  NMB: white, black.  Futaba: Cherry stem.  Omron: yellow.  Topre: 45g  Various: Apple II+, TRS80 Model 1, C64, Acorn Electron, ZX81 (lol!).

Offline fl0w3n

  • Thread Starter
  • Posts: 269
Re: AMIGA 2000 + Arduino Leonardo = PC Compatible
« Reply #2 on: Tue, 18 March 2014, 23:24:33 »
Very interesting, thanks for that info! That does offer a bit more knowledge on it, and I think could help.

Do you know if there's a way I can decipher which is the KDAT and KCLK line utilizing my multimeter?  That would be extremely helpful. 

Of the five pins in the diagram I showed, I've been able to properly identify only one of them - 5v.  I assume NC means No Connect, and I would leave this unconnected from the Leonardo.  If I'm able to figure out which wire is KDAT and KCLK from my multimeter, then that leaves only to guess which is COM and which is NC.  I don't know what COM would mean, my only guesses are common or communication.   

This is from the arduino thread, but it must be from a different revision AMIGA because I have less wires than shown
Code: [Select]
Keyboard   Leonardo
Connector  IO           

1   KBCLK   8
2   KBDATA  9
3   KBRST   10
4   5v      5v
5   NC
6   GND     GND
7   LED1    5V
8   LED2    -

Offline Shayde

  • Posts: 88
  • Location: Auckland, New Zealand
Re: AMIGA 2000 + Arduino Leonardo = PC Compatible
« Reply #3 on: Wed, 19 March 2014, 00:52:18 »
COM will be short for COMmon, and will be the ground wire.

Because you won't be supplying the proper synchronising it'll be going into its special lost-sync mode and will be pulling KDAT low (a 1) and it'll be cycling KCLK, though you won't see that on your multimeter because it happens way too fast.  So one will be just below high (KCLK) and one will be low (KDAT).  In theory, anyway. :)
Collector-of-switches.  Cherry: red, brown, blue, black, grey (linear), green.  Alps: simp./comp. white, comp. blue, Matias.  NMB: white, black.  Futaba: Cherry stem.  Omron: yellow.  Topre: 45g  Various: Apple II+, TRS80 Model 1, C64, Acorn Electron, ZX81 (lol!).

Offline fl0w3n

  • Thread Starter
  • Posts: 269
Re: AMIGA 2000 + Arduino Leonardo = PC Compatible
« Reply #4 on: Thu, 20 March 2014, 23:02:52 »
COM will be short for COMmon, and will be the ground wire.

Because you won't be supplying the proper synchronising it'll be going into its special lost-sync mode and will be pulling KDAT low (a 1) and it'll be cycling KCLK, though you won't see that on your multimeter because it happens way too fast.  So one will be just below high (KCLK) and one will be low (KDAT).  In theory, anyway. :)


In my second picture you can see a separate black wire that is grounded to the PCB.  I was using that as Ground.  Should I not hook that one up and be using the COM instead to ground to the Leonardo?

Hmm, I only partially understood the last bit... mainly the part where you said my multimeter won't bail me out here :( haha

Do you have any suggestions for identifying KCLK and KDAT then? 

Offline Shayde

  • Posts: 88
  • Location: Auckland, New Zealand
Re: AMIGA 2000 + Arduino Leonardo = PC Compatible
« Reply #5 on: Fri, 21 March 2014, 07:21:16 »
Well you did make your job harder by snipping off the original 5-pin DIN plug, unless you recorded the colours that were attached to each pin before you snipped?

The black wire is connected to the plug shielding.  Pin 4 is GND (COM), as confirmed by this page:

http://www.sacc.org/mouse-joy-keyb/a-keyboard.html

So you should be plugging that into your Leonardo ground.  You already have the working code for reading the keyboard's pins, so you just need to attach what you think is KCLK to pin 8 and what you think is KDAT to pin 9.  And if that doesn't work, swap 'em.  ;D
Collector-of-switches.  Cherry: red, brown, blue, black, grey (linear), green.  Alps: simp./comp. white, comp. blue, Matias.  NMB: white, black.  Futaba: Cherry stem.  Omron: yellow.  Topre: 45g  Various: Apple II+, TRS80 Model 1, C64, Acorn Electron, ZX81 (lol!).

Offline fl0w3n

  • Thread Starter
  • Posts: 269
Re: AMIGA 2000 + Arduino Leonardo = PC Compatible
« Reply #6 on: Sat, 22 March 2014, 18:35:18 »
Well you did make your job harder by snipping off the original 5-pin DIN plug, unless you recorded the colours that were attached to each pin before you snipped?

The black wire is connected to the plug shielding.  Pin 4 is GND (COM), as confirmed by this page:

http://www.sacc.org/mouse-joy-keyb/a-keyboard.html

So you should be plugging that into your Leonardo ground.  You already have the working code for reading the keyboard's pins, so you just need to attach what you think is KCLK to pin 8 and what you think is KDAT to pin 9.  And if that doesn't work, swap 'em.  ;D


Hmm, I still have the original 5 pin I cut off and I used my multimeter to figure out which color went to which pin.

I will try switching my ground, and then going off your link that you posted. Thanks for the help.