Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: Teensy 4.0 USBHost_t36 - Won't Recognize USB Hub

  1. #1
    Junior Member
    Join Date
    Jun 2022
    Posts
    6

    Teensy 4.0 USBHost_t36 - Won't Recognize USB Hub

    Hello! I tried to look through all the other forum posts about this before creating another of my own, but I haven't been able to solve my issue. I am making a MIDI USB Host like this one https://little-scale.blogspot.com/20...idi-5-pin.html. The only difference is I'm using a Teensy 4.0. I'm trying to connect a Novation Launch Control XL and Launchkey Mini through this hub: https://www.amazon.com/dp/B00BWF5U0M...roduct_details. Both controllers work fine when connected to the Teensy USB Host port without the hub. But with the hub it's not working properly, it's only passing power. When I run the HIDDeviceInfo example project I am able to see the information of the 2 controllers when they are plugged in individually (without the hub), but there is no information when the USB Hub is plugged in. I have tested the USB hub with my Macbook Pro and it works as it should. I'm a beginner when it comes to code so I could be missing something obvious. I tried running the other MIDI examples projects where there are more hubs and devices setup, but the hub isn't recognized with those projects either. Thanks in advance for any help!

    Arduino 1.8.19
    Teensyduino 1.56
    MacOS Mojave

    Code:
    #include <MIDI.h>        // access to serial (5 pin DIN) MIDI
    #include <USBHost_t36.h> // access to USB MIDI devices (plugged into 2nd USB port)
    
    MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI1);
    
    USBHost myusb;
    USBHub hub1(myusb);
    
    MIDIDevice midi01(myusb);
    
    elapsedMillis ledOnMillis;
    
    void setup() {
      pinMode(13, OUTPUT); // LED pin
      digitalWrite(13, LOW);
      MIDI1.begin(MIDI_CHANNEL_OMNI);
    
      delay(1500);
      delay(10);
      myusb.begin();
    }
    
    void loop() {
      bool activity = false;
    
      if (MIDI1.read()) { // 5 pin DIN to USB Host
        sendToHost(MIDI1.getType(), MIDI1.getData1(), MIDI1.getData2(), MIDI1.getChannel(), MIDI1.getSysExArray());
        activity = true;
      }
    
      if (midi01.read()) { // USB Host to 5 pin DIN
        uint8_t type =       midi01.getType();
        uint8_t data1 =      midi01.getData1();
        uint8_t data2 =      midi01.getData2();
        uint8_t channel =    midi01.getChannel();
        const uint8_t *sys = midi01.getSysExArray();
        sendToMIDI(type, data1, data2, channel, sys);
    
        activity = true;
      }
    
      if (activity) {
        digitalWriteFast(13, HIGH); // LED on
        ledOnMillis = 0;
      }
      if (ledOnMillis > 15) {
        digitalWriteFast(13, LOW);  // LED off
      }
    
    }
    
    void sendToMIDI(byte type, byte data1, byte data2, byte channel, const uint8_t *sysexarray)
    {
      if (type != midi::SystemExclusive) {
        MIDI1.send(type, data1, data2, channel);
      } else {
        unsigned int SysExLength = data1 + data2 * 256;
        MIDI1.sendSysEx(SysExLength, sysexarray, true);
      }
    }
    
    void sendToHost(byte type, byte data1, byte data2, byte channel, const uint8_t *sysexarray)
    {
      if (type != midi::SystemExclusive) {
        midi01.send(type, data1, data2, channel);
      } else {
        unsigned int SysExLength = data1 + data2 * 256;
        midi01.sendSysEx(SysExLength, sysexarray, true);
      }
    }

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,217
    That looks to be an unpowered hub?

    With T_4.0 connection wires had to be soldered to the bottom Host D+ and D- pins, those lines have to be done well. Good sign both devices work individually.

    The T_4.0 unlike the T_4.1 doesn't have an onboard current control chip and the hub and device(s) may be stunning the T_4.0?
    Without external power beyond the computer the power is limited to and through the Teensy.

    Using a powered hub may give better results.
    There is a DEBUG #define under comment in the Host.c file that will provide generous Serial output of any events as they happen. Enabling that may show signs of activity.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,563
    Two quick things to try...

    1: replace MIDIDevice with MIDIDevice_BigBuffer.

    2: edit ehci.cpp to uncomment this line:

    Code:
            //USBHS_PORTSC1 |= USBHS_PORTSC_PFSC; // force 12 Mbit/sec
    To be honest, I'm skeptical either of these will make a difference. But they're easy to try, so I'm hoping you can check whether the buffer size or USB high speed mode are a factor before I order this particular USB hub and put this on the list of issues to investigate.

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,771
    The Amazon page said I ordered one of these 5 years ago... Don't remember it, but will look around and see if I find it

  5. #5
    Junior Member
    Join Date
    Jun 2022
    Posts
    6
    @ Paul Thank you for the quick response! I tried both of those things and it did not make a difference.

  6. #6
    Junior Member
    Join Date
    Jun 2022
    Posts
    6
    @defragster Is the debug you're referring to #define USBHOST_PRINT_DEBUG in the USBHost_t36.h file?

  7. #7
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,217
    Quote Originally Posted by grub View Post
    @defragster Is the debug you're referring to #define USBHOST_PRINT_DEBUG in the USBHost_t36.h file?
    Yes, sorry - indeed, in that .h file : ...\USBHost_t36\USBHost_t36.h

    Code:
    // Uncomment this line to see lots of debugging info!
    //#define USBHOST_PRINT_DEBUG

  8. #8
    Junior Member
    Join Date
    Jun 2022
    Posts
    6
    I uncommented that out, but after doing so I don't see anything in the Serial Monitor when I'm running my original program. I'm not too familiar with this process, I'm assuming where the debug information would be is in the Serial Monitor, is that correct?

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,563
    I ordered this hub today. Or really, Robin did

  10. #10
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,771
    I also have one on order... I found the other hub, that I ordered back then

  11. #11
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,217
    Quote Originally Posted by grub View Post
    I uncommented that out, but after doing so I don't see anything in the Serial Monitor when I'm running my original program. I'm not too familiar with this process, I'm assuming where the debug information would be is in the Serial Monitor, is that correct?
    Yes, that part of p#2was correct: "will provide generous Serial output of any events as they happen"

    With that enabled, remove the HUB and try a device individually and that should then show since the device connects in that case.

  12. #12
    Junior Member
    Join Date
    Jun 2022
    Posts
    6
    Iím excited to see what you guys find out about this hub. Thanks for the help and interest in my issue!

  13. #13
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,771
    Just an FYI - This hub has been mentioned before as working back in 2017 in the thread:
    https://forum.pjrc.com/threads/42505...l=1#post135868

    And there was talk about Multi-TT...

  14. #14
    Junior Member
    Join Date
    Jun 2022
    Posts
    6
    I looked through that thread and itís talking about using the USB Hub to connect the Teensy to a PC. Iím trying to use mine standalone, not connected to PC. Sorry if Iím not understanding whatís being discussed in that thread correctly. So has this been tested as working in the same way Iím using it? Connected to the Teensyís USB Host port?

  15. #15
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    10,771
    Yes some/most of that may have been mentioning about The teensy was plugged into one of these. But I mentioned it because maybe Paul had one around... Or maybe more information in the thread about the hub that might give some indication.

    Note: My new one did arrive, and for example I ran it connected to the USB Host on a Teensy MicroMod running the Mouse USBHost example sketch.

    And so far everything appears to be working.

    Code:
    
    USB Host Testing
    960
    *** Device Hub1 5e3:608 - connected ***
      product: USB2.0 Hub
    *** Device HID1 46d:c063 - connected ***
      manufacturer: DELL
      product: DELL USB Laser Mouse
    *** HID Device Mouse1 46d:c063 - connected ***
      manufacturer: DELL
      product: DELL USB Laser Mouse
    *** Device HID2 4ca:27 - connected ***
      manufacturer: Lite-On Technology Corp.
      product: USB Multimedia Keyboard
    *** Device KB1 4ca:27 - connected ***
      manufacturer: Lite-On Technology Corp.
      product: USB Multimedia Keyboard
    key 'i'  105 MOD: 0 OEM: C LEDS: 0
    key 'f'  102 MOD: 0 OEM: 9 LEDS: 0
    key 'a'  97 MOD: 0 OEM: 4 LEDS: 0
    key 't'  116 MOD: 0 OEM: 17 LEDS: 0
    key ' '  32 MOD: 0 OEM: 2C LEDS: 0key 'r'  114 MOD: 0 OEM: 15 LEDS: 0
    key 's'  115 MOD: 0 OEM: 16 LEDS: 0
    key 't'  116 MOD: 0 OEM: 17 LEDS: 0
    Mouse: buttons = 0,  mouseX = -2,  mouseY = 0,  wheel = 0,  wheelH = 0
    Mouse: buttons = 0,  mouseX = -8,  mouseY = 5,  wheel = 0,  wheelH = 0
    Mouse: buttons = 0,  mouseX = -8,  mouseY = 3,  wheel = 0,  wheelH = 0
    Mouse: buttons = 0,  mouseX = -10,  mouseY = 4,  wheel = 0,  wheelH = 0
    Mouse: buttons = 0,  mouseX = -11,  mouseY = 6,  wheel = 0,  wheelH = 0
    Mouse: buttons = 0,  mouseX = -12,  mouseY = 6,  wheel = 0,  wheelH = 0
    Mouse: buttons = 0,  mouseX = -12,  mouseY = 7,  wheel = 0,  wheelH = 0
    Mouse: buttons = 0,  mouseX = -13,  mouseY = 6,  wheel = 0,  wheelH = 0
    Note: I don't have a midi, so can not test that part...

    On your test case, have you tried adding another HUB object to your sketch:
    USBHub hub2(myusb);

    And see if that helps.
    The reason I suggest that is some devices have a built in USB Hub. I have a few keyboards that are built that way. And if there is not a HUB object available, it won't then talk to the actual device, in my case a keyboard.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •