Wiring USB keyboard direct to Teensy for MIDI control.

Status
Not open for further replies.
Hi all,

I would like some method of directly wiring a USB keyboard to the GPIO of a Teensy (or Arduino) and for the Teensy to be able to read the keyboard input and to then output it as MIDI. I’m aware that most DAWs allow you to map MIDI functions to almost any USB input device, including keyboards, but I want native MIDI output and enough free GPIO on the Teensy to add additional MIDI functionality to the keyboard (knobs/sliders etc.)

My understanding of the theory is that the keyboard PCB & firmware essentially act as a large multiplexer/shift register allowing multiple inputs to be routed through far fewer GPIO (much like the 74HC4051 but with a greater number of inputs) I have seen several examples of this using PS/2 keyboards (http://www.instructables.com/id/MIDI-Controller-With-Keyboards/?ALLSTEPS) but none that cover USB.

Any advice/thoughts/brutal criticisms would be appreciated.
 
Either you add a USB host card and all that entails or you figure out how to bypass the keyboards usb curcuitry... neither is worth it.
 
Generally speaking, you can think of a teensy as a smaller, more powerful, cheaper and easier to break Arduino!
You could easily replace the Arduino in that instructable with a teensy, assuming you handled the level shifting. There's a lot of 5V in that system, and teensy is 3v3 only.
Have a look at the reference page for teensy on PJRC, you can probably get your fill of knobs/sliders using the other available pins.

Teensy has built in libraries to do midi over USB (acting as slave). You can find a few midi based projects at PJRC under "projects", I assume they'll have code to go with them.
 
Either you add a USB host card and all that entails or you figure out how to bypass the keyboards usb curcuitry... neither is worth it.

Thanks for your reply. I don't actually need the keyboard to be recognised as a USB device, I just need some way of routing data from it, so a USB host seems like overkill. Looking at the range of cheap PS/2 to USB converters (and vice versa) available on eBay seems to suggest that there's some commonality between the two types of connector.
 
Generally speaking, you can think of a teensy as a smaller, more powerful, cheaper and easier to break Arduino!
You could easily replace the Arduino in that instructable with a teensy, assuming you handled the level shifting. There's a lot of 5V in that system, and teensy is 3v3 only.
Have a look at the reference page for teensy on PJRC, you can probably get your fill of knobs/sliders using the other available pins.

Teensy has built in libraries to do midi over USB (acting as slave). You can find a few midi based projects at PJRC under "projects", I assume they'll have code to go with them.

Thanks for your advice. It's the initial hurdle of getting the keyboard to talk to the Teensy via GPIO that's proving difficult.
 
I would guess you would have more luck using the output from the switching matrix directly... the contacts seem to be row/column signals that would be easy to MUX compared with bypassing the USB part of whatever controller board may be inside.
 
I would guess you would have more luck using the output from the switching matrix directly... the contacts seem to be row/column signals that would be easy to MUX compared with bypassing the USB part of whatever controller board may be inside.

I thought that might be the route I'd have to take, any thoughts on execution? Wiring the contacts from the keyboard PCB direct to GPIO or via another MUX?

Do you think using this method might introduce any kind of latency?
 
I don't see how latency would be a problem. It might be the one advantage this scheme has is that the debounce time needed by the switches should be low.

You would pretty much have to mux it... 8x16 should give enough coverage. You don't want to give up 24 pins I assume.

But this assumes a design with a switch-matrix circuit board with connectors for a separate controller board.

I wouldn't make this your first Teensy project or even the first mux with Teensy project.
 
Last edited:
I don't see how latency would be a problem. It might be the one advantage this scheme has is that the debounce time needed by the switches should be low.

You would pretty much have to mux it... 8x16 should give enough coverage. You don't want to give up 24 pins I assume.

But this assumes a design with a switch-matrix circuit board with connectors for a separate controller board.

I wouldn't make this your first Teensy project or even the first mux with Teensy project.

Thanks for your advice. I've got a couple of methods to go at, i'll let you know how it goes.
 
oh... I gather the dimensions for a full keyboard are 8x18 so that will complicate things a bit.

If anyone has already build a 'keyboard controller' replacement with Teensy for a 'standard' keyboard switch matrix you could convert that to MIDI fairly easily... but I could not find an example.

This project uses an AVR uC natively (and so is largely over my head) but the matrix stuff may help.

http://kuku.eu.org/?projects/keyboard/index

The ghost issue is relevant as in a MIDI controller you don't just have a sequence of keystrokes with a occasional modifier but 'chording' that could lead to ghost problems.

https://en.wikipedia.org/wiki/Rollover_(key)
 
Last edited:
oh... I gather the dimensions for a full keyboard are 8x18 so that will complicate things a bit.

If anyone has already build a 'keyboard controller' replacement with Teensy for a 'standard' keyboard switch matrix you could convert that to MIDI fairly easily... but I could not find an example.

This project uses an AVR uC natively (and so is largely over my head) but the matrix stuff may help.

http://kuku.eu.org/?projects/keyboard/index

The ghost issue is relevant as in a MIDI controller you don't just have a sequence of keystrokes with a occasional modifier but 'chording' that could lead to ghost problems.

https://en.wikipedia.org/wiki/Rollover_(key)

I've found an example of that here; https://blog.lmorchard.com/2016/02/21/modelm-controller/
 
Status
Not open for further replies.
Back
Top