Arduino controlled Dual Mono AK4490 DAC (Part 2)

Following up on Part 1, it’s time to talk about the “brains of the operation”. Bare with me, this is going to be a rather long read.Hardware selection

The DAC needed to be controlled by a microcontroller so I looked into my options. I wanted something that would:

  • Be easy to program, so the Arduino IDE was a must.
  • Be able to drive a TFT.
  • Have enough storage capacity to store enough code & fonts for the TFT.
  • Be readily available.
  • Be relatively low cost, since it would have no influence on the dac’s SQ.
  • Be easy to build / integrate into a new design, even by a novice.

After some consideration, I decided to use an STM32F103 ready-made module. It would plug in to a “mainboard” of my design, along with the chosen TFT. It would be fast enough, have enough flash & ram, be easy to integrate and develop for and it would cost next to nothing.

Next up was the TFT. I’d seen on Ebay an interesting one that was relatively big, high resolution and inexpensive. It was this one:

It can be found on Ebay by searching for “3.5 tft uno 320 x 480”. Expect to pay 6-8€ inc. shipping.

After some searching I found a suitable library that (after some slight tinkering) would allow my tiny STM32 to drive it properly. (Note: do not download the library from this link. I will provide a customized version of the library together with my code).

I found a ready-made library for configuring the Si570 and modified it to run on my STM32, using one of its hardware I2C ports. I will also include this library in my code. To complete the recipe I also found working rotary encoder and IR receiver libraries.

The code

Next up was the prototyping work. I adapted my TFT HiFiDuino Pro code to run on the STM32 & TFT combo, with support for AK4490 dual mono operation. The end result had this feature list:

  • Support for either Dual Mono or single chip setups.
  • Support for the Amanero Combo384 USB to I2S module (must be set up as slave with MCLK/2 and F0,1,2,3 enabled).
  • Control with one rotary encoder with push-to-select functionality.
  • IR Remote support.
  • Support for software volume control, from -99dB to 0dB
  • Display incoming signal sampling rate and type, determined by “reading” the relevant I/O pins of the USB to I2S board.
  • Display and control of the AK4490’s digital filter.
  • Selection of the proper MCLK frequency according to incoming SR and type and programming of the Si570 accordingly.
  • Control of “DSD Direct” function of the AK4490s.
  • Control of the DSD Filter’s Frequency (50KHz or 150KHz).
  • Control of the Sound Mode of the AK4490.
  • Choice of either inverted or normal analog output for the AK4490s.
  • Choice of two sets of MCLK frequencies, either 22/24MHz or 45/49MHz.
  • Remote power on/off functionality (or always on – configurable in the code).

Software Requirements:

In the download I am including the modified versions of the libraries (as mentioned above) as well as the necessary font files. Be sure to extract the contents of “Libraries (place in Libraries folder)” to your Arduino IDE’s “libraries” folder.

Download it here: aKduino v2 (49349 downloads )

Here is the revision history:

v1.72 24/12/2017:

  • Minor changes to make compatible with current stm32duino core (changed HardWire.h to Wire.h and other minor stuff).
  • First public release as part of completed dual mono DAC project.

v1.66 10/10/2017:

  • Minor volume bugfix.
  • SuperSlow filter still problematic.
  • Enabled DAC synchronization feature (experimental..).

v1.64 30/09/2017:

  • Bugfixes.

v1.60 20/09/2017:

  • Added support of rotary encoder and IR remote control.
  • 3.5″ TFT support.

v1.50 07/01/2017:

  • Added support of rotary encoder for volume control.
  • Bugfixes related to DSD.

v1.41 06/01/2017:

  • Added support for dual mono mode.

v1.36 03/01/2017:

  • Added very basic TFT support.

v1.35 20/12/2016:

  • Code cleanup for first public release.

v1.33 19/12/2016:

  • Added full control of sound parameters through serial port.

v1.27 18/12/2016:

  • First functional version.
  • Automatic switching between PCM and DSD by monitoring DSDPIN.

The “motherboard”

After I was certain that everything related to the software was working the way it should, I designed a “motherboard” that would take care of the following:

  • Accept the STM32F106 board.
  • Accept the 3.5″ TFT.
  • Accommodate an 24LC256 EEPROM chip, used to store the DAC’s configurable settings.
  • Accommodate two sets of I2C signal isolators and I/O expanders.
  • Include headers for the encoder, IR receiver, power relay, non-isolated and isolated I2C communication, unused uC pins, etc.

This is what I ended up with:

Basic Hardware Requirements:

  • STM32F106 module (a.k.a. “blue pill”, search Ebay for “stm32f106c8t6 board”)
  • 3.5″ TFT with resolution of 320 x 480 (Search Ebay for “3.5 tft uno 320 x 480”)
  • 24LC256 EEPROM chip
  • I2C Isolator ICs, I/O expanders, passive components, etc (see BoM)
  • Rotary Encoder
  • IR Receiver
  • Compatible IR remote control (Apple Remote or other – in any case you must edit the code and input the proper IR codes for your remote, see below)
[table “” not found /]

How do I make it work?

Power

You have to supply the board with 5VDC at ~300mA through header DC_5V.
[table “” not found /]

Basic connectivity

Serial port:
[table “” not found /]

Rotary encoder:
[table “” not found /]

IR control:
[table “” not found /]

If you will be controlling a power on/off relay, you can use the POWER_RELAY header:
[table “” not found /]

Expansion header:
[table “” not found /]

I2C header (non-isolated):
[table “” not found /]

Isolated I2C ports

The board has provisions for two separately isolated I2C ports, complete with I/O expanders on their isolated sides. The idea is to connect the DAC board to one of the isolated ports (I2C_ISOL1 & MCP_ISOL1) and your USB-to-I2S board to the other isolated port (usually MCP_ISOL2)
[table “” not found /]

[table “” not found /]
[table “” not found /]
[table “” not found /]

That’s it for Part 2. Stay tuned for Part 3: The output stage.

Arduino controlled Dual Mono AK4490 DAC (Part 1)

For the better part of a year I’ve been busy developing what one would call a “respectable” DAC from scratch. It has been a team effort, with different people becoming more involved with specific aspects of the project, but pretty much everyone involved ended up learning a lot about DACs. Right now, the project is for the most part finished, in that it is fully functional with a USB input and a pair of single ended outputs (or balanced, if you use a passive transformer-based stage). It is controlled by an Arduino-compatible micro-controller, running my aKduino v2 code (more on that in a future post).

I will do a series of posts detailing the design and build process, with each post covering a specific PCB. When the series is complete, the contents of all of the posts will be concatenated into a project page.

So, without further ado, this is the schematic of the main DAC board:

(Right click, Save Image As.. to download it in full resolution)

This is the 4-layer PCB:

This is the parts placement diagram:

And this is the BoM (v1.9) in xls format: Dual AK4490 DAC (main board BoM) (10608 downloads )

Design considerations

The design goal was to do a dual mono design so as to maximize SNR and channel separation. A 4-layer PCB design was chosen so as to have a very solid, low impedance ground plane as well as proper power and signal planes. The I2S, audio signals and power after the local LDO regulators are routed on the top layer, the 2 middle layers are ground and power planes, and the bottom layer serves to route I2C signals and some power lines.

Power

All of the local power supplies are implemented using the currently top-of-the-line LT3042 LDOs. The VDDL & VDDR (analog power supplies) are set to 7.2V so as to maximize SNR and dynamic range. There is provision for providing separate pre-reg power supplies for the L and R channels (headers AVDDL and AVDDR) but I don’t consider that to be critical to SQ since there are local LDOs and the power draw is very very small. In my implementation I’m using a common pre-reg for both the AVDDL & AVDDR. The AVDDs and DVDDs are also supplied by LT3042 LDOs set to output 3.3V. The Si570 has its own dedicated 3.3V supply implemented with an LT3042 and features extra filtering.

Overall, the power requirements of the board are:
1) AVDDL: 8-10V DC at 40mA max
2) AVDDR: 8-10V DC at 40mA max
3) DVDD: 4-6V DC at 200mA max

Clocking & input signals

It was decided that the MCLK would be provided by a programmable low jitter oscillator, namely the Si570. This way we could select different MCLK frequencies at will, supporting different sampling rate families and different USB to I2S boards.

Speaking of USB to I2S boards, the DAC board has a very specific requirement: The USB board must be able to receive MCLK externally. In other words, the DAC board and USB board must be clocked from the same oscillator. This is due to the AK4490’s design. Unlike the ESS designs which by default run asynchronously, it needs to be on the same clock domain as its I2S sources.

So, the DAC board needs to output MCLK back to the USB board. There exist a number of USB boards that support that. The most popular ones are the Amanero Combo384 and JLsounds’ I2SoverUSB.

Since I had decided to do reclocking using flip-flops as close to the AK4490s as possible, and the flip-flops are clocked by the MCLK, its frequency needs to be sufficiently high in order to reclock signals corresponding to high sample rates. This translates to 49.152 MHz for sampling rates of 384KHz. If you’re content with going only up to 192KHz, you can use a MCLK of “just” 24.576 MHz. Of course you will also need the corresponding MCLKs of 45.1584 and 22.5792 MHz for the 44.1K families of SRs.

If you decide that you don’t want to do reclocking on the DAC board, you can just not solder on the flip-flops and just connect the proper pads together with some wire so as to bypass them. That way you can run with 22.5792 & 24.576 MHz clocks with SRs up to 384KHz (and probably beyond..).

If you decide that you would also prefer to not use the Si570 and just clock the DAC board directly from your USB to I2S board (or other suitable I2S source) you can also do that. You just don’t solder-on the Si570 and make a couple of changes to the Arduino code (to be implemented..).

But I urge you to try the Si570 & reclocking way first..

Construction hints

Start by first soldering on the power supply components (LDOs, resistors, caps, etc.) and testing that everything works the way that it should.

The LT3042s are pretty tiny and its easy to make a mistake while soldering them. I’ve found that the easiest method is by using a hot air rework station. First I use a regular soldering iron to tin the thermal pad and the pads with a small amount of solder. Then I apply a good amount of high quality solder paste, put the LDO on top of the pads and heat the area of the board until the solder melts. I set my hot air station to a relatively low temp of ~280 degrees C and the process takes less than a minute (per LDO). But you could also solder them with a soldering iron. To solder the heatpad, warm up the pad from the underside of the board and add solder.

After the power section, you should solder on the AK4490s and other low profile components. I do that with a low power (18W) soldering iron with a fine tip.

Next up is the Si570 programmable oscillator. I start by putting a little solder on one of the pads:

Then I add soldering paste and I place the Si570 on top of the pads. I use the fine tipped soldering iron to melt the solder on the tinned pad, effectively soldering the Si570 on the board. I then proceed to solder the rest of the pads by applying heat with the soldering iron to the side of the pads of the Si570 and adding solder.

You should finish up by soldering the electrolytic capacitors and other higher profile parts.
Beware that the spacing around the electrolytics is very tight. You should take that into account when selecting parts. The parts in the BoM are sure to fit in the available space.

That’s it for Part 1. Stay tuned for Part 2: The Controller.

TFT HiFiDUINO Pro update..

I finally managed to find the time to actually integrate my upgraded Buffalo III board into my Buffalo DAC.

In the process I discovered and took care of a number of bugs in my TFT HiFiDUINO Pro code.

The most serious bug was one that failed to properly initialize a new (blank) 24LC256 EEPROM chip. That effectively caused the code to crash.

Here is the change log:

v1.08 15/10/2017:

  • Fixed EEPROM init bug
  • Fixed DPLL settings bug & default DPLL settings for USB 2
  • Added alternative way of controlling Solid State Sidecar (via Pin A1)
  • Changed input names & icons to match my Buffalo III
  • Other minor bug fixes
  • Inverted power-on signal to make fully compatible with “TFT HiFiDuino” code
  • Inverted rotation of encoder to make fully compatible with “TFT HiFiDuino” code

v1.06 23/07/2017:

  • Initial release.

The new version of the code can be found at the project’s page.

Winter 2017-2018 teaser :-)

So many projects, so little time.. Here’s a teaser on what’s to come:

PGA2311-based preamp, with multiple inputs board, controlled by a custom Arduino, with an OLED screen.

Salas DCG3 preamp, powered by custom Salas Shunt Reg 1.2R.

MPD TFT display for Rasberry Pi, controlled by an STM32.

Ian’s Multichannel FIFO.

Allo.com’s DigiOne RPi HAT.

Dual Mono AK4490 DAC with on-board Si570 programmable oscillator and reclocking, Single ended Class A discreet output stage, Arduino controlled with STM32 controller and 3.5″ TFT screen.

Arduino controlled AK4118 based s/pdif receiver, with AK4137 SRC.

ArDAM Lite custom PCBs for diyaudio.com

This post serves mainly as a placeholder for the build guide that I wrote for the PCBs, since it seems that some people had problems with the download link that I provided.

The build guide can be downloaded by clicking here: ArDAM Lite Build Guide (45139 downloads )

I do have a few left over PCBs, if you’re interested contact me for more info.

ES9028Pro power wows

Following-up on my previous post, I soldered a Crystek 100MHz clock and had a new set of Trident replacement boards made for my upgraded Buffalo III.

The new boards are direct replacements for the Tridents, supplying 2 x 3.3V for AVCC_L & AVCC_R, 3.3V for the oscillator, 3.3V for the AVDD and 1.2V for DVDD.

Upon powering up the board with the new clock and power supplies, I noticed a problem. Whenever I tried to play material with sampling rate over 44.1KHz, the sound became garbled.

In my test rig I had also used the same power supplies with no problem, so I guessed that the problem had to be the new oscillator. But the new oscillator appeared to be working just fine.

To further complicate things, when I turned off oversampling and the DPLL filter the sound improved (but still sounded bad because I was doing no oversampling).

After some probing and prodding, I realized that my 1.2V supply was sagging below 0.9V when the sampling rates went above 44.1KHz. That should not be happening, since I had set the current limit on my LT3042 regulators to about 125mA with the data sheet specifying the 9028’s 1.2V supply current consumption to 82mA. But it appeared that my 9028 was pulling in a lot more current.

So I disabled current limiting and tried it again. This time everything was working just fine, with no sagging, but my LT was getting hot. Real hot. Like 80 degrees C hot when playing 352.8KHz material. So I did a couple of things. First I desoldered the 1.2V power supply and inserted my DMM in series in order to measure the actual current draw. I got these results:

44.1KHz -> 140mA
DSD64 -> 147mA
DSD128 -> 157mA
352.8KHz -> 200mA

So up to 200mA! No wonder my LT3042 was having a hard time.. I was working it very close to its thermal limits.

I decided to mount it vertically and to add a heat sink to the back of the PCB.

With this arrangement I was getting about 62 degrees C with 44.1KHz material and up to about 75 degrees with 352.8KHz. This is tolerable for 44.1KHz playback but not cool (pun intended 😛 ) for high sampling rates. Since 200mA is pretty much the LT3042’s upper current limit, I’ll have to design a new power supply, either with two paralleled LTs or some other LDO. The bigger problem is the heat dissipation. I will have to make the PCB as big as possible in order to have a lot of room for heat sinking.

But why does this chip’s actual power consumption differ so much from the published specs? As always, the devil is in the details. The stated 82mA is for a sampling rate of 48KHz and a clock frequency of 40MHz. I’m using a 100MHz oscillator so power consumption ought to go up, but I never expected it to increase so much. I wonder what will happen if I input a 768KHz signal.

Yes, I put an ES9028Pro on my Buffalo III

A few years back I was hit by Murphy and I was hit hard.

It was the time when you had to be very patient and even somewhat lucky if you wanted to buy a Buffalo DAC. You had to wait for the boards to go on sale and then be quicker than the other (equally “DAC hungry”) DIYers for the privilege of owning one.

I had just gone through all of that trouble and had managed to acquire a brand new Buffalo III board. I remember it like it was yesterday, even though it’s already been more than 5 years. I had it connected to my bench top power supply and was just doing a dry-run, I hadn’t even built the IVY-III yet, looking to see that everything was working as it should, when all of a sudden the lights on the Tridents all went very bright for half a second and then the magic smoke escaped. My power supply’s regulator IC had chosen the worst possible time to kick the bucket. Cost of repairing the power supply: ~1€. Cost of getting a new B3: ~400€ plus another 2 months of waiting.

An autopsy of the damaged board confirmed my suspicions: Almost every active component on the board was gone. Besides the Tridents and the AVCC module, the ES9018S and the Crystek clock were toast. The only components that survived were the ones behind the 3.3V regulator, which proved to be resilient enough to withstand the ~35 volts that were fed to it. So the cost of repair would be prohibitive, especially considering that I couldn’t find anyone that would sell a single ES9018S chip. So the bad board went into a cardboard box and lay there for close to 5 years.

Fast forward to 2016. ESS announces the successors to the ES9018S, the ES9028Pro & ES9038Pro chips.

