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.
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…
Schaltplan ist oben ⬆️
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…
Ok danke
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…
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.
Es ist ein Arduino Nano Every falls das etwas hilft
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…
And I've already discovered that the Arduino's RX port is defective, so the problem is solved. Thanks for the help.
mit dem pitch geht es aber, da da fast immer Daten kommen
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…
I already know that, but since it didn't work, I first tried to see if the Arduino was getting any power at all.
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.
And it's not the MIDI cable, I know that
The Arduino doesn't say anything on the SerialMonitor unless I manually apply 5V. It doesn't work with the MIDI cable. That's the strange thing.
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.
I have already connected an LED to the output of the midi connector and it worked.
Then I connected the optocoupler to 5V, which worked. But everything doesn't work together.
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.
I have already applied the 5v to pin 2 and 3, but with a resistor so that the LED does not burn out
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.