Friday, 4 November 2016

Spanish Spectrum+ 128K Keypad

Following on from the previous post about the Spanish Spectrum+ 128K 'Toastrack', this is the keypad that was shipped with it. It came as standard with Spanish models. There was a UK version advertised for a short while, but I don't think it was ever sold.
The keypad plugs into the BT jack socket marked 'Keypad' on the front of the Spectrum+. Not the best position, the cable doesn't really sit right.
The later +2 had the sockets on the back which seems a better idea. This looks like it had a label stuck on the top with superglue or something which has melted the plastic a bit.
Six screws on the back remove a back plate, and inside it is a similar construction to the Spectrum+.
The thick clear membrane is similar to that used on some Spectrum+ models, and those ones are usually still fine, most of the thinner opaque ones tend to go brittle and fail.
Beneath that is is keymat and captive keys, the same arrangement as the plus.
This does not have a separate backplate as the case acts as that.
The membrane is plugged into a small controller board.
Unusually for Sinclair, it's not a Ferranti ULA, but a PIC microcontroller. No Microchip logo on this one, it is GI, General Instruments, Microchip was formed several years later. This is the PIC1652, one of the very early ones, not even mentioned in my well thumbed Microchip 'bible' from the 1990s.
It is pin compatible with a lot of the later 18 pin pics from the 16C54 through the good old 16C84 and later. Here it is used to scan the keypad the feed keypresses back to the Spectrum via a serial protocol.
It is technically an RS232 serial port, with MC1488/1489 drivers, but it was actually implemented by bit banging IO pins on the AY-3-8912A sound chip. Although these signals are at +/- 12V, the keypad uses zener diode / resistor circuits to drop it's supply and data input to around 5V.
The keypad doesn't actually use an asynchronous serial protocol like RS232 (i.e. a clock running at both ends at an agreed speed). It's sort of synchronous (data and clock both sent from a master source), in that the Spectrum initiates all the transfers. There is a lot of handshaking going on, it says hello, waits for the keypad to say hello, the says hello again and the keypad sends back one bit of data. It does this by setting the line low, waiting for the keypad to set it's line low, then setting it high and waiting for the keypad to set it's line high etc.
When reading these, the top row is from the Spectrum, but bottom a reply from the keypad. The larger pulses in the reply are 1, a pair of shorter ones is 0. The protocol is variable length, if no keys are pressed, the keypad returns 1 for each row, 1 1 1 1 1 (as in the first plot). If a key is pressed, it returns 0 for a row, then follows that with 4 key bits, 0 if pressed, 1 if not.  The second plot shows 1 1 0 1 1 0 1 1 1,  that is no keys pressed on the first two rows. The third row is a 0, so is followed by 4 bits of key data for that row, the 0 indicates the 3rd key is pressed down. The final two ones are rows 4 and 5, no keys pressed.
When running, the keypad can be used for various editing functions, moving or deleting characters or words, jumping to the end of the line etc. There is also a menu with options to renumber the code or print a listing. I got those responses using a UK Spectrum+ 128K, since the Spanish Spectrum 128K has not been repaired yet. The keypad seemed intermittent, sometimes returning very long pulses or nothing at all, I tried with a couple of UK toastracks.
These parts are now going their separate ways. The original keyboard  and keypad are, as the owner requested, to be converted to USB devices. Don't shoot me, I'm just following orders. I intent to repair the board from the Spanish 128K and rehouse that in a standard 48K Spectrum+ case, and maybe make a replacement keypad to go with it. [Update: USB keyboard conversion article]

If you want to support this blog, you can donate via Patreon or Paypal, or buy something from my store.