S/PDIF-switcher

The receiver for my old sound system only had one optical S/PDIF (Toslink) input which is a problem since I have more devices I'd like to run on S/PDIF (and none of them have coaxial). I could've bought a commercial S/PDIF switch but that's no fun...

Instead I ordered a bunch of Toslink receivers and transmitters and set out to build a simple switcher! The design is very simple; a couple of inputs, a 7432 quad OR-gate, a 7408 quad AND-gate, a MCU (AVR ATmega168) and a couple of buttons. The AVR handles the actual switching by toggling one of the inputs per AND-gate, where the other input per AND-gate is one of the Toslink receivers. The outputs from the AND-gates are all going to the OR-chip, putting em all together and outputting the signal to the transmitter.

You could argue that the MCU is a bit overkill, switching could be done with just a couple more 74xx ICs. I did however notice a little bug with my receiver where the MCU makes things a lot easier. If you switch between two inputs without any delay, the receiver becomes somewhat confused as you suddenly start transmitting data from another stream, causing somewhat broken audio data. A tiny delay between switching where nothing is sent solved this as it causes the receiver to reset its S/PDIF logic as if you've just unplugged it.

Pictures and source code will be available soon(ish).