Z80 Space-Time Productions Single Board Computer
Technical Support Information

MIDI - Musical Instrument Digital Interface

I have had the rare priveledge of getting to exchange email with one of my life-long heroes - Doug Ingle of Iron Butterfly fame. He has been a very gracious and bright place in my universe for several months now, and we have had some great conversations. Our exchanges covered some of the musical equipment they used and are using today. In my curiosity about the Vox Continental organ [which was used to record "In-A-Gadda-Da-Vida"] , I spent quite a few hours researching vintage organ and synthesizer technology, as well as some of the more modern samplers and keyboard synthesis modules that are available today.

Well, I've been a synthesizer nut since I was about 12 years old, listening to all kinds of Moog music, and building several PAIA electronic music kits during the 70's pretty well cemented my feet as I submerged into total geekdom, (but in a good way - ha).

http://www.paia.com
Click here to visit PAIA's web site. If you are into electronics and enjoy electronic music, this is the place for you!

Moving forward, my research led me across a very interesting series of web pages concerning the SID-6521 synthesizer IC, which was used in the Commodore C-64 computer around 1983. No small number of people have salvaged these IC's from the old Commodores and created quite an array of music synthesizers using MIDI interfaces. MIDI, with a little processing overhead, seems to be more the native home of the SID-6521 than the actual Commodore C-64 computer for which it was designed.

There are albums of music created on these, and there is even one professional product out there surrounding the SID built by Elektron of Sweden, called the "SIDStation". The music that comes out of this one IC is pretty amazing.
http://www.sidstation.com

I decided this chip should be easy enough to get my hands on, and that I should design and build a small synthesizer [daughterboard] for my Z80 computer, also design and build a MIDI interface on a separate daughterboard, and get busy writing software.


MIDI Interface Design:

The 6N139 optoisolator seems to be the opto of choice among home-built MIDI interface fans. It's specs have the appropriate rise time that one needs to intercept MIDI data. Most of the designs I have seen use CMOS inverters, CMOS is a little touchy as far as ESD goes. I decided to use 74LS14 Schmitt Trigger Inverters. Midi standard is to sink 5mA of current, the 74LS14 will handle 8mA without cooking. I have a fistful of these from a medical equipment salvaging operation.

The second serial port on the Space Time Z80 is not really implemented in that there are no second pairs of 1488 and 1489 IC's to convert the SIO's B channel for use. This is part of the conservative design of the board. The kits that are for sale now on Ebay have a daughterboard that uses the 1488 and 1489 to convert the TTL levels to RS232. If the original use called for a printer, the RS232 daughterboard could be easily added and voila! If it didn't need it, then components could be saved. At one point I had built my own daughterboard using an MC145406 RS232 transceiver, built mostly for PRINTing from BASIC. Then I got busy dreaming of Vox Continentals and synthesizers from my old PAIA electronics days as a teenager. Midi seemed the logical use of this port.

I was lucky to stumble over a vintage computer A-B-C switch at a junk equipment sale recently (remember, the old PC's keyboard cables were 5 pin, 180 degree DIN - same as MIDI). The A-B-C switch was used to connect a single keyboard and EGA screen to three separate PC's. Those three female DIN connectors on the back of that unit were exactly what I needed. The interconnecting cables from the computer to the A-B-C switch are essentially MIDI cables- 6 feet long, perfect. I drilled one of the backplane panels on my rack box and screwed the sockets to it. I used an old ribbon-cable type jumper to make the connections back to the PCB, and a PC board standoff and screws to lift the daughter board I built off of the ST board - there is an unused mount hole near the J-2 SIO connector.


Baud Rate Clock

Your original board probably uses the 2.0MHz system clock to drive the 8253 PIT counter so you can get 4800 baud for your SIO. This is the max speed you can derive using 2.0MHz, it actually delivers 4806 baud. I salvaged a 1.8432MHz Xtal from an old PC serial card, and soldered it to the pins of J-4 to clock two of the 8253's counters. This way I was able to burn a new monitor rom that sets the counter and SIO for 38400 baud, which works great. I tried 56K, but the monitor program can't seem to quite keep up, so I set it back for 38400 where it is plenty fast.

MIDI's baud rate is not evenly divisible off of a 1.8432MHz clock, so the 8253 counter # 2 is CLK'd off of the 2.0MHz system clock, the PIT is set to deliver 500kHz (500,000 / 16 = 31250 baud), the SIO set to divide the clock by 16. The 8253 counters # 0 and # 1 are CLK'd off the 1.8432MHz, delivering 38400 baud (Serial A) and 4800 baud (unused).

One thing that has crossed my mind during the preliminary software design is that the 8253 PIT has a vacant counter which is not being used for anything. I would be pretty simple to read the Midi Note-Ons and Note-Offs to gate and set the count rate. All that would be needed would be to build a cross-over table to take the Midi note value and convert it to a two-byte 8253 count value. The On and Off function could be an I/O output pin tied to the 8253 Gate input pin. A "1" would cause the note-on and a "0" would disable the count, silencing the generator. Tie the output of the 8253 counter to a simple speaker drive transistor so as not to load down the 8253 output pin, and Voila'! A very simplistic synthesizer is born.

Take note that this will not be a perfectly pitched device, since most notes are not integer value (most have long decimal places e.g. - Bb with a Midi value of 58 is actually 233.0818807590 Hz. A little play with a calculator (2x10^6) / Freq in Hz = 16 bit count - will show that you can get close, but not perfect.

Another thing to bear in mind is that there is no hardware on the Z80 to control amplitude, in other words to make a sound envelope for your new synth. You notes would simply be on and off at full volume, about like a caliope or worse. This experiment might be worth a few laughs, but I don't think the hardware changes and the work involved would give you results that you would pat yourself on the back for. Also, it would be monotonic - one note at a time. So I'm keeping this idea on the back-burner in case the SID gets hard to find - but I've pretty well discarded this 8253 idea for now.


The Future is Here

This MIDI Interface page will probably mutate into a "Z80-MIDI-SID Synthesizer" page in the near future, so keep checking back. I started writing some experimental code for the SID interfaced to the Z-80, but without an actual IC I'm having to focus on some other things. I've also put some thought into the coding required to use the 8279 panel to control the SID, and my first run of key-inserts has the basic parameters to drive the SID, but haven't gone much farther than that yet (November 2005).

Got a home-built synth or SID project you want to talk about? Email me.

I guess most of you have seen the video that traveled around email, not to mentioned appeared in a beer commercial about the house with the computer-controlled music syncronized lighting. I'm not sure if this is going to become part of this computer or another, but I have set my sights on having at least a computer-controlled tree for Christmas 2006. I recently purchased two each 16 opto triac modules in racks for a total of 32 switchable channels at 10 amps, so the project is well on it's way.

I'm not sure just exactly how I'm going to control this - MIDI looked like a good answer, but getting a playlist of audio files to sequence in time with MIDI looks pretty difficult without SMPTE time code to help. More on this later.


All information contained herein that is generated by J.Owens (c) 2004, 2005.
Other information credited to its sources.
This Site is not affiliated with Space-Time Productions, Mr. M.Simon, or Mr. Ron Weiss, however I extend a grateful Thanks to those parties.
This site has a sole purpose to provide technical information, and is not intended to infringe any prior
copyrights nor to derive funds that would otherwise be the property of Microsoft, Space-Time Productions
or it affiliates, either past or present.
May the Force be with you.