USBHost_t36 doesn't recognize MIDI-keyboard?

Myreauks

Active member
Hi!

I am creating a synth with Teensy 4.1. It is currently controlled with a M-Audio Keystation Mini32 MK3 via the USB-Host connection on Teensy 4.1 board. The Teensy has been programmed with Teensyduino 1.56 on macOS 10.15.7.

I was troubleshooting the USB-Host MIDI connection for a long time and finally managed to get it working by plugging a Macally-branded USB-hub to the Teensy USB-host port and the MIDI-keyboard to the USB-hub. After this, the keyboard even started working without the USB-hub in-between.
However, the MIDI-keyboard still stops working intermittently. I still have not figured out what it is exactly that makes it stop working. Adding the USB-hub between the Teensy and the MIDI-keyboard always fixes the connection for some time and then the Teensy doesn't receive any MIDI messages again. The connection should be alright as a pc keyboard works just fine even when the MIDI-keyboard doesn't.

Any ideas what the problem might be? Maybe the Teensy is not recognising the M-Audio Keystation for some reason?
 
You're a few steps ahead of me, but it sounds like a problem with insufficient power, to me. Does your USB hub have it's own power supply? That would explain why it usually works with the hub. The intermittent problem might be a bad USB cable or connection. Are they USB-3.x?
There's a great GUI app for designing MIDI controls called Pure Data that I'll be using over the next few days to connect to my Akai APC-40 over USB. So, I might discover similar issues. 'Notes and Volts' has a great Teensy MIDI tutorial series that has been a tremendous help for me. Dave covers Pure Data in Part 2.
 
You're a few steps ahead of me, but it sounds like a problem with insufficient power, to me. Does your USB hub have it's own power supply? That would explain why it usually works with the hub. The intermittent problem might be a bad USB cable or connection. Are they USB-3.x?
There's a great GUI app for designing MIDI controls called Pure Data that I'll be using over the next few days to connect to my Akai APC-40 over USB. So, I might discover similar issues. 'Notes and Volts' has a great Teensy MIDI tutorial series that has been a tremendous help for me. Dave covers Pure Data in Part 2.

Thanks for the reply! I have also thought about it being a problem with power. However, my usb hub doesn't have a separate power supply. This makes me think that power is fine.
Maybe it could be tested by feeding 5V straight into the USB-Host rather than using the power from Teensy. I wonder if there is a chance of damaging the Teensy board by doing this?

Yeah, 'Notes and Volts' is great! I watched that whole tutorial series when starting my project.
 
Sorry, I have not done anything with MIDI...

But might be interesting to see if you can get any hints by turning on the debug outputs in USBHost...
Go to the header file USBHost_t36.h and uncomment the line:
Code:
// Uncomment this line to see lots of debugging info!
//#define USBHOST_PRINT_DEBUG
And rebuild and see if the system sees your midi, and if stays or does it drop...
 
I'm only a Teensy newbie, but have been using other MCUs on maker projects for a few years now. I've seen pjrc articles warning against powering the Teensy via the 5VDC GPIO and the USB at the same time, without isolating them by cutting a track on the Teensy's PCB. But, if you're only using 5VDC to power via USB, I think you'll be fine.
I would begin by monitoring the USB's 5VDC with a meter or an o'scope, if you have one. Looks like @KurtE also has a good testing option, of which I'm not familiar with but will research for my own projects.
"our pal Dave" also mentioned some issues with powering on the Teensy and USB host in the correct order, which may be a factor worth considering. Is there no pattern to the problem, which might provide some clues or is the connection dropped completely at random? I'm kinda throwing darts at the board while blindfolded.
I need to get my Teensy and audio board soldered, just to catch up with you.
 
Sorry, I have not done anything with MIDI...

But might be interesting to see if you can get any hints by turning on the debug outputs in USBHost...
Go to the header file USBHost_t36.h and uncomment the line:
Code:
// Uncomment this line to see lots of debugging info!
//#define USBHOST_PRINT_DEBUG
And rebuild and see if the system sees your midi, and if stays or does it drop...

Thanks for the tip Kurt, I will check the debug with this the next time the midi-keyboard stops working.



I'm only a Teensy newbie, but have been using other MCUs on maker projects for a few years now. I've seen pjrc articles warning against powering the Teensy via the 5VDC GPIO and the USB at the same time, without isolating them by cutting a track on the Teensy's PCB. But, if you're only using 5VDC to power via USB, I think you'll be fine.
I would begin by monitoring the USB's 5VDC with a meter or an o'scope, if you have one. Looks like @KurtE also has a good testing option, of which I'm not familiar with but will research for my own projects.
"our pal Dave" also mentioned some issues with powering on the Teensy and USB host in the correct order, which may be a factor worth considering. Is there no pattern to the problem, which might provide some clues or is the connection dropped completely at random? I'm kinda throwing darts at the board while blindfolded.
I need to get my Teensy and audio board soldered, just to catch up with you.

Thanks for the suggestions again. So far it has gone like this:
At first, the midi controller does not work at all. Then I got the idea to plug it in through the usb hub and it magically starts working. After this it worked fine except for some random lag where the notes would play very slowly.
Then it suddenly stopped working at all for no apparent reason. I plugged it in through the usb hub again and it has worked with zero issues after that with or without the usb hub.

The next time it stops working, I will first try the debug method suggested by Kurt. If that does not prove results, I'll try powering the USB Host port straight from 5V.
 
Thanks for the tip Kurt, I will check the debug with this the next time the midi-keyboard stops working.





Thanks for the suggestions again. So far it has gone like this:
At first, the midi controller does not work at all. Then I got the idea to plug it in through the usb hub and it magically starts working. After this it worked fine except for some random lag where the notes would play very slowly.
Then it suddenly stopped working at all for no apparent reason. I plugged it in through the usb hub again and it has worked with zero issues after that with or without the usb hub.

The next time it stops working, I will first try the debug method suggested by Kurt. If that does not prove results, I'll try powering the USB Host port straight from 5V.

If this problem wasn't happening when you initially started working with the Teensy, then it's possible that the micro-USB connector on the Teensy has an intermittent connection. I've had it happen with SBCs that don't have power switches. So the micro-USB connector suffers from the wear and tear of repeated connects & disconnects. There is a lot of force on the micro-USB connector every time. Sometimes it is simply a dry solder joint and other times, the pad actually separates from the PCB.
It happened to me with a $150 SBC's USB-C one time. It was surface mounted and mechanically held in place with glue. To make bad matters worse, it was PD capable so there were 8/9 tiny pins soldered on top of tiny tracks, instead of through-holes. So I invested another $150 into a reflow station in order to salvage the SBC. But, after repeated attempts, the tracks lifted off the PCB and made even a worse mess of it. So, the SBC ended up in my dead electronics box.
After that experience, I purchased a powered USB3.0 hub, with individual power buttons for each USB outlet. That eliminates the need to connect/disconnect and saves the micro-USB connectors on the devices from being damaged. My powered hub also has a dedicated 5VDC connection for charging devices, which is very handy, as well.
I suggest closely examining the PCB pads on the opposite side from the micro-USB connector. See if you can wiggle it (carefully). A dry solder joint can be repaired with a 3 second touch of a soldering iron tip.
 
Man, what a timely post for me! I was just thinking of hosting an Alesis V49 piano keyboard Midi controller on a Teensy 4.1, and was wondering about whether power management was going to be an issue, or whether there would be other issues as well. So I'll be following this thread with great interest. I think the idea of using a powered USB hub in between is probably the most reliable way to go as far as power is concerned.

Along these lines, how much power can be delivered over the USB Host connections on the Teensy 4.1 by itself (without hub in between)?

BTW: The reason for wanting to hook the Alesis V49 midi controller to a Teensy 4.1 is to correct some velocity sensitivity problems with the keys. It appears the black keys are more sensitive than the white keys and thus go to "max" (V = 127) much more often. With the Teensy, I want to monitor the midi messages and for any Note On messages for black keys, I'll modify the velocity curve to make it more like the white keys. Also, I'd like to add an expression pedal and be able to send CC messages from that pedal as well as pass thru all the keyboard messages.

ALSO: Just wanted to second TheHermit's thoughts on always using a switched powered hub for Teensy's. I can't tell you how many times I've had trouble with flaky USB connections (USB Micro B connectors should be banned from the planet as far as I'm concerned.) I learned the hard way that plugging and unplugging the USB connector to the Teensy leads to way too many problems, and I've discovered that such flaky connections can cause otherwise inexplicable noise on the A/D lines of the Teensy. I finally went to a 4 channel powered hub that has power switches for each channel, so I can turn on/off the Teensy quite conveniently without ever having to unplug the cable.
 
Back
Top