59 thoughts on “SPDIF switch

  1. once you see the datasheet for the 4052, you won’t need a schematic – it’s really “that easy” – the fancy optical jacks do all the hard work of converting optical to electrical and back again.

    the CD4xxx series chips are from the cold war era (moldy oldy), but lots of sites still sell them. a slightly less old part would be the 74HC4052 (substitute LV, F, VHC, etc for the letters)

    it would be a nice extension to add a little uC to this with an IR decoder, so you can switch spdif signals from the couch!

  2. If you could refrain from bullshitting around and leaving comments like this hackaday might change. Instead you end up with a simple comment explaining nothing but your narrow mind.

    Hackaday has changed, soldering parts together is just as much a hack as any software application makes it easier. Get your head straight instead of calling people retards, retard.

  3. Now, alu, just because it’s not a “hack” by itself (what do you define as a hack anyway?) doesn’t mean it’s not valuable information. maybe you have a bunch of toslinks laying around and you don’t want them going to waste. what would you do with them?

    I have a bunch of cd4066 and 74hc4066 ics that i got in a grab box of stuff. i wonder if they might be usable for this? they would have to have a little external support, i’m sure.

  4. This article prompted me to release one of my abandoned projects as public domain (my name isn’t even on it). For those that are in need of a 2-to-1 optical toslink switch, this design should work for you. I never got around to testing it in hardware, but I simulated the logic and it seemed fine. Cadsoft schematic and board layout included. Zip file contains everything.



  5. @micajah

    I find those jacks on old DVD players, maybe old PS2’s as well.

    As for the ‘input’ side, I don’t know what kind of optical sensor it would need.

    I too would like to see more hacks with optical cable, especially with something like an open-source motor controller (google “Paul and sabrina’s” for the forum thread), or high-voltage control circuit.

    Maybe even DIY fiber network?

  6. Nice project. I personally really like DIY AV stuff because commercial AV products are often either overpriced or inflexible. Definitely a “hack” in my book. Plus, I wonder if you could send data between microcontrollers over such an optical cable. SPDIF is just serial, right?


    “i’m going to become rich and famous after i invent a device that allows you to stab people in the face over the internet” –bash.org

  7. wow.. hack a day on friday is for n00bs?

    That EXACT same circuit has been in countless audio switching projects. So running digital through an analog switch is now “a hack”

    It must suck growing up today and not having the resources we did in the 80’s. the Forrest Nims books on electronics hacking you were able to buy at radio shack before they became a Cellphone and satellite TV store were killer. In fact you use to make that same thing but for audio switching.

    tommorow on Hack-a-Day.. an amazing hack that makes an LED blink!!!!OMG!!

  8. I can’t believe your talking out your ass because a project is not new to you. I try to get inspiration from the projects on here and this is great inspiration. So if we are all too noob for you then maybe you need to go back to your lab at area 51 and hang with your eleet buddies. Please post more blinking led projects I say thanks.

  9. @fartface

    No, I prefer the resources that I have today. Those electronics hacking books are still available I’m sure (plus many more). But we also have sites like instructibles. It’s a great wealth of information. Anyone (even you) can submit content. Sure, the majority of the stuff on there is crap, but there is alot on there that is fantastic. Again, because anyone (even you) can submit content.

    I also like that someone can get started with programmable microcontrollers easily with $30 and no previous programming experience. Could you do that in the 80’s? Sure, we get alot of ‘over engineered mouse traps’ and ‘fart sensing chairs’ but it’s also contributed to projects like the reprap project and helped me personally achieve many things I wouldn’t have been able to do otherwise.

    I think hack a day has been doing well. Maybe it’s difficult finding a mind-blowingly awesome hack every single day. Let’s see you do better. Aside from the search feature not being great (hard for me to find old articles that I remember reading), I have no complaints. If you don’t like this site so much, then offer some ‘constructive’ criticism or maybe just don’t visit it anymore?

  10. @mike
    i agree with you entirely. i fall into that experimenting with “microcontrollers easily” crowd. if not for this site and others like it i would not have this knowledge….

    people that bitch about “not a hack” are stupid.

    if you think you can do better i noticed that realhackaday.com is available. go get started.

    to you that agree with mike and I do the following: never under any circumstance reply to those stupid comments from now on. starting now. right now. ok? good.

  11. hi, this is linux-works here ;)

    I was WONDERING why my flicker site had so many hits on that one photo. lol.

    schematics will come. as one posters said, its mostly trivial to figure out if you have the photos.

    the spdif driver circuitry is mostly ‘classical’ stuff that has been around for over a decade.

    the only thing semi-novel about this is using a very cheap CMOS analog switch chip instead of the more fancy spdif receiver/de-jitter chips.

    planned is an arduino controller (I already have that part working), an lcd display and an IR receiver. it will be open-sourced.

    thanks for the interest ;)


  12. as to the comments about this being ‘easy’ – well, it is ;)

    that is, unless you’ve not done it before.

    I paid over $200 for a ‘psyclone’ (brand) hdmi/spdif switcher that had an lcd display, ir remote and 4 inputs. yes, it had hdmi but finding spdif switches is still hard today and expensive.

    it does not have to be that way. at least for ‘easy’ things like spdif.

    also, a lot of switches don’t have decent lcd display support and almost all of them (all the commercial ones) are closed source so you can’t extend them. mine will be open and you can edit the device name strings all you want in your text editor before you download firmware ;)

    you have a 2 or 3 bit binary address you can also use (manually) to remotely select inputs. what other commmercial spdif switches let you do that (easily)?

    this is not rocket science but there IS a market need for this, expecially at the DIY level when it can be made for pocket change.


  13. also, in the interest of accuracy, the switch was always meant to have both opto and coax in and out.

    the current version on my site does show all the i/o options on the board:

    DIY: spdif switching COAX to COAX (testing up/down/up conversion)

    that shows the ‘popcorn hour’ (coax-out device) talking to the switch, the switch converting coax 0.5v level to TTL level, going thru the switch and then back down to 0.5v level again for coax-out.

    both coax-out and toslink-out are driven concurrently, of course.

    for some history on the motivation, see this link:


    I used some ideas from that circuit for my switch.


  14. Thanks, Jeff for posting your schematic. Not much to it but it was nice to see the parts list (TORX177L and TOTX177L). Last time I checked digikey those opto modules were $20, probably because I didn’t know the right place to look. Does anyone happen to whether digikey has the fiber cables? I tried searching for TOSLINK and found nothing. I’m new to this and so I don’t know what anything is called. Also, does anyone know whether any cheap opto modules are able to do bidirectional communication? If so it would be nice to have an optical RS232 connection.

  15. The optical components are TOTX (transmitter) and TORX (receiver) modules. They’re readily available at DigiKey, Mouser and others. And yes, they can certainly be used for vanilla asynchronous serial communication, but the range is quite short – only about 10m or so – it’s just LED/photodiode based and doesn’t use lasers.

    Why use the analog switch when you’re already converting to TTL levels ahead of it? Doesn’t a fast digital chip make more sense?

  16. @dan: You can get TOSLINK cables cheap at monoprice: http://www.monoprice.com/products/subdepartment.asp?c_id=102&cp_id=10229 not sure if Digikey carries them, but they’re usually relatively expensive for cables and the like.

    I don’t think you’ll find any cheap full-duplex optical links. Unfortunately it’s somewhat akin to the difficulties of getting full-duplex over a single wire – non trivial to solve. It usually makes more sense just to run a second fibre.

  17. If your project painfully reminds me of the dumbshits at my school who randomly go around saying “penis” because they somehow think that’s funny, then I’m not afraid to bitch (twittering fart chair anyone?). But this project, as well as a large majority of the things featured on hackaday, is a nice implementation of a good idea. It may be painfully simple to anyone who has ever played around with bilateral analog switch chips, but that doesn’t make it any less useful or respectable. In fact, one thing that separates “hackers” from everyone else is our ability to realize that an extremely simple circuit can take the place of something a store will try to sell you for $100. And hey, [fartface] and others, if anyone here feels they have found yet another interesting and innovative use for a flashing LED, post away! Finding elegantly simple solutions to life’s technology problems is, in many respects, the very definition of hacking. So for everyone here being positive, keep up the good work. And for everyone else that does nothing but bitch, why don’t you put your electrical engineering degree back up your ass where it belongs, or, if you really want to be cool, use it to create for that uber-mega-hack you keep whining about for yourself. :P

    Happy hacking.

  18. @error404: this is not the final or ultimate design ;)

    this was my FIRST try at getting bits to fly. I didn’t even expect this low-end chip to work at this ‘speed’ but it seems to, just fine. I’ll test at 96k when I get a chance, as well.

    an alternate approach was to try a video switch chip that is really meant for 75ohm semi-high freq data, but I figured I’d try the CHEAP solution first before assuming I needed something more powerful ;)

    the intention is to find the cheapest and easiest to find parts that get the job done. a lot of people live in parts of the world that don’t have ‘easy access’ to mouser, digikey, newark and so on.

    the next better design evolution is to use a true spdif receiver chip like the cs8416. that means surface mount work and since I plan this to be an easy DIY project for people, I wanted to avoid SMD. plus that chip isn’t all that cheap, either.


  19. @dan: 74151 might also work. what I would do is put as many variations on the scope and see which maintained the best looking waveform. I think that would be standard practice – to try out a few different approaches (the analog switch, the specialty video chip and then even logic chips) and see if any one had a clear advantage over the other or not.

    with the analog switch, though, you do have the freedom to switch ‘native coax levels’, ie at half a volt instead of translating to TTL and then back down again. so if someone wanted an all coax switch, going to TTL and back is not useful to them and a logic switch won’t be the best solution.

    but I’d certainly try the digital mux chip (151) and see how it performed. go with the cleanest output waveform, at least out of the switch.

    for the final drivers, though, I might also want to look at long cable lengths and see if the drivers I picked got me the best signal wave at the far end.

    really, if you want to do the switch ‘properly’ I’d pick the cirrus cs8416 or similar chip and not only would it directly receive both toslink and coax-spdif but it has 4/8 inputs (depending) that all de-jitter and reclock. more of a bridge than repeater, sort of.


  20. Could this proyect be use for recording???, i mean, one pc with an vsti synth outputs sound via toslink cable, another one records the sound via toslink cable too, i tried directly with a toslink cable and it doen’t work (i knew but i had to try), i know in studios people use something called wordclock or something like that.

    thanks for all guys

  21. @Tachikoma: recording is no different than playback. bit data is bit data. the only time it ‘matters’ is at the final stage of converting digital to analog and then ‘jitter’ matters. sort of.

    but during file copy or bit to bit transfer, as long as the bits are not so noise-laden, they will transfer just fine.

    just connecting toslink may not be enough. what are you running at the toslinks? are they both the same format? you could be running 24bit/96k on one and maybe the other is not setup for that? or similar.

    opto and coax are physical things and don’t care about what format or packet-data you send thru it. just because the ports will connect physically does not mean that the data formats are compatible.

    the wordclock is something to keep all the data synchronized and the clock is embedded in the spdif protocol (along with the data). in consumer spdif, you extract the clock from the data (via a ‘receiver chip’) and that controls the clocking at the DAC side. clock recovery is not needed for digital to digital copying – it only matters at the final end d/a conversion.


  22. I’m running an rme digi96/8 pad sound car, i ask cause what i try to do is very usufull for musicians and you can save a lot of money if it works, a friend of mine (in studio of course) does this:

    he plays ej. piano with a vsti, and outputs this audio via its toslink cable, this audio is sent to a mixer (behringer mixer with adat extension) and from de mixer the audio comes back to the rme sound car input, toslink too (we always use opto instead of rca ). What i’m hoping is to loop back this audio to my sound card.

    With this you can record audio instead of midi information (when you have a lot of midi->vsti tracks with samples things get ugly)

    thanks for all man.

  23. Since there’s no schematic for this:

    It’s good to know there’s no difference in coding for the optical and coax variant of spdif. If you want to make an optical out on your coax cd-player, simply make buffer that turns a led while each logical “1” is passing, and switching it off when a logical zero happens. A 4066 can do this very well. You will only need that IC your current limiting resistor for the LED. Connect the coax signal to the control leg, and let it switch the supply for the LED directly.

    Converting optical to coax is also easy. You will need an “eye”. Basically, this is a diode that gets conductive when light falls on it. Diodes are faster then LDR’s btw.
    A resitor and this diode will make a ‘voltage-devider’. If you choose your resistor correctley, the voltage will alternate between less then 0.7 and more than 3 volts, which is then understood as a logical 0 and 1 by the 4066.

    You might get more stable results inverting the output of the light-sensitive diode and let a NAND do the switching.


  24. guys, there WILL be schematics and all that. chill out, ok? ;)

    schematics, board layouts, BOMs, perhaps even a group-buy on boards.

    I’m not ‘holding out’, I’m simply doing some testing before I say ‘this is my best effort’. this was NOT intended for public release (yet!) – nd I was not the one who submitted this. my photos were shot at an alpha or even pre-alpha stage. ;)

    the plan was to post an intro thread to head-fi or headwize or diy-audio when the design is complete and enough alpha testing was done. I’ll also post a followup here, as well.

    currently, I have an arduino controlling it, using an IR sensor and a sony dvd player remote (sony IR codes are easy to parse in software and there was an arduino libr I found that pretty much ‘just worked’). here’s a shot of the work-in-progress:

    DIY: SPDIFmaster (top) and VoluMaster (bottom)

    the green lcd on top is the spdif switch.

    so, if you can just wait a bit, you’ll get full source code, schematics and board layouts.

  25. for those that want to see what the bottom ‘layer’ is, here’s the ‘phy’ that I used as a model:


    that pretty much was my inspiration, a box called the ‘DSD’ from the early 90’s. it was a community design and its time proven (to me, at least). I’ve had mine for well over a decade now and that does prove something to me ;)

    so I used the same idea for input, the 3486 diff receiver chip. I like it. its cheap, it works, and its proven itself. any spdif I throw at this, it works fine with. its important to keep the pulse transformers and isolate the ground from the chassis. use pulses on BOTH inputs and outputs!


  26. more progress, a case is added and a color backlit LCD for user-selectable input names:

    IR controlled using an arduino and sony IR code parsing from the ard. playground.


  27. yes, there is some progress. I’ve been testing the current switch (more or less the one shown in the photo on this page) and so far have not heard any dropouts and have not had any brownouts, so things look pretty reliable so far. at least for the listening tests.

    I’ve been swapping between coax and opto and it does not seem to matter on the sound. that’s good and to be expected but it did have to be tested.

    I’m now trying to size reduce things a bit. I have some samples of smaller chips (9637 diff receiver chips in soic8 format). I’m thinking this will also work to convert coax to/from TTL and if it works I’ll have a much smaller and cheaper way to up/down convert coax.

    the opto parts are working well and don’t need any changing but I did want to see if I could get rid of the DIP16 parts and size reduce as much as I could.

    there is now also an lcd interface to it and the code is mostly finished but more features (rgb backlight control) need refining:

    DIY: a trio of arduino ;)

    the spdif switch is on the right in that orange display box. its actually an RGB 3 color led backlight but off-axis it looks like a solid color background instead of black bg on color/rgb text.

    when I have the smaller soic8 driver chips installed and tested I’ll update this thread with new photos and schematics.


  28. more progress. finally got around to testing out my preferred front-end coax-in buffer chip.

    here are some pics:

    the new plan is to use modules like that 2-port board and then mix them at the ‘fabric’ level, at TTL.

    this little board gives 2 coax-in ports and uses 1 small soic8 chip, a 9637 differential receiver chip.

    I think I’ll go with this chip, for now, at least. it was a plug-in replacement for the 3486 I was using, but its a bit more space saving and easier to connect, as well.

    the general idea (schematic) is here:

    coax_to_opto_converter schematic

    translate those pins to the new one, diff input pins (2 of them) and output pin (1 of them). easy. add +5 and ground. that’s it.

    that gets you coax-in to TTL.

    opto-blocks are used as-is, they are native TTL. you can find schematics for them or use this as a guide:


    opto blocks are easy since they are native TTL in and out.

    the missing part that I’ll work on next is the coax-out driver, using a matching series of chip.

    so, there’s some progress. this is the chip (series) I wanted since its small, cheap and seems to work ok.


  29. update:

    some pics:

    the new plan is to use modules like that 2-port board and then mix them at the ‘fabric’ level, at TTL.

    this little board gives 2 coax-in ports and uses 1 small soic8 chip, a 9637 differential receiver chip.

    I think I’ll go with this chip, for now, at least. it was a plug-in replacement for the 3486 I was using, but its a bit more space saving and easier to connect, as well.

    the general idea (schematic) is here:

    coax_to_opto_converter schematic

    translate those pins to the new one, diff input pins (2 of them) and output pin (1 of them). easy. add +5 and ground. that’s it.

    that gets you coax-in to TTL.

    opto-blocks are used as-is, they are native TTL. you can find schematics for them or use this as a guide:


    opto blocks are easy since they are native TTL in and out.

    the missing part that I’ll work on next is the coax-out driver, using a matching series of chip.

  30. with the caveat that its still an early pre-release version, here is the location of the C source code:


    it uses the lcd (arduino standard) library and the pin definitions should be pretty clear from the source code. that’s most of what you’d need to know, to be able to interface this to the switch chip.

    I’m working on the switch ‘fabric’ board now. I have already done the various i/o ports boards (coax ports need a board; toslink do not) and so once the fabric is done, that’s the last part in the system. after *that*, then I can finally document it.


  31. another update: I have an annotated perf board photo (top and bottom) of the completed switch fabric (main board):

    DIY: spdif digital audio switch 'fabric' board

    DIY: spdif digital audio switch 'fabric' board

    its still not formal docs, but its getting closer and I did label the various header blocks.



  32. thanks ;)

    it requires the user to select which input.

    the reason is: in digital, there really is no ‘off’ state, even when the music is not playing. so, if you had 4 source and they were all paused, then you unpaused one, there would be no clear way to see that one is now active. they all transmit a ‘carrier’ (loose use of the word) even when idling.

    I’ve seen some dacs that auto-select inputs but its not a good or reliable way to do digital audio. most components do shut off their spdif outputs when turned OFF but if they’re on and stopped, the auto-select won’t work, then. it pretty much has to be manual.

    one good thing about this, though, is that I use eeprom to save the last button presses; so whatever input you selected, it stays there even on power down/up.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s