Commit MetaInfo

Revision68d2992bdaebfb2f83ac9a5f31635674d21916c6 (tree)
Time2019-02-03 20:27:11
Authoringlorion <homemicro@ingl...>
Commiteringlorion

Log Message

described PS/2 keyboard interface

Change Summary

Incremental Difference

diff -r be9593040a6f -r 68d2992bdaeb docs/design/keyboard.txt
--- a/docs/design/keyboard.txt Fri Feb 01 23:04:12 2019 -0800
+++ b/docs/design/keyboard.txt Sun Feb 03 03:27:11 2019 -0800
@@ -1,6 +1,116 @@
11 #+TITLE: Keyboard Design
22
3-* Layout
3+The Home Micro keyboard interface is designed to accommodate two
4+different types of keyboard. One option is a simple keyboard that
5+can be build by hand using passive components. This is described in
6+further detail under [[Native Keyboard]]. The other option is to
7+interface to a PS/2 Keyboard. Such keyboards can be bought
8+pre-built. This option is described in more detail under
9+[[PS/2 Keyboard]].
10+
11+* PS/2 Keyboard
12+
13+The PS/2 keyboard interface was originally introduced with the IBM
14+PS/2 series of personal computers. It was widely adopted by other
15+computer manufacturers. Although the PC world has largely moved to
16+using USB to interface to keyboards, PS/2 keyboards are still
17+manufactured and sold.
18+
19+The PS/2 keyboard protocol is a two-wire serial protocol using a data
20+pin and a clock pin, both equipped with pull-up resistors. In addition
21+to clock and data, the interface also provides +5V and GND.
22+
23+** Parts
24+
25+ - 1x 8-bit flip-flop for the rows. 74HC574.
26+ - 1x 8-bit buffer for the columns. 74HCT245.
27+ - 1x ATmega328p.
28+ - 2x pull-up resistor, 10K ohm.
29+
30+** Firmware
31+
32+Firmware that allows the ATmega328p to interface between the PS/2
33+keyboard and the Home Micro keyboard interface is in
34+[[../../keyboard/ps2kbd-m328.s]]
35+
36+Using the [[file:atmega328-programmer.txt][ATmega328 Programmer Circuit]]
37+it can be built and written to the ATmega using
38+
39+#+BEGIN_SRC sh
40+homemicro$ cd keyboard
41+keyboard$ make
42+keyboard$ sudo avrdude -p m328p -c rpi -C +$HOME/.avrdude.conf -U flash:w:ps2kbd-m328.hex
43+#+END_SRC
44+
45+In addition to writing the firmware, the fuses must be set so that the
46+ATmega runs at a higher clock speed than the default 1MHz. We use the
47+clk7 signal from the clock divider to provide a 7.16MHz clock to the
48+ATmega's XTAL1 pin. To use this, the low fuse must be set to e0, which
49+selects the external clock source and disables the clock division by 8.
50+
51+#+BEGIN_SRC sh
52+keyboard$ sudo avrdude -p m328p -c rpi -C +$HOME/.avrdude.conf -U lfuse:w:0xe0:m
53+#+END_SRC
54+
55+** ATmega328 Wiring
56+
57+| Pin | Connection |
58+|------------+------------------------------------------------|
59+| 1 (reset#) | Vcc |
60+| 2 (pd0) | kbcol0# (pin 2 of the keyboard column buffer) |
61+| 3 (pd1) | kbcol1# (pin 3 of the keyboard column buffer) |
62+| 4 (pd2) | kbcol2# (pin 4 of the keyboard column buffer) |
63+| 5 (pd3) | kbcol3# (pin 5 of the keyboard column buffer) |
64+| 6 (pd4) | kbcol4# (pin 6 of the keyboard column buffer) |
65+| 7 (vcc) | Vcc |
66+| 8 (gnd) | GND |
67+| 9 (xtal1) | clk7 (pin 14 of the clock divider) |
68+| 10 (pb7) | kbdrow6# (pin 13 of the keyboard row register) |
69+| 11 (pd5) | kbcol5# (pin 7 of the keyboard column buffer) |
70+| 12 (pd6) | kbcol6# (pin 8 of the keyboard column buffer) |
71+| 13 (pd7) | kbcol7# (pin 9 of the keyboard column buffer) |
72+| 14 (pb0) | kbdrow0# (pin 19 of the keyboard row register) |
73+| 15 (pb1) | kbdrow1# (pin 18 of the keyboard row register) |
74+| 16 (pb2) | kbdrow2# (pin 17 of the keyboard row register) |
75+| 17 (pb3) | kbdrow3# (pin 16 of the keyboard row register) |
76+| 18 (pb4) | kbdrow4# (pin 15 of the keyboard row register) |
77+| 19 (pb5) | kbdrow5# (pin 14 of the keyboard row register) |
78+| 20 (avcc) | Vcc |
79+| 21 (aref) | Vcc |
80+| 22 (gnd) | GND |
81+| 23 (pc0) | kbdrow7# (pin 12 of the keyboard row register) |
82+| 24 (pc1) | ldkbrow (pin 11 of the keyboard row register) |
83+| 25 (pc2) | NC |
84+| 26 (pc3) | NC |
85+| 27 (pc4) | /ps2clk/ |
86+| 28 (pc5) | /ps2data/ |
87+
88+
89+** PS/2 Port
90+
91+: /-|___|-\
92+: / \
93+: / 6 | | 5 \
94+: | | | |
95+: | 4 3 |
96+: \ /
97+: \ 2 1 /
98+: \-------/
99+
100+Connections:
101+
102+| Pin | Name | Connection |
103+|-----+------+---------------------------------------------|
104+| 1 | DATA | ATmega328 PC5 (pin 28) through 10K resistor |
105+| 2 | NC | no connect |
106+| 3 | GND | Connect to ground |
107+| 4 | Vcc | +5V |
108+| 5 | CLK | ATmega328 PC4 (pin 27) through 10K resistor |
109+| 6 | NC | no connect |
110+
111+* Native Keyboard
112+
113+** Layout
4114
5115 : ESC
6116 :
@@ -20,11 +130,11 @@
20130 : SP CTL LE DN RI
21131 :
22132
23-** Comparison
133+*** Comparison
24134
25135 By comparison, here are some other home computer keyboard layouts.
26136
27-*** Atari (57 keys)
137+**** Atari (57 keys)
28138
29139 : ! " # $ % & ' @ ( ) CLR INS DEL
30140 : ESC 1 2 3 4 5 6 7 8 9 0 < > BS BRK
@@ -36,7 +146,7 @@
36146 : SH z x c v b n m , . / ATR SH
37147 : SP
38148
39-*** Commodore 64 (66 keys)
149+**** Commodore 64 (66 keys)
40150
41151 : ! " # $ % & ' ( ) CLR INS F1
42152 : BS 1 2 3 4 5 6 7 8 9 0 + - GBP HME DEL F2
@@ -49,7 +159,7 @@
49159 : SP
50160
51161
52-*** ZX Spectrum (39 keys)
162+**** ZX Spectrum (39 keys)
53163
54164 : 1 2 3 4 5 6 7 8 9 0
55165 : Q W E R T Y U I O P
@@ -59,7 +169,7 @@
59169 : CAPS Z X C V B N M SYM BRK
60170 : SH z x c v b n m SH SP
61171
62-* Matrix
172+** Matrix
63173
64174 +---+-----+-----+---+----+----+----+----+----+
65175 | | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
@@ -82,7 +192,7 @@
82192 +---+-----+-----+---+----+----+----+----+----+
83193
84194
85-* Ghosting
195+** Ghosting
86196
87197 The rows are selected by the byte written to the keyboard row
88198 register, and the columns are read when the keyboard column register
@@ -130,14 +240,14 @@
130240 - UP+LE
131241 - UP+RI
132242
133-* Electrical Interface
243+** Electrical Interface
134244
135245 The rows are connected so that they are either high impedance or 0.
136246 The columns are connected through 100K ohm pull-up resistors.
137247 When a key is pressed when its row its active, it drives its column
138248 low. Columns in which no key is pressed (on the active row) are 1.
139249
140-* Parts
250+** Parts
141251
142252 - 1x 8-bit flip-flop for the rows. 74HC574.
143253 - 1x 8-bit buffer for the columns. 74HCT245.
@@ -156,6 +266,45 @@
156266 the PS/2 keyboard protocol.
157267
158268
269+** Paper Keyboard
270+
271+The file [[../../keyboard/keys.ps]] is a PostScript document that can
272+be used to build a Home Micro compatible keyboard from paper.
273+
274+Of the 5 pages, the first two show the locations of conductive traces
275+that must be made. You can make these using conductive ink, which can
276+be bought in pens. Different conductive inks have different levels of
277+conductivity. No exhaustive testing has been performed on what level
278+of conductivity is required, but, in general, more conductive should
279+be better. For the same reason, it may be a good idea to make the
280+traces thicker than shown. Although the outlines of the keys are not
281+filled in in the printouts, these should be filled with conductive
282+ink. When a key is pressed, it makes a connection between a row (on
283+page 1) and a column (on page 2). Follow the instructions for the
284+conductive ink. It may need several hours to dry.
285+
286+Wires need to be attached to the traces. Make note of which wire
287+connects to which row or column so that they can be wired
288+to the computer correctly.
289+
290+After the pages with traces are two pages with key shapes, but no
291+text. The key shapes need to be cut out, so that there are holes where
292+the keys are going to be.
293+
294+The final page contains keys with symbols.
295+
296+Once the holes have been cut, the traces have been drawn and dried,
297+and the wires attached, the layers need to be stacked. Page 2 goes on
298+the bottom, with the conductive traces facing up. Pages 3 and 4 go on
299+top of page 2, creating some distance from the conductive surfaces and
300+insulation between the keys. Page 1 goes on top of those, with the
301+conductive surfaces facing down. Finally, page 5 goes on top, with
302+the symbols facing up. The end result should be that, for each key,
303+there is a symbol facing up, a pad facing down, 2 pages worth of empty
304+space, and a pad facing up. When pressing the symbol, the pads should
305+connect, creating the electrical connection that allows the computer
306+to detect the key press.
307+
159308 * Programming Interface
160309
161310 2 memory locations. CPU writes column number to one, reads row from
diff -r be9593040a6f -r 68d2992bdaeb docs/how-to-build.txt
--- a/docs/how-to-build.txt Fri Feb 01 23:04:12 2019 -0800
+++ b/docs/how-to-build.txt Sun Feb 03 03:27:11 2019 -0800
@@ -16,8 +16,6 @@
1616 - 3x 74HC541 octal buffer/line driver; 3-state.
1717 - 1x 74HC299 8-bit universal shift register; tri-state.
1818 - 1x 74HC574 octal D-type flip-flop; positive edge-trigger; tri-state.
19- - 8x 1N4148 small signal diode.
20- - 8x 100K ohm resistor.
2119 - 5x 1K ohm resistor.
2220 - 2x 10K ohm resistor.
2321 - 1x 100 microfarad capacitor.
@@ -731,11 +729,6 @@
731729 | 19 (y0) | /kbdrow0#/ |
732730 | 20 (vcc) | Vcc |
733731
734-Each of the ouputs (y0..y7) should be connected to the cathode of a
735-diode (1N4148, unless you made substitutions). The cathode of the
736-diode is usually marked with a band. The anodes of the diodes will be
737-connected to the rows of the keyboard.
738-
739732 Here is the wiring for the keyboard column buffer, a 74HC541:
740733
741734 | Pin | Connection |
@@ -761,7 +754,15 @@
761754 | 19 (oe2#) | oe# (pin 11 of the '08) |
762755 | 20 (vcc) | Vcc |
763756
764-Connect the a0..a7 inputs to the columns of the
765-keyboard, and add 100K ohm resistors to pull them up to 5V.
757+There are two possibilities for connecting the keyboard row register
758+and keyboard column buffer to an actual keyboard. The recommended way
759+is to use a PS/2 keyboard. Alternatively, you can make your own
760+keyboard. Both of these options are described in more detail in the
761+[[./design/keyboard.txt][keyboard design document]].
766762
767-With this, the computer should be able to detect key presses.
763+Once the keyboard is connected, the computer should be able to detect
764+key presses. You can check this with the testkeys program from the
765+source code repository.
766+
767+If you have made it this far, congratulations! You have built a
768+working microcomputer.
Show on old repository browser