|
Understanding the PC's MIDI
Interface
by Stuart Ball
Start ı How
Does MIDI Work? ı How the Circuit Works
ı Sources and PDF
HOW THE CIRCUIT WORKS
The first two gates of U1 (pins 14)
buffer the MIDI TX signal from pin 8 of the IDC header (pin 12 on
the DA-15 connector) and drive the current sink pin of the MIDI OUT
connector through a 330-ohm resistor. The current source pin is connected
to 5 V through another 330-ohm resistor. When the MIDI OUT connector
is connected to the MIDI IN on a MIDI device, the optoisolator LED
at the MIDI IN end is connected between pins 4 and 5. So, when U14
goes low, the LED turns on. Because these LEDs have a typical forward
voltage drop of about 1.6 V, the current through the diode is about
5 mA. When U14 is high, there is no current through the diode.
The input to the MIDI OUT driver is pulled
to 5 V with a 47-kilohm resistor. This ensures that an unconnected
input wonıt float, while providing a high enough impedance to avoid
upsetting the MIDI output signal from the computer. Some soundcards
have a resistor of 1 kilohm or so in series with the MIDI output.
This prevents damage to the soundcard if a joystick directly connects
pin 12 to one of the other 5-V pins, but it could cause problems with
the adapter circuit if a smaller pullup is used.
Serial, current-loop data on the MIDI
IN connector drives the LED in optoisolator U2. The output of U2 goes
low when current is flowing in the LED, and this signal is buffered
by two more gates of U1 (pins 1013). U110 drives the MIDI
RX signal to the computer. Diode D1 protects the LED in U2 against
a miswired MIDI cable, which would apply reverse voltage to the MIDI
input connector. The diode in U2 is only rated for a maximum reverse
voltage of 5 V. If the leads on the MIDI cable are reversed, D1 conducts,
limiting the reverse voltage to 0.6 V.
The relatively high transfer rate of
the MIDI signal (32 ıs per bit) requires use of a fast optical isolator
such as the 6N137. Slower devices, if they can switch the signal at
all, have long turn-on and turn-off times that will distort the received
waveform.
ICs U3 and U4 are ı555 timers that function
as one-shot multivibrators. When a low occurs at the MIDI TX signal,
U3 (pin 2) goes low and the output of U3 (pin 3) goes high for about
0.01 s. This causes LED D3 to briefly flash.
IC U4 works the same as U3, except that
LED D2 flashes for incoming MIDI data. The LEDs indicate activity
on the MIDI lines and can be used to troubleshoot the MIDI hookup
when things aren't working right.
CONSTRUCTING THE CIRCUIT
The prototype circuit was constructed
on perfboard using point-to-point wiring and housed in a plastic Radio
Shack box. The MIDI connectors are mounted on one side of the box,
and the LEDs on the other (see Figure 4). A slot was cut in the case
cover to accommodate the ribbon cable. The female end of the ribbon,
where the joystick plugs in, can be mounted to the side of the case
if you choose. I brought both sides of the ribbon out through the
slot.
 |
| Figure 4ıThe four signals needed
by the translator circuit are taken from the ribbon cable at
J1. |
Figure 4 shows a right-angle connector
for J1 because that's what I used. An upright connector will work
just as well. I built the prototype as shown because the adapter sits
on the left side of the computer. If your adapter is on the right
side, you might want to reverse the circuit board in the case so the
LEDs face you when the ribbon cable comes out the left side of the
case and the MIDI cables come out the back.
As already mentioned, the 6N137 optoisolator
at U2 is a high-speed part required for the high MIDI bit rate. Don't
try to substitute the common 4N25 or other slower device because then
the circuit won't respond.
The LEDs are mounted to holes drilled
in the case and connected to the circuit board with wire. You can
use LED panel mount holders, but I simply glued the LEDs into the
case. The LEDs are optional. If you don't want them, you can leave
off U3, U4, R4R7, C3, C4, and the two LEDs. For better visibility,
you can use high-intensity LEDs and make one red and the other green
so that you don't have to look at the lettering on the box to tell
which is active.
The bypass capacitors (C2, C5, and C6)
should be located near U1, U2, U3, and U4. U1 is a 74HCT14 on the
parts list. You could also use
a 74ACT14 or 74HC14.
When you make the ribbon cable, clip
wire 16 at both ends so the cable will fit into the DA-15 connectors.
Be sure to clip wire 16, not wire 1. When you connect to the IDC-16
header on the board, make certain that you connect to the correct
pins. The DA-15 connectors number their pins 1 through 8 down one
side and 9 through 15 down the other. The IDC connector has the even
pins on one side and the odd pins on the other, as shown in Figure
4. The connector cable manufacturers sell expensive crimpers for their
cables, but a vise works well if you are careful.
If you don't want to make a ribbon cable,
put both male and female DA-15 connectors on the plastic case and
wire them together (pin 1 to pin 1, pin 2 to pin 2, etc.). Bring out
the four wires needed for the circuit. I think the ribbon cable is
easier. You can increase the LED ON time, making them more visible,
by changing R4 and R6 from 100 kilohms to 220 kilohms.
CHECKOUT
You should verify all the wiring before
installing the ICs and plugging the circuit into the computer. The
simplest way to check the adapter is to connect it to an instrument
using a MIDI cable and send a MIDI file using an audio utility that
is capable of communicating with a MIDI device. Many computers come
with MIDI Orchestrator or a similar program. Many soundcards come
with a CD that includes audio software, including a MIDI player. If
everything is working, youıll see the LEDs flash and will be able
to send and receive MIDI data. Of course, you must have the instrument
set up to operate over its MIDI interface as well.
If you donıt have a MIDI instrument,
or if you just want to play it safe and test the circuit before you
connect it to your $2000 synthesizer, connect the adapter to the joystick
interface. Then, using software that can send data to the MIDI port,
transmit a MIDI file. You should see the MIDI OUT LED blink. Now,
use a MIDI cable to connect the MIDI IN and MIDI OUT connectors together.
When you send the MIDI data again, both LEDs should be active. If
you connect an oscilloscope to the MIDI RX signal on the joystick
end of the ribbon cable, you should see the serial MIDI data being
transmitted.
If you donıt get data, first make sure
the computer is generating output to the MIDI port. Most soundcards
under Windows 95 or 98 can send data either to the external MIDI device
via the MIDI interface or to the speakers via a FM wavetable synthesizer.
You can check this by going to control panel/multimedia/MIDI and verifying
that the external MIDI device is selected.
If you still canıt get the interface
to work, monitor the MIDI TX signal into the adapter circuit with
an oscilloscope or logic probe. If there is no signal there, make
sure that one of the ribbon cable connectors isn't attached backwards
and that the connectors aren't crimped to the cable at an angle. If
they are, you will usually end up with two wires shorted together.
Once the MIDI part has been verified,
plug in a joystick and test it using the Windows joystick test feature
(control panel/joystick/test in Windows 95). You can use the MIDI
adapter to verify that a MIDI device is transmitting. Plug the MIDI
OUT from the device into the MIDI IN on the MIDI adapter. When the
MIDI device is sending MIDI data, the MIDI IN LED on the adapter will
blink. The computer doesn't need to be running any MIDI software for
this to work. As long as the computer is powered and the adapter is
plugged in, the LEDs will indicate activity on the MIDI line.
You can use the same technique to troubleshoot
a string of MIDI instruments when one isn't sending. Just connect
the MIDI OUT or MIDI THRU from each instrument, one at a time, into
MIDI IN on the adapter and check the LED.
Thatıs it. Youıre ready to control the
MIDI world.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ıCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |