home *** CD-ROM | disk | FTP | other *** search
/ Micro R&D 1 / MicroRD-CD-ROM-Vol1-1994.iso / hardware / drivr / ibmk.lha / ibmk / keydoc < prev    next >
Text File  |  1992-08-20  |  12KB  |  334 lines

  1.  
  2.  
  3. IBM Keyboard Interfact Project, by Eric Rudolph, 1991.
  4. No Copyright Whatsoever, but I would like credit where it's due.
  5.  
  6. This is documentation for the circuit I built which converts the information
  7. put out by an XT or AT keyboard to that which can be recognized by an Amiga.
  8.  
  9. The circuit itself is a simple 8051 with an address latch and an Eprom.
  10. It is inserted between the keyboard and the Amiga and sends data in both
  11. directions to the Keyboard and the Amiga.
  12.  
  13. Parts count could be reduced by using an 8751 which contains a 4k internal
  14. Eprom. Seeing as how I don't know how to program them yet, I will stick to
  15. the above design, but I am sure it's not hard to do. :-\
  16.  
  17. Full Parts List:
  18. ================
  19. 1) Intel 8031/8051, preferrably low power
  20. 2) 74373 address latch
  21. 3) 2732 Eprom
  22. 4) 11.059 MHZ crystal
  23. 5) 2 30pf caps
  24. 6) 1 10k resistor, 1/4 watt
  25. 7) 1 10uF electolytic cap
  26. 8) 2 momentary pushbutton switches. Neither is really needed.
  27. 10) connectors to the Amiga and the IBM
  28.  
  29. The total cost for these parts come to about $18.00 minus box and breadboard.
  30. It certainly would be cheaper to use some used components.
  31.  
  32. Wiring List:
  33. ============
  34. INTEL 8031/8051:
  35. Port1, pins 1-8 can be connected in any manner whatsoever,
  36. so long as you change the source code. You can relocate
  37. the lines to the Keyboard and the Amiga wherever suitable.
  38. If you understand the 8051 or read the 8051 manual, it will make more
  39. sense.
  40.     pin    to
  41.     ===    ==
  42.     1(p1.0)    Keyboard Clock. Female 5-pin, pin #1
  43.     2    Keyboard Data, Female 5-pin, pin #2
  44.     3
  45.     4    Amiga Clock
  46.     5    Amiga Data
  47.     6    Amiga Reset
  48.     7
  49.     8(p1.7)    XT/AT pin. Tie low to always convert an XT keyboard.
  50.         For Auto detect, leave pin unconnected.
  51.     9(reset) to - side of 10uF cap & 10k resistor & pushbutton switch
  52.         only if you want a manual CIRCUIT reset switch.
  53.     10(p3.0)
  54.     11
  55.     12(int0)  pushbutton switch2
  56.     13-16
  57.     17(p3.7)
  58.     18    clock crystal & 30pf cap1
  59.     19    clock crystal(other pin) & 30pf cap2
  60.     20     Ground
  61.     21(a8)    Eprom Addr8, 2732 pin#23
  62.     22     Eprom Addr9, 2732 pin#22
  63.     23     Eprom Addr10, 2732 pin#19
  64.     24(a11)    Eprom Addr11, 2732 pin#21
  65.     25-28
  66.     29    Eprom Read, 2732 pin#20
  67.     30    373 Gate, pin# 11
  68.     31     Ground
  69.     32(ad7)    373 D7, pin#13 & Eprom Data7, pin#17
  70.     33    373 D6, pin#14 & Eprom Data6, pin#16
  71.     34    373 D5, pin#8 & Eprom Data5, pin#15
  72.     35    373 D4, pin#7 & Eprom Data4, pin#14
  73.     36    373 D3, pin#4 & Eprom Data3, pin#13
  74.     37    373 D2, pin#3 & Eprom Data2, pin#11
  75.     38    373 D1, pin#17 & Eprom Data1, pin#10
  76.     39(ad0)    373 D0, pin#18 & Eprom Data0, pin#9
  77.     40    +5 Volts
  78. 74373:
  79.     1    Ground
  80.     2    Eprom Addr2, pin#6
  81.     3    done
  82.     4    done
  83.     5    Eprom Addr3, pin#5
  84.     6    Eprom Addr4, pin#4
  85.     7    done
  86.     8    done
  87.     9    Eprom Addr5, pin#3
  88.     10    Ground
  89.     11    done
  90.     12    Eprom Addr7, pin#1
  91.     13    done
  92.     14    done
  93.     15    Eprom Addr6, pin#2
  94.     16    Eprom Addr1, pin#7
  95.     17    done
  96.     18    done
  97.     19    Eprom Addr0, pin#8
  98.     20    +5 volts
  99. 2732 Prom:
  100.     1-11    done
  101.     12    Ground
  102.     13-17    done
  103.     18    Ground (chip enable. Doesn't save power very much)
  104.     19-23    done
  105.     24    +5 volts
  106. crystal:
  107.     connected between 8051 pins 18 and 19
  108. 30pf cap1:
  109.     connected between a lead of cystal and ground
  110. 30pf cap2:
  111.     connected between other lead of crystal and ground
  112. 10uF Electrolytic Cap:
  113.     minus end to 8051 pin9, + end to +5 volts.
  114. 10k resistor:
  115.     tied between ground and 8051 pin 9
  116. VVV reset pushbutton switch. This is not absolutely necessary.
  117. Pushbutton Switch1:
  118.     tied between 8051 pin9 and +5 volts
  119. VVV only use if you want a one-button hard reset.
  120. Pushbutton Switch2: (amiga reset switch)
  121.     tied between 8051 pin12 (int0) and ground
  122. 5-pin Female IBM connector:
  123.     Connect plus voltage pin to +5 volts
  124.     Connect ground pin to ground
  125.     connect clock and data as in above
  126. (pin1=clock, pin2=data, pin3=NC, pin4=ground, pin5=+5v)
  127. (as you face the back of the 5-pin female din, with the notch pointing up,
  128. the pin order from left to right is 1,4,2,5,3)
  129.  
  130. Amiga Connector: each of the amiga connectors for the 500/1000/2000 will
  131.     be different.
  132. On the Amiga 1000, the keyboard connects by means of a telephone
  133.     HANDSET connector with a regular phone handset cord. The pins
  134.     from left to right on the back of the Amiga 1000 are +5,clock,data,GND.
  135.     If you make this circuit yourself, I suggest purchasing a little jack
  136.     from the local telephone repairman. They are fairly standard jacks
  137.     I believe. Connect red on the jack to +5,white to clock,greeen to
  138.     data, black to ground. (On the circuit board, that is...)
  139.     Clock and Data are wherever you locate them in the source code.
  140.     As it stands, Amiga Clock is on pin 3 of the 8051, and Data is
  141.     on pin 4.
  142.  
  143. For the Amiga 500, there is a 8 pin straight line on the mother board.
  144. These pins from left to right are
  145. 1. Data
  146. 2. Clock
  147. 3. Reset
  148. 4.+5
  149. 5 Not connected. (Key)
  150. 6.Ground
  151. 7. Status (not used)
  152. 8. Disk Light (not used)
  153.  
  154. Make yourself a special adaptor that connects your amiga to the circuit.
  155. You WILL need to connect the reset line if you want to soft reset from
  156. the keyboard. The A500 only resets by having the Reset line driven low.
  157.  
  158. It says in my hardware manual here that The connector TO the keyboard
  159. goes as follows:
  160. 1: Clock
  161. 2: Data
  162. 3: Not connected.
  163. 4: Ground
  164. 5: +5 volts.
  165. I imagine it's just like the AT connector, but it's a shame they don't use
  166. the same data signals!
  167.  
  168.  
  169.  
  170. VERY IMPORTANT:!!!! The cord from the Amiga to the Converter must be
  171. very very short and have very low resistance for this circuit to run on it's
  172. own power. Do NOT use a long handset cord, it will load down the power lines.
  173. IT's made of ribbon copper wound around some white stuff and it conducts poorly
  174. on purpose. I used a hackup phone handset cord that is only about 3 inches
  175. long. That works fine. You may need to get a phone repairman to make the
  176. little cord special. He can do it, I know. It's a common thing. It shouldn't
  177. be expensive. The one he made for me cost 1$.
  178.  
  179. That's it!
  180. ====================================================================
  181. A little background on the IBM AT keyboard:
  182. The keyboard I used for this circuit was a BTC 5339sx. It costs about $40
  183. Lucky Computers, 1-800-348-5825. I have also tested the circuit on a
  184. standard PC keyboard, and an HP Vectra AT keyboard.
  185.  
  186. The AT keyboard DIN connector has 5 pins. Pin 3 is called Reset, but it's
  187. reserved, so we can't use it. Forget it exists on the AT keyboard. They just
  188. charge you money for it. (joke) Open collectors drive the clock and data pins,
  189. so when they are not driven low, they float at 5 volts.
  190.  
  191. The keyboard transmits data by bits, each synchonous somehow with the clock
  192. line. They keyboard when clocking in or out data, always runs the clock.
  193. The controller can drive the clock line, but not with reference to data.
  194.     When the Keyboard sends data, it first sets the data, then drives
  195. clock low, then high, and then changes the data to the next value.
  196.     The AT uses 11 bits for a transmission, 1 start bit (0), 8 data
  197. bits, 1 parity bit-set if the number of 1's in the data bits is even, and
  198. a stop bit (1). When the keyboard sends it's last bit, the stop bit, the
  199. controller must drive clock line low as a handshake and to tell the
  200. keyboard not to send until clock goes high again.
  201.     Theoretically, the controller could interrupt the sending of the
  202. bits, but I consider this unnecessary, and don't bother with it.
  203. When the computer needs to send a command to the keyboard, it sets clock
  204. line high and the data line low. When the keyboard sees this, it will
  205. start clocking pulsed on the data line.
  206. Then, the controller must look for the clock line going low, set the data
  207. bit, wait for the clock to go high, then wait for the clock to go low
  208. again, and then change the bit. Thus, it changes the data in the middle
  209. of the clock low pulse. When the keyboard has received it's 10th bit,
  210. it will drive the data line low while at the same time clocking out
  211. an extra clock low pulse. Then, it expects a handshake of the clock line
  212. low from the controller.
  213.                     0       1       2   |   7       P     stop    extra
  214. Clock:------------\___/---\___/---\___/---\___/---\___/---\___/---\___/end
  215.  
  216. Data:-------\_______00000001111111122222|6677777777PPPPPPPP1111xxxxxxxx_____
  217.  
  218. Notice there is NO start bit when the controller sends data to the Keyboard.
  219.  
  220. Special Commands the Keyboard can Send to the Controller:
  221. -----------------------------------------------------------
  222. 00     Keyboard buffer overflowed
  223. AA     Selftest passed
  224. FA    The command sent was received correctly
  225. FE    The command sent was received poorly. Please resend.
  226.  
  227. Special Commands the Controller can Send to the Keyboard:
  228. -----------------------------------------------------------
  229. ED    Set the LEDs according to next byte I send
  230.     bit 0=Scroll lock 1=on
  231.     bit 1=Num lock
  232.     bit 2=Caps lock
  233.     bits 3-7 must be 0
  234. F4    clear the key buffer and start scanning
  235. F6    restore default values
  236. FE    retransmit last character, please
  237. FF    Reset, you stupid keyboard!
  238.  
  239. Whew! That about raps it up for the AT keybard! Enough said, right?
  240.  
  241.  
  242. XT keyboards transmit much the same way except they only use 10 bits.
  243. Two start bits (both high) and 8 data bits, transmitted in order 0-1-2...-7
  244. The last bit is a make/break bit which is 1 to signify a break.
  245.  
  246. The XT can have no commands sent to it. The way to reset it is to drive
  247. the Clock line low for some longish period of time. The keyboard will not
  248. send data (it will hold off) if the data line is being held low by an
  249. external source (the controller)
  250.  
  251. AMIGA SIDE=========================================
  252.  
  253. Now I bet you are all wondering which keys are mapped to which keys.
  254. I am using the 101 AT keyboard.
  255.  
  256. AT            Amiga
  257. ==            =====
  258.  
  259. Left Ctrl        Left Amiga
  260. Right Ctrl        Right Amiga
  261. F11            Numeric Keypad (
  262. F12            Numeric Keypad ) (doesn't work on A1000's)
  263. Capslock        Control (IF used in conjunction with another key)
  264. Delete            Delete
  265. Page Down        Help
  266. PrintScreen        Left Amiga
  267. ScrollLock        Right Amiga
  268. NumLock            Control
  269. (the above three keys mapped for easy one-hand reset)
  270. Insert            Amiga+Left Cursor
  271. Home            Amiga+Up Cursor
  272. End            Amiga+Down Cursor
  273. PageUp            Amiga+Right Cursor
  274. (the above keys mapped for easy mouse pointer control in workbench.)
  275.  
  276. The BTC keyboard I used also included a Macro key (conveniently) that
  277. is mapped as a control key.
  278.  
  279.  
  280. All other keys are mapped exactly the same.
  281.  
  282. Since the Control Keys on the AT are mapped to the Amiga keys,
  283. I made a little routine that defines the Capslock Key to work as
  284. Control if you hold it down first, then type the other key.
  285. Just use it as you would an ordinary Control key.
  286. This only works for the AT, not the XT since I can't control the lights
  287. on the XT.
  288.  
  289. The explanation for how the Amiga Keyboard works is provided in the
  290. Hardware Reference Manual. I will not repeat this info here, for fear of
  291. copyright infringements and because the manual is cheap and a valuable
  292. must for anyone who indulges in this kind of thing.
  293.  
  294.  
  295. <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
  296.  
  297. SOFTWARE:
  298.  
  299. I have included the source and the machine code for the software that
  300. runs this circuit. The timing loops are pretty stringent so if you want to
  301. change things, better have a logic analyzer on hand!
  302.  
  303. I am also going to include a simple 8051 code assembler for those who don't
  304. like to hand-code. If you keep your programs neatly written, it should
  305. assemble fine.
  306.  
  307. Documentation is within the program listing. It's not too hard to follow if
  308. you know what you are doing.
  309.  
  310. Feel free to change anything you want, but before you redistribute it,
  311. please tell me of the changes. Make it known within the program that you
  312. have made changes.
  313.  
  314. The circuit, once built, should never have to be removed once plugged into
  315. your computer. It should Auto Detect which style keyboard is hooked up
  316. if the XT/AT pin (now coded as Port 1.7 (pin 8)) is not tied low.
  317. IF for some reason the circuit does not start up fine, you may need
  318. a reset CIRCUIT switch. This is different than the reset Computer
  319. switch. This switch SHOULD restart the circuit and make it sync
  320. up to the computer and the keyboard.
  321.  
  322. I will sell anybody any number of the parts needed, from circuit board
  323. to telephone connectors to the whole thing.
  324.  
  325. Circuit board alone: 5$
  326. Telephone connector: 1.50$
  327. Whole thing minus case:25$ plus shipping.
  328. Full documentation: 1$ plus postage.
  329.  
  330. Any questions? Be glad to answer em!
  331.  
  332. Phone # 503-745-5794 (Oregon)
  333.  
  334.