Turning an old PC into a MIDI-CV converter
gstopp at fibermux.com
gstopp at fibermux.com
Mon Mar 25 19:48:00 CET 1996
Hi list, here's another DIY project from hell...
A while back I posted the idea of building my own MIDI-to-CV converter
based on my long-dormant PC-XT and an Analog Devices D/A chip. Well I
got the heart of it running and so I thought I'd post the details. Be
aware that I haven't yet made any music with it, but it looks like it's
gonna work pretty good and I figgered I'd let others in on it so they
could start on their own if they wanted to (or suggest better features
before I finish it).
I had thought about a hardware-based MIDI-CV solution, then realized
that using a processor would be a whole heck of a lot better. But an
embedded solution (uP with EPROM) needs an EPROM development system,
and even then once it's built it wouldn't be easy to change its
functionality on the fly. A multi-channel MIDI-CV converter should be
able to control pitch and gate on several different synthesizers, or
control multiple CV's on one or two modular machines, or anything in
between. I wanted a more open-ended system. So my thoughts turned to
my old dusty PC-XT, with its MPU-401 still installed. I figgered that
all I'd have to do is put a multi-channel D/A converter on it, and
write some code, and I'd have a cool and cheap MIDI-to-analog
controller with a powerful user interface (CRT, mouse, keyboard), that
could do whatever I wanted it to.
(The XT used to be the main sequencer in my setup, running Cakewalk
and Texture under DOS. Even though it would make a fine slave
sequencer, I have 112 MIDI channels already on the new PC. My wife
wants to throw the XT away to free up the garage shelf space. It's
really not worth much right now.)
The design uses an Analog Devices AD7228 Octal 8-bit DAC which is
installed in an external rack-mount panel that attaches to the PC via
the parallel port. I chose the printer port over the serial port for a
couple reasons:
1. The external hardware would be less complicated
2. The throughput would be higher
The PC's parallel port provides eight data bits, plus four more
outputs that are used as control pins for the printer. All these
signals are controlled by two I/O port address locations - one for the
eight data bits, and another for the control lines (with four unused
bits). All of these signals behave simply as latched bits, so even
though the documentation labels the control pins as such things as
"data strobe" or "select", I didn't follow these functional
assignments since I'm not going to use standard BIOS calls or printer
drivers.
Since there are four control lines, the DAC is eight channel. Three
control lines function to select one of eight channels, and the fourth
control line is the data strobe to write in the data. A 74HCT259 octal
addressable latch is used to provide eight latched bits for eight
V-gate outputs. Since MIDI note values range from 0 to 127 (a range of
slightly over ten octaves), only 7 of the 8 data bits into the DAC are
used, so I simply grounded the D0 input on the DAC and ran the lowest
7 bits from the parallel port into the highest 7 bits on the DAC. The
MSB of the data goes into the addressable latch. Therefore writing a
value between 0 and 127 to a DAC channel will create an analog voltage
with its corresponding gate off, and writing a value between 128 and
255 to the channel will create an analog voltage with its gate on.
This corresponds to a MIDI "note-off" and MIDI "note-on".
The DAC requires a low-impedeance level on the Vref input. For this I
used a 78L05 regulator with a trimpot to set it to the required
reference level for 1V/octave semitones per bit (slightly over 10
volts). If you don't do this the reference voltage will be loaded down
depending on the state of all the DACs and the voltages will have
errors.
Each CV output from the DAC goes into a lag circuit, into a
level-shifting buffer, into a scale control. Each gate output from the
addressable latch goes into a comparator to bring the level up to +12
volts from +5 volts, to provide the gate output and to drive the gate
LED. Therefore each CV and each gate output require one op-amp. I'm
using four LM324's total. Each channel will have the following:
Gate LED
Lag Control
Range Control (DC offset trimpot)
Scale Control (attenuation trimpot)
CV output jack (1/4")
Gate output jack (1/4")
Power supply requirements are as follows:
+15 - DAC, Vref, CV op-amps
+12 - Gate output comparators
+5 - 74HCT259 latch
GND
-15 - CV op-amps
I chose to put the gate output comparators on their own regulator to
avoid glitching the supply that the CV's run on.
To write data into the DAC, I use the following algorithm:
PortReg_1 = Data register
PortReg_2 = Control line register
Address = DAC channel, 0 to 7
Value = DAC data, 0 to 127
Send (Address, Data)
OUT PortReg_2, Address plus data strobe high
OUT PortReg_1, Data
OUT PortReg_2, Address plus data strobe low
OUT PortReg_2, Address plus data strobe high
RETURN
The first OUT sets up the address lines so they'll be stable for the
third OUT.
The second OUT sets up the data lines.
The third out strobes the data. Data strobe low writes the data into
the DAC (the DAC is transparent when strobe = low, and latches data on
the rising edge of the strobe).
The fourth OUT brings data strobe high again to latch the DAC, as well
as leave things in a quiescent state for the next event.
To test the DACs I used a test program in QuickBasic, with nested
FOR/NEXT loops to write ascending staircases to all DACs
simultaneously. This resulted in eight rising 10 volt ramps, with an
overall repeat rate of 283 milliseconds. This multiplies out to 3,618
note events per second (8 x 127 x .283).
Also I measured the note duration writing to a single DAC channel.
This measured 246 microseconds per note, which comes out to 4,065
note events per second.
All of these timing measurements will be machine dependent, I think.
This was done under QuickBasic under Windows on what appears to be
some run-of-the-mill 386/25 here in the lab. It'll probably be slower
on my XT, especially as I add more smarts to the code, but it's
plenty fast enough already so I'm not too worried.
I don't have any plans to add linear VCO control capability, as all
my analog synthesizers are exponential. Somebody else can tackle that
part.
Anyway in another post I will bring up the subject of how to parse
MIDI data to control the DAC under any conditions, plus muse on all
the possible CV scenarios and their corresponding programs. Lemme
know what you think guys.
- Gene
gstopp at fibermux.com
More information about the Synth-diy
mailing list