                      =======================
                      =  MIDI-in-a-D-shell  =
                      =======================
                         Hardware project

1. MIDI FOR A SONG
==================

A little while ago, I was looking for a MIDI (Musical Instrument
Digital Interface) for my PC. Although there are numerous
sound-cards on the market with some sort of MIDI interface, the
cheaper ones are all FM-synthesis based (ie not suitable for
music), and the wave-table based ones were all up around $500AUD+.
At that price, given the rapid rate of obsolescence of computer
hardware, it make better economic sense to buy a stand-alone MIDI
sound module for a little extra.

The thing that REALLY irked me, was invariably you had to pay
another $90AUD+ to get the MIDI interface, sold as an optional
'MIDI Cable'.

This project is my answer. It should cost about $35 AUD,
plus the cost of a Serial IO Card - about another $50 should
get you a reasonable hi-speed serial IO card, with at least
one 16550A UART on it (the 16550A is not essential, but nice).

The bonus is you can still use the extra serial IO card for
'normal' serial IO - except the maximum data rate will be
250k baud instead of 38.4k baud.


1.1 Suitable Platforms
======================
Since this MIDI adaptor works from a standard RS232 serial
interface, I have tested it on the following hardware platforms
and found it to work properly in all cases:

  * IBM-PC with doctored serial card, running Linux OS

  * Amiga (2000) (using standard hardware and software)

  * Sun Sparc10 with standard hardware and modified 
    kernel software

See Chapter titled 'Software' for more information about
the software which may be used.

The MIDI-adaptor will work with a 9-pin serial port, when
used with an normal 9-25 pin serial adaptor.

If you have a Sound Blaster equivalent or a Gravis Ultra Sound,
the D25-serial-to-MIDI adaptor cannot be used.
This is because the logic levels for 0 and 1 which appear on the
D15 plug are the inverted when compared with a normal serial port.

1.2 Sound Blaster / Gravis Ultra Sound (addendum)
=================================================
If you have one of these cards, an appropriate adaptor is described
in the files:
	D15.circuit.fig
	D15.mech.fig
This was really just an afterthought, so I haven't described it
explicitly. Most of what I've written about the D25-serial-to-MIDI
adaptor can be applied directly to the D15-SoundBlaster-to-MIDI
adaptor.

1.3 Manifest
============
You should have the following files:
	README           ...this file, general instructions
	                    for this project
	README.pcb       ...instructions for making the PCB
	D25.circuit.fig  ...Contains circuit diagram for the
	                    D25-serial to MIDI adaptor
	D25.mech.fig     ...D25 mechanics including PCB layout,
	                    component placement and drilling
	                    diagram for the D25-shell for the
	                    D25-serial to MIDI adaptor
	UARTs.fig        ...Pinout diagrams of the 16450, 16550,
	                    and NS16C552 UART IC's.
	                    Also includes the circuit diagram of
	                    the crytal oscillator circuit
	serial.fig       ...Diagram of a serial card, showing
	                    necessary modifications
	D15.circuit.fig  ...Contains circuit diagram for
	                    SoundBlaster / GUS MIDI adaptor
	D15.mech.fig     ...D15 mechanics including PCB layout,
	                    component placement and drilling
	                    diagram for the D15-shell for the
	                    SoundBlaster / GUS MIDI adaptor

	D25.circuit.ps   ...PostScript verion of D25.circuit.fig
	D25.mech.ps      ...PostScript verion of D25.midi.fig
	UARTs.ps         ...PostScript verion of UARTs.fig
	serial.ps        ...PostScript verion of serial.fig
	D15.circuit.ps   ...PostScript verion of D15.circuit.fig
	D15.mech.ps      ...PostScript verion of D15.midi.fig

	HISTORY          ...Revision History
	COPYRIGHT        ...just so there's no doubt


1.4 Performance
===============
The performace of this circuit is limited primarily by the
delays through the opto-coupler.
Any delays on the transmit circuit were insignificant in
comparison to the delays in the receive circuit.

The rise and fall times of the prototypes I made were typically
about 5-10 us, which is acceptable considering that a
single data bit at 31250 baud is around 30us long.
As tested with a loop-cable, the maximum baud rate for reliable
operation varied with each opto-coupler.
This was a low as 45454 baud in one prototype, and as high
as 125000 baud in another.
Around 50-60k baud is typical for the maximum baud rate.

The Tx and Rx LEDs are a bit faint during normal operation,
(hence the preference for high-efficiency LEDs).
All in all, they still gave clear and useful indications that
things where happening. Given that they are only used during
setup and debugging of the MIDI cabling, any more complex
LED driving circuitry is not warranted.

1.5 Diagrams
============
All diagrams have been drawn with the freely-distributable X11
drawing package known as 'xfig', and have filenames of '*.fig'
In each case, a corresponding PostScript file is also included.

Both the D15 and D25 PCBs are single-sided. The diagrams include
both a normal and mirror-image of the trackwork. The latter is
required if the PCB is made according to the method described in
the README.pcb file.

2. Circuit Description
======================
The basic hardware required for MIDI is simplicity
itself: a plain serial interface (along the lines
of RS232) but with an opto-isolator at the receiving end to
prevent hum-loops in amplifiers and other musical equipment.

The only thing you need apart from the opto-isolator is
the right baud rate of 31250 baud. 
This odd-seeming baud rate was chosen to be a binary factor
of 1Mbaud.

Most IBM-PC serial cards cannot support the 31250 baud
because they have a 1.84 MHz reference clock oscillator.

Unfortunately, 1.84 MHz cannot give a baud rate which
is close enough to 31250, because the UART first divides
the clock rate by 16.
This gives us a base-baud rate of 115200, which can then
be further divided by a software-controlled divisor to
give 115200, 57600, 38400, 28800...
The rate of 28800 is close, but not close enough
(and yes, I tried it).

All is not lost, because some of the 16450 UARTS and all the
newer 16550 UARTs can handle clocks of up to 8 MHz.
The NS16C552 (which is a dual UART version of the 16550)
can handle clock rates of up to 24MHz.
This means that all it takes to modify an existing serial
IO card to work with the MIDI baud rate is to replace
the crystal oscillator.

This is actually easier than it sounds, because the 16450
and 16550 already have an internal oscillator circuit which only
requires a crystal and a few discrete components to be added.
See Figure 'UARTs.fig' for the circuit diagram.

The Midi-In-A-Dshell - transmit circuit
---------------------------------------
The transmit circuit consists of a few resistors and a zener
diode and an indicator LED (labelled TxLED).

The zener diode is there to limit the effective driving
voltage for the MIDI output.
The driving voltage on Tx (D25 / pin 2 ) could be anything from 5V
to 15V.
The desired driving voltage is 5V, but the current must always
flow through TxLED, which has a fairly constant voltage drop of
about 2V.
Hence the choice of a zener diode around 7V.

The same effect could be achieved by putting TxLED before the
zener diode, and using a 5V zener, but this would mean that the
TxLED may come on whenever there was a signal on the pin 2 of
the RS232, regardless of whether the cable was connected or not.

By placing the TxLED after the zener, TxLED will ONLY come
on when the cable is actually connected, and the circuit is
complete (and when there is a signal, of course).
This gives a good indication that the state of the cable
which is the first thing to suspect when things don't work.

The only other noteworthy point is the 330 ohm resistors on BOTH
the 'driver' lead and the 'ground' lead of the MIDI-out cable.
This may seem redundant, but it adds another level of protection.

Let me illustrate, by assuming that instead of 2x330 ohm
resistors, we just have one 680 ohm resistor on the 'driver'
lead, (pin 4 of MIDI out) and that the 'ground' lead (pin 5 MIDI
out) is connected directly to the ground of the computer 
(via pin 7)

If the MIDI-out is plugged into another MIDI-out then the two
driver circuits are at least separated by the (fictitious) 680 ohm
resistor
If however, the MIDI-out is plugged into, say, another MIDI-out,
with an incorrectly wired cable (eg reversed), what would happen?
Not a problem, you may think, because the resistor on the 'driver'
side is still in series with the Tx circuit on both sides. The
only difference is that the maximum potential difference across
the resistor is 10V instead of 5V (when both drivers are 'on').
Except that there is another connection you should be aware of:
the signal ground of your computer is almost certainly connected
to ground through the mains plug. Your keyboard or sound-module
may also be connected to ground in the same fashion. This would
mean that the driver on the other MIDI-out would be connected
directly to ground, with the possible addition of hum-loop
currents.  Of course, the other MIDI-out should be able to survive
a short-to-ground like this, but who's to say WHAT is on the other
end?

The 330 ohm resistor on the 'ground' side of the Tx circuit
limits the current which may flow through this 'ground' circuit which
may be formed by equipment earths, and provides a degree of protection
for the 'foreign' equipment.


The Midi-In-A-Dshell - receive circuit
---------------------------------------
I have used 2 LED indicators on the receiving side.
One (the 5mm RxLED) indicates that there is data on the
line, and being received. The other (3mm LED) is an idiot 
LED to give an immediate indication of a reversed MIDI cable.
Needless to say, this LED should be off during normal operation.

Power for the receive circuit is obtained by tapping into
the CTS and DTR signals from the RS232. The diodes are there
to prevent current from flowing from one to the other if
one is high and the other is low.
I've tapped into both CTS and DTR to ensure that we are more likely
to get power, since the Rx circuit is useless without it. 
I've also included a power indicator LED (labelled 'OnLine'), so
that it is immedately obvious when the receive circuit is getting
power (or not).  CTS and DTR are 'high' during normal operation,
which is normally the same voltage that Tx is at when it is high.

The actual voltage could be anything from 5V to 15V, but 9V-10V
seems to be typical.

The receive circuit centers around the 6N138 opto-coupler.
The photo-transistor has a maximum Vce of 5V, so it was
not acceptable to simply connect it in series with a
pullup or pulldown resistor, across the 5-15V power supply.

Instead, the photo-transistor of the opto-coupler is conected to a
pullup resistor, which is connected to the OnLine LED.
Although the current through this LED may vary widely (2-7mA)
the voltage across it remains fairly constant, around 2V.
The resulting signal out of the optocoupler swings from
0 to 2V, and is then fed into the transistor, which
inverts the signal (again) and give the correct voltage levels of
0 and 5-15V

In fact, the correct voltages for RS232 are actually -5V to -15V
for a low level (logical 1), and 5 to 15V for a high level
(logical 0) (and yes, this is the reverse of the usual
convention).

So in fact, this adaptor does not give the 'correct' voltages for
RS232. Its one redeeming feature is that it works reliably,
anyway.


2.1 Parts List
==============

I have provided a price with each component, to act as a guide
to the overall cost of the project.
The prices given are 'expected and typical' retail prices for
the components, based on prices in late 1994.  All figures are in
Australian dollars.
(sorry, I've forgotten what I actually paid for each, but
the figures below should be very close)

None of the components are difficult to get.

D25-serial-to-MIDI adaptor:
---------------------------
D25 socket (25 pin female D-connector)        $2.00
D-Shell for D25 connector                     $2.50
1 x 6N138 opto-coupler                        $5.00
1 x 1k  0.25W resistors                       $0.05
1 x 2k2 0.25W resistors                       $0.05
2 x 4k7 0.25W resistors                       $0.10
2 x 330 ohm 0.25W resistors                   $0.10
1 x 220 ohm 0.25W resistors                   $0.05
2 x 5 pin 180 degree DIN plugs                $4.60
3m x Cable, figure-8                          $1.50
1 x 6V8 1W Zener Diode                        $0.50
2 x 1N4148 Diodes                             $0.20
1 x 3mm RED LED                               $0.20
1 x 5mm GREEN LED, hi-efficiency preferred    $1.50
1 x 5mm YELLOW LED, hi-efficiency preferred   $1.50
1 x NPN Transistor, BC549, BC337, BC548 etc   $0.50
                                             ======
