Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MIDI and Arduino

Status
Not open for further replies.

Schiller

New Member
Hi there, i'm designing a midi input circuit. It would work with an Arduino Uno
i read carefully this post and the official midi hardware specs
Both resources have been very useful..

I would pose a question:

apparently, my midi input circuit works only with pin 4 (from midi connector) attached to pin 3 of the optocoupler
and pin 5 (from midi connector) attached to pin 2 of the optocoupler. So it works only if i invert the two connections between the midi port and the optocoupler

May this depends from using the circuit with Arduino?

Thanks for your attention...

As I had questions about this myself I thought I'd post a helpful diagram for anyone who might happen to wonder how to properly hook up a 6N138 optoisolator as a MIDI Input. This diagram shows both the MIDI In and the MIDI Thru. A MIDI Out is identical to a MIDI Thru, however the input to the first Schmitt Trigger inverter is tied to the UART TX rather than the UART RX. This allows you to send the same OR different data from the UART TX to the MIDI Out rather than just mirroring the incoming data from the MIDI In like the MIDI Thru does.

The 1K resistor from pin 7 to ground is required for the quickest rise/fall time of the output transistor as you only have 32uS per byte. It can be 1K or higher. Some have used values as high as 22K here.

Hope this helps anyone who has this question -

**broken link removed**
 
So it works only if i invert the two connections between the midi port and the optocoupler
Any signal inversion required can be taken care of in the Arduino software.
 
If you're using a 6N138 opto isolator, pin 4 should connect to pin 2 of the opto with a 220R series resistor while pin 5 should connect to pin 3 of the opto directly. A backwards 1N4148 diode should be connected across pins 2 and 3 of the opto (cathode to pin 2, anode to pin 3).

If you're using a Sharp PC900, pins 1 and 2 on the opto should be used in place of pins 2 and 3 respectively.

If you're using any other opto besides these two, make sure the output of the opto is rated for a rise time of less than 2uS (high speed opto) as per the MIDI specification.

The data should not be inverted at the opto output as a low at pin 5 (current on) is a logic 0 while a high at pin 5 (current off) is logic 1. The opto output drops low when current is on while rising high when current is off. This is the correct polarity and no inversion is necessary.
 
Last edited:
Here is a schematic for a MIDI interface showing MIDI In, Thru, and Out ports. Uses a 6N138 high speed optoisolator on the MIDI In port.

The buffers on MIDI Out may/may not be necessary. They've been part of the MIDI hardware specification since the days of earlier processors that didn't have symmetrical source/sink currents and thus couldn't provide the current drive for the current loop. But the Thru port definitely needs it.

midi-png.100927
 

Attachments

  • MIDI.png
    MIDI.png
    15 KB · Views: 1,421
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top