MIDI Output spec - I found simpler.. Or did I? - Page 1
Forum section: electronics / projects

author: Saimoun
author_rank: Frequent Contributor
timestamp: December 16, 2020, 11:45:31 am
content: HiSo I'm looking at the MIDI output spec, and I'm thinking... I think I can do it better?! Something must be wrongFor those who do not know MIDI, it's a protocol to send music data (notes) from one instrument to another. The output is a UART 5mA current loop, with a LED (optocopler) on the MIDI input connector. Logical zero on the UART means current ON.The spec is here:https://www.midi.org/specifications-old/item/midi-din-electrical-specificationThe designs suggested by the spec are:MIDI Output:MIDI Input:This makes sense, the UART is default high (current OFF), and logical one will be current OFF, logical zero will be current ON - it make sense.So - my idea! Currently we have, for the output circuit:* pin 4 = VCC* pin 5 = UART (zero=low=current ON)Would that not be the same result if we do:* pin 4 = inverted UART* pin 5 = GNDthis still gives default state = logical one = pin 4 low = current OFFand logical zero = pin 4 high = current ONIn my mind this is a lot simpler - it removes the requirement for the extra resistor, and on a board GND is a lot more accessible than VCC.Of course the UART needs to be inverted but with any modern MCU this can be done pretty easily.So my question is - have I missed something here?

author: Saimoun
author_rank: Frequent Contributor
timestamp: December 16, 2020, 11:49:05 am
content: Maybe the problem is that not following the spec on one end is OK, but if the people making the MIDI input circuit do the same and change the design assuming that the MIDI output follows the spec, well then

author: SeanB
author_rank: Super Contributor
timestamp: December 16, 2020, 12:53:57 pm
content: The goal of MIDI is isolation of ground loops, so you need that fast optocoupler in there, and the symmetrical resistors are there for some protection if somebody plugs in a microphone cable with phantom power, so that the resistors hopefully burn out and not destroy all the semiconductors on the board, as resistors are easy to change, but custom silicon less so.

author: magic
author_rank: Super Contributor
timestamp: December 16, 2020, 03:58:14 pm
content: Quote from: simonlasnier on December 16, 2020, 11:49:05 amYeah, nothing wrong with it until somebody thinks he's being clever powering something from that VCC line using the shield as ground return, or grounds the shield to local ground and ends up frying something, or whatever.

author: SiliconWizard
author_rank: Super Contributor
timestamp: December 16, 2020, 06:36:05 pm
content: Quote from: SeanB on December 16, 2020, 12:53:57 pmYep.On top of that, the benefit here is that VTx is sourcing the current for the receiving optocoupler. If you replace this with a simple IO, now the IO will have to source the current - which is a different story! Unless you add some buffer, in which case there is really no benefit at all.And, saving one resistor for a port output, "a lot simpler"? Really? GND more accessible? Note that Vtx in the specs in not necessarily "Vcc", nor may it be desirable - if by that you mean the main digital power supply on your board.Additionally, they suggest ferrite beads, which frankly is a good idea here, and will cost more than a single resistor anyway. And that said, additional ESD protection may also not be a luxury - IMO. So in the end, a single resistor in the final BOM for one MIDI out port won't matter whatsoever.Side note - although still ubiquitous, the original MIDI standard is getting old. There is a work in progress for a MIDI HD standard, with extensions to the protocol, but also extension to other physical busses such as USB and Ethernet. No clue when it will get finalized though, it's been years already.

author: Saimoun
author_rank: Frequent Contributor
timestamp: December 17, 2020, 12:21:21 pm
content: Ha ha!Fair enough - my "a lot" simpler is not that much. The idea is though to remove not only 1 resistor but a "big" one, i.e. there is no need for a 0.5W one anymore (which can be a bit more expensive since you have to go above 1206 packages). The 0.5W was to protect the VCC/VTX to GND - now our pin is already grounded and the other one will only need a 0.25W resistor since it can now be bigger.And just FYI pretty much any modern MCUs can easily handle the load (5-8mA max) from an IO pin. Also it would not matter if it sinks or sources the current since both are limited with same amount (usually 15-20mA).Quote from: SeanB on December 16, 2020, 12:53:57 pmOhh - never thought about that! You mean a 5-pin XLR for example? Would that fit in a DIN-5 plug?In the MIDI spec they say the resistors are for:1) getting the right current through the optocoupler (around 5mA)2) protecting the circuit in case of short from:* VTX (pin 4) to ground* VTX to UART (pin 4 to pin 5)(short from pin 5 to GND is ignored with the idea that the UART is an open drain IO)

author: Yansi
author_rank: Super Contributor
timestamp: December 17, 2020, 12:26:42 pm
content: Jeez, how hard it is to follow such a super simple spec? Do it properly according to a spec and stop bitching like a small child.Otherwise do whatever you want, but don't claim your interface is MIDI. MIDI compatible at best. So that the user will know, that some dumbass needed to cheap out on two resistors and now they have some expensive equipment not working (even though it should), or possibly even something expensive has blown its ass, due to some "MIDI compatible" device.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 17, 2020, 01:01:04 pm
content: so far I had no problems with midi circuits; indeed every uC usart is able to drive the current loop; 2x 220R gives about 7-8mA in a 5V environment, on the mini in you go with a 6N135

author: Jan Audio
author_rank: Frequent Contributor
timestamp: December 17, 2020, 02:53:12 pm
content: Dont drive from microcontroller, use the specs.

author: Yansi
author_rank: Super Contributor
timestamp: December 17, 2020, 02:59:33 pm
content: Quote from: Jan Audio on December 17, 2020, 02:53:12 pmExactly. I did interface an RS232 port to CMOS 5V logic through series resistors (just two inverters). Did it work? Yes. But is it the way it should be done? Hell no!

author: jeroen79
author_rank: Frequent Contributor
timestamp: December 17, 2020, 03:25:37 pm
content: Quote from: magic on December 16, 2020, 03:58:14 pmI guess that a 'clever hack' is fine until it encounters another 'clever hack'.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 17, 2020, 03:43:09 pm
content: Quote from: Jan Audio on December 17, 2020, 02:53:12 pmok, I solemnly swear to use buffers from now on

author: helius
author_rank: Super Contributor
timestamp: December 17, 2020, 04:01:33 pm
content: Another consideration when the spec was being designed (1980) is that TTL circuits have much stronger negative compared to positive drive capability. A TTL output can sink 16 mA in the LOW output state, but can only source 0.4 mA in the HIGH output state. This is why you only want to use the driver to pull current through the loop from Vcc, not to push it through the loop to GND. CMOS drivers don't have this problem but it's still good practice.

author: HB9EVI
author_rank: Frequent Contributor
timestamp: December 17, 2020, 04:10:07 pm
content: I guess 74HCT should meet that requirements, though I'm used to use 74HC most of the time

author: Saimoun
author_rank: Frequent Contributor
timestamp: December 17, 2020, 11:10:30 pm
content: Quote from: helius on December 17, 2020, 04:01:33 pmOh this is really interestingThat explains a lot actually!