These chips have a brand new digital core, much improved from the ES9018. There are new digital filters, a new DPLL system, new THD compensation features, a new gain compensation function, etc.
The ES9028Pro is supposed to be an ES9018S with an updated digital core, while the ES9038Pro is supposed to be an ES9028Pro with 4 times the output stages, resulting in an extreme output current capability. This very high current would be the reason why its DNR and THD+N performance would be off-the-charts. But it also meant that all of the existing I/V stages that were designed for the ES9018 would not work for the ES9038Pro. As of this writing, neither Twisted Pear Audio or Acko have on offering proper I/V analog stages.

I made this little table to give you a better idea of the differences between the old and new chips:

[table “” not found /]

* up to 13
** most likely an error in the datasheet

This info comes from the official brochures that are available on-line, with some additional info from the NDA-protected “full” datasheets. ESS, if you are reading this (and you probably are), there really is no point in trying to keep these datasheets secret. If someone like me (with my non-existant connections) can find them, so can your competitors. Plus I can’t really say that I found any content in your datasheets that would warrant such extreme measures. But I digress.

So, upon inspection of the datasheets the first thing one notices is that both new chips are pin to pin compatible with the ES9018S. That was just too convenient for me and my bad Buffalo board. Good job ESS, I really appreciated that. 🙂 🙂

On the software side, things were very different to the ES9018S. The number of registers had more than doubled (48 registers in the ES9018 versus 115 in the ES9028/38) plus their arrangement was totally different, so I would need to do a total rewrite of the code to support it. Good. More fun to be had. 😀

So now a lightbulb had lit up in my head. I didn’t have much to lose – I already had the board, I could hook up temporary power supplies and a temporary clock so all I had to buy was the actual chip. Considering that I would like to be able to use my existing analog stage, I chose to go with the ES9028Pro. I got on Ebay and ordered a couple (a friend had also decided to bite the proverbial bullet and do the same “mod” to his Buffalo).

Next up was power requirements. The required voltages are the same but the required current has doubled or even tripled, depending on which chip we are talking about. That could be a problem for the AVCC module and Tridents of the Buffalo 3. I needed to do some reading-up on the AVCC & Trident modules. It turns out that the Trident modules are capable of supplying up to 100mA of power (with the proper CCS resistors) so in theory they could be made to work. But my (burnt) Tridents were v1.1, meaning that they were not exactly famous for their robust-ness. Asking them to work near their thermal limits would be looking for trouble. Plus, while researching the Tridents I learned of their latest version, the Trident SR. These now use ultra low noise LDOs (ADM715x) and are rumoured to sound even better than their older shunt types. These days my ultra low noise LDO of choice is the LT3042 so I drew up a set of PCBs that would be a drop-in replacement for the Tridents & AVCC and made an order to a well-known Far East board house.

While waiting for the chips to arrive I had put together some Arduino code that would initialize the chip and provide some basic functionality. It was nothing special – serial port only – but it would get the job done.

After a few days the ES9028Pro chips came and there was no way I was going to wait another month for the new Tridents.

Off came the damaged components..

..to be replaced by fresh capacitors and the brand new ES9028Pro.

For the time being I chose to not solder on a new Crystek since I could not be 100% sure that the board would work.

Instead, I soldered on a two pin header to which I connected an Si570 programmable oscillator that I had lying around.

Power was to be delivered by the on-board die-hard 3.3V LDO with a little help from a small PCB holding a LT3042 taking care of the 1.2V.

I hooked everything up, connected my Arduino, powered the thing on and loaded an I2C scanner on my Arduino. I did a scan and found a single I2C address. That was not good. I should have found two (one for the on board port expander and one for the ES9028). I double checked my connections, my power, made sure that my Si570 was outputting a proper clock, but still nothing. It was time to go back to the datasheet.

My eye fell on the section pertaining to the Reset pin. It stated that it was an active-low pin and that a system reset could be performed either by pulling the pin low or by a software command. The Buffalo III design called for this pin to be pulled low by default so I hadn’t paid any real attention to it. It turned out that I should have. I soldered a 2 pin header and put a jumper on it. The board immediately came alive and was detected by my I2C scanner. 😀 So, the Reset pin should be pulled up.

With that out of the way, I connected my test I2S source (a Chinese clone of an Amanero – not as good as an original Amanero but OK for testing and pretty expendable). The DAC locked with no problem into all sampling rates up to 352K and DSD128 (I didn’t bother to try to go higher) and started playing music!

Now I’m waiting for the new replacement Tridents & AVCC module PCBs to arrive so that I can do a proper test vs. my Buffalo III.

I also need to do a version of my TFT HiFiDuino code for the 9028/9038. Stay tuned.