Use the Spectrum 128 style menu below to navigate to the various sections detailing the keypad.

Keypad Main Menu Title
View History Of The Keypad
View Appearance Of The Keypad
View Editing Functions Available Via The Keypad
View Method Of Operation
View Communication Details
View Timing Details
View Hardware Details
View Software Details
View Details About Building A Compatible Keypad


Communication Details

The Spectrum 128 controls communications to the KEYPAD socket (and also the RS232 socket) via the I/O register 14 of the AY-3-8912 programmable sound generator. The other I/O registers are all used exclusively for sound generation. Register 14 is selected by writing the value 14 to I/O port FFFDh (65533), and once selected the 8 bits that make up the register can be written to via I/O port BFFDh (49149) and read from via port FFFDh (65533). The 8 bits of register 14 control the following functions:

BIT SOCKET PIN FUNCTION
0 Keypad 2 Output
1 Keypad 4 Output
2 RS232 5 CTS Out
3 RS232 3 RXD Out
4 Keypad 3 Input
5 Keypad 5 Input
6 RS232 4 DTR In
7 RS232 2 TXD In

Both the KEYPAD and RS232/MIDI sockets are driven by MC1488 and MC1489 RS232 driver and receiver ICs, and hence a logic 1 is represented by a voltage between -15V to -3V and a logic 0 by +3V to +15V.

The KEYPAD socket consists of six connections with pin 6 being on the side with the clip mechanism. Note that communications to the keypad only utilises pins 1, 2, 5 and 6. The colours of the wires in the keypad lead connecting to the socket pins are listed below:

KEYPAD Socket Pin Out
PIN FUNCTION COLOUR
1 0V White
2 Reg 14 Bit 0 (Out) Green
3 Reg 14 Bit 4 (In) -
4 Reg 14 Bit 1 (Out) -
5 Reg 14 Bit 5 (In) Blue
6 +12V Red
FRONT VIEW OF SOCKET

The KEYPAD socket's input and output lines can be controlled and monitored from BASIC. The following program reads the two input lines:

  10 OUT 65533,14
  20 PRINT AT 0,0;IN 65533;" "
  30 GOTO 20

The program is best run in 48K mode so that the keypad is not read via the new ROM routines.

The program will display 255 by default when there is nothing connected to the KEYPAD and RS232 sockets or when input line bit 5 and / or bit 4 of the KEYPAD socket is connected to 0V. When the input line bit 5 is connected to +12V the display shows 223 (11011111b, DFh), and when the input line bit 4 is connected to +12V the display shows 239 (11101111b, EFh). When both bits 4 and 5 are connected to +12V the display shows 207 (11001111b, CFh). These figures are summarised below:

BIT 5 BIT 4 DEC BINARY HEX
n/c n/c 255 11111111 FF
0V 0V 255 11111111 FF
0V +12V 239 11101111 EF
+12V 0V 223 11011111 DF
+12V +12V 207 11001111 CF

The input lines of the RS232 socket can be tested in a similar fashion.

The keypad communicates to the Spectrum 128 by setting output line bit 5 to either +5V or 0V. These levels will be read by the Spectrum 128 as logic 0 and logic 1 respectively. Thus if the keypad 'wants' the Spectrum 128 to read in a 0 it must send out a 1 and vice versa. This inversion is caused by there not being a TTL to RS232 conversion at the keypad end of the communications line. As a result, the keypad software must take this into account by inverting all input and output signals appropriately.

In a similar manner to the previous program, the following will write out to the two output lines and will rapidly sequence through:

  1. Output line bits 0 and 1 to logic 0 (i.e. +12V)
  2. Output line bit 0 to logic 1 and bit 1 to logic 0 (i.e. +12V and -12V)
  3. Output line bit 0 to logic 0 and bit 1 to logic 1 (i.e. -12V and +12V)
  4. Output line bits 0 and 1 to logic 1 (i.e. -12V)
  10 OUT 65533,14
  20 OUT 49149,0
  30 OUT 49149,1
  40 OUT 49149,2
  50 OUT 49149,3
  60 GOTO 20

The program is again best run in 48K mode so that the keypad is not read via the new ROM routines as this would affect the state of the output lines of the RS232 socket. Similar BASIC code can also be used to control the two output lines of the RS232 socket.