TOSLINK to Analog converter

Instead of a $10 box from Amazon, go above and beyond

Similar projects worth following
You can get the equivalent of this for $10 from Amazon - it's an optical digital audio to analog audio conversion box. But the typical cheap units don't really tell you anything about how good they are. Instead of settling for that, this project aims to bring quality parts and modern design to bear.

This came about because I bought a box from Belkin to do AirPlay 2 for our patio speakers (which have an amplifier I built myself). That Belkin box's analog audio output is about 20 dB too low, but fortunately they include a TOSLINK output jack. Buying the aforementioned $10 box from Amazon solved my problem, but I kinda wanted to know how to build the equivalent, and having done so, try to do better.

The current design comes down to three separate subsections.

First is a TOSLINK receiver module. This is a little plastic thing that takes in 5 volt power and outputs a TTL level stream matching the optical input. There isn't a whole lot to say about this. It's self-contained and just needs a single bypass cap and series inductor for the supply pin. The optical signaling is biphase encoding. This makes for easy clock extraction. Between every clock period the signal changes state. If the input pulse train is the same bit level as the previous bit, then nothing else happens. If it's different, then at the 180º mark there is a second state change. So for an input clock frequency of 1 MHz (just an example), a series of either 00000... or 111111.... is represented by a 1 MHz square wave. A series of 01010101.... is represented by a 2 MHz square wave.

The next section is the digital data stream receiver. For this, I've gone through three different choices. The first iteration used the STA120. That worked, but it only comes as a SOIC28, which is rather large, and seemed to be heading towards obsolescence (did I mention that this whole project is at least 10 years out of fashion?). Replacing that was the DIR9001, which was a good choice, but like the STA120 was limited to 96 kHz sample rates. To go higher, I needed to find a better chip that was still capable of being configured purely with hardware strapping. The best choice I could find was the CS8416. It can go up to 200 kHz sample rates and can be strapped with 8 47 kΩ pull-up-or-down resistors. The CS8416 can take care of any pre-emphasis correction for us, allowing us to just strap the DAC for no pre-emphasis. In all 3 cases, the output was configured for i2s, with the receiver being the master and a master clock of 256x the L/R clock.

The original DAC was a CS4334. It takes i2s input. This consists of the master clock (SCK), bit clock (BCK), L/!R (LRCK), and DATA. Instead of the BCK signal, you can send a de-emphasis selection signal from the STA120, but when I attempted this with a prototype the audio sounded noisy. It would seem that when you don't send SCLK, the CS4334 makes assumptions about the relationship between SCK and the frequency of LRCK to derive an internal bit clock. This seems to not work for the output format of the STA120. That, and the !DEM signal was always high, which implies that emphasis on the digital signal is never used, so there's no harm in not supplying that signal to the DAC.

Along the way I decided to attempt to design something a bit better. This started with the PCM1793 192 kHz 24 bit DAC. That DAC has fairly impressive THD and S:N specs, and requires an external differential to single-ended converter and LPF. That uses the OPA2134 dual op amp, which is also an impressive part in and of itself. As before, the output DATA, BCK, LRCK and SCK (configured at the receiver for 256xFs) are fed directly. In addition, I decided to connect the ERR output of the decoder to the MUTE input of the DAC, just to insure bad data doesn't turn into bad sound. Since the DAC has separate de-emphasis selection pins, I decided to try to support it for the sake of old CD players and the like. Unfortunately, the DIR9001 only has a single de-emphasis output signal and there are four possible de-emphasis configurations, depending on sample rate. It's not convenient to try to figure out which mode to use, so I settled on simply supporting only 44.1kHz de-emphasis, which is the only one likely to be used. This can simply be accomplished...

Read more »

Adobe Portable Document Format - 82.42 kB - 09/20/2021 at 02:24


sch - 315.85 kB - 09/20/2021 at 02:23


brd - 111.32 kB - 09/20/2021 at 02:23


Adobe Portable Document Format - 76.35 kB - 09/20/2021 at 02:24


sch - 306.46 kB - 09/20/2021 at 02:23


View all 9 files

  • Going further

    Nick Sayer5 days ago 0 comments

    The boards for the DIR9001 + PCM1793 aren't back yet, but the DIR9001 only going to 96 kHz only allows for half of the DAC's sample rate range to be used. Swapping the DIR9001 out for the CS8416 would fix that. They're backordered until the next ice age, but I have thrown together a design that puts the 8416 in hardware mode and configures it how I think it ought to work for the 1793.

    Meanwhile, I have every confidence that the boards that arrive this week will work. I also have some confidence that I can put this on Tindie at $50 (board only) and in comparison to other products on Amazon that are using these same chips, I think the pricing may not be completely out of line.

    EDIT: It bugged me a little that the oscillator frequency of the MAX1721 is about 125 kHz. For the 96 kHz variant, that doesn't bother me too much, but I really want the charge pump to run faster than the maximum sample rate for the board. I've discovered the SP6661, which runs at just under a megahertz, so that's going to be the device for the CS4816 variant.

  • More tests

    Nick Sayer09/15/2021 at 19:10 0 comments

    I hacked together a charge pump on a little SOT23 breakout board and wired that into the prototype. It sounds really good. I certainly can’t hear any artifacts from the charge pump in the audio. And the chip I used had quite a low oscillation frequency. I want to use the MAX1721 in the final design so that hopefully the switching frequency will be too high to impact the audio.

    I tested with my AirPods Max so as to try to maximize my ability to pick up any noise or distortion, but didn’t hear anything untoward. That’s not a great test, of course, but it’s a start.

    I also tested against the other two TOSLINK DACs I have handy - a $10 one from Amazon and the one built with the CS4334. The other two sound distinctly flat to me by comparison. I am not sure if it’s a placebo effect or not (and I’m not sure I would be able to by definition), but the more expensive DAC does seem to make a difference.  

  • Next prototype built, but there's a problem

    Nick Sayer09/13/2021 at 03:55 0 comments

    I built the next prototype. While the boards were being fabbed, I found an error in the schematic - for the left channel, the + and - differential outputs from the DAC were reversed. I cut the traces on the board and bodged them back.

    But the audio of the prototype sounded bad. After spending the afternoon trying to figure it out, it turns out that the problem was that I gave the final amplifier a unipolar power supply (that is, the V- pin of the amp was grounded.

    Lifting that pin and temporarily hacking in a 5 volt wall wart with - to V- and + to ground gave correct audio (albeit with a nasty 60 Hz hum).

    The problem now is that everybody I've found on the Internet who has made the schematic of their DAC public has a bipolar power supply.

    Well, you can make -5 volts from +5 with a charge pump. The MAX1721 has a switching frequency of 125 kHz, so ostensibly above anything audible. Hacking in a MAX1720 on the prototype did make it work. But if it's possible, rebiasing the output amp to operate on a 2.5 volt offset, reducing the gain and adding a DC block on the output would probably be better for the THN spec of the result.

    The next prototype board (boards?) will test one or both of these options.

  • Even better

    Nick Sayer08/26/2021 at 02:09 0 comments

    I'm still not entirely sure this project is worth productizing or not. But if it is, there is probably room at the high end for something particularly good.

    In looking for interface chips, it appears that the DIR9001 is the best overall choice.

    For DACs... well, it's all over the place. The PCM1730E is an excellent choice... at $20 a piece.

    The PCM1793 is much more reasonably priced, at about $6.25 each. Couple that with an OPA2134UA at about the same price to be the output LPF and buffer... and we might have something worth actually trying to sell.

  • Chip change

    Nick Sayer08/23/2021 at 02:02 0 comments

    It turns out that the receiver chip I chose for the first versions - the STA-120 may be nearing obsolescence, and thus may be difficult to find going forward. Fortunately, there's another option - the DIR9001. It's not at all compatible, but it does have the virtue of coming in a TSSOP-28 instead of a SOIC-28, so it's smaller. Of course, that doesn't benefit us a whole lot seeing as how the board is now the 38x59 mm size for the chassis. But if it turns out that the STA-120 becomes unavailable, at least there is a second choice.

    Of course I can't test that design right now because they're backordered until next year. 

  • Future options

    Nick Sayer08/23/2021 at 01:56 0 comments

    The idea of perfecting this project is rapidly consuming me.

    Making the board slightly bigger (38x59 mm) makes it fit very nicely into a Hammond extruded aluminum case, just like my GPSDO. And like that project, I can probably design a pair of PCBs to fit into the ends with the correct perforations for the jacks and the error LED light pipe. I still can't match the Amazon price point selling them on Tindie, but I pretty much put that down to volume. I can get them down to a retail-plus-free-US-shipping price of about $20 for the board, $20 for the case, and $10 for a power supply. That's at least not Fred Falvy levels of price foolishness.

  • Making it a little cheaper

    Nick Sayer08/22/2021 at 23:17 0 comments

    The TORX1355s are super expensive. Turns out that there is a much cheaper alternative. The PLR237/T10BK‎ is more like $1.50 at Q:10. They also have 25 MHz of bandwidth (overkill for the CS4334 DAC and the STA120, which can only do up to 96 kHz audio - even at 64 bits per sample that's only 6 MHz). It works at both 3.3 and 5 volts, but they suggest adding output capacitance at 5 volts, so running it at 3.3v saves us a part. I've also taken a shine to USB C of late, so swapping out the barrel connector for USB C isn't a bad idea. Since we only want 5 volts at way less than 5 watts we can just use 5.1 kΩ CCx pull-down resistors.

    Lastly, it may not be a bad idea to add an LED for the VERF pin and a light pipe to aim it out the front.

  • One more change

    Nick Sayer08/18/2021 at 00:09 0 comments

    It turns out that correcting the mode of the STA120 was not enough. The audio sounded way distorted. The music was identifiable, but it was very, very fuzzy. I tried playing with the !DEM/SCLK pin, but that didn't change anything. The steady state of the de-emphasis output from the STA120 was off (high) anyway, so on a whim I hooked !DEM/SCLK up to the SCLK pin of the STA120 and that made the audio perfect.

    So 3 total changes: adding a series inductor to the supply pin of the optical module, fixing the mode pins on the STA120, and hooking the SCLK pin between the two.

    I'm going to order one more set of boards from OSHPark and call it a day.

  • Good news, bad news

    Nick Sayer08/17/2021 at 22:39 0 comments

    The boards came back and there are two errors (so far).

    1. The optical receiver I sourced is only good to 500 kb/sec. The optical audio stream I’m trying to decode is way faster than that. I’ve ordered some of the 10 MHz variant. The datasheet for those says that they recommend a series inductor on the supply pin, so that’ll be a change to the board I need to make. 
    2. I made a mistake wiring the mode pins up to the decoder. I’ve asked for mode 4, but I need mode 2. So that too will need to be a board revision.

    I was able to test this by poaching the optical output stream from my Amazon TOSLINK decoder box. It sorta worked, but the L/!R signal was way wrong, so I will need to lift and rewire M1 and M2 and try again. If I see correct audio on the scope, then I will feel good about my chances.

    EDIT: Upgrading the optical receiver to the TORX1355 fixed the first issue, and lifting the two pins and using bodge wires fixed the second.

View all 9 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates