testing some USB MIDI adapters, or: where the hell are my SysEx bytes?! - Page 1
Forum section: electronics / general

author: FrankBuss
author_rank: Unknown
timestamp: October 26, 2013, 06:22:27 pm
content: I'm developing a file transfer program, to send data from a PC (or Mac) to a Commodore C64 via MIDI. My idea was to use standard SysEx commands for file transfer, but looks like some very cheap adapter from eBay just ignores any byte after the third byte. This is my report so far, comparing two other USB MIDI adapters:http://www.frank-buss.de/midi/index.htmlI can do a teardown, if someone is interested. Maybe would be interesting to see which chips they are using, and if the MIDI-in shield and ground is not connected to the system ground, to avoid ground loops. Should we bet which device does it right and which wrong?But the problem is that other people have the cheap eBay device, too. What should I do to transfer data to the C64? I could wrap it in 3-byte messages, but then it would need longer to transfer, because of the long USB-delays. Or I could require non-buggy MIDI adapters, if someone wants to use my program.

author: andyjh
author_rank: Newbie
timestamp: October 27, 2013, 01:07:16 pm
content: MIDI is an opto isolated system, so should be isolated from any ground. It was designed that way to ensure no earth loops between connected instruments. The MID input socket, should not have any ground connection to pin 2.I have used the basic in-line style interfaces, from CME (CME 2-MIDI) and ART (USB 2 MIDI), and they both work well with long sys-ex messages. The ART one, looks the same as the Bespeco one - or at the least the case is the same. These use the operating system's generic driver, but do seem to work all OK, but there are many areas with MIDI that can catch interfaces out, such as MIDI clock, active sensing and running status, and of course sys-ex, it probably depends on how fast the operating system is sending the data down the USB cable, because MIDI can only work at 31 K baud, so the interface may have to buffer quite a lot of data, it might be hard to discover how much RAM is available for such tasks in these interfaces. But generally, cheap interfaces are cheap for a reason (they don't work properly !).The opto coupler should remove the noise from the data, but these devices are powered from the USB cable, so that can put all the noise back anyway - there are so many areas where these devices can fail.I have opened up a CME one, but it's just a potted blob on the pcb - it would be interesting to see what's inside these cheap interfaces though, I am sure there will be some without an opto isolator in them.

author: kaz911
author_rank: Super Contributor
timestamp: October 28, 2013, 05:36:25 pm
content: In the very old days ('84?) - I converted normal DOS PC ISA serial ports to MIDI by exchanging the crystal to hit the right baud rate - worked fine. The opto isolation is not needed for "1-1 hack setups" - and is there first of all to enable hot-plug of instruments for drunk musicians and 2nd to minimize potential ground loops.I wrote a whole driver lib for "serial midi" and a sys-ex editor/midi sequencer on DOS in Turbo Pascal. It was published in the Danish magazine "Circuit Design" with lists of compatible serial cards with appropriate warningsSo if bytes are not coming out - I would say it is an issue on the USB->SERIAL(cheap midi) port. All serial ports have buffers - so you push in a byte - that is converted to a serial bitstream and sent out. Once the serial chip knows it has been transmitted - it opens the buffer for the next byte. Clearly something is not letting the buffer close or re-open and you get stuck at 3 bytes for what ever reason...

author: true
author_rank: Frequent Contributor
timestamp: October 29, 2013, 12:27:04 am
content: Most of those cheap Chinese ones won't do Sysex correctly, and finding one that might is a crapshoot. And even some more recognized brands (Yamaha) won't either.I have an M-Audio and it works well.Generally the requirement I have seen from application developers is that buggy devices aren't used, which is why I have the M-Audio

author: oPossum
author_rank: Super Contributor
timestamp: October 29, 2013, 02:27:14 am
content: Those cheap USB to MIDI cables use a COB (chip on board). Some of them also have omitted the opto!

author: Stonent
author_rank: Super Contributor
timestamp: October 29, 2013, 09:12:54 am
content: That brings me back... I used to have one of those old pro audio spectrum joystick to midi adapters that I used with a few different sound cards. I had a Yamaha PSS-480 keyboard that was FM Synth only and found that routing it back through midi to my AWE64 let me use the wavetable instruments.If they still make the MIDI to Joystick cables, I wonder if you could run it through a USB to Joystick cable? (Assuming all else fails)

author: FrankBuss
author_rank: Unknown
timestamp: October 29, 2013, 10:10:21 am
content: I read the USB MIDI specification:http://www.usb.org/developers/devclass_docs/midi10.pdfIt is a bit bloated and difficult to read, as most of the time with USB specifications. And it doesn't make sense for me that there are "virtual MIDI cables", because USB allows compound devices, where each device could be a MIDI interface, so this is redundant for me. And then there is the code index nibble, which says what MIDI message follows. Well, the MIDI message itself does this very nicely, so redundant as well.Ok, enough ranting, this is what is sent on the bulk channel when I send a note-on message:09 90 01 64The first byte is the code index nibble 9, and virtual cable nibble 0. Then the MIDI message follows.For the EOF SysEx message this bulk packet is sent:04 f0 7e 64 07 7b 00 f7The code index 04 says "SysEx starts or continues". Then the first 3 bytes of the SysEx message follows and then a new code index 07, which means "SysEx ends with following three bytes". I guess the cheap adapters just ignore anything after the first 3 bytes.I can't find any flow control in the USB MIDI specification. My adapters are using USB Full Speed (12 MBit/s). Because it is a bulk-endpoint, there is no speed limit as known from the control-endpoint used e.g. for HID. Would be interesting to see what the adapters do when I send with max USB speedBut on a lower level USB devices can send NAKs to temporary stop the transfer from the host.Quote from: Stonent on October 29, 2013, 09:12:54 amProbably only the joystick signals are connected, because most users don't need MIDI.Quote from: kaz911 on October 28, 2013, 05:36:25 pmNice. Sometimes I wish PCs were as easy as in old days. Soldering a 1 MHz crystal instead of the 1.8432 MHz crystal to a ISA serial card, and you have perfect 31,250 Baud MIDI. And no complicated protocol on top, just an "outp" command in assembler to send a byte.I'll open the adapters when I have some time to see what's inside, and update the article on my webpage.

author: NiHaoMike
author_rank: Super Contributor
timestamp: October 29, 2013, 02:51:38 pm
content: What about a microcontroller to translate between MIDI and RS232?Before USB, some force feedback joysticks used MIDI for sending the motor control signals.

author: FrankBuss
author_rank: Unknown
timestamp: October 31, 2013, 02:16:36 pm
content: Quote from: NiHaoMike on October 29, 2013, 02:51:38 pmThis should work, but then no Windows program could use it, because they expect standard MIDI interfaces, or you have to write a driver which provides the MIDI OS interface for a serial port.QuoteIntersting, I didn't know this.I found some time for a teardown and updatedthe webpage. Now there are images of the PCBs of all three adapters, with some comments. Conclusion: The cheapest eBay adapter is crap, no opto-isolator, but even the expensive RME Babyface (with an opto-isolator) has the shield connected to ground of the PCB, for both, MIDI-In and MIDI-Out, which makes the opto-isolator useless, if the shield is connected to ground on MIDI-Out of the sending device, too. And no ground connection (pin 2) for both connectors.

author: David_AVD
author_rank: Super Contributor
timestamp: October 31, 2013, 08:56:06 pm
content: I believe the MIDI specification has provision for powering devices. This is why there is a (current limited) +5V supply on another pin and the output is grounded.

author: FrankBuss
author_rank: Unknown
timestamp: November 01, 2013, 09:23:29 am
content: Quote from: David_AVD on October 31, 2013, 08:56:06 pmI can't find this in the specification, do you have a reference? This is the electrical specification:http://www.midi.org/techspecs/electrispec.phpWould be difficult to use it as a power source, because the specification says that pin 4 on MIDI In has to go into an opto-isolator, so the voltage would be low at this pin. And if you use it for powering a device, the voltage could get too low for the LED in the opto-isolator. But it would work with some low power microcontroller circuit.

author: David_AVD
author_rank: Super Contributor
timestamp: November 01, 2013, 01:07:33 pm
content: A Google search for "midi output circuit" showed this image as the first image hit. There are others too. I don't have the midi spec to hand, but was sure it was part of the later revisions.So, it's now quite how I remembered it; the 5V supply is still on pin 4 and there's the ground so you can draw current from it all the time. Not a lot of current, but active midi devices do exist.