Pi in BBC Micro case


16 posts
by godslust » Wed May 02, 2012 8:37 pm
While I am waiting for my pi, I have had the chance to get hold of a couple of faulty BBC Micro"s one of which is repairable but the other is sadly dead :"( , so I thought it would be fitting to install my pi in its case with a HDD hub etc.

But in order to do it justice I would like to use the micro"s keyboard with the pi, does anyone know if it would be possible to interface the Micro"s keyboard with the pi? If it is possible could someone point me in the direction of how to go about it?

Dont worry I am not going to harm any working or potentially repairable micros as that would just stupid IMHO.

EDIT: Spelling
Posts: 13
Joined: Sun Feb 26, 2012 12:04 pm
by cheery » Wed May 02, 2012 9:05 pm
Do you know the keyboard protocol of BBC Micro? If so, bitbang it through GPIO like a man! Of course my guide might be wrong as it may be too complex or there's easier and simpler way to connect the thing.

I'd start with research. Find anything you can about BBC Micro keyboards and if you can't find everything go and study at the keyboard itself. See whether you can get something out of it. Analyze how the working keyboard works by inserting a sniffer into middle. That sort of things.
User avatar
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm
by godslust » Wed May 02, 2012 9:24 pm
cheery said:


Do you know the keyboard protocol of BBC Micro? If so, bitbang it through GPIO like a man! Of course my guide might be wrong as it may be too complex or there's easier and simpler way to connect the thing.

I'd start with research. Find anything you can about BBC Micro keyboards and if you can't find everything go and study at the keyboard itself. See whether you can get something out of it. Analyze how the working keyboard works by inserting a sniffer into middle. That sort of things.


After I wrote the above post I indeed did do a little resarch and it looks like it is possible to convert the keyboard to USB HID Keyboard I found a few pages covering wha I was after (should really google then post, not the other way round) I found this page, it looks like a good start, now to research more.

EDIT: After a little more googling found this,  It is possible!
Posts: 13
Joined: Sun Feb 26, 2012 12:04 pm
by kimondo » Thu May 03, 2012 11:13 am
Came across this project to put an EEEpc in an electron case:

http://forums.bit-tech.net/sho.....p?t=213247

This is quite a long winded way of doing it - essentially involves connecting each key individually to a USB keyboard controller.

I'd feel a little bit sad pulling apart a BBC B though, even a broken one.
Posts: 9
Joined: Thu Oct 27, 2011 8:51 pm
by godslust » Thu May 03, 2012 5:00 pm
kimondo said:


Came across this project to put an EEEpc in an electron case:

http://forums.bit-tech.net/sho.....p?t=213247

This is quite a long winded way of doing it – essentially involves connecting each key individually to a USB keyboard controller.

I'd feel a little bit sad pulling apart a BBC B though, even a broken one.


Yep it is sad pulling apart a Micro, and your link looks very intresting, but I ideally want to avoid butchering the Micro / or modifying the case too much if I can help it (just encase I find the gubbins to fix the broken one in the future), my second link looks like the way to go as it looks like a way of doing what I want without destroying the Micro and to avoid a birds nest of wires.

Now to find more details, of how the guy did it!
Posts: 13
Joined: Sun Feb 26, 2012 12:04 pm
by Casalor » Fri May 04, 2012 9:25 am
I've done something similar with an old Amstrad CPC 6128 (which was fried – so I didn't have any moral dilemma about dissecting it). I simply wanted to get it working well enough in X to use properly. The steps I took (from memory) were;


  1. Worked out the Amstrad keyboard matrix (luckily I found a diagram online).

  2. Ripped out the interface from a standard pc usb keyboard.

  3. Got an old IDE ribbon cable (as it was handy) and did a soldering job which roughly approximated the x and y table of the Amstrad keyboard to the usb interface.

  4. Worked out the keypress events in linux by pluggin the amstrad keyboard into my netbooks usb port (using xev in a desktop terminal session).

  5. Wrote out an xmodmap parameter file.

  6. Take delivery of Pi.

  7. Install debian to an SD card.

  8. Switch on machine with a standard usb keyboard attached (otherwise I would have got gibberish).

  9. Enable gui login (in the /etc/inittab file).

  10. Call /etc/X11/Xmodmap (with my mapped keys) from /etc/gdm/PreSession/Defaults (I put the call somewhere near the bottom I think).

  11. Unplug usb keyboard and reboot.


Frankly I’m amazed it works as well as it does.
User avatar
Posts: 66
Joined: Wed Feb 15, 2012 11:14 am
Location: Nantwich, UK
by godslust » Sat May 05, 2012 1:02 pm
Casalor said:


I"ve done something similar with an old Amstrad CPC 6128 (which was fried – so I didn"t have any moral dilemma about dissecting it). I simply wanted to get it working well enough in X to use properly. The steps I took (from memory) were;


  1. Worked out the Amstrad keyboard matrix (luckily I found a diagram online).

  2. Ripped out the interface from a standard pc usb keyboard.

  3. Got an old IDE ribbon cable (as it was handy) and did a soldering job which roughly approximated the x and y table of the Amstrad keyboard to the usb interface.

  4. Worked out the keypress events in linux by pluggin the amstrad keyboard into my netbooks usb port (using xev in a desktop terminal session).

  5. Wrote out an xmodmap parameter file.

  6. Take delivery of Pi.

  7. Install debian to an SD card.

  8. Switch on machine with a standard usb keyboard attached (otherwise I would have got gibberish).

  9. Enable gui login (in the /etc/inittab file).

  10. Call /etc/X11/Xmodmap (with my mapped keys) from /etc/gdm/PreSession/Defaults (I put the call somewhere near the bottom I think).

  11. Unplug usb keyboard and reboot.


