Email Address:
Password:

Lost your password?

This is the legacy website; please use the new website.

The USB MIDI-Mate: A MIDI Interface for PCs

An up-to-date MIDI interface for PCs

By Jim Rowe

Ten years ago, in the February 2001 issue of SILICON CHIP, we described a project called the MIDI-Mate – an easy-to-build MIDI interface to go with the PCs that were then available. At that stage, most PCs had either no built-in MIDI port at all or just a rudimentary MIDI port tucked away inside their sound card and available only via a couple of pins on the sound card’s game port.

The original MIDI-Mate was designed to expand those crude MIDI “core ports” into a full MIDI port which could be hooked up to any standard MIDI synthesiser, instrument or keyboard using standard MIDI cables. The unit was pretty popular and we think this updated USB version will be too.

Now it’s true that basic USB-MIDI adaptor cables are already available at fairly low cost, offering a MIDI IN and MIDI OUT port at the end of a cable which plugs into a PC’s USB port. But these devices only offer the bare minimum of MIDI interfacing facilities. There’s no MIDI THRU output linked to the MIDI IN jack and only a single MIDI OUT jack, which restricts you to a very simple set-up.

Our aim in developing our new USB MIDI-Mate has been to come up with an up-to-date interface offering the same expanded MIDI ports as our original unit. At the same time, the cost should be only slightly higher than a USB adaptor cable.

As with the original MIDI-Mate, it’s powered directly from the PC so no separate power supply is needed.

What it does

This unit provides a 2-way serial communications “bridge” between one of the USB ports on a PC and external MIDI devices. This enables the PC to send a MIDI music file out to a synthesiser and/or other electronic musical instruments via the interface’s MIDI OUT jacks. In addition, the PC can receive MIDI messages from a keyboard or other MIDI controller, via the interface’s MIDI IN jack.

Both the MIDI IN and MIDI OUT messages are relayed to and from the PC (and the software running on it) via a single USB cable.

Click for larger image
The rear panel provides access to the Type-B USB socket and a reset switch. The two LEDs show the USB status and blink alternately when the device is plugged into a computer and working correctly.

Considering that USB is a serial bus and MIDI is also serial data communication, you’d perhaps expect that an interface bridging between the two would be quite straightforward – a bit like a couple of UARTs (Universal Asynchronous Receiver Transmitters) connected back-to-back. It’s not quite that easy though, largely because of the protocols that must be used when any kind of data is sent over the USB.

That’s because all USB communication is controlled by the host (ie, the PC) and the device at the other end of a USB cable is not free to upload any data it likes, whenever it likes.

In addition, each MIDI message sent over the USB needs to be “packetised” (packaged into a standard USB data packet) with an identifying header byte attached to the start of the packet – a bit like an address label. This is to ensure that each packet reaches the correct destination at the receiving end.

Quite apart from these complications, any USB device also has to provide answers to a standard set of questions from the host PC as soon as it’s plugged into a USB port. This rigmarole is known as the “enumeration sequence”, because the host needs to know quite a lot about the device before it can give it a USB address and install the appropriate drivers so its software can communicate with the device correctly.

Click for larger image
The two USB Status LEDs, the USB socket and the Reset switch are accessed via the rear panel.

In short, even though our little USB-MIDI interface is just acting as a 2-way communications bridge, it needs to be based around a microcontroller to handle the USB enumeration and communications protocols. In this case, we’re using a PIC18F14K50 microcontroller, which is about the smallest and lowest-cost device available with an in-built USB module, as well as a USART module capable of working at the MIDI data rate of 31.250kHz.

The USB module inside the PIC18F­14K50 is actually pretty impressive. It includes a full-speed and low-speed compatible USB serial interface engine (SIE) plus a USB transceiver so that it can connect directly to a USB cable. It takes its clock signals from the PIC’s main clock circuitry, which in this case also includes a frequency-multiplying phase-locked loop (PLL) to provide a 48MHz clock derived from the external 12MHz crystal.

Data can be exchanged very efficiently between the PIC’s CPU and the USB module’s SIE. That’s because they share a 256-byte dual-port static data RAM (SRAM), with each side controlling one of the ports.

Share this Article: 

Privacy Policy  |  Advertise  |  Contact Us

Copyright © 1996-2018 Silicon Chip Publications Pty Ltd All Rights Reserved