Teensy 2 ++ Midi out problem.

Status
Not open for further replies.
When using Teensy 2 ++ as a Usb midi device I have no problems.
I need to send Midi out to another device through the Midi port , I tried this schematic and code :

http://www.pjrc.com/teensy/td_libs_MIDI.html

I used an oscilloscope to see if there was a a signal from the TX pin (pin 3) but found no signal ...

When I use MIDI.sendNoteOn(note, 100, channel); nothing but usbMIDI.sendNoteOn(note, 100, channel); works fine.

Thank you

Brgds

Kristinn
 
I can give it a try here on a Teensy++ 2.0, but only if you post the code you're testing, and specific which version of the library you're using.
 
Thanks !

I am using Midi library 3.2 and just using this code:

#include <MIDI.h>

const int channel = 1;

void setup() {
MIDI.begin();
}

void loop() {
int note;
for (note=10; note <= 127; note++) {
MIDI.sendNoteOn(note, 100, channel);
delay(200);
MIDI.sendNoteOff(note, 100, channel);
}
delay(2000);
}
 
And the schematic (only the midi out part) : td_libs_MIDI_sch.gif
 
Try to include Arduino.h before including MIDI.h.

From the MIDI.h file:

// Use Serial1 on all Teensy boards, because Serial is USB virtual serial
// Arduino.h must be included before MIDI.h to define CORE_TEENSY
 
Thanks for the help , but no change :

#include <Arduino.h>
#include <MIDI.h>

const int channel = 1;

void setup() {
MIDI.begin();
}

void loop() {
int note;
for (note=10; note <= 127; note++) {
MIDI.sendNoteOn(note, 100, channel);
delay(200);
MIDI.sendNoteOff(note, 100, channel);
}
delay(2000);
}





When I change it to :


#include <Arduino.h>
#include <MIDI.h>

const int channel = 1;

void setup() {
MIDI.begin();
}

void loop() {
int note;
for (note=10; note <= 127; note++) {
usbMIDI.sendNoteOn(note, 100, channel);
delay(200);
usbMIDI.sendNoteOff(note, 100, channel);
}
delay(2000);
}

I get the notes played over USB.

The project I am doing would be so much better if I can avoid USB.

I appreciate the help :)
 
I needed to change Serial to Serial1 in Midi.h

Was this code present in Midi.h?

Code:
// Use Serial1 on all Teensy boards, because Serial is USB virtual serial
// Arduino.h must be included before MIDI.h to define CORE_TEENSY
#if defined(CORE_TEENSY)
#undef USE_SERIAL_PORT
#define USE_SERIAL_PORT         Serial1
#endif
 
Yes , but it was #define USE_SERIAL_PORT Serial.
Not Serial1.




Was this code present in Midi.h?

Code:
// Use Serial1 on all Teensy boards, because Serial is USB virtual serial
// Arduino.h must be included before MIDI.h to define CORE_TEENSY
#if defined(CORE_TEENSY)
#undef USE_SERIAL_PORT
#define USE_SERIAL_PORT         Serial1
#endif
 
Did you get the MIDI library from the page on PJRC, or from the Teensyduino installer, or from the Sourceforge site?

The copy on Sourceforge doesn't have those extra lines to automatically use Serial1 for Teensy.
 
The copy on PJRC has this in MIDI.h:

Code:
#define USE_SERIAL_PORT         Serial      // Change the number (to Serial1 for example) if you want
                                                               // to use a different serial port for MIDI I/O.

Then right after that in MIDI.h, it has this:

Code:
// Use Serial1 on all Teensy boards, because Serial is USB virtual serial
// Arduino.h must be included before MIDI.h to define CORE_TEENSY
#if defined(CORE_TEENSY)
#undef USE_SERIAL_PORT
#define USE_SERIAL_PORT         Serial1
#endif

It's supposed to undefine "Serial" and automatically change it to "Serial1".

I'm trying to understand why this didn't work for you. Maybe it's a bug that needs to be fixed?

Could you please take another quick look at your copy of MIDI.h? Does it have both of these, or only the first part? If it was simply missing the 2nd part, then that's the cause. But if that 2nd part is present in your copy, then I have more work to do to figure out why it didn't work as intended.

I really do want to make sure this problem don't affect anyone else, so if you could please just take another quick look at your copy of MIDI.h and check if it has only 1 or both of these parts, that would really help! :)
 
The copy on PJRC has this in MIDI.h:

Code:
#define USE_SERIAL_PORT         Serial      // Change the number (to Serial1 for example) if you want
                                                               // to use a different serial port for MIDI I/O.

Then right after that in MIDI.h, it has this:

Code:
// Use Serial1 on all Teensy boards, because Serial is USB virtual serial
// Arduino.h must be included before MIDI.h to define CORE_TEENSY
#if defined(CORE_TEENSY)
#undef USE_SERIAL_PORT
#define USE_SERIAL_PORT         Serial1
#endif

It's supposed to undefine "Serial" and automatically change it to "Serial1".

I'm trying to understand why this didn't work for you. Maybe it's a bug that needs to be fixed?

Could you please take another quick look at your copy of MIDI.h? Does it have both of these, or only the first part? If it was simply missing the 2nd part, then that's the cause. But if that 2nd part is present in your copy, then I have more work to do to figure out why it didn't work as intended.

I really do want to make sure this problem don't affect anyone else, so if you could please just take another quick look at your copy of MIDI.h and check if it has only 1 or both of these parts, that would really help! :)


In my Midi.h I have :

#define USE_SERIAL_PORT Serial // Change the number (to Serial1 for example) if you want
// to use a different serial port for MIDI I/O.

// Use Serial1 on all Teensy boards, because Serial is USB virtual serial
// Arduino.h must be included before MIDI.h to define CORE_TEENSY
#if defined(CORE_TEENSY)
#undef USE_SERIAL_PORT
#define USE_SERIAL_PORT Serial1
#endif


So , I don´t understand what caused it ?
 
Hi, I have the same issue.

My system (Teensyduino 1.30 supports Arduino versions 1.0.6.11).

I have downloaded the Midi-Lib from PJRC.
While the code works below fine for Arduino UNO but it does not work for Teensy 3.2.

In adddition I have some questions

1: I have downloaded the MIDI-LIB and added it as Library in Arduino
The code compiles even when I remove the downloaded Midi-Lib form my computer.
So, how can I be sure that the downloaded Midi-Lib is used.

2: I have inserted the line
#include <Arduino.h>
but it did not get red color, does it mean, the Lib is not installed ?



My Code
----------
#include <Arduino.h>
#include <MIDI.h>
/*
Basic I/O MIDI tutorial
by Franky
28/07/2009
*/


void setup() {

MIDI.begin(4); // Launch MIDI with default options
// input channel is set to 4
}

void loop() {

MIDI.sendNoteOn(42,127,1); // Send a Note (pitch 42, velo 127 on channel 1)
delay(1000); // Wait for a second
MIDI.sendNoteOff(42,0,1); // Stop the note
}


My Midi.h
----------
#define USE_SERIAL_PORT Serial // Change the number (to Serial1 for example) if you want
// to use a different serial port for MIDI I/O.

// Use Serial1 on all Teensy boards, because Serial is USB virtual serial
// Arduino.h must be included before MIDI.h to define CORE_TEENSY
#if defined(CORE_TEENSY)
#undef USE_SERIAL_PORT
#define USE_SERIAL_PORT Serial1
#endif
 
Status
Not open for further replies.
Back
Top