Acorn Electron USB Keyboard

by TheSpodShed in Circuits > USB

20976 Views, 85 Favorites, 0 Comments

Acorn Electron USB Keyboard

IMG_0909 Keyboard with lead.jpg

Make a retro USB keyboard out of a 1980's Acorn Electron computer!

The Electron was an 8-bit computer first produced in 1983, based on the legendary BBC Micro. Although it was a budget home machine, it came equipped with a decent keyboard. To many of us who grew up in the 80s the sound and feel of an authentic mechanical keyboard brings back many happy memories.

Incomplete, untested or non-working Electrons can still be found on Ebay and elsewhere, sometimes for as little as £10, and this project will give these noble machines a second lease of life. I use mine as a keyboard for a much later British computing success, the Raspberry Pi.

Assemble the Ingredients!

IMG_0838 Electron top view.JPG
IMG_0913.JPG
IMG_0845 IDC sockets loose.JPG
IMG_0914.JPG

You will need:

  • An Acorn Electron computer unit. If you find one that doesn't boot, or is missing its power supply, so much the better!
  • A Freescale FRDM-KL25Z ARM development board. These excellent little boards are available for under £10 (e.g. from Farnell) and need no additional tools for programming.
  • Two 2 x 8-way 0.1" pitch headers, and matching 2 x 8-way IDC sockets.
  • Some 0.05" (1.27mm) pitch IDC ribbon cable. You'll need a 20cm lengths of 26-way cable (split into one 12-way and one 14-way). For instance, you could recycle an old IDE hard disk lead.
  • A USB "A" to "Mini B" cable
  • M3 nuts and bolts

The tools needed are:

  • A soldering iron and solder
  • A solder sucker or desoldering braid
  • A scalpel or sharp knife
  • A Philips screwdriver, pliers, wire stripper etc.
  • A bench vice
  • A drill

You will also need (brief) access to a PC running Windows.

Dismantle the Electron

IMG_0839 Internal keyboard with flex PCB.JPG
IMG_0840 Keyboard removed from case.JPG

Open the Electron case by removing the four Philips screws on the underside. Gently separate the top and bottom halves of the case: the keyboard is attached to the top half, and the power supply and motherboard PCBs are on the bottom.

The keyboard connects to the motherboard via a flat flexible cable (see photo). Unplug this (it just pulls off) from the motherboard. The motherboard and power supply boards can now be unscrewed from the case and removed; they are no longer needed.

Next, unscrew the keyboard unit from the upper case by removing 5 Philips screws.

Cleaning

If the case or keyboard is dirty, now is a good time to clean it up. I found that an old toothbrush and sodium bicarbonate worked very well: wet the toothbrush, then pick up a small amount of bicarbonate powder with it. If you drop anything between the keycaps, make sure it is removed before proceeding.

Detach the Flexi Cable

IMG_0841 Keyboard flex cut off.JPG
IMG_0842 Keyboard desoldered.JPG

The first version of this project use the existing flexible cable connected to a pin header, but it was awkward to construct, and the cable itself was unreliable where it entered the connector. The best solution turned out to be removing the cable altogether and replacing it with ribbon cable.

To remove the cable:

  • cut through the cable with scissors, just above where it joins the keyboard (photo)
  • using a scalpel or sharp knife, cut the plastic between each connection
  • turn the keyboard over and scrape away the foam padding covering the connector pins
  • each connection can then be desoldered individually
  • clean each PCB pad up with a solder sucker or desoldering braid, so the hole is accessible

Solder in the Headers

IMG_0847 FRM board view.JPG
IMG_0846 IDC on FRDM board.JPG

The two 16-pin headers can be soldered into positions J1 and J9 on the KL25Z board, as shown in the photograph. There is a small capacitor (marked C24) which will prevent the J9 header from sitting on the board properly - I found the easiest answer was to file away a small notch in the header to allow clearance.

Prepare the Ribbon Cables

IMG_0930.JPG
IMG_0936.JPG
IMG_0937.JPG
IMG_0856 Ribbon cables top view.JPG

The keyboard is connected to the KL25Z via two ribbon cables. The "J1" socket (the lower one in the photo) needs a 14-way ribbon cable, and the "J9" socket a 12 way cable. Both of these cables should be placed in the left-most 14 or 12 spaces in the 16-way socket (as shown in the photos). IDC sockets can most easily be assembled by gently squeezing them onto the cables in a bench vice.

Note: if the sockets have a 'polarising' bump, so they only fit in the 16-way headers one way round, make sure you get them on the right way round! Refer to the photos for details.

Once the sockets are on, separate the individual wires at the other ends, strip them and tin them so they will go through the holes on the keyboard PCB. Wiring these up is mostly straightforward...

We'll call the left-most wire in each ribbon cable "wire 1", so we have "J1 wire 1" to "J1 wire 14", and "J9 wire 1" to "J9 wire 12".

We'll number the holes in the keyboard PCB from 1 to 22, with 1 being nearest the edge (at the left in the above photo).

The ribbon cable wires then go into the keyboard PCB holes as follows:

1. J9 wire 1 (PTE5)

2. J9 wire 3 (PTE4)

3. J9 wire 4 (GND)

4. J9 wire 10 (P3V3)

5. J9 wire 5 (PTE3)

6. J9 wire 7 (PTE2)

7. J9 wire 9 (PTB11)

8. J9 wire 11 (PTB10)

9. J1 wire 1 (PTA1)

10. J1 wire 2 (PTC7)

11. J1 wire 3 (PTA2)

12. J1 wire 4 (PTC0)

13. J1 wire 5 (PTD4)

14. J1 wire 6 (PTC3)

15. J1 wire 7 (PTA12)

16. J1 wire 8 (PTC4)

17. J1 wire 9 (PTA4)

18. J1 wire 10 (PTC5)

19. J1 wire 11 (PTA5)

20. J1 wire 12 (PTC6)

21. J1 wire 13 (PTC8)

22. J1 wire 14 (PTC10)

Note that four of the signals on the J9 cable are not used. The signal names (PTE5 .. PTC10) are shown on the Quick Reference card which accompanies the KL25Z board - you can use this for fault-finding if the keyboard doesn't quite work as planned.

If you've got this far: well done, the hardest part is now over! Time to put the kettle on and fire up that PC.

Load the KL25Z Firmware

IMG_0954.JPG
Bootloader-1.png
Bootloader opened-2.png
MBED folder.png

The firmware required to run the keyboard was built using the tools at mbed.org. To set up the firmware on the board requires two stages:

  1. Changing the bootloader on the board, to allow mbed programs to be loaded.
  2. Uploading the keyboard firmware to the board.

You will need a PC running Windows to do this.

Changing the bootloader

The official instructions for upgrading the bootloader are at http://mbed.org/handbook/Firmware-FRDM-KL25Z , but I'll recap them here.

  1. Find the pushbutton marked 'reset' between the two USB sockets on the board.
  2. Whilst holding down this button, plug the USB socket labelled 'OpenSDA' (the left-hand one in the photo) into the PC.
  3. Windows should identify the board as a USB mass storage device. It may need to load some drivers, then it will display an 'AutoPlay' dialog for a disk labelled 'BOOTLOADER'. Select 'Open folder to view files'.
  4. Download the file mbed_if_v2.1_frdm_kl25z.s19 attached to this page. Find the file in Windows Explorer (usually in the Downloads folder) and drag it to the BOOTLOADER file view window.
  5. Wait a few seconds for the file to appear in the file viewer (see picture).
  6. Unplug the KL25Z board from the PC.

Loading the keyboard firmware

  1. Plug the KL25Z into the PC using the 'OpenSDA' socket (don't hold down the pushbutton this time).
  2. The PC should detect a disk labelled 'MBED'. Again, select 'Open folder to view files'.
  3. Download the file electron_kbd_KL25Z.bin attached to this page.
    • Update 4-Sept-2017: I've had some reports that this firmware no longer works. File electron_kbd_KL25Z-20170904.bin is rebuilt with the latest mbed compiler and libraries.
  4. Find the file (usually in the Downloads folder) and drag it to the MBED window.
  5. When the file has finished copying, the bootloader will eject the disk. (Windows may show a dialog warning you it hasn't been ejected properly: don't worry about this). A short time later it will reconnect.
  6. You can now unplug the KL25Z board.

Modifying the firmware

If you would like to create your own custom keyboard firmware, or are just curious, the source code is available on the website at http://mbed.org/users/IH/code/electron_kbd/

The source file main.cpp contains detailed comments about the keyboard wiring and how the Electron keys are mapped to USB ones.

Put It All Together!

IMG_0874 Assembled, case open.JPG
IMG_0872 Board mounted in case.JPG

Once the firmware is loaded, you can assemble the KL25Z board into the Electron case, as shown.

Remove the rubber feet which go through the mounting holes, place the board in a suitable location in the case, and mark through the holes (I used a fine-tipped permanent marker) onto the case. Drill out these holes (a 4mm wood bit will do a good job) then mount the KL25Z using M3 nuts and screws.

I used nylon washers between each nut and the PCB to avoid damage. Note that one of the four holes is very close to J1, and you may not be able to use this mounting hole.

The keyboard's USB cable is a USB A to mini-B cable plugged into the other socket on the board (labelled 'KL25Z') to the one you used for programming. It can be threaded out through the slot in the back of the lower case moulding. I glued a small rubber grommet around the cable at this point to provide some strain relief.

When this is done, you can plug the two ribbon cables in as shown, and you're ready for testing!

Troubleshooting

When assembly is complete, you can test the keyboard by plugging it into a Windows, Linux or Mac computer.

If there are any problems, here are some tips:

Check the board is powered

  • Check that the LED (D3) on the KL25Z board is on. If no light comes on at all, check that the USB cable is plugged in all the way on the KL25Z and at the PC.
  • If this seems OK, unplug the ribbon cables from the headers. If the LED now comes on, it's possible the keyboard wiring is faulty and is shorting out the power.

Check the firmware is loaded

  • When the firmware is running, the LED should appear to glow a red-pink colour. If it doesn't, check the firmware was loaded properly in step 6.
  • The keyboard should be recognized as a standard USB HID device. To check this on Windows, search for and run 'Device Manager', and look for "Human Interface Devices" (next to 'Floppy drive controllers'). You should see 'HID-compliant consumer control device' and 'USB input device'.

Check the keyboard wiring

  • If the keyboard is recognised by the PC, but some or all of the keys appear to be not working, check the keyboard wiring.
  • If the 'P3V3' wire is not connected, nothing will work properly.
  • If some keys operate correctly, but other don't, individual wires may be broken. If keys operate but produce the wrong characters, wires may have become swapped.
  • If all the keys in a horizontal row don't work, the fault is probably on the J9 ribbon cable.
  • If all the keys in an approximately vertical 'column' don't work, the fault is probably on the J1 ribbon cable.

Keyboard Mapping

You may have noticed there are far fewer keys on the Electron keyboard than on a modern machine, and that a number of the symbol keys are in odd places. Where there's a discrepancy I've tried to keep keys in the places your fingers expect them to be. This gives the following keyboard mapping:

  1. Shift + 6 produces ^, not & as the key cap is labelled. Similarly
    • Shift + 7 produces &
    • Shift + 8 produces *
    • Shift + 9 produces (
    • Shift + 0 produces )
    • Shift + - produces _
  2. Shift + ; produces : (as on a normal keyboard), not +
  3. The ': *' key behaves like a ' " key (or ' @ key, depending on UK or US keyboard mapping)
  4. CAPS LK/FUNC is now a Tab key. (There is no caps lock key).
  5. BREAK is a backspace key.
  6. The DELETE key is now an ALT key. ALT + letters work normally, but in addition we have:
    • ALT + left-arrow gives a ` (backtick), ALT + SHIFT + up-arrow gives ~ (tilde)
    • ALT + right-arrow gives \ (backslash), ALT + SHIFT + right-arrow gives | (pipe)
  7. The COPY key is now a [ key ({ when shifted), ALT + COPY gives the ] key.