Sub Total:                                   $20.35

Plus the cost of the circuit board, which will vary greatly
depending on whether you already have the chemicals & materials
required to make your own PCB. Anything from $20 up depending
on your approach, less if you already have the equipment.

MIDI Serial interface
---------------------
(not required for Sun or Amiga)

1 x High Speed serial card, preferably with 
    through-hole mounted or socketted UARTS  $50.00
1 x 8 MHz Crystal                             $4.00
1 x 1M 0.25W resistor                         $0.05
1 x 1k5 0.25W resistor                        $0.05
1 x 20 pF Capacitor, Ceramic                  $0.20
1 x 39 pF Capacitor, Ceramic                  $0.20
                                             ======
Sub Total:                                   $54.50


2.2 Parts List - SoundBaster-MIDI interface
===========================================
D15 plug (25 pin male D-connector)            $2.00
D-Shell for D15 connector                     $2.50
1 x 6N138 opto-coupler                        $5.00
1 x 4k7 0.25W resistors                       $0.05
1 x 2k2 0.25W resistors                       $0.05
2 x 330 ohm 0.25W resistors                   $0.10
1 x 220 ohm 0.25W resistors                   $0.05
1 x 3mm RED LED                               $0.20
1 x 3mm YELLOW LED                            $0.20
1 x 3mm GREEN LED                             $0.20
2 x 5 pin 180 degree DIN plugs                $4.60
3m x Cable, figure-8                          $1.50
                                             ======
Sub Total:                                   $16.45

Plus the cost of the circuit board (see above).


3. Construction Tips
====================

3.1 MIDI-in-a-D-Shell
=====================

The D25-serial-to-MIDI consists of a SINGLE-SIDED PCB.
(ie it has copper trackwork on one side only, the other side being bare).
All components are mounted on the 'component side' ie the opposite side
to the copper trackwork.
The D25 connector is soldered directly onto the PCB.

The D15-SoundBlaster-to-MIDI is also contructed on a SINGLE-SIDED PCB.
There are components on both sides, of the PCB (more info. below).

Making the PCB
--------------
See file: README.pcb 
for a cheap and simple approach to making the PCB

Drilling the D-shell
--------------------
Cut out a template from a printout of the file 'D25.mech.fig'
Center-punch the drill holes from the INSIDE of either half of the
D-shell, and drill pilot holes.
You may need to break off some plastic tabs inside the D-shell,
which are normally used to hold the cable-clamp in place.

Choose a drill size which is exactly the same diameter as the LEDs,
or slightly smaller, and drill from the inside of the D-shell.
This means any 'burs' made by the drill entering will not be
visible on the outside.

Gradually ream out the holes until the LEDs just slide snuggly
in and out of their holes.


Assembling
----------
Solder the D-connector onto the PCB first.
The D-connector is mounted onto the edge of the PCB, such that
the PCB fits snuggly between the two rows of pins on the D-connector.
You may need to bevel the edge of the PCB in order to be able to slide
it between the pins of the D-connector.
On the copper side of the PCB, each copper pad on the edge of the PCB
should be directly under a pin of the D-connector.
There is only one such way to attach the D-connector,
so if it looks right, it is right. 

Solder all the remaining components EXCEPT the LEDs at next.

If you are making the Sound Blaster MIDI adaptor, bend all the
pins down flat before soldering.  Components on the solder-side
of the board should be raised slightly off the board, and not
mounted flush against the board. Be sure to solder the ground
lead (going to pin 5 of the optocoupler) before mounting the 2.2k
resistor.

Position the LEDs on the PCB (without soldering), and place the
drilled half-D-shell into position.
The 3mm LED may need to be elevated off the surface of the PCB in
order to keep it level with the 5mm LED next to it. Alternately,
if you mount it flush with the PCB, it will appear 'recessed' in the
final product.
With the half-D-shell in place, and the LEDs protuding at your
chosen height from the D-shell, solder the LEDs.
By soldering the LEDs with the D-shell in place, we prevent undue 
strain being placed on the LEDs, due to any misalingment of the 
PCB / D-shell assembly. It also avoids the need to make the holes
oversize, which looks a bit rough.

Cables
------
I used 5-pin DIN PLUGS (male) on the end of the cables, rather
than the more traditional MIDI 5-pin DIN SOCKETS (female).
This meant that I did not need any additional MIDI cables at all,
I just plug my MIDI-adaptor straight into my keyboard.
1.5m - 2m for each cable is a sensible length.

I also made up a special cable for loop-testing, consisting
of 2 x 5-pin DIN line-sockets on a short piece of cable.

It is a good idea to put some silastic / silicone sealant around
the cables where theyjoin up to the PCB. This is will inhibit 
fatigue which usually occurs at the end of cables, and is a common
cause of failure in cables. Non-acetic silicone is preferable.


3.2 Modifying the Serial Card
=============================

The Oscillator Circuit
----------------------
This does not require an special PCB, and I made this up on a
piece of vero-board. In most computer equipment I've seen I noticed
that the crystal case is normally connected to ground. I expect
this is to ensure that the metal case acts as a constant capacitor,
rather than an intermittently variable one, so I followed suite.

Keep the wires connecting the oscillator circuit to the main board
as short as is reasonably possible. I used about 15mm of solid core
ex-telephone cable wire.

The Serial Card
---------------
Since your serial card may be different to the one I used, you 
will have to use your better judgement on how best to make the 
necessary modifications to the serial card.

I'll outline the basic steps required:

1. Locate the XIN pin on each of the UARTS. These will probably
   be connected to each other, and to a driver elsewhere on the
   board. 
   The XOUT pins should be unconnected.

2. Cut the track which connects the XIN pins to the original clock
   driver.
   In my case, the driver was a 18.4 MHz oscillator which was fed
   into a divide-by-ten circuit on a 82C11 IC.

   There should not be any other pins left connected to the
   isolated XIN pins.

3. Choose one of the 2 UARTS to drive the new ocillator
   circuit (I'll call it the 'driver UART').
   If you have a socketed UART, chose it to be the driver UART.

4. Isolate the XIN pin of the driver UART
   If you are cutting the track, make the piece of track attatched
   to the driver UART XIN as short as possible.

   Since I have a socketted IC, I removed the IC from the socket
   and bent up the XIN pin, so that it became free standing.
   If your IC is not socketted, it is easier to cut the track to
   the chosen XIN pin, rather than try to desolder the pin and
   bend it up to horizontal.

5. Connect the XOUT pin of the driver UART to the XIN of the other
   UART.

   I did this by bridging the (empty) XIN pin and XOUT pin on the
   socket with a solder-blob. The existing track connected the
   XIN pins of the 2 UARTs.

6. Connect the oscillator circuit to XIN, XOUT and ground of
   the driver UART.


4. Testing
==========
The MIDI-in-a-D-shell can be tested seperately by making up a
cable with a MIDI-socket on each end.
This can then be used to connect the MIDI-out to the MIDI-in
of the adaptor (assuming you've put MIDI-plugs on the end of your
cables, of course).

Do not be concerned if the OnLine LED does not come on when you
first plug the adaptor into the computer. The CTS and DTR lines
are under software control, and are often kept 'low' until the
software actually tries to use the serial port.

Any ordinary modem driver software, such as 'kermit', can be used
to test that the adaptor is working properly.  
Local echo should be off (off by default anyway).
What you type in terminal mode is what you should see on the
screen. (Remember you have to type a ^J to get the cursor to move
down the screen).

This should work at all speeds up to and including 38400 (EXTB).

It can be useful to use a lower baud rate, in order to give a
better indication on the LEDs.


4.1 Serial Card Configuration
=============================
Set up your serial card for COM3 and COM4 operation
(ie base addresses 0x03e8 and 0x02e8)
Consult the documentation on your serial card for how to do
this.
I used IRQ's 5 and 7 for the second serial card, since the
parallel ports do not need to use interrupts unless you are
using them as a network connection.
Linux uses polling drivers for the printer ports by default, so
this is a safe choice of IRQ's

4.2 Setting up the Serial Card for Linux
========================================
a) In the file:
	/etc/rc.d/rc.S
   replace the line:
	# /bin/sh /etc/rc.d/rc.serial
   with:
	sleep 20 &
	TIMEOUT_PID=$!
	( /bin/sh /etc/rc.d/rc.serial ; kill $TIMEOUT_PID ) &
	wait $TIMEOUT_PID

b) In the file:
	/etc/rc.d/rc.serial
   add the lines:
	echo "Setting cua2,3 baud_base = 500k and divsor = MIDI on EXTB ..." >&2
	${SETSERIAL} /dev/cua2 baud_base 500000 divisor 16 spd_cust
	${SETSERIAL} /dev/cua3 baud_base 500000 divisor 16 spd_cust
	if [ "`${SETSERIAL} -bg /dev/cua3`" != "" ]; then
		echo "Setting baud rate EXTB (spd_cust) on /dev/cua3 ..." >&2
                stty raw -icanon -echo 38400 < /dev/cua3
	fi

4.1 Testing Serial Card (Linux OS)
==================================
Testing the modified serial card is largely a matter of either it
works, or it doesn't.
If the oscillator refuses to oscillate, this is evident in that
commands like 'setserial' and 'stty' will hang on the first use.

If it doesn't work, check all your work thoroughly, and maybe try
varying the value of the capacitors in the oscillator circuit.
Try adjusting the values down first, since there may be some
stray capacitance to account for.
Also try shortening the wires going to the oscillator circuit,
as you may have made these too long.
As a last resort, try using a lower frequency crystal, such as
4 MHz

4.2 Testing Sound Blaster MIDI adaptor (Linux OS)
=================================================
It is not possible to use 'kermit' to loop-test this adaptor as
kermit refuses to reconise the midi device file (/dev/midi) as a
tty line. I used 'seyon' (another terminal program) instead,
which gave a lot of warning messages, but worked anyway.

5. Software
===========
Oh, hell, I was hoping you wouldn't ask.
Software support is currently limited, but some does exist.

IBM-PC / Linux
==============
For Linux, the operating system supports the 'customized'
serial port very well. However, there are no applications
which you can use off-the shelf.

Given that the source-code is always readily available, this
is not necessarily a problem.

The major hurdle is that most of the applications written for
Linux use the /dev/sequencer pseudo-device to generate timing.
The obvious solution is to modify the /dev/sequencer driver
to redirect output to a nominated serial port.

(I have been writing my own application which reads and writes
the serial port directly.
It uses system-exclusive messages to control my keyboard parameters,
and this has been quite successful.)

One difficulty I had was that Linux does not support the
Unix signal SIGIO, which is normally sent when there is data
available to be read. This would allow data to be received
asynchronously. 
As it is, you will need to poll the device to see if there is any
midi data available.


IBM-PC / MS-DOS
===============
MS-DOS? What's that?


Amiga / Amiga-DOS
=================
The adaptor works with the same hardware as any other
Amiga MIDI interface, so all normal MIDI software works.


Sparc / SunOS 4
===============
OK, so you probably don't have one of these at home, but
they're fairly common in Uni's and in the workplace.

I managed to find a kernel hack that gives the correct serial
data-rate (31250 baud) out of the standard serial port.

This was part of package called 'Incidental Music Generator' which
I found on the anonymous ftp site:
	ftp.uu.net
The file was called:
	/pub/music/img.tar.Z


6. Design Notes
===============
While gathering information for this project, I came across a
variety of information ranging from confusing through misleading
to just plain wrong.

6N138
-----
I first used the 6N138 pin-out in the back of an old Dick Smith
catalogue, and this was in the category of "just plain wrong".

I also received a circuit diagram for the SB-MIDI interface
in the form of a text file, which seemed to originate from a BBS
in the USA. While this was at least internally consistant,
it did have the D15 pin-numbering mirrored left-to-right.
It also referred to a 6-pin device as being a 
'PC900 or 6N138'. Need I say more? At least it gave me the right
connections and polarity for the SB-MIDI.

The 6N138 pin-out in the circuit diagrams 'D25.circuit.fig' and
'D15.circuit.fig' is from a Philips databook (ref [5]) describing the
6N138/6N139 optocouplers, and is correct.  
(Note that pins 1 and 4 of the 6N138 are Not Connected)

For some reason, the 6N138 in one prototype I made gave an
order of magnitiude better preformance than the others, with
a top baud rate of over 100kbaud rather than the usual 50-60kbaud.
This used a HP 6N138, and a subsequent prototype I made with
another HP 6N138 gave a top baud rate of about 70k. 
I am not prepared to draw conclusions from this,
The databook, ref [5], quotes maximum propogation delays of 10us
to turn the device on and 35us to turn it off.
Propogation delays of 5 - 10 us seem to be typical.


Amiga Users Please Note:
------------------------
I also have a circuit diagram in the form of a IFF file, which
described a MIDI interface for the AMIGA.
This shows 6N138 (with the correct pin-out), together with a
74LS04. The 74LS04 is fed power directly from pin 21 of the serial
port.  Although neither the diagram nor the accompanying text say
so explicitly, it was obviously written for the Amiga 1000.  
In the Amiga Hardware Reference Manual, pin 21 of the serial
connector is described as +5V for the A1000, and 'blank' for the
A500/A2000. There is NO convenient source of +5V on the A500/A2000
serial connector, so this circuit could not be used as-is.
Pin 9 supplies +12V but - beware - this is unregulated.
I seem to recall replacing a soldered-in fuse with a 7812
regulator after I blew the fuse...
I like my circuit better, because it's not Amiga-specific.

RS-232 Loading et al
--------------------
One point to note is that the Tx signal on pin 2 of the D25
swings to negative volts, not 0V, when it is low. This means that
the zener will be forward biased (ie conducting) and a current of
5-15 mA will be drawn through the 1k resistor (depending on the
driving voltage).
While this is higher than the current drawn on positive volts, it
has not caused me any problems on the systems I tested it on.

The RS232 spec. defines a nominal load of 3k-7k ohms.
So, in fact the MIDI-in-a-D-shell does overload the serial port a
bit. Another diode in series with the 1k resistor on the Tx line
would aleviate the problem, but also introduce another 0.6V drop
in the Tx line.  Suppose the Tx line is supplying it's minimum
volts of 5V, that's 2V for the TxLED, 2V for the receiving
optocoupler, 0.6V for the diode...  not much left, is there?

Take this together with the fact that Rx swings only to 0V,
instead of negative 3-15 V, and it becomes clear obvious that
this adaptor doesn't even try to adhere to the letter of the
RS-232 spec.  It does work though, on all of the three different
platforms I tested it on.

Cheap and nasty? Or elegantly simple?
Make up your own mind.

UART Clock Rates
----------------
I also came across a comment in the Linux system file:
	/usr/src/linux/drivers/char/serial.c
saying how nice it would be to have a serial card with a 24.576 MHz
clock...
"since the 16550A is capable of handling a top speed of 1.5 megabits"
I could not find any information to back this up, though.

According to the information  I found, the maximum clock rate is
8MHz in general.  In fact, for the NS16550AF, it is stated that 4
MHz is the highest input clock frequency recommended when the
divisor is 1.  The minimum (recommended?) divisor with an 8MHz
clock is 2.  This gives a maximum practial baud rate of 250k
baud.

Interestingly enough, no such restrictions are placed on the
NS16C552 where 24MHz is the highest input clock frequency, with a
divisor of 1.

The TL16C450 and TL16C550 also make no mention of any restriction
on the divisor, and the maximum clock rate given is 8MHz (or 9MHz,
depending on which part of the databook you happen to be reading).

I had originally assumed that all 16450's were created equal, but
it does not seem to be so. I have to think, though, that most of
them are capable of running at higher speeds. On the serial IO
card which I modified, I used the existing 16450 equivalent
device (W86C450) as the 'driver UART', and it seems to cope with
the 8MHz clock quite well. It doesn't seem to like divisors
smaller than about 4, but I'm not sure whether this is the UART
or the CPU that is having trouble keeping up.

The table below gives the manufacturer's quoted maximum clock
frequency for as many devices as I could get information on.

+----------------------------------------------------------------+
| Device                | Manufacturer  |  Max   | Recom.  | Ref |
|                       |               |  Clk   | Min Div.|     |
+-----------------------+---------------+--------+---------+-----+
| INS8250, INS8250B     | National      | 3.1 MHz|   1     | [1] |
|                       | Semiconductor |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| NS16450, NS16C450     | National      | 3.1 MHz|   1     | [1] |
| INS8250A, INS82C50A   | Semiconductor |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| NS16550AF             | National      |  8  MHz|   2     | [1] |
|                       | Semiconductor |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| NS16550A              | National      |  8  MHz|   2     | [2] |
|                       | Semiconductor |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| NS16C552              | National      | 24 MHz |   2     | [1] |
|                       | Semiconductor |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| TL16C450              | Texas         |  9 MHz |   1     | [3] |
|                       | Instruments   |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| TL16C550A             | Texas         |  9 MHz |   1     | [3] |
|                       | Instruments   |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| TL16C552              | Texas         |  8 MHz |   1     | [4] |
|                       | Instruments   |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| VL16C450              | VLSI Tech Inc | ?  MHz |   ?     |     |
+-----------------------+---------------+--------+---------+-----+
| VL16C550              | VLSI Tech Inc | ?  MHz |   ?     |     |
+-----------------------+---------------+--------+---------+-----+
| WD16C450              | Western       | ?  MHz |   ?     |     |
|                       | Digital       |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| WD16C552              | Western       | ?  MHz |   ?     |     |
|                       | Digital       |        |         |     |
+-----------------------+---------------+--------+---------+-----+
| ST16C450              | Startech      | ?  MHz |   ?     |     |
+-----------------------+---------------+--------+---------+-----+
| ST16C550              | Startech      | ?  MHz |   ?     |     |
+-----------------------+---------------+--------+---------+-----+
| ST16C552              | Startech      | ?  MHz |   ?     |     |
+-----------------------+---------------+--------+---------+-----+
| CM16C550              | CMD Micro     | ?  MHz |   ?     |     |
+-----------------------+---------------+--------+---------+-----+
| CM16C552              | CMD Micro     | ?  MHz |   ?     |     |
+-----------------------+---------------+--------+---------+-----+

D-shell Mechanics
-----------------
The files D25.mech.fig and D15.mech.fig are not off any
specfication, but just what I measured up with a ruler from the
actual D-shells I bought.
Unfortunately, there does not seem to be much consistancy in the dimensions
of DIFFERENT STYLES of D-shells. However, the 'grey plastic' style seems
to be fairly widely available, and (hopefully) all these will have
closely similar dimensions.

References
==========
[1] National Semiconductor databook 
    "Data Commumications, Local Area Networks, UARTs" 
    1990 Edition

[2] National Semiconductor databook 
    "Data Commumications, Local Area Networks, UARTs" 
    1988 Edition

[3] Texas Instruments databook
    "Interface Circuits, Data Transmission and Control
    Circuits, Peripheral Drivers/Power Actuators,
    Display Drivers"
    1991 Edition
    
[4] Texas Instruments databook
    "Data Transmission Circuits
    Line Drivers, Receivers, Transceivers, UARTs"
    1993 Edition
    
[5] Philips Semiconductors databook
    "Optocouplers"
    Book SC12
    1991 Edition

[6] Amiga Harware Reference Manual
    by Commodore-Amiga Inc.
    Addison-Wesley Publishing Company, Inc
