MIDI UART not successfully communicating with all receiving devices

Status
Not open for further replies.
I'm working on a controller for hardware synths. I'm using the UART to transmit midi. The controller only sends midi. I'm not certain whether this is a Teensy issue or a problem with my external hardware. It's my first project so thought I'd start here in case I'm missing something.

The problem I'm having is not all hardware is responding to the midi message being sent. Using a midi to usb interface with my computer and logging with MIDI Monitor (http://www.snoize.com/MIDIMonitor/), the messages are successful every time. Most of my other hardware responds to the messages every time however one does not. It never responds to the messages from Teensy but does respond to messages from other hardware. Additionally, it will respond to the message sent by Teensy if I connect to a different piece of hardware that has a MIDI thru jack and then connect that thru jack to it.

My code is transmitting on midi channel one. I tried the synth on both omni mode and set to channel one.

My questions are:
1. Is this likely to be Teensy related or the synth that is not responding? Or combination?
2. Are there suggested steps I can take to debug this issue?

I'm a beginner with hardware so any tips on debugging are appreciated. My first thought was maybe Teensy isn't providing a high enough voltage to the midi jack pin 4 and some devices could deal with that while others couldn't and using the thru jack amplified that enough to work. Not sure how to test that or if even a reasonable idea.

The good news is it works with a bit of a hack. Would be nice to find a more direct solution and understand the issue. Thanks for any suggestions.

Teensy 3.1
Arduino 1.0.5
Teensyduino 1.19
Using MIDI library
Wired as described in MIDI library example for output: 220ohm resistors between Tx and 5v, plus ground. https://www.pjrc.com/teensy/td_libs_MIDI.html

Short example source code to illustrate issue:

Code:
#include <MIDI.h>

const int midiChannel = 1;

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

void loop() {
  MIDI.sendNoteOn(60, 99, midiChannel);
  delay(1000);
  MIDI.sendNoteOff(60, 99, midiChannel);
  delay(1000);
}
 
I suspect you will find that it will work with
Code:
const int midiChannel = 0;
Most MIDI devices refer to midi channels as being from 1-16 but when writing code to generate midi messages, the channels are encoded as 0-15.

Pete
 
Thanks for the quick reply Pete.

Unfortunately this didn't work. When set to 1, MIDI Monitor reports the channel as 1. When set to 0, MIDI Monitor doesn't appear to receive any messages. Also, I tried my hardware synth set to receive both on specific channels and omni mode and either way get no response.
 
Yeah, sorry. The MIDI library also uses 1-16. I was confusing it with a different package I used on a different machine.
It is strange that it works if you connect it to a midi thru. That suggests a hardware problem but I don't know why the thru would be different from a normal input.

Pete
 
Is the Midi thru buffered?, could it be a loading problem on the bus?.. What you are discussing sounds to me like poor rise time or "Slow Edges" on the midi data and my hint was the pass through caused a difference in the device operation.

Doc
 
Thanks for the ideas.

I'm not positive whether the midi thru is buffered -- unable to find a service manual for it. Based on my understanding of the midi spec, it should be.

I'm not sure what you mean by a loading problem on the bus -- I'm definitely a beginner at this.

If it is a case of slow edges, would reducing the 220ohm resistor help? I noticed this example from the midi spec includes a 7417n between the Tx and the resistor. Perhaps this is necessary to be compatible with a broader range of devices? I'll need to do some research to understand what the 7417n is doing in that circuit.
 
Teensy 3.1
Arduino 1.0.5
Teensyduino 1.19
Using MIDI library
Wired as described in MIDI library example for output: 220ohm resistors between Tx and 5v, plus ground. https://www.pjrc.com/teensy/td_libs_MIDI.html

Nicely done problem statement. The error is in your circuit; on the page cited you seem to have missed
Teensy 3.0: Use two 47 ohm resistors on MIDI OUT, with the pin 4 resistor to +3.3 volts. For MIDI IN, connect the 270 ohm resistor to +3.3 volts.

DIN MIDI is a current loop interface. When the voltage goes from 5V to 3V3 the resistor values need to be altered so the same current flows.
 
Great catch. Whether this solves the issue or not I think it revealed a mistake on my part with how I have my breadboard setup. I thought I measured that voltage but may have made other changes since. I also missed some of the differences in the setup of the Teensy 2 in the tutorials (for example, the LED Wiring & Testing here: https://www.pjrc.com/teensy/tutorial2.html) and the 3.1 I'm using.

I'll review my breadboard and try the 47 ohm resistors. Thank you.
 
Capacitive loading comes from long wires, or low buss current (DI/DT issues) and to the second part, Yes reducing the series resistance will improve the issue as this increases the 'DI'' term... Remember that time is the inverse of frequency (F = 1/T) so more current = less charge time, obviously within the device and supply parameter limits.
There is one more liikely issue and that is the "Effective ESR" of the power supply, one of the reasons for smaller sized bypass caps ie 100 nF or so used as close to each device drawing current from the power bus.. It's the leading edge of the pulse as.. as DT approaches "0" DI approaches infinity or the limits of the power supply. It's really a simple thing but, really is due to two things.. one is the series inductance of the power supply distribution [both power and the ground. Wide traces for both Vcc and Gnd/return and the other is the available surge current or Big bypass capacitors (10 to 50 uF) every two or three IC's as well as the smaller HF (fast rise time) bypass capacitors... It's a lot like the fulcrum used in conjunction with the lever used to "Move the World".
The bypass capacitors are used to negate the inductance of the power supply in Toto...
This comes from Xc = 1/2 * pi * F * C and Xl = 2 * Pi * F * l where units are F = HZ and L = H and C = F.
also note that Xc is the inverse of Xl..

Doc
 
Last edited:
My guess is changing to 47 ohm resistors is likely to fix the problem. The one troublesome device probably has a less sensitive optocoupler at its input, which probably isn't getting quite enough current with the 220 ohm resistors and only 3.3V.
 
Thanks for the help everyone. The switch to 47 ohm resistors fixed the issue.

Sorry to have overlooked/misread that bit of the documentation but glad it was an easy fix.
 
Last week I met with Tom White of the MIDI Manufacturers Association (MMA). We discussed a number of issues with the MIDI spec (like why isn't there a PDF freely downloadable) and implementation completeness, but the issue relevant to this thread is the so-called electrical specification for MIDI over DIN, which is just an example circuit diagram with no indication of how to use or adapt it for other voltages. He agreed that this was an issue and said it had recently been addressed; an updated electrical specification will be published "soon". I don't have any other details, until I see it.
 
Status
Not open for further replies.
Back
Top