Close
0%
0%

TOSLINK to Analog converter

Duplicating a $10 box from Amazon just because

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. I just want to see if I can make one just to learn something.

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'd kinda like to know how to build the equivalent.

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 chose the STA120. It unfortunately requires 3.3 volt power instead of 5 (which is what every other part of the board needs). It has a number of pins that are tied either high or low to configure it, and converts the S/PDIF input stream into an i2s compatible output stream for the DAC. It's configured in this case for "mode 2," which seems to be the best choice for i2s output. It's set up to send the master clock, SCLK, L/R, and data output to the DAC.

It turns out that the STA120 is nearing obsolescence, so an alternative is the DIR9001. It's not at all compatible, but like the STA120, it's configured with a number of strapping pins, accepts the input from the optical receiver module and outputs the same 4 lines to the DAC.

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. The unfortunate part of this design is that the input sample rate is constrained to 96 kHz because of the DIR9001. I haven't yet found a reasonable replacement for that part that doesn't require the addition of a controller to the circuit. As before, the output DATA, BCK, LRCK and SCK (configured at the DIR9001 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...

Read more »

Adobe Portable Document Format - 72.61 kB - 08/26/2021 at 23:22

Preview
Download

sch - 296.43 kB - 08/26/2021 at 23:22

See BOM
Download

brd - 105.19 kB - 08/26/2021 at 23:22

Download

Adobe Portable Document Format - 35.59 kB - 08/18/2021 at 00:04

Preview
Download

sch - 162.10 kB - 08/18/2021 at 00:03

See BOM
Download

View all 6 files

  • More tests

    Nick Sayer3 days ago 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 Sayer6 days ago 0 comments

    I built the next prototype. While the boards were being nabbed, 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 8 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

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