Pico based serial/USB keyboard membrane emulator.

Nagging hardware related question? Post here!
stephen_usher
Super Gold Card
Posts: 586
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Pico based serial/USB keyboard membrane emulator.

Post by stephen_usher »

Over the last week I've been working upon a way of talking to a bare BBQL motherboard from another system.

Well, as of today I can do so with a prototype system...

IMG_4524.jpeg

Currently I can plug the Pi400 into the PIco's USB port and use minicom so that I can type on the machine as if I'm using the keyboard, well, other than no ALT key as there's no way that ASCII can translate to that really.

The QL's matrix is effectively just 8 scan lines and 8 sense lines. The Shift, Ctrl and Alt keys map into sense line 7.

One problem I had was that the matrix diagram I had to map the matrix to keys was wrong. It had 1 and 3 transposed, similarly 9 and o.

The other thing to note is that to enable one of the modifier keys you first have to enable them on their own before ORing them with the key code data.

Anyway, I've designed a more generalised PCB (which can handle up to 12 sense lines) which also adds an RS232 port. Once I can move stdio over RS232 then I can develop the USB HID code to allow the use of USB keyboards and do away with an extra machine.

Pico-Keyboard-Matrix-Interface.jpg

Hopefully the PCBs will arrive around the end of the week and I can move away from the RatsNest(tm).


stephen_usher
Super Gold Card
Posts: 586
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: Pico based serial/USB keyboard membrane emulator.

Post by stephen_usher »

The boards arrived just after lunch, so I quickly built one up. Just a minor issue with the DB9 sockets I bought overlapping one of the header positions, but nothing a pair of wire cutters couldn't fix.

The good news is that it works at least as well as the breadboard version so far. I've not tested the RS232.

IMG_4532.jpeg
IMG_4533.jpeg


stephen_usher
Super Gold Card
Posts: 586
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: Pico based serial/USB keyboard membrane emulator.

Post by stephen_usher »

And the RS232 works... though when the board is powered by the PicoATX power supply the 74LS244 didn't get power as it seems that the Pico doesn't power the VBUS line if powered by VSYS, so a bodge wire was necessary.


User avatar
Popopo
Super Gold Card
Posts: 532
Joined: Wed Apr 07, 2021 10:37 am

Re: Pico based serial/USB keyboard membrane emulator.

Post by Popopo »

I like it. Congrats for successful development

For what the serial port?
Would not save resources (in this case) to use the Arduino Nano? for power and signal level compatibility.


stephen_usher
Super Gold Card
Posts: 586
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: Pico based serial/USB keyboard membrane emulator.

Post by stephen_usher »

Popopo wrote: Fri Aug 01, 2025 5:57 pm I like it. Congrats for successful development

For what the serial port?
Would not save resources (in this case) to use the Arduino Nano? for power and signal level compatibility.
The serial port is there mainly so that I can debug the USB HID (keyboard and maybe joystick) support via the Pico's USB interface. It's also a neat use case of controlling a QL remotely... :-)

As for why the Pico? I'm more comfortable with the programming in C with dual core and accelerated programmed I/O. One ARM core purely deals with the QL side of things and the other purely the input. As it is the Pico is just about keeping up with the IPC's scans in this configuration.

The board is also not only for the QL potentially, which is why I added an extra four output lines. I can use this board for other systems which have a larger number of sense lines. It can also double as a useful generic Pico interface board with 8 inputs and 12 outputs.


stephen_usher
Super Gold Card
Posts: 586
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: Pico based serial/USB keyboard membrane emulator.

Post by stephen_usher »

Using some example USB keyboard code I found on Github I've managed to get a USB keyboard mostly working.

IMG_4536.jpeg

Autorepeat isn't working and there is some key bounce, which could be being caused by the same thing.

More worryingly, however, with the keyboard plugged into the Pico I'm getting random memory corruption on the QL. I don't know how this is happening as the Pico board and the QL are independently powered by the same PicoATX power supply which should have ample oomph to power everything on the +5V rail and have about 100 watts to spare.


User avatar
bwinkel67
QL Wafer Drive
Posts: 1569
Joined: Thu Oct 03, 2019 2:09 am

Re: Pico based serial/USB keyboard membrane emulator.

Post by bwinkel67 »

Oh, so this could eventually be used for something like an Amiga then too? A handy item would be something of a pass-through connector that lets you hook up both original and the USB keyboard so you could run a connector outside the case and use both the original or hook the USB to it.

Funny that you are getting memory corruption when your only interface is the keyboard ribbon.


stephen_usher
Super Gold Card
Posts: 586
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: Pico based serial/USB keyboard membrane emulator.

Post by stephen_usher »

And all fixed!

https://youtu.be/eKsEGuwRFOQ?si=gRmY12IxoGUb2Pni

Once I've cleaned up the code I can post all of this on Github.

Adding replacement software for different machines shouldn't be too difficult using the QL code as a basis. It'll be mostly the translation code which would need to be changed.
Last edited by stephen_usher on Sun Aug 03, 2025 10:38 pm, edited 1 time in total.


stephen_usher
Super Gold Card
Posts: 586
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: Pico based serial/USB keyboard membrane emulator.

Post by stephen_usher »

bwinkel67 wrote: Sun Aug 03, 2025 9:12 pm Oh, so this could eventually be used for something like an Amiga then too? A handy item would be something of a pass-through connector that lets you hook up both original and the USB keyboard so you could run a connector outside the case and use both the original or hook the USB to it.

Funny that you are getting memory corruption when your only interface is the keyboard ribbon.
Technically you could rewrite the code to handle anything which has up to 8 scan lines and 12 sense lines.

I don't see why having the keyboard connected as well wouldn't work.

For that use case, however, you'd probably design a new PCB onto which you put the Pico and the Amiga keyboard ribbon connector and run a ribbon cable to the motherboard. You'd not need the serial port, unless you want to be able to control your Amiga remotely via serial. :-)

As for the corruption, I'm wondering if it's a grounding issue or somesuch.


stephen_usher
Super Gold Card
Posts: 586
Joined: Tue Mar 11, 2014 8:00 pm
Location: Oxford, UK.
Contact:

Re: Pico based serial/USB keyboard membrane emulator.

Post by stephen_usher »

After much wall head butting to try to get git to create a repository on my NAS box due to new, higher security (paranoia) updates I've finally got the code and PCBs onto Github here:

https://github.com/stephen-usher/Pico-S ... x-Emulator

I'll add a binary for the QL firmware later.


Post Reply