MIDI out circuit not working as expected

I have a simple MIDI board that I need to use with an Arduino:


I reverse engineered it by measuring it out entirely:


(the 47k resistor was a typo, it's actually 4.7k)

Then I took my Arduino Leonardo and conencted 5V to 5V, Gnd to Gnd, RX (midi out) to pin 10 and TX (midi in) to pin 11 and tried to use it with this little sketch:

#include <SoftwareSerial.h>

const unsigned long interval = 3000; // 3-second interval
unsigned long lastSendTime = 0; // Time of the last MIDI message

SoftwareSerial midiSerial(10, 11);  // midi RX, midi TX

void setup() {
  Serial.begin(115200);   // Debugging via Serial Monitor
  midiSerial.begin(31250);   // MIDI communication at 31.25 kbps
  Serial.println("MIDI ready.");
}

void loop() {
  // Send a MIDI Note On every 3 seconds
  if (millis() - lastSendTime >= interval) {
    lastSendTime = millis();
    sendMIDINote();
  }

  // Check for incoming MIDI data
  while (midiSerial.available()) {
    byte incomingByte = midiSerial.read(); // Read the incoming byte
    Serial.print("Received byte: 0x");
    Serial.println(incomingByte, HEX);  // Print the echoed byte to Serial Monitor
  }
}

// Send a MIDI Note On message
void sendMIDINote() {
  midiSerial.write(0x90); // Status byte: Note On, channel 1
  midiSerial.write(60);   // Note number
  midiSerial.write(100);  // Velocity
  Serial.println("Sent Note On: Middle C");
}

Now the great news is that the complicated part (midi in) using the optocoupler IC is working perfectly fine, I can receive any midi messages without any issues.
But the really simple part (midi out) is for some reason not working at all. No matter if I loop midi out back to midi in or if I use any midi device or midi interface to send a message to it.

I even double checked that the resistance from 5V from Arduino to the MIDI out port pin 5 is 220 ohms and the resistance between the Arduino midi tx pin (11) and the MIDI out port pin 4 is 220 ohms and that between GND from Arduino and MIDI out port pin 2 is 0 ohms.

From what I can tell, this should be a perfect circuit, but I must be missing something here. Any help would be appreciated.

Can You please post schematics? Pen and paper works fine. Remember to write the pin symbols.

That circuit is wrong for a MIDI output. First off you are using the same pins 10 & 11 to send MIDI out BUT you are using these pins to connect to the opto isolator for some unknown reasion.

Second those capacitors across the MIDI output will kill any MIDI signal on it.

Third I am not sure if software serial is implemented on a Leonardo.

What exactly makes it wrong in your opinion? This is a very widespread piece of hardware among musicians.

Is it possible that I just I've just mistaken 5V for TX and vise versa?

Edit:

I just tried it and that was exactly the problem :roll_eyes:
Now it works like a charm :slight_smile:

I have told you, what about what I have told you do you not understand?

On a Leonardo you can use pins 0 & 1 as an extra MIDI output / input using serial 1.

I find it difficult to believe that. But if you think it works like a charm then so be it. I suspect you will be back when the charm wares off.

As I said, this is extremely widespread hardware (designed by Behringer 20 years ago) and used by tens of thousands of musicians and I've never heard anyone complain about it. The only thing that was wrong, was the way I wired it to the Arduino (mistaking TX for 5V and vice versa), other than that the circuit works fine. If you find that hard to believe feel free to take another look at it.

Yes and I think I have found the problem.

I think that what you have presented in your "physical layout diagram" (this is not a schematic as asked for) is incorrect. Leading to post #5 being a nonsense.

How have you tested this circuit?
In particular have you looked at the MIDI out signal on an oscilloscope?

The physical layout shows layout shows the capacitor C4 (what value is this?) being connected between the signal and ground, which is only going to degrade the signal.

You show the same nonsense on the input signal as well.

This is the schematic from the H11L data sheet. Note the total absence of capacitors.

The MIDI in and out schematics are shown here:-

Again notice there are no capacitors used at all. You may disagree with the PNP transistor circuitry but it ensures that what ever sort of Arduino you use you can drive it with this circuit.

I get that the capacitors are not necessary, but I don't think that you can strictly say that the capacitors will degrade the signal. Realistically they probably serve to do the opposite, right? Maybe they help filtering out high frequency noise (>31.25 kHz).

I don't have an easy way to measure the capacitance, but I would assume it's much lower than you may think.

No they do degrade the signal.

And what do your mind reading skills know what I might think?

No matter how small it will degrade any signal by slowing down the rise and fall times.

No they will not period. Filters simply do not work like that. Any cutoff frequency is only the frequency that is 3dB down on the input (or 6dB another reference). Have you read any filter theory?

I had my first article about MIDI published in 1995 "Acorn Computing" it was about:-

Special 1995 RTR9
MIDI interface. The AKA12 MIDI interface is available at a knock down price. Unfortunately it only connects up to the A3000. This article shows how to convert it to plug into a standard podule socket.

I had been using MIDI way before that.

Now I wonder why you bother to ask questions if you are not going to listen to people who know what they are doing?

Conclusion is that you don't like being corrected, and therefore this forum is not for you.

So I have put this thread on mute, meaning I will not get any more notifications from you, so I will not see any replies you make.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.