Tynemouth Software LLP - Old computers, New computers, Bespoke Web Design and Software Development, Computer repairs, IT and Media Services - www.tynemouthsoftware.co.uk
Monday, 29 September 2014
BBC Micro USB Keyboard
This is one I said I wasn't going to do. I have a lot of respect for the BBC, and I'd rather have a working BBC than a keyboard. It is also a very large case, so it's a bit bulky to use as a keyboard. It does, however, have a very nice mechanical keyboard, with it's trademark red function keys.
I've had a few requests for them, so I thought it was about time I did one. I've also had something sitting around for a while which will resolves my objections.
This is a Viglen case for a BBC. It's in too poor condition to use, the plastic supports for the internal metalwork are all snapped off, some parts are missing, and the front is cracked. The idea with these is that the case replaced the top case of the BBC. The keyboard was then moved into a separate unit.
This is also in bad shape, but other than needing a good clean, it's mainly the paper label which is the problem. That would make a nice keyboard. Inside, it is just the standard BBC keyboard, with a nice curly cord extending the normal 17 pin connector.
Most of the USB keyboards I've built in the past have been simple matrix, so that can be connected to the controller to set the rows and scan the columns. The BBC is quite different. It has circuitry on board to drive the columns and read the rows. 4 of the outputs from the BBC are latched into a 74LS161, then to a 7445 binary to decimal converter, which drives the columns. The rows are fed into a 74LS251 8 channel mux to select the row to read. There is also a 74LS30 nand gate which gives a signal if any of the keys on the current column are pressed.
There are also three LEDs (originally Motor, Caps Lock and Shift Lock), and a special key, Break, which is wired to the 6502 reset line. To drive this keyboard, I could remove the logic and drive the matrix directly, but there's no reason to do that, I can just use them in the way they were intended.
A bit of extra coding is required, but nothing too taxing. The '163 can be used as a counter, but it's wired in direct mode, so just set the row number and pulse the clock line. Reading the rows just required setting the address of the row in the '251 mux. The '30 could be used to check if keys are pressed, the BBC uses this so it doesn't waste time scanning rows separately. The USB controller doesn't have anything better to do, so I just ignore that and scan all the time.
Later BBC keyboards have a speaker mounted to them, seems a shame not to use it. The BBC makes two beeps on startup, so I've emulated those on power up. It wasn't right without them. It is an 8 ohm speaker, so I can't drive it directly from the microcontroller, as the output pins are limited to 40mA. I was going to use a simple transistor amplifier, but I though I'd try a series resistor. 220 ohms in series takes it to 228 ohms, which on 5V should draw 22mA. That was loud enough, so I just left it with that.
The keyboard in the Viglen case was an older one without a speaker, so I fitted a small piezo speaker. to that one.
With that installed in the case, the keyboard bolts over the top.
I need to cut some black paper, or spray it black, but other than that it's finished.
Most of the key mapping was reasonably straightforward, although I did notice the circuit diagram in the user manual had the 9 and I keys the wrong way around. The only unusual keys are Break, which I've set as Ctrl+Alt+Delete, Copy which I've mapped to Ctrl+C and Shift Lock which is now the Windows key. The LEDs are mapped to the three normal keyboard LEDs, Num Lock, Caps Lock and Shift Lock, and change accordingly.