S/PDIF Stuff

Keep in mind that this page was started in a different time. (1999 to be exact) Back then doing high quality digital audio recording with a PC was REALLY new. Digital audio on computers is so commonplace now, and most machines have quite good audio hardware, much of which is good enough for music use.

Introduction to S/PDIF

Digital audio is really cool. Also cool are the mostly standardized formats for sending digital audio between devices. There is a professional format called AES/EBU, but most consumer gear, as well as very many professional devices use S/PDIF. “S/PDIF” stands for: “Sony Philips Digital InterFace”.

S/PDIF is just like MIDI, in that there are two distinct parts to what people mean when they say “S/PDIF”:

  • a data protocol
  • a hardware interface

Data Protocol

The data protocol is universal across all S/PDIF devices. It can support different sampling rates and resolutions between 16 and 24 bits. It can also support up to 4 channels, but I have yet to see a device that uses this capability. Most people won’t hack the data protocol at all.

Hardware Interface

The hardware interface is the actual physical connection that is used to send data between devices. If you are hacking around with S/PDIF, it will most likely be by building various hardware interfaces. Most of the confusion surrounding S/PDIF is because there are several different ways of sending S/PDIF data. You might find the following types of interfaces:

  • coax - this is a 75 ohm coaxial cable that connects with RCA plugs
  • TOSLINK - this is an optical connection
  • TTL - this kind of signal is present on sound cards, and on TOSLINK modules

Let me just make it clear that no matter which type of hardware interface you need to use, the data that is being sent is the same. S/PDIF is also polarity independent, which makes it a lot easier to work with.

Coax

The coax interface uses 75ohm coax cable with RCA connectors. Even cheesy audio patch cables work well for transmitting S/PDIF. The signal is +/-0.5V and should be terminated with 75 ohms on the receiving end. (termination is built into coax inputs)

TOSLINK

The TOSLINK interface uses cheap mylar optical fibre cables that plug into TOSLINK modules. These modules input or output a TTL signal. Both Sharp and Toshiba make the modules. Also, stereo stores like to over-charge for these cables, selling 6 foot cables for upwards of $100. A 6 foot cable should only cost $15.

There are two styles of TOSLINK connectors. Some have the standard square TOSLINK plug, and the others have an 1/8″ style plug. The latter is found on portable MD recorders, and usually doubles as an analog line input. You can get modules of either type, and you can also get cables that connect between one and the other. The 1/8″ is purely for compactness in small devices. Other than the shape of the plug, it works the same way.

TTL

The electrical connections to and from TOSLINK connectors is TTL. TTL is 5V/0V on/off pulses. This type of signal is used within most digital electronic devices, (although often at lower voltages) and many simple digital logic chips are compatible with TTL. Also, TTL is found on many sound cards like the Soundblaster Live!. Creative Labs sells add-on units that feature TTL<->coax or TTL<->TOSLINK converters. You can of course build these converters yourself to save money and provide exactly the kind of connections you need.

Projects

I’ve built several different S/PDIF devices that I use regularly. The first thing I found was that TOSLINK modules are hard to get. You can salvage transmitters fairly easily from old broken CD players. Receivers are harder to find. At first I tried to make my own transmitter using a red LED, since it’s just red light that comes out of a TOSLINK transmitter. Although the LED worked, it was very difficult to position properly so as to maintain a reliable signal. It was clear that proper TOSLINK modules were necessary. I scoured the net and found a guy that was selling receiver and transmitter modules for $10USD each. Unfortunately I can’t find that site any longer, but there may be other sources now. Building the coax and TTL connections only requires standard electronic components. If you don’t need TOSLINK connections, it’s best to avoid the hassle.

Coax <-> TOSLINK converter

In an effort to be able to connect anything coax to anything TOSLINK and vice versa, I needed a box to convert between the two. The converters I found commercially available were >$100. I built the one here for about $30. I’ve used it in all sorts of situations. I bought the TOSLINK receiver off the net for $10USD, and I got the transmitter from a broken CD player.

There isn’t a schematic for this project because I just figured it out as I went along. The coax <-> TTL schematics below were used for the coax parts. The TOSLINK modules need almost no external parts. I just followed the TOSLINK modules datasheets for suggestions on use. A small regulated power supply was also built inside the box, to provide clean power from the AC adaptor.

S/PDIF circuits

Here are a few S/PDIF circuits you can incorporate into your own designs. I haven’t included drawings for TOSLINK devices because they are quite simple, and the datasheets provide enough information to use them easily. These schematics are very basic but usable circuits. These circuits were originally found on other sites, but after having been successful using them, I decided to post my own drawings of them.

Notes about the circuits above:

  • If you build the circuits exactly as shown, they probably won’t work! These examples are to demonstrate the concept and suggest some ideas. You will at the very least need some power supply bypassing and filtering. In every digital circuit always put a 0.1uF mono or ceramic capacitor between every power supply pin an ground! Otherwise the chip will most likely oscillate at high frequencies and not do the intended job.
  • What about logic part types? The circuit calls for HC, but other types will work too. HCT and AC, ABT, etc. will work. Just make sure you use a logic family designed for at least 20mA output drive and 5 volt operation.
  • Be careful when using +5V power from inside your computer. Most modern computers have enough current on the low voltage lines (+5 and +3.3) to weld or start fires. If you have a short circuit on your board, you will most likely notice the wires powering your circuit get really hot and smelly.
  • What about part values? When building many electronic circuits, most part values aren’t all that critical. The following give an overview of how each of the above circuits operates. I find if I understand a circuit, it makes it much easier to improvise when I can’t find exactly the parts that it calls for.
  • The general idea with the the TTL to coax circuit is as follows:
    • Buffer the TTL input with U1a. This causes it to invert, and provides a high input impedance for the output from your TTL S/PDIF connection.
    • U1b, c, and d provide lots of current output to drive the output line.
    • C1 provides some AC coupling. A S/PDIF signal is supposed to wiggle around ground as an AC signal of about +/-0.5V. C1 removes the DC and lets the signal float around ground. S/PDIF is a signal in which each bit causes a transistion in the signal. AC coupling only works for a signal like this.
    • R1 and R2 form a voltage divider to bring the voltage level down. The output from the logic gates will be 5 volts. But S/PDIF coax wants about 1V. (peak to peak) Also, it wants somewhere close to a 75 ohm source impedance. Perhaps these values should be slightly lower to match the line impedance better. But this is what I used and it worked for me.
  • The coax to TTL circuit works as follows:
    • R4 terminates the input with 75 ohms.
    • C2 couples the signal, removing any DC components.
    • R3 and R5 make U2a work as an amplifier with a controlled amount of gain.
    • U2b buffers the signal to the output.
    • When a small signal is applied to the coax input, it jiggles the input of U2a enough to case a full 5V transition on the output.
  • Unused logic inputs? You should always terminate unused inputs on logic chips. Usually this means tying them to the positive supply. (+5V) If you don’t do this they will pick up nearby signals and noise and waggle the circuits inside the chip. This wastes power and can cause interference with other parts of your circuit. Don’t connect unused outputs to anything.

FAQ

What’s up with Dolby Digital?

Most DVD players and home theatre receivers have digital audio connections. They use either coax or TOSLINK connections. If you play a CD, or a DVD in stereo PCM mode, a standard stereo S/PDIF signal will most likely come out of the connector on your DVD player. In surround mode, a flag bit is set that instructs the receiver that the data is not raw audio samples. The specifics of the data sent would depend on which surround format was in use.

I want to send audio all over my house with S/PDIF

S/PDIF is not designed for long-distance transmission. It is not a balanced signal, and because the data rate is 5-6MHz or so, unless done properly, long unbalanced coax cables will be susceptible to errors. That’s not to say it shouldn’t be tried, but S/PDIF circuitry might not adequately drive long cables. For TOSLINK cables, you’ll find that long cables are very expensive. When the signal is not receiving properly you will know right away because the sound will either be noisy, or the receiver won’t even lock up.

Consider using good quality analog wiring. You can get transformers to allow you to use balanced cabling with unbalanced audio gear. Alternately, if your equipment has good strong low-impedance outputs, try just using long patch cables. The biggest culprit you will face is shielding problems and ground loops. There are many other pages dedicated to these topics.

Also, think about using RS-485 or RS-422 wiring for S/PDIF signals. There are very simple transceiver chips made by Maxim (see MAX308x series) that convert a TTL signal into a balanced RS-485 signal. Some of these ICs can work at up to 10MHz. With proper wiring you could send S/PDIF over thousands of feet. AES/EBU uses a hardware interface like this. Some newer RS-485 transceivers support special electrical signaling to send digital data farther through the same type of cable. Use standard low-cost CAT5e cable for a very cost-effective installation.

I want to mix two S/PDIF signals together

This is a complicated task that requires expensive hardware, and most often requires that the sources be synchronized, which is not possible with most home audio equipment. I’m not aware of a simple S/PDIF blending circuit, other than professional digital mixing systems.

Update (2002-01-17):

Someone has suggested that the above statement is not entirely true. I’m aware that there are many digital audio ICs that are inexpensive and provide advanced functions. Apparently Texas Instruments makes a chip called the TAS3001. It’s a stereo audio digital equalizer. It has EQ functions as well as 2 input mixing and volume controls. Sounds like a cool chip!

This is still certainly not an off-the-shelf unit though, and most people do not have the facilities to implement circuits with these parts. Most of my questions come from people that don’t really want to build stuff. Thanks to Tyler who sent me this info.

Most people want to do this so that they can chain 2 mega CD changers together. Consider using the analog connections and an A/D converter if you really want a digital signal to send around your house. Most mega changers have facility for daisy-chaining the audio for multi-player setups.

Make me schematics or build me circuits!

My work involves making circuits and systems for a living. I don’t have the time or facilities to build custom electronic circuits for other people. Buy some good books on electronics and a soldering iron and learn how to make things yourself. I enjoy learning about it, and you just might too. It’s worth it!

Wireless S/PDIF?

Someone wrote to ask whether or not it would be possible to use a wireless video sender to send S/PDIF around his house. I’d never thought of this but it seemed possible, and a great idea! I thought about it and concluded that it just might work. He went out and got a 2.4Ghz video sender from Radio Shack. Amazingly it worked, and he was able to send wireless S/PDIF. Not bad for $100.