PHPnews.io

MIDI controller to PS/2 - part 1 [blog]

Written by Remy Sharp / Original link on Sep. 2, 2021

A little while back I saw a technical demo that used the shell of MIDI controller and inserted a PS/2 keyboard (effectively) under the keys to then control a program on the ZX Spectrum Next.

This prompted me to buy a MIDI controller but I didn't want to gut out the new hardware. So instead I found a way to map the USB MIDI to the PS/2 key presses, allowing me to use the piano keyboard on the retro hardware.

These posts (I'm hoping for three of them) is a tutorial on how to get your own USB MIDI controller talking to a PS/2 interface.

However I'm also intending to build these for others on demand only asking for the components and postage to be covered. If that's something you're interested I've set up an enquiry form here.

TL;DR

And that's it. The default mappings are for NextDAW but could be modified to your liking by editing the source code.

Demo

Prior Art

Richard Braithwaite's original post is behind Facebook (i.e. not public), but this was his process that spurred the interest in me:

It was simple in concept, but fiddly to pull off. I took the guts of an old PS/2 keyboard and an old un-working midi controller keyboard, bought a load of keyboard switches off ebay, mounted them under the keys of the music keyboard, then wired it all up. Once I shoved the bits from the PS/2 keyboard inside the midi controller, it works surprisingly well.

But for me it wasn't feasible to gut out a MIDI controller so I started looking at how to solve this in a non destructive way.

Version 1: simple or naive but pricier

By "pricey" it's really not that expensive, but there is - at time of writing - an 8 week wait for parts.

What you'll need are:

You'll also need some wire and some soldering will be required.

Schematic

The wiring process is relatively straight forward and can be seen in the diagram below:

midi-to-ps2-v1.png

On the USB Host Controller, wire:

On the Pico, besides the pins we've wired already, wire the following to the PS/2 connector:

I tend to get my orientation messed up when it comes to the PS/2 connector, so this is what you should be looking for - and you would be wiring from behind this connector into these pins - so remember that pin 1 is on the right when attaching from behind.

ps2-pinout.jpg

The next stage now is the software to translate the data from the USB Host Controller to the PS/2 keyboard key strokes.

Pico Firmware

Firstly ensure the PS/2 connector is disconnected - so that there's no power going to the Pico.

Now to load the firmware you need to hold the "boot" button on the Pico and connect it's USB port (then release the "boot" button). Now you can download and save the pico-midi-to-ps2-v1.uf2 file to the Pico.

Now you're ready to reconnect and play.

Note that the firmware has been configured for NextDAW on the Spectrum so the key mapping is very specific. Currently only the piano keys and a single knob with the CC value of #74 configured for relative change which moves the play head when dialed.

The full source code is available on Github - specifically if you wanted to change the key press mapping. Note that the code is a little brief but moreover uses the Arduino for Pico project (which you can read about here).

As this project progresses, I hope to add more knob and CC mappings to NextDAW functions.

What's next?

The next stage is to remove the USB Host Controller board in favour of the bare IC - which I've already achieved (see photo below), but it's still in breadboard form so I'd like to clean it up for a single board.

midi-to-ps2-ic-v2.jpg

I'm also investigating using the Pico itself as the USB host, though examples are thin and it's an area that I don't have a great depth of knowledge in, but if it works, it means the costs are the Pico, one PS/2 connector and one USB 2.0 to USB mini adapter.

I'll post a follow up in the coming weeks, and again, if you're interested in the project but would rather I do the build for you, please let me know via the enquiry form I've made.

Originally published on Remy Sharp's b:log

remysharp

« Laravel Console Spinner - Multiple Accounts and Git »