Yet Another QL Keyboard Conversion

Nagging hardware related question? Post here!
Post Reply
User avatar
lostcarpark
ROM Dongle
Posts: 25
Joined: Thu Feb 19, 2015 6:08 pm
Contact:

Yet Another QL Keyboard Conversion

Post by lostcarpark »

I know a few people have done this before, but here is my QL keyboard conversion story.

A few years ago I picked up an empty QL case (I have no idea why it had been separated from its contents).

I got thinking that it would be interesting to use it to house a Raspberry Pi running a QL Emulator, but obviously that would only be interesting if the keyboard worked. So I spent some time looking at writing USB keyboard interfaces for Arduinos or other microcontrollers.

However, I then stumbled on the Teensy board, which is an Arduino compatible(ish) board, but the reason it interested me was because it had a library to support USB keyboard interface. It also supports the keyboard interface over the same USB port that it's programmed through, which I believe isn't possible on most Arduinos. Aside from being convenient, this saves a couple of IO pins.

The project evolved very slowly. At first, I couldn't get hold of proper QL keyboard connectors, so I was trying to use a Spectrum edge connector, which sort of worked with an extra piece of plastic to give the correct thickness, but aligning the connectors was a pain. Then I came across RWAP Software, who sold me the last set of connectors they had.

I did some initial prototyping on a breadboard, but as the result was going to be too thick to fit inside the case, I moved on to prototype board. Here's is what I ended up with:
ql_keyboard_prototype.jpg
It's about as simple as it could be, with one set of output pins connected to the keyboard pins through diodes, and the inputs connected directly to the columns.

The software scans each keyboard row in turn and keeps an internal map of which keys are pressed, as well as up to six concurrently pressed keys (though in practice, pressing more than two keys at once doesn't really work on the QL keyboard).

It also detects combos like CTRL+LEFT and converts them into PC keys like Backspace.

At present I've set up the following combinations:
  • CTRL LEFT = BACKSPACE
  • CTRL RIGHT = DELETE
  • ALT LEFT = HOME
  • ALT RIGHT = END
  • ALT UP = PAGE UP
  • ALT DOWN = PAGE DOWN
  • CTRL ALT RIGHT = CTRL ALT DEL
  • ALT F5 = SUPER (Windows) Key
  • ALT \ = PRINT SCREEN
  • ALT 4 = RIGHT-ALT 4 - Euro sign on UK Keyboard
  • ALT A E I O U = RIGHT-ALT A E I O U - This is useful to me for Irish keyboard layout, but probably not much for anyone who doesn't write in Irish.
I've made the source code and details of the design available on GitHub:
https://github.com/lostcarpark/ql_keyboard

Edit: Forgot to mention I've written this post with it. It's fun typing on a PC with a QL keyboard, though I'm not quite ready to use it as my daily driver keyboard.


Exile
ROM Dongle
Posts: 38
Joined: Sat Jan 15, 2022 8:55 pm

Re: Yet Another QL Keyboard Conversion

Post by Exile »

Nice work, and definitely more professional than the USB keyboard driver I’ve recently completed ;)

Apologies for posting on the same thread, but to avoid creating yet another another USB keyboard thread, here are details of a version using a Raspberry Pi Pico. An m0+ running as 125Mhz is definitely over specified for a keyboard driver, so I used some of the capacity to run CircuitPython, as that has good USB HID support built in.

The Ds1020 connectors were soldered to Veroboard, and then links made to the Pico, mounted on a breadboard. I found that I did not need diodes if I limited key detection to 3 simultaneous presses. It translates a similar selection of keys, basically the code translates keypresses so that the keyboard appears as a standard GB USB keyboard (albeit with less keys).

It uses the yellow Power LED as a Caps Lock key, although it has been configured so that the Power light glows when in the more common setting i.e. Caps Lock is not enabled.

I contacted RWAP to see if they had any connectors, but they had sold their last ones :-), so I bought some 12 way Ds1020 connectors off ebay from a very helpful seller from Poland. They took a couple of weeks to get to the UK, but the tracking from Polish Mail and the Royal Mail was good.

Why did I do this?

1. I consider the QL case as a good example of industrial design.
2. It allows use of a modern emulator (either under MS Windows or Linux) with an authentic keyboard.
3. It makes a change for me to code for a real time application in Python, rather than C

It is also amusing that a $3 dollar part, running at 125MHz, with 264kB of RAM and 2MB of Flash, is being used to control the keyboard of the QL, when it is so much more powerful than the original QL hardware. No mods were made to the case, so it can still take the new hardware proposed by Peter in the future.

Code and full details can be found at: https://github.com/ikjordan/QL_USB_KBD


User avatar
lostcarpark
ROM Dongle
Posts: 25
Joined: Thu Feb 19, 2015 6:08 pm
Contact:

Re: Yet Another QL Keyboard Conversion

Post by lostcarpark »

Exile wrote:Nice work, and definitely more professional than the USB keyboard driver I’ve recently completed ;)
Thanks! Though you probably wouldn't say that if you saw the soldering around the back of the board...
Exile wrote:Apologies for posting on the same thread, but to avoid creating yet another another USB keyboard thread, here are details of a version using a Raspberry Pi Pico. An m0+ running as 125Mhz is definitely over specified for a keyboard driver, so I used some of the capacity to run CircuitPython, as that has good USB HID support built in.
That's okay. I know there have been a few similar projects. It would be interesting to see a comparison of the approaches different people have taken.

I think the Pi Pico is a good choice, and if I hadn't started mine before it existed, I might have gone that route. I think it would be fairly easy to make my code support either device, so I would be tempted to build a Pico version at some point.
Exile wrote:The Ds1020 connectors were soldered to Veroboard, and then links made to the Pico, mounted on a breadboard. I found that I did not need diodes if I limited key detection to 3 simultaneous presses. It translates a similar selection of keys, basically the code translates keypresses so that the keyboard appears as a standard GB USB keyboard (albeit with less keys).
I'm not sure how necessary the diodes are on mine. Even with diodes, if you press three keys making a square across different rows, there's no way to stop a fourth "ghost" key being detected.

Those connectors look like they might be a viable alternative if the proper ones can't be got.
Exile wrote:It uses the yellow Power LED as a Caps Lock key, although it has been configured so that the Power light glows when in the more common setting i.e. Caps Lock is not enabled.
I haven't done anything with LEDs yet. I'm wondering if the Q68 could be made to drive them.
Exile wrote:Why did I do this?
My reasons were very similar.
Exile wrote:It is also amusing that a $3 dollar part, running at 125MHz, with 264kB of RAM and 2MB of Flash, is being used to control the keyboard of the QL, when it is so much more powerful than the original QL hardware. No mods were made to the case, so it can still take the new hardware proposed by Peter in the future.
I think the Teensy is a great board for mine, but if I was starting from scratch, I'd almost certainly have chosen the Pico as it's about a quarter of the cost of the cheapest Teensy (I think mine was around $20). There are lots of boards based off the RP2040, so they're generally widely available.

Part of me wonders if you could emulate the whole QL on one, but that might be a tall order (and the 256KB onboard RAM would make it difficult to emulate anything more than an unexpanded 128KB QL).


Exile
ROM Dongle
Posts: 38
Joined: Sat Jan 15, 2022 8:55 pm

Re: Yet Another QL Keyboard Conversion

Post by Exile »

lostcarpark wrote:Part of me wonders if you could emulate the whole QL on one, but that might be a tall order (and the 256KB onboard RAM would make it difficult to emulate anything more than an unexpanded 128KB QL).
There are interesting examples in the Raspberry Pi forums of people emulating the BBC micro and a Memotech, using the second Pico core + its PIO to generate VGA or DVI output. It would be a labour of love though. As you say, the result would be limited compared to the emulators we already have for Windows, Mac and Linux. It would definitely be easier to put a Pi3 or Pi4 in the case instead ;-)


User avatar
Peter
QL Wafer Drive
Posts: 1953
Joined: Sat Jan 22, 2011 8:47 am

Re: Yet Another QL Keyboard Conversion

Post by Peter »

lostcarpark wrote:I haven't done anything with LEDs yet. I'm wondering if the Q68 could be made to drive them.
I'm afraid the answer ist no, as the Q68 PS/2 controller for keyboard is unidirectional. Sorry for this, but I never look at the Capslock LED and simplified the logic somewhat.


User avatar
lostcarpark
ROM Dongle
Posts: 25
Joined: Thu Feb 19, 2015 6:08 pm
Contact:

Re: Yet Another QL Keyboard Conversion

Post by lostcarpark »

Peter wrote:
lostcarpark wrote:I haven't done anything with LEDs yet. I'm wondering if the Q68 could be made to drive them.
I'm afraid the answer ist no, as the Q68 PS/2 controller for keyboard is unidirectional. Sorry for this, but I never look at the Capslock LED and simplified the logic somewhat.
I was thinking more along the lines of the power and SD lights on the Q68 motherboard. I was wondering if soldering the QL LEDs over the Q68 ones would work. I know the QL ones are quite power hungry compared to modern ones, so an amplifier circuit might be needed. Worst case scenario, a photodiode could be placed in front of each Q68 LED and used to relay the signals.


User avatar
Peter
QL Wafer Drive
Posts: 1953
Joined: Sat Jan 22, 2011 8:47 am

Re: Yet Another QL Keyboard Conversion

Post by Peter »

lostcarpark wrote:I was thinking more along the lines of the power and SD lights on the Q68 motherboard. I was wondering if soldering the QL LEDs over the Q68 ones would work.
Ah now I understand. :) I would just desolder the Q68 LEDs and replace them by the QL ones. That is uncritical and delivers the full current (about 14 mA for the red ones).
When you look from the front, the left pin is anode and the right pin cathode.

Since you seem interested in mounting your Q68 inside a QL case, please note that the new QL baseboard can be used without Qzero as well. It has connectors for a Q68 and supplies it with matrix keyboard, power from the back, a power switch, audio amplifier for the QL speaker and the QL network circuitry which otherwise has to be added externally. It also solves the "Q68 power down brings QL network down" issue. ;)

The new QL baseboard is designed for DIY soldering, if you can solder SMD at 0805 size. Most connectors are throughhole. I do have some spare PCBs, so if you feel keen, send me a PM.


Post Reply