Frankly I’m amazed it works as well as it does.


Hi Casalor,

Your technique looks just what I need & a lot less bother than the other ways of doing it, I guess I could get a connector that fits the BBC's keyboard connector and follow your plan that would save me doing any shady & immoral practices to the keyboard (destroying any part of the BBC working or not imho is immoral). I just found the data for the keyboard (here), so might have a go this weekend to get the keyboard woring, sadly no PI yet if I do get it working :-(

Posts: 13
Joined: Sun Feb 26, 2012 12:04 pm
by plugwash » Sat May 05, 2012 1:05 pm
unfortunately because of the way the BBCs keyboard works (logic chips on the keyboard) I don't think you would be able to connect a PC keyboard controller to the connector on the keyboard.

So you would probablly either have to modify the keyboard to get at the raw matrix or program a microcontroller to do the scanning and act as a hid keyboard.
Forum Moderator
Forum Moderator
Posts: 2341
Joined: Wed Dec 28, 2011 11:45 pm
by tech_monkey » Sat May 05, 2012 1:26 pm
Another option would be to use something like an iPAC four And connect the individual keys up to a terminals.  Or use the UHID board.
http://www.casatech.eu
Posts: 130
Joined: Fri Mar 09, 2012 6:12 pm
by godslust » Sat May 05, 2012 1:31 pm
plugwash said:


unfortunately because of the way the BBCs keyboard works (logic chips on the keyboard) I don"t think you would be able to connect a PC keyboard controller to the connector on the keyboard.

So you would probablly either have to modify the keyboard to get at the raw matrix or program a microcontroller to do the scanning and act as a hid keyboard.



I was just looking at the keyboard data and realised that, doh! Looks as if I am going to have do the unthinkable and get the soldering iron out, and go down that route trying the pc controller & raw matrix as programming a microcontroller is a bit beyond me at the moment. Pity though, but morals aside just got another two BBC's off  ebay for £20, so at least I have spares.
Posts: 13
Joined: Sun Feb 26, 2012 12:04 pm
by Gert van Loo » Sat May 05, 2012 1:46 pm
godslust said:

... as programming a microcontroller is a bit beyond me at the moment.

It is not too difficult. In fact it is so simple that I think you can find somebody to help you or even do it for you**. I am convinced there are others who would like to put a PI in the BBC micro case. So together you should be able to easy the burden.

I would take out a soldering iron only as last rsort.

**It is no more the a big loop which does

for (scan=0 ; scan<max_scan; scan++)

{  scan_pins = 1<< scan;

key_pressed = input_pins;

for (key=0; key<max_key; key++)

if (key_pressed & (1<<key))

output key_code_table[scan][key]

}
User avatar
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2078
Joined: Tue Aug 02, 2011 7:27 am
by prophet36 » Mon May 07, 2012 4:49 pm
godslust said:

Looks as if I am going to have do the unthinkable and get the soldering iron out, and go down that route trying the pc controller & raw matrix as programming a microcontroller is a bit beyond me at the moment.


I suggest using a Minimus with a LUFA firmware to act as a USB keyboard. I've done something similar with a PS2 keyboard. If you want to go this route, let me know and I'll have a go at wiring my own Beeb's keyboard to a Minimus in this way, using the matrix-scanning approach suggested by Gert.
Posts: 8
Joined: Thu Dec 22, 2011 4:20 pm
by slacker » Tue May 08, 2012 4:43 pm
A friend has asked me have a go at doing this using the circuit from here, same one godslust posted earlier. From the info in the source code and by studying the photos and the ucontroller datasheet, I've figured out the schematic, looks straightforward enough. I just need to check that the keyboard has the same connections as the one he used, my mate's has two ribbons with single row connectors, but hopefully the keyboard circuits are the same. If they are I'll order the components so should be able to get it on the breadboard in the next few weeks.

I post my progress and if it works I'll post the schematic and vero layout.
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm
by godslust » Tue May 08, 2012 9:32 pm
Hi Slacker, from your description your mates keboard is likely a BBC Master 128 Keyboard, I found the following site had more info on the different BBC revisons http://www.8bs.com/insides.htm .
Posts: 13
Joined: Sun Feb 26, 2012 12:04 pm
by slacker » Wed May 09, 2012 5:00 pm
Yeah that's the one, from what I can see the keyboard matrix is the same, just different connectors so it should just be a case of working out what goes where, probably involve a bit of trial and error, but hopefully I can figure it out.
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm
by slacker » Thu May 17, 2012 8:12 pm
Quick update if anyone's interested, I've got the chip programmed and working, plug it in and it's recognised as a USB device. That's the hard bit out of the way, just got to hook the keyboard up to it now.
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm