[sdiy] Detecting the presence of a receiving MIDI device through current sensing

rsdio at audiobanshee.com rsdio at audiobanshee.com
Tue Jan 28 07:55:30 CET 2020


I like your line of thinking.

I’m a big fan of D/A chips that convert to current rather than voltage. They have weighted current sources, each producing half the current of the previous bit. You simply feed the digital value in parallel, and the current sources are combined to produce the correct total current according to the digital value. What I find to be really neat is that all of the bits that are “off” are actually just switched to an inverted output, rather than trying to turn off the current. You then have both the normal and the inverted signal and can combine them with a differential operational amplifier stage. This differential output from the D/A converter ends up producing a lot less noise than a single-ended converter. Another benefit of this design is that the D/A converters can run at rates like 125 MHz. Yeah, that’s 125 MHz, not just 125 kHz.

But now I digress…

Getting back to your idea, I have a couple of points.

First, MIDI is not 1 mA to 5 mA. Instead, it’s defined specifically as a 5 mA loop. That’s a nominal value, so it doesn’t have to be perfect, but the specification is not a range but a set value. You need to send enough current to fully engage the optoisolator LED emitter. Sending one-fifth the current is likely to cause issues with some MIDI devices. Granted, the MIDI Specification requires that the optoisolator must turn on with less than 5 mA, but it doesn’t allow the transmitter to produce less than 5 mA by design.

As for the two supported optoisolators (Sharp PC-900 and HP 6N138) producing different currents, I’ve always understood that they both have approximately the same Forward Voltage across the LED. Thus, both should produce the same 5 mA nominal current loop. The SHARP data sheet says 1.1 V typical, 1.4 V maximum, with a note that extremely low currents (300 uA) might result in a 1.0 V Forward drop, but that is not applicable with a guarantee of 5 mA when working within the MIDI Standard. Fairchild says 1.30 V typical, 1.75 V maximum. Lite-On 1.1 V typical, 1.7 V maximum. Running those numbers, I see the current should always be between 4.3 mA and 5.3 mA (I’ve accounted for the typical 0.4 V minimum output low for the inverters).

That said, you will need to allow for quite a bit of variation. You can alleviate some of that by using a precision 5 V reference and 0.1% resistors.

At first, I thought it wouldn’t matter about devices that are powered off, but then I realized that your solution wouldn’t detect the moment when a connected device actually turns on, so you wouldn’t know that the previous-off device needs Status.

Patent this quickly, because you’ve already published...

Brian


On Jan 27, 2020, at 8:07 PM, Didrik Madheden <nitro2k01 at gmail.com> wrote:
> I had an idle thought about reducing power rail interference in audio
> circuits by equalizing the currents that any given part of the circuit
> draws at any given time. For example, a MIDI transmitter may use up to
> 5 mA when transmitting. If the circuit was also set to dump 5 mA into
> a dummy resistor whenever it was NOT transmitting, that part of the
> circuit would always draw exactly 5 mA, and no interference would be
> injected into the power lines due to changes in load. Then I realized
> that different MIDI implementations might draw slightly different
> amounts of current depending on which optocoupler it's using, not to
> mention what would happen if no MIDI device was connected, in which
> case the circuit itself would inject the exact same amount of analog
> noise it was supposed to prevent...
> 
> This is an absolutely silly consideration. At least in this context. […]
> 
> But I digress. Normally, this is where my train of thought would end,
> and I would go think about something else. This time, however I
> remembered the discussions on this list about MIDI running status woes
> where a device may get unconnected and reconnected. So I thought, hmm,
> could the idea discussed above actually be useful?
> 
> Consider this: 5 pin MIDI is a 1-5 mA current loop that typically goes
> through a 1.6 V optocoupler and three 220 ohm resistors. So, by
> sensing the voltage after the 220 ohm resistor on the +5 V line, you
> could deduce whether a device is present on the other side. If nothing
> is connected, you're just seeing +5V through a 220 ohm resistor, which
> should be close to rock solid. If it's transmitting, by Ohm's law
> there will be at least a V=I*R=0.001*220=0.22 V voltage drop while
> transmitting a byte. With a bit of margin, you could detect anything
> below 4.9 V as the presence of another device. You could for example
> detect this by sampling the voltage with an ADC in a suitable moment.
> Or, you could use a comparator with one input set to a 0.98*Vcc
> voltage divider.
> 
> A good time to check this would be when sending active sense commands,
> which are meant for exactly this thing, just not exactly like this.
> 
> This approach would have several downsides. It can't detect if a
> device has been powered off but is still connected. It can't detect
> anything about thru-connected devices. It would probably fail to
> produce any useful information on non-powered MIDI splitter devices.
> 
> What it *could* do, is to provide a basic heuristic for when a
> transmitting device might suitably need to refresh the status byte, as
> well as potentially resend CC's. Something that would nominally not
> hurt anyway.
> 
> It's silly. It's crazy. But has something like this ever been done to
> anyone's knowledge?
> 
> -- 
> /Didrik





More information about the Synth-diy mailing list