MIDI Library, Teensy 4.1 & Dodgy Old Synth! (DX7)

Hi There!

I have a very simple prototype board made up of a MIDI Output circuit (https://www.pjrc.com/teensy/td_libs_MIDI.html) and one Momentary Switch and one Pot. Both these controls are configured to send a simple Control Change (Sustain on/off and Volume).

I am using the "controller" code from https://www.notesandvolts.com/2016/03/arduino-midi-controller-potentiometers.html to handle switch bounce and Pot noise etc, and of course the MIDI library.

All is good, and i can see the expected output (simple controller changes) in my midi monitor software.
All is also good when i plug the MIDI OUT into a Yamaha Reface CP.

However, if i instead plug the MIDI OUT into a DX7 (Mk1) the dreaded MIDI DATA ERROR occurs, and the synth becomes unusable until I remove the MIDI cable.

If I plug the powered up board into the DX7 before turning the DX7 on, the DX7 gets stuck at boot.

This synth is renowned for being rather crap at MIDI, especially handling "large" amounts of data, and other controller manufacturers have implemented "speed controls" to slow down MIDI messages from those controllers (Dtronics DT-7 has a variable control, the PGX7 has a fixed "speed" that works).

If I plug the MIDI OUT from the Teensy into an old Yamaha YMM2 Thru box and then connect the THRU to the IN of the DX7 - hey presto - everything works just great. Controller changes work just fine, seems the THRU box is filtering or throttling or otherwise cleaning up the output. It also seems as if the MIDI library is sending stuff as soon as MIDI.begin() is called. but this (if true) doesn't show up in my MIDI monitor s/w.

Therefore my question is: is there anything i can do either via the MIDI library, or perhaps in my code that can "slow things down" so that I can use this prototype board directly plugged ino the DX7?
Perhaps it is how often I'm checking if the controls have been touched? But wondering if there is some "global" midi tweak I can make to avoid having to throttle things for a particular synth.


The relevant code in the INO file is basically this:

Code:
MIDI_CREATE_DEFAULT_INSTANCE();
MIDI.begin(MIDI_CHANNEL_OFF);

And then the appropriate

Code:
MIDI.sendControlChange

for the switch or the Pot.

I have tried a few things already, turning MIDI THRU off, using custom settings for the instance, attempting to lower the baud. None of these seemed to have any effect. I can't be sure i did that correctly:

Code:
struct MySettings : public midi::DefaultSettings {
  static const long BaudRate = 9600;
};

MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial1, MIDI, MySettings);
 
a short update, I got rid of the more 'elaborate' routines and loaded up this simple test Note On, Note Off program instead, with the exact same results:

works fine on Reface CP - playing the notes
works fine via a MIDI Thru box to the DX7
fails when connected directly to the DX7

Code:
#include <MIDI.h>

#define LED 13

MIDI_CREATE_DEFAULT_INSTANCE();

void setup()
{
  pinMode(LED, OUTPUT);
  MIDI.begin(MIDI_CHANNEL_OFF);
}

void loop()
{
  digitalWrite(LED, HIGH);

  MIDI.sendNoteOn(56, 127, 1);
  delay(300);		       
  MIDI.sendNoteOff(56, 0, 1);
  MIDI.sendNoteOn(57, 127, 1);
  delay(300);		       
  MIDI.sendNoteOff(57, 0, 1);
  MIDI.sendNoteOn(61, 127, 1);
  delay(300);		       
  MIDI.sendNoteOff(61, 0, 1);
  MIDI.sendNoteOn(62, 127, 1);
  delay(300);		       
  MIDI.sendNoteOff(62, 0, 1);
 MIDI.sendNoteOn(66, 127, 1);
  delay(300);		       
  MIDI.sendNoteOff(66, 0, 1);
  MIDI.sendNoteOn(62, 127, 1);
  delay(600);		     


  MIDI.sendNoteOff(62, 0, 1);

MIDI.sendNoteOn(62, 127, 1);
  delay(200);		       
  MIDI.sendNoteOff(62, 0, 1);
MIDI.sendNoteOn(61, 127, 1);
  delay(200);		       
  MIDI.sendNoteOff(61, 0, 1);
MIDI.sendNoteOn(62, 127, 1);
  delay(200);		       
  MIDI.sendNoteOff(62, 0, 1);
MIDI.sendNoteOn(66, 127, 1);
  delay(300);		       
  MIDI.sendNoteOff(66, 0, 1);

MIDI.sendNoteOn(57, 127, 1);
  delay(300);		       
  MIDI.sendNoteOff(57, 0, 1);

  MIDI.sendNoteOn(50, 127, 1);
  delay(300);		       
  MIDI.sendNoteOff(50, 0, 1);





  digitalWrite(LED, LOW);
  delay(2500);
}
 
Assuming that you have used a Teensy LC or later, try reducing the value of the 47R resistors to 33R or 27R.
 
I appear to have narrowed it down to nothing whatsoever to do with the MIDI library!

Even with the simple "blink" example running on the Teensy, the DX7 barfs as soon as power is provided to the Teensy

If i disconnect the TX1 pin from the MIDI output jack - everything is good (at least it doesn't cause the error). It seems on power up the TX1 (serial) is sending something the DX7 doesn't like. Any ideas?
 
Does the DX7 respond to MIDI from another piece of equipment? Can you control it using the Reface CP? I'm wondering if your MIDI out circuit needs a buffer, usually two hex inverters in series. Your MIDI Thru box probably does something similar. The forty year-old PC900 optocoupler chip used in the DX7 MIDI in, may be to blame.

zRbhj.jpg
 
Last edited:
Thanks!

Yup, the DX7 is fine being controlled by other gear, a KX88, the reface, a Clavinova, my computer running MidiOX or a DAW etc. I mean i say "fine" with the usual caveats around this board! :)

I also tried another thru box (which I made using 6N138s) which works. I've no doubt it's the dodgy old board to blame.

At any rate, I was running short of ideas, so switched the connection to MIDI pin 4 from Vin (which is the positive rail of the rest of the circuit) to the 3.3V pin, and hey presto everything works great.

Feeling rather dumb for not trying this earlier, and for not really understanding why it makes a difference, although it seems clear the DX7 doesn't like the 4.9V sent via pin 4. I presume it's more to do with amps than voltage.

But at any rate, the whole circuit is now using 3.3V, and I can get on with working on the reason for making the prototype!!!





Does the DX7 respond to MIDI from another piece of equipment? Can you control it using the Reface CP? I'm wondering if your MIDI out circuit needs a buffer, usually two hex inverters in series. Your MIDI Thru box probably has this. The forty year-old PC900 optocoupler chip used in the DX7 MIDI in may be to blame.

View attachment 32058
 
Feeling rather dumb for not trying this earlier, and for not really understanding why it makes a difference, although it seems clear the DX7 doesn't like the 4.9V sent via pin 4. I presume it's more to do with amps than voltage.
Not knowing stuff isn't dumb, though it can lead to expensive or even dangerous mistakes!

For the benefit of future generations ... the reason you had problems is actually more to do with volts than amps. If you look at the receiver end of MIDI, you see it's just the LED inside an optocoupler, plus a 220R resistor. This is powered from the transmitter end, with pin 4 being power and pin 2 being pulled low during transmission. What pulls pin 2 low is of crucial importance. In both of Paul's circuits you linked in post #1, it's just a CPU pin; UHF's circuit in post #5 adds a couple of buffers, but doesn't tell you what the power supply is to them ... let's go with Paul's circuits, since that's what you referred to. These are directly driven by a Teensy 4.1 port pin, which can swing (roughly) between 0V and 3.3V, BUT ... and this is crucial ... 3.3V is still 1.7V less than 5V, so even when supposedly inactive there's still some voltage available to drive the LED. It might be a bit weedy (not enough amps through the LED and resistors .. so yes, amps do come into it), but clearly in this case not weedy enough.

It also won't work to configure the output as "open drain", so it can only sink current to ground but not source 3.3V. Even if you did that, there are protection diodes on every pin which will prevent the pin going much more than about 0.3V above the supply (or -0.3V below ground). This is to protect the chip from minor mishaps, but results in there still being 1.4V available to drive that receiver LED...

MIDI is technically a current loop, requiring "less than 5mA to turn on". As far as I can see there's no specification as to what the voltage drop across the receiver diode is, but most circuits show 3 220R resistors and a 5V supply, so you should budget for 1.7V or less; the 6N137 data sheet I have to hand says typically 1.4V at 10mA. With the 3.3V supply and 2x 47R resistors and one 220R, you get about 6mA current, so within the specification.
 
Thanks muchly for the further explanation.

Serves me right for not paying attention to the "basics", every other device working except the DX sent me on wild goose chase!.
After some rest it makes complete sense. I have seen so many other circuits based on 5V (that use older boards like Ard Uno etc) I made an assumption I should use that pin for the positive rail. and somehow i managed to muddle up the Teensy 2.0 and 4.1 circuits.

cheers


Not knowing stuff isn't dumb, though it can lead to expensive or even dangerous mistakes!

For the benefit of future generations ... the reason you had problems is actually more to do with volts than amps. If you look at the receiver end of MIDI, you see it's just the LED inside an optocoupler, plus a 220R resistor. This is powered from the transmitter end, with pin 4 being power and pin 2 being pulled low during transmission. What pulls pin 2 low is of crucial importance. In both of Paul's circuits you linked in post #1, it's just a CPU pin; UHF's circuit in post #5 adds a couple of buffers, but doesn't tell you what the power supply is to them ... let's go with Paul's circuits, since that's what you referred to. These are directly driven by a Teensy 4.1 port pin, which can swing (roughly) between 0V and 3.3V, BUT ... and this is crucial ... 3.3V is still 1.7V less than 5V, so even when supposedly inactive there's still some voltage available to drive the LED. It might be a bit weedy (not enough amps through the LED and resistors .. so yes, amps do come into it), but clearly in this case not weedy enough.

It also won't work to configure the output as "open drain", so it can only sink current to ground but not source 3.3V. Even if you did that, there are protection diodes on every pin which will prevent the pin going much more than about 0.3V above the supply (or -0.3V below ground). This is to protect the chip from minor mishaps, but results in there still being 1.4V available to drive that receiver LED...

MIDI is technically a current loop, requiring "less than 5mA to turn on". As far as I can see there's no specification as to what the voltage drop across the receiver diode is, but most circuits show 3 220R resistors and a 5V supply, so you should budget for 1.7V or less; the 6N137 data sheet I have to hand says typically 1.4V at 10mA. With the 3.3V supply and 2x 47R resistors and one 220R, you get about 6mA current, so within the specification.
 
Back
Top