I need help with a MIDI input circuit?

I want to build a MIDI input circuit with Arduino, but I've encountered the following problem: The MIDI command isn't reaching the Arduino. Everything should work, but it doesn't. All components are working perfectly, and now I'm wondering if the optocoupler is even necessary in the circuit? Feel free to write me any answers or solutions to this problem.

(1 votes)
Loading...

Similar Posts

Subscribe
Notify of
20 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
RareDevil
9 months ago

You'd first need the circuit diagram, know your setup, and possibly your program… But yes, optocouplers are basically used for galvanic isolation, which is often advantageous for effectively preventing ground loops, potential ripple effects, etc. Something else could potentially break if external potentials are incorrectly introduced… So the optocoupler probably serves as protection against this…

RareDevil
9 months ago
Reply to  GartenGnom33

Well, that's just the level conversion via the optocoupler. Have you been able to see the data protocol on the RX pin? How is everything connected to the Arduino? What is your program on the Arduino for reading and processing the MIDI protocol? What does the SerialMonitor output when you output what you've read? With only fragments and partial excerpts, no one can help you…

RareDevil
9 months ago

Just read it…

Serial.Begin is the USB-Serial

Serial1.Begin is the RX0 and TX0 on the pin header…

So if you use RX0 from the pinheader, you have to initialize Serial1 with 31250 baud… and also send all commands/queries to Serial1…

RareDevil
9 months ago

Okay, it has two separate interfaces. One is only connected to the USB controller, and the second is connected to pins 0 and 1 (RX and TX). Now I don't know if the serial interface needs to be addressed specifically, since there are two. In other words, you might use Serial.Begin to address the USB interface (for SerialMonitor), and use a separate command/complement for the second serial interface.

RareDevil
9 months ago

The RX is also used by the PC (so pins 0 and 1 are the USB connection to the PC), if you have a connection to it. You'll need to use a software serial or an Arduino with two serial interfaces… So it doesn't necessarily have to be defective…

RareDevil
9 months ago

The data arrives too fast to be captured digitally. That's 31,200 bits/sec. So, 31,200 highs and lows… You don't see that as a binary input. You have to set up a serial connection and read the interface at that speed…

RareDevil
9 months ago

A fixed 5V shouldn't actually output anything, since MIDI is a protocol, not just 5V either there or not. Data is transferred. This is an interface that must be read and processed via a serial port. Therefore, you have to process the read-in data packets and assign functions to the control commands accordingly, which is what the Arduino should then do.

easylife2
9 months ago

Yes, you need the optocoupler. MIDI is a galvanically isolated current loop for a good reason.

Check the circuit to make sure everything is wired correctly and the resistors have the correct values. Then check the RX pin (oscilloscope) to see if there's a proper square wave. It could also be a software error.

easylife2
9 months ago
Reply to  GartenGnom33

Then I connected the connection on the optocoupler with 5v

Which connection? Hopefully, 5V isn't applied between pins 2 and 3, otherwise the LED in the optocoupler will burn out.

If you've already made the MIDI output of the connected device "visible" with an LED, you can also connect this LED to the circuit you've shown (between the "RX pin" and GND). The MIDI signal should also be visible on the LED, but inverted. The inversion must then be handled in software.

easylife2
9 months ago

And double-check that the 1N914 protection diode is installed the right way round. If it's reversed, it won't work.

And if the pins on the MIDI socket are mixed up (pin 4 and pin 5) it won't work either.