A friend asked me if it would be possible to convert a BBC Master Compact computer into a USB keyboard for use with emulators. I decided to take the project on. As well as making the keyboard work on a PC I installed a Retro Adapter and made the built-in speaker carry PC sound.

Hardware

The BBC Master Compact is a strange computer. While the motherboard is inside the keyboard, similar to an Amiga 500 or Atari ST, it also connects to a full size desktop case which houses floppy drives and other peripherals.

Spec-wise the Master is a step up from the BBC Micro Model B, with more RAM and an improved CPU. The motherboard is a two sided PCB and all components are through-hole.

The keyboard module is bolted to the top part of the case but is easy to remove. It uses a conventional PCB rather than a membrane like modern ones. That made discovering the pin-out of the connector and the layout of the key matrix a lot easier and I completed it with just a multimeter and notepad. I had looked for information online as 8 bit computers from the early 80s often came with complete schematics and detailed service manuals were usually available. Unfortunately I could not find one until after I had mapped everything out, but when I did it confirmed by work.

~

The USB controller board has an ATmega162 running at 15MHz. This AVR has plenty of I/O lines. Beyond the USB interface (which uses V-USB and the reference Zener diode implementation) and some power supply capacitors no extra circuitry is required. The keyboard matrix connects directly to the AVR pins through the original ribbon cable.

The keyboard also has a built-in Retro Adapter.

Firmware



The firmware is based on V-USB. I started with the code from my Quick Launch Keys which was in turn based on the reference HIDKeys. I also looked at the code for the C64 Keyboard by Mikkel Holm Olsen and the RUMP Model M controller for inspiration.

The keyboard scanning code works as similarly as possible to the BBC ROM code. Not having a working BBC to compare with this took a little bit of experimenting to get right, but with help from some BBC owners and by doing a partial dissasembly of the actual ROM it is now pretty accurate.

Because emulators use the standard OS keyboard reading functions it is important to mirrow the way the real machine works. In particular key ghosting (where multiple key presses result in an extra key being mistakenly detected due to the way the keyboard matrix works) has to be right for games which use the keyboard for input to work. Programmers chose sets of keys that were immune to ghosting so that they player can press several keys at once.

Since the keys on the Beeb keyboard do not match standard PC keyboards some keys had to be re-mapped.

BBC PC USB F0 F10 F1..F9 F1..F9 BREAK Break Arrow Keys Arrow Keys ESCAPE Esc 0..9 0..9 Minus (-) Minus (-) Caret (^) Backtick (`) Backslash (\) Backslash (\) TAB Tab Code Hash (#) Square Brackets ([]) Square Brackets ([]) Underscore (_) Equals (=) CAPS LOCK Caps Lock CTRL Ctrl (Left) Colon (:) Apostrophe (') RETURN Return SHIFT LOCK Num Lock SHIFT (Left) Shift (Left) SHIFT (Right) Shift (Right) Comma (,) Comma (,) Full Stop (.) Full Stop (.) Forward Slash (/) Forward Slash (/) DELETE Backspace COPY Alt (Left) SPACE BAR Space Bar Number Pad + Number Pad + Number Pad - Number Pad - Number Pad / Number Pad / Number Pad * Number Pad * Number Pad 0..9 Number Pad 0..9 Number Pad Hash (#) Hash (#) Number Pad DELETE Delete Number Pad , Print Screen Number Pad . Number Pad Decimal (.) Number Pad RETURN Number Pad Enter



Highlighted keys have been re-mapped.

The Beeb keyboard has 3 LEDs: POWER ON, CAPS LOCK and SHIFT LOCK. CAPS LOCK naturally is the normal Caps Lock LED. SHIFT LOCK is the inverse of the Num Lock LED (so when Num Lock is on the LED is off and vice-versa) and POWER ON is the inverse of the Scroll Lock LED.

PC Keyboard LED BBC Keyboard LED Caps Lock CAPS LOCK Num Lock SHIFT LOCK (inverted) Scroll Lock POWER ON (inverted)

Installation



In order to fit everything in to the Master Compact case some parts of the motherboard had to be removed. The board itself had to stay as some of the rear connectors and PCB traces were needed.

I removed all socketed ICs and a few of the soldered ones. I was planning to use the motherboard's audio amplifier to drive the speaker but proved to be impossible without some major re-working of the circuit. As time was a factor I decided to simply use an off-the-shelf amplifier module. The speaker was simply wired directly to the video port for connection of an RCA audio lead from the amp.

Since I was also fitting a Retro Adapter I decided to install a USB hub. I bought one for £1 and took it apart, but the PCB was so cheaply made it failed while I was soldering wires to it. I bought another one and simply added USB-A plugs to the keyboard controller and Retro Adapter.

Overview USB hub and Retro Adapter Keyboard controller Looks like a normal Beeb!

Download



Connections for the keyboard controller are documented in the source files, as is the keyboard matrix.

beeb_keyboard_1.0.zip