Using the USB Host Cable for Midi in out.

Hi all. I soldered 5 pins for the USB host cable onto my Teensy 4.1 and I plugged in a midi adapter - It requires power and when plugged into a computer lights up -
Nothing lit up!

Then I plugged a usb cable between the host cable and a midi synth that takes type C and may trans midi on it....

Nothing detectable.

Any Ideas?
 
Hi all. I soldered 5 pins for the USB host cable onto my Teensy 4.1 and I plugged in a midi adapter - It requires power and when plugged into a computer lights up -
Nothing lit up!

Then I plugged a usb cable between the host cable and a midi synth that takes type C and may trans midi on it....

Nothing detectable.

Any Ideas?

Plug in a USB mouse or USB keyboard & see if either are recognized (may have to run one of the example programs to see USB detection reports) ?? Maybe try swapping D+ & D- ??

Mark J Culross
KD5RXT
 
and I plugged in a midi adapter - It requires power and when plugged into a computer lights up -
Nothing lit up!

The USB host port on Teensy has a power switch. It's not like USB host on most PCs where the USB power is always on.

The USB host port power turns on when you call the USBHost begin() function. Before you call that function, the power to USB host devices is turned off. Simplest way is to open any of the exmaples, like File > Examples > USBHost_t36 > MIDI > Basic and program it onto your Teensy 4.1.

Also look for the line with the comment "// wait for Arduino Serial Monitor". If you leave that in the code, you will need to open the Arduino Serial Monitor for the example to actually run. Just delete that line if you want the example to start up even when your computer isn't watching.
 
What is D+ & D-

I will try plugging the host cable in reverse -turn it around.

Be careful !! The USB host interface has 2 GROUND pins at one end & +5VDC at the other end (when enabled, as Paul indicated). Reversing the cable could potentially cause significant damage to any devices that you might plug in !! Be very careful !!

The D+ & D- are the USB data signals (in between the +5VDC & GROUND pins).

Mark J Culross
KD5RXT
 
Mark
If I send a pic can you guide me.
As it is I have the windows on the host plug for each pin facing the center of the teensy board. Or the red white black black is starting on the usb plug end of the teensy.... dangerous?

Can you say if that is incorrect?
It would help as the plug
 
It should be plugged in as shown here:

https://www.pjrc.com/store/cable_usb_host_t36.html

cable_usb_host_t36_2.jpg
 
Again, you MUST run a program on Teensy 4.1 to cause the USB host port to turn on. The default behavior is no power on the USB host port. It only turns on when initialized by a program. If you haven't uploaded an appropriate program onto your Teensy, no amount of fiddling with the cable will ever help, because the host port remains in a powered off state.

On the positive side, if you plugged it in backwards but didn't run a program, odds of harm to the hardware are very low because remained in a powered off condition the whole time.

If that program has "while (!Serial) ; // wait for serial monitor" at the beginning, you either need to open the serial monitor on your PC or delete that line before uploading the code. With that line in the program, Teensy will just sit and wait for the serial monitor (so you're able to see everything it prints when you do open that serial monitor window) so if you just want to cause the USB host port to turn on, delete that line before uploading the code onto your Teensy.
 
My teensy is blinking so I think the appropriate program ran.

Now if that is correct my next issue:

I want to write code and It has not been compiling.
I was told to go and pick Tools > Boards menu to select Teensy 4.1

I did this.
They also said to send and recieve midi, I have to build the MIDI input circuitry described here: https://www.pjrc.com/teensy/td_libs_MIDI.html

However I heard that the teensy 4.1 will transmit midi via usb.

So I wonder if I have to build that circuit.

Please help.
 
My teensy is blinking so I think the appropriate program ran.

Now if that is correct my next issue:

I want to write code and It has not been compiling.
I was told to go and pick Tools > Boards menu to select Teensy 4.1

I did this.
They also said to send and recieve midi, I have to build the MIDI input circuitry described here: https://www.pjrc.com/teensy/td_libs_MIDI.html

However I heard that the teensy 4.1 will transmit midi via usb.

So I wonder if I have to build that circuit.

Please help.

The Teensy MIDI capability supports standard MIDI to/from serial (using the external hardware interface that you seem to have already built), MIDI to/from the standard USB interface (the same USB cable used to program the Teensy, selecting "Serial + MIDI" for the "USB type" in the "Tools" menu of the Arduino IDE), and MIDI to/from a device connected to the USBhost interface (accessed via pads on the bottom of the T4.0 & via the 5-pin interface with a host cable on the T4.1).

You'll need to define & include appropriate libraries for each of them as follows:

Code:
#include <USBHost_t36.h>
#include <MIDI.h>

USBHost thisUSB;
USBHub hub1(thisUSB);
MIDIDevice_BigBuffer usbhostMIDI(thisUSB);

MIDI_CREATE_DEFAULT_INSTANCE();

One way to execute the MIDI capability is to define & write a handler for each of the functions for each of the interfaces, for example:

Code:
   usbMIDI.setHandleNoteOn(USBhandleNoteOn);
   usbMIDI.setHandleNoteOff(USBhandleNoteOff);
   usbMIDI.setHandleAfterTouchPoly(USBhandleAfterTouchPoly);
   usbMIDI.setHandleControlChange(USBhandleControlChange);
   usbMIDI.setHandleProgramChange(USBhandleProgramChange);
   usbMIDI.setHandleAfterTouchChannel(USBhandleAfterTouchChannel);
   usbMIDI.setHandlePitchChange(USBhandlePitchBend);
   usbMIDI.setHandleSystemExclusive(USBhandleSystemExclusive);
   usbMIDI.setHandleTimeCodeQuarterFrame(USBhandleTimeCodeQuarterFrame);
   usbMIDI.setHandleSongPosition(USBhandleSongPosition);
   usbMIDI.setHandleSongSelect(USBhandleSongSelect);
   usbMIDI.setHandleTuneRequest(USBhandleTuneRequest);
   usbMIDI.setHandleClock(USBhandleClock);
   usbMIDI.setHandleStart(USBhandleStart);
   usbMIDI.setHandleContinue(USBhandleContinue);
   usbMIDI.setHandleStop(USBhandleStop);
   usbMIDI.setHandleActiveSensing(USBhandleActiveSensing);
   usbMIDI.setHandleSystemReset(USBhandleSystemReset);

   MIDI.setHandleNoteOn(MIDIhandleNoteOn);  // Put only the name of the function
   MIDI.setHandleNoteOff(MIDIhandleNoteOff);
   MIDI.setHandleAfterTouchPoly(MIDIhandleAfterTouchPoly);
   MIDI.setHandleControlChange(MIDIhandleControlChange);
   MIDI.setHandleProgramChange(MIDIhandleProgramChange);
   MIDI.setHandleAfterTouchChannel(MIDIhandleAfterTouchChannel);
   MIDI.setHandlePitchBend(MIDIhandlePitchBend);
   MIDI.setHandleSystemExclusive(MIDIhandleSystemExclusive);
   MIDI.setHandleTimeCodeQuarterFrame(MIDIhandleTimeCodeQuarterFrame);
   MIDI.setHandleSongPosition(MIDIhandleSongPosition);
   MIDI.setHandleSongSelect(MIDIhandleSongSelect);
   MIDI.setHandleTuneRequest(MIDIhandleTuneRequest);
   MIDI.setHandleClock(MIDIhandleClock);
   MIDI.setHandleStart(MIDIhandleStart);
   MIDI.setHandleContinue(MIDIhandleContinue);
   MIDI.setHandleStop(MIDIhandleStop);
   MIDI.setHandleActiveSensing(MIDIhandleActiveSensing);
   MIDI.setHandleSystemReset(MIDIhandleSystemReset);

   usbhostMIDI.setHandleNoteOn(USBhandleNoteOn);
   usbhostMIDI.setHandleNoteOff(USBhandleNoteOff);
   usbhostMIDI.setHandleAfterTouchPoly(USBhandleAfterTouchPoly);
   usbhostMIDI.setHandleControlChange(USBhandleControlChange);
   usbhostMIDI.setHandleProgramChange(USBhandleProgramChange);
   usbhostMIDI.setHandleAfterTouchChannel(USBhandleAfterTouchChannel);
   usbhostMIDI.setHandlePitchChange(USBhandlePitchBend);
   usbhostMIDI.setHandleSystemExclusive(USBhandleSystemExclusive);
   usbhostMIDI.setHandleTimeCodeQuarterFrame(USBhandleTimeCodeQuarterFrame);
   usbhostMIDI.setHandleSongPosition(USBhandleSongPosition);
   usbhostMIDI.setHandleSongSelect(USBhandleSongSelect);
   usbhostMIDI.setHandleTuneRequest(USBhandleTuneRequest);
   usbhostMIDI.setHandleClock(USBhandleClock);
   usbhostMIDI.setHandleStart(USBhandleStart);
   usbhostMIDI.setHandleContinue(USBhandleContinue);
   usbhostMIDI.setHandleStop(USBhandleStop);
   usbhostMIDI.setHandleActiveSensing(USBhandleActiveSensing);
   usbhostMIDI.setHandleSystemReset(USBhandleSystemReset);

And finally, allow for each of the interfaces to process messages as follows (to be included in the loop() function):

Code:
      MIDI.read();
      usbMIDI.read();
      thisUSB.Task();
      usbhostMIDI.read();

Hope this helps to answer the question that you asked . . .

Mark J Culross
KD5RXT
 
The Teensy MIDI capability supports standard MIDI to/from serial (using the external hardware interface that you seem to have already built), MIDI to/from the standard USB interface (the same USB cable used to program the Teensy, selecting "Serial + MIDI" for the "USB type" in the "Tools" menu of the Arduino IDE), and MIDI to/from a device connected to the USBhost interface (accessed via pads on the bottom of the T4.0 & via the 5-pin interface with a host cable on the T4.1).

You'll need to define & include appropriate libraries for each of them as follows:

Code:
#include <USBHost_t36.h>
#include <MIDI.h>

USBHost thisUSB;
USBHub hub1(thisUSB);
MIDIDevice_BigBuffer usbhostMIDI(thisUSB);

MIDI_CREATE_DEFAULT_INSTANCE();

One way to execute the MIDI capability is to define & write a handler for each of the functions for each of the interfaces, for example:

Code:
   usbMIDI.setHandleNoteOn(USBhandleNoteOn);
   usbMIDI.setHandleNoteOff(USBhandleNoteOff);
   usbMIDI.setHandleAfterTouchPoly(USBhandleAfterTouchPoly);
   usbMIDI.setHandleControlChange(USBhandleControlChange);
   usbMIDI.setHandleProgramChange(USBhandleProgramChange);
   usbMIDI.setHandleAfterTouchChannel(USBhandleAfterTouchChannel);
   usbMIDI.setHandlePitchChange(USBhandlePitchBend);
   usbMIDI.setHandleSystemExclusive(USBhandleSystemExclusive);
   usbMIDI.setHandleTimeCodeQuarterFrame(USBhandleTimeCodeQuarterFrame);
   usbMIDI.setHandleSongPosition(USBhandleSongPosition);
   usbMIDI.setHandleSongSelect(USBhandleSongSelect);
   usbMIDI.setHandleTuneRequest(USBhandleTuneRequest);
   usbMIDI.setHandleClock(USBhandleClock);
   usbMIDI.setHandleStart(USBhandleStart);
   usbMIDI.setHandleContinue(USBhandleContinue);
   usbMIDI.setHandleStop(USBhandleStop);
   usbMIDI.setHandleActiveSensing(USBhandleActiveSensing);
   usbMIDI.setHandleSystemReset(USBhandleSystemReset);

   MIDI.setHandleNoteOn(MIDIhandleNoteOn);  // Put only the name of the function
   MIDI.setHandleNoteOff(MIDIhandleNoteOff);
   MIDI.setHandleAfterTouchPoly(MIDIhandleAfterTouchPoly);
   MIDI.setHandleControlChange(MIDIhandleControlChange);
   MIDI.setHandleProgramChange(MIDIhandleProgramChange);
   MIDI.setHandleAfterTouchChannel(MIDIhandleAfterTouchChannel);
   MIDI.setHandlePitchBend(MIDIhandlePitchBend);
   MIDI.setHandleSystemExclusive(MIDIhandleSystemExclusive);
   MIDI.setHandleTimeCodeQuarterFrame(MIDIhandleTimeCodeQuarterFrame);
   MIDI.setHandleSongPosition(MIDIhandleSongPosition);
   MIDI.setHandleSongSelect(MIDIhandleSongSelect);
   MIDI.setHandleTuneRequest(MIDIhandleTuneRequest);
   MIDI.setHandleClock(MIDIhandleClock);
   MIDI.setHandleStart(MIDIhandleStart);
   MIDI.setHandleContinue(MIDIhandleContinue);
   MIDI.setHandleStop(MIDIhandleStop);
   MIDI.setHandleActiveSensing(MIDIhandleActiveSensing);
   MIDI.setHandleSystemReset(MIDIhandleSystemReset);

   usbhostMIDI.setHandleNoteOn(USBhandleNoteOn);
   usbhostMIDI.setHandleNoteOff(USBhandleNoteOff);
   usbhostMIDI.setHandleAfterTouchPoly(USBhandleAfterTouchPoly);
   usbhostMIDI.setHandleControlChange(USBhandleControlChange);
   usbhostMIDI.setHandleProgramChange(USBhandleProgramChange);
   usbhostMIDI.setHandleAfterTouchChannel(USBhandleAfterTouchChannel);
   usbhostMIDI.setHandlePitchChange(USBhandlePitchBend);
   usbhostMIDI.setHandleSystemExclusive(USBhandleSystemExclusive);
   usbhostMIDI.setHandleTimeCodeQuarterFrame(USBhandleTimeCodeQuarterFrame);
   usbhostMIDI.setHandleSongPosition(USBhandleSongPosition);
   usbhostMIDI.setHandleSongSelect(USBhandleSongSelect);
   usbhostMIDI.setHandleTuneRequest(USBhandleTuneRequest);
   usbhostMIDI.setHandleClock(USBhandleClock);
   usbhostMIDI.setHandleStart(USBhandleStart);
   usbhostMIDI.setHandleContinue(USBhandleContinue);
   usbhostMIDI.setHandleStop(USBhandleStop);
   usbhostMIDI.setHandleActiveSensing(USBhandleActiveSensing);
   usbhostMIDI.setHandleSystemReset(USBhandleSystemReset);

And finally, allow for each of the interfaces to process messages as follows (to be included in the loop() function):

Code:
      MIDI.read();
      usbMIDI.read();
      thisUSB.Task();
      usbhostMIDI.read();

Hope this helps to answer the question that you asked . . .

Mark J Culross
KD5RXT
Hi, Mark!

Thanks a bunch for posting this. I am new to Teensy and beginner level with electronics, c, c++. I am going to give this a try!

73

Pete
W7PMA
 
Pete (W7PMA):

Good luck & make sure to let us know how it goes and/or if you have any other questions . . .

Mark J Culross
KD5RXT
 
Pete (W7PMA):

Good luck & make sure to let us know how it goes and/or if you have any other questions . . .

Mark J Culross
KD5RXT
It's going great! I'm using the USB Host pins like you mentioned and processing CC and Note On commands. Is there an easy way to detect that a MIDI device is connected and powered on? I'd like to display an error message. I'm often switch the MIDI cables around. Thanks!
 
Back
Top