Pi Pico gate array keyboard interface?

For experts to discuss very technical stuff and newbies to ask why the Spectrum they bought off ebay doesn't work.
Post Reply
User avatar
flatduckrecords
Manic Miner
Posts: 831
Joined: Thu May 07, 2020 11:47 am
Location: Oban, Scotland
Contact:

Pi Pico gate array keyboard interface?

Post by flatduckrecords »

Can I use a Raspberry Pi Pico to simulate/dispatch key presses on a gate-array Spectrum?

…and does "5V tolerant" mean I can connect it via the keyboard connector like…so?


[embiggen] Figure 1. Incomplete and not to scale. Objects in mirror may be closer than they appear.

Please accept my apologies for butchering Guesser's +3 schematic. Hopefully it illustrates what I mean! I havent shown connections to all the keyboard-y lines but that's my intention since the Pico has lots of GPIO.

I was hoping to program the Pico (using Micropython, assuming it's fast enough?) as follows:

To "press" key "1" wait for KBX1 (Pi GPIO 11 input) to go HIGH then bring BKY1 (Pi GPIO 0 output) HIGH. To press "B" we need to wait for KBX8 to go HIGH and then bring up KBY5, and so on.

I have a Spectrum +3 that has been cobbled together from spare parts. I quite like using it, but my current solution for connecting the keyboard is far from elegant:


Figure 2. Not elegant.

I'd use a USB keyboard (or maybe even Bluetooth since I have a Pico W) instead of the original Spectrum one. (I.e. it would be disconnected). I'd need to consider what happens to the Pico's GPIO outputs when a joystick is used?

What do you reckon, though? Feasible?
zx64
Manic Miner
Posts: 212
Joined: Sat Jul 11, 2020 3:25 am
Location: Australia

Re: Pi Pico gate array keyboard interface?

Post by zx64 »

Should work.
When no key pressed, you probably need to set your outputs to high-impedance state. Check if Pico supports it
User avatar
TomD
Manic Miner
Posts: 400
Joined: Tue Nov 13, 2018 9:47 am
Location: Leeds UK
Contact:

Re: Pi Pico gate array keyboard interface?

Post by TomD »

This is exactly what I've done for my programmable joystick interface, albeit using a joystick to press the keys rather than an actual keyboard.

Couple things:

I'd highly recommend using a bus transceiver rather than have the Spectrums data and address lines directly connected to the Pico, 5v tolerant or not. These will give you the high impedance required to ensure you are not interfering with the data or address bus when not required. I use the 74LVC245 chip which has 8 I/O so you'll need more than one.

I'm not sure Micropython is fast enough. I'm using the PiO to quickly interpret the address line and push data onto the databus. I did try with C SDK and it missed the timing sometimes (missed key presses), MIcropython is much slower than C SDK. You can use the PiO in Micropython so you don't need to have the C SDK.

TomD
Retro enthusiast and author of Flynn's Adventure in Bombland, The Order of Mazes & Maze Death Rally-X. Check them out at http://tomdalby.com
User avatar
flatduckrecords
Manic Miner
Posts: 831
Joined: Thu May 07, 2020 11:47 am
Location: Oban, Scotland
Contact:

Re: Pi Pico gate array keyboard interface?

Post by flatduckrecords »

Thanks both!

From what I’ve read so far the Pico doesn’t provide a high-impedance mode, so some others have suggested toggling the GPIO from output to input …to achieve a similar thing? (I’m not sure I understand!)

I think I’ll give the transceivers a bash, and read up on PIO.

I’ll let you know how I get on, thanks for your help.
Post Reply