MIDI In problem with Teensy 2

Status
Not open for further replies.

peeddrroo

Member
Hi
I am using a Teensy 2 and want to to get MIDI In from a 5 pin DIN.
I am using a 6N138 based circuit, instead of a PC900 like recommended here: https://www.pjrc.com/teensy/td_libs_MIDI.html
I am getting unexpected values on my MIDI in port, they seem shuffled.
Could the 6N138 be the reason for the unpredictable results?

(I know I am supposed to follow the recommendations, but I was previously using a 6N138 with a Teensy LC, which was working fine, and I am having troubles finding a PC900 for SMT, so I wanted to give the 6N138 a try).
 
Hello, how are you sending MIDI to the Teensy? 6N138 based circuits work fine, do you have the circuit diagram that you used?
 
Well, the diagram is a bit of a mess right now, I'll try to clear it up and post it if needed. But the 6N138 part is similar to the one on the pjrc website.

Just to give you an idea of what happens, here's a screenshot of MIDI Monitor.
Basically, I have a note 60, velocity 100 channel1 sent every second to "Port 1" (note off 1 sec later, vel 64). Port 1 is harwdware MIDI Out port from my soundcard, which is connected to the Teensy 2 MIDI In port (the one with the 6N138).
The Teensy (renamed SotL Mk2) is supposed to send the received note back to its usbMIDI port, as per the code below.
So we are supposed to see "To Port 1 note 60 vel 100 channel 1" and just below, "Form SotL Mk2 note 60 vel 100 channel1", but as you can see, the result is unpredictable (although not completely random, I can see a pattern...)

So the 6N138 does receive data. It's just that the MIDI data seems a bit shuffled from time to time.

Capture d’écran 2020-09-26 à 19.51.57.jpg


Code:
#include <MIDI.h>

MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);

void setup() {
  MIDI.begin(MIDI_CHANNEL_OMNI);
  MIDI.turnThruOff();
  MIDI.setHandleControlChange(onControlChange); 
  MIDI.setHandleNoteOn(onNoteOn); 
  MIDI.setHandleNoteOff(onNoteOff);
}

void loop() {
  MIDI.read();
  }

void onControlChange(byte channel, byte control, byte value) { 
  usbMIDI.sendControlChange(control, value, channel);    
 }

void onNoteOn(byte channel, byte note, byte velocity) { 
  usbMIDI.sendNoteOn(note, velocity, channel);
}
    
void onNoteOff(byte channel, byte note, byte velocity) { 
  usbMIDI.sendNoteOff(note, velocity, channel);
}
 
Teensy LC is a 3V3 device, Teensy 2 is a 5V device. Would the MIDI circuit need to be modified to handle the difference and did you do that?

Pete
 
Teensy LC is a 3V3 device, Teensy 2 is a 5V device. Would the MIDI circuit need to be modified to handle the difference and did you do that?

Pete

Well, I think it would only be relevant for the out port (Tx), the In port shouldn’t be affected as far as I know.

But in any case, I have no clue why the Teensy 2 is supposed to be used with a PC900. I would be interested to know the reason.
 
APOLOGIES!!! I didn’t mean a 6N138, but a 4N35.
The 4N35 was working fine with the LC, but is acting with the T2.
 
Thanks Paul for the feedback.
Well, I managed to get it working fine with the LC.

Ok, going to move to 6N138 as I’m having a hard time finding PC900 in SMT.

While you’re (hopefully) reading this message, just want to thank you for your products and dedication.
Cheers
 
Status
Not open for further replies.
Back
Top