UPDATE : I still can't receive MIDI as of 2019年07月01日.
Here goes so far : I'm trying to follow this schematics from instructables, using 6N138. To make it easier, I'm going to copy his schematics. enter image description here
===================================
I'm using Arduino Mega. I tried to find specific topic about this and can't find any.
The target is actually send and receive MIDI, then replace the whole Arduino Mega to ESP8266 (probably the ESP-01, or Wemos D1), but I'm afraid it is too specific.
Here's the code so far on PasteBin
Here's my work so far. enter image description here 6N138
The diodes were replaced with LED, because I don't have one Original guide here. But that schematics on that thread also didn't work for some reason.
-
What is the Mega supposed to do? The ESP8266 can easily handle all of that on its own.tttapa– tttapa2018年09月21日 11:35:45 +00:00Commented Sep 21, 2018 at 11:35
-
@tttapa I'm using the esp8266 only as the wifi module, mega for the restRinaldo Jonathan– Rinaldo Jonathan2018年09月24日 07:13:22 +00:00Commented Sep 24, 2018 at 7:13
-
Define "the rest"?tttapa– tttapa2018年09月24日 07:14:01 +00:00Commented Sep 24, 2018 at 7:14
-
@tttapa mega would receive the power, receive midi connection, send midi back, and doing everything esp8266 is only for wifi shield replacement.Rinaldo Jonathan– Rinaldo Jonathan2018年09月24日 07:23:08 +00:00Commented Sep 24, 2018 at 7:23
-
The ESP8266 can easily handle MIDI connections, as well as receiving power. Using an extra microcontroller is just making everything more difficult, and is a waste of time and resources, in my eyes.tttapa– tttapa2018年09月24日 07:24:39 +00:00Commented Sep 24, 2018 at 7:24
4 Answers 4
There are plenty of MIDI circuits and most of them are quite simple, mostly an optocoupler (6N137 or 6N138, although I had better luck with H11L1), some resistors and that's mostly it. I also added ferrite beads for EMI protection, but this is not absolutely necessary.
To test your circuit, use a lot of data (e.g. by pitchbend/aftertouch), and play notes meanwhile. If you hear stuck notes (meaning the MIDI Note Off command is missed), you know the circuit is not full proof.
Regarding libraries: the FortySeven Effects library is really easy to use. I used it in the beginning before I moved on to STM32 and having to write my own, but this is a good starting point.
For the schematics I based my circuit of can be found at H11L1 optocoupler.
The best way is to read the official MIDI documentation, see page MIDI 1.0 Specification, than search for
Download the Complete MIDI 1.0 Detailed Specification Document (1996)
(Please Register! It's Free!).
-
Do you have some example schematics? That would help alot. Thanks!Rinaldo Jonathan– Rinaldo Jonathan2018年09月21日 14:10:45 +00:00Commented Sep 21, 2018 at 14:10
-
1Note that there has been an addendum in 2014: Electrical Specification Update (CA-033) It adds a specification for 3.3V systems.tttapa– tttapa2018年09月21日 14:23:44 +00:00Commented Sep 21, 2018 at 14:23
-
1@tttapa Thanks for that remark (didn't know about that addendum)Michel Keijzers– Michel Keijzers2018年09月21日 15:20:50 +00:00Commented Sep 21, 2018 at 15:20
-
just realized nobody sells 6N137/6N138, H11L1, or everything else I found at arduino.cc that can be used as alternative.Rinaldo Jonathan– Rinaldo Jonathan2018年09月24日 07:24:01 +00:00Commented Sep 24, 2018 at 7:24
-
@RinaldoJonathan I buy them from AliExpress, no problems at all.Michel Keijzers– Michel Keijzers2018年09月24日 08:47:59 +00:00Commented Sep 24, 2018 at 8:47
Most start at the midi site at playground.arduino.cc. But there are numerous web sites across the Internet. It is important to understand that the MIDI interface uses a current loop to send and receive data. While the Arduino normally uses voltage levels to communicate. As such, an electronic interface needs to be built or bought to convert between these two types of signals. Some interface designs are simple and limited. Others are complex and robust.
-
Thats a lot of read. I'll try to read them one by one. Thanks!Rinaldo Jonathan– Rinaldo Jonathan2018年09月21日 14:11:26 +00:00Commented Sep 21, 2018 at 14:11
-
Use wikipedia as a reference (don't read it all, just what you need). The playground.arduino.cc site is likely your best source. The simple design isn't that simple and the complex not all that complex. I was looking more for examples of simple (direct connections) and better (optically isolated) ways to convert voltage levels to current loops.st2000– st20002018年09月22日 13:11:07 +00:00Commented Sep 22, 2018 at 13:11
-
@RinaldoJonathan, your question has changed a lot. On some bread boards the power doesn't connect from one end to the other. In such a case you need to jumper the power bus together where they don't connect. Or move the power wires to the side where you are powering your chip.st2000– st20002019年07月01日 11:35:14 +00:00Commented Jul 1, 2019 at 11:35
-
the other power line isn't used at all.Rinaldo Jonathan– Rinaldo Jonathan2019年07月01日 11:40:06 +00:00Commented Jul 1, 2019 at 11:40
-
@RinaldoJonathan, that is not what I meant. On some bread boards like yours, there are 4 power bus lines. Two on each side. Broken in the middle. I see your bread board has uninterrupted blue and red lines. So I think your bread board only has 2 power bus lines. But it would not hurt to move where you supply power to the end of the board closest to where you use power just to check. Take a look at how the lines are painted on this bread board.st2000– st20002019年07月02日 12:21:52 +00:00Commented Jul 2, 2019 at 12:21
How to connect 6N138 to Arduino :
enter image description here Schematics : enter image description here
Basically the above schematics and installation is already okay, but instead of 1k, I used 10k on 6N138 PIN 7 to GND. VCC to 470 ohm is on PIN 6, also RX out, connected in series.
Just in case you want to use 6N137 :
Schematics : enter image description here
- Pin 5 of the MIDI DIN connector goes to pin 2 of the 6N137
- Pin 4 of the MIDI DIN connector goes via 330 ohm resistor to pin 3 of the 6N137 (so the 6N137 pins and the resistor are connected in series)
- You should also have a reverse connection protection diode between pins 2 and 3 of the 6N137 but I like living dangerously and rely on the diode inside the 6N137
- Pin 8 and 7 are connected to VCC
- Pin 6 is connected to RX
- Pin 5 is connected to GND
- 4.7 kohm pullup resistor between pin 8 and 6 (VCC and signal out)
Adapted from this blog post.
How to test it :
- I used Arduino Mega with this code.
- I then attached the Arduino Mega to Hairless MIDI, then to loopMIDI.
- Then I read the MIDI output using MIDIOX.
I might update it with H11L1 / PC900 later, if I have some time. Also, I'm going to put this thread in Indonesian in my blog later.
I use this library with Arduino Uno (where can change bootloader): https://github.com/TheKikGen/USBMidiKliK And after the device is recognized from windows how a Midi device, so not need any other program to interface em.
You can use your preferred sequencer program and your arduino interface is recognized how a midi interface.
The sketch is very simple:
/**********************************************************************************
KIKGEN MIDI USB
A MIDI USB RELIABLE INTERFACE
USB-MIDI simple converter Sketch for Arduino
USB ATMEGA8U2 ATMEGA 328P
-------------- ------------------------------ ---------------
IN Endpoint o<--------o USBOUT | usbMidiKliK | RX o<--------o (TX) MIDI IN
OUT Endpoint o-------->o USBIN | firmware | TX o-------->o (RX) MIDI OUT
The RX/TX on the Arduino must no be crossed, as the ATMEGA8U2 is directly connected
to the RX and TX pins. When PIN0 (RX) and PIN1 (TX) are configured as INPUT, we
can talk directly with the ATMEGA8U2 managing the USB, making the Arduino transparent.
************************************************************************************/
void setup() {
// Make Arduino transparent for serial communications from and to USB
pinMode(0,INPUT); // Arduino RX - ATMEGA8U2 TX
pinMode(1,INPUT); // Arduino TX - ATMEGA8U2 RX
}
void loop() {
}
And hardware schema is this: enter image description here
Explore related questions
See similar questions with these tags.