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 (43312 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.

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.

Controlling an AK4490 DAC with an Arduino

These days I’m co-developing an AK4490 based DAC. The aim is to end up with a no-compromise dual mono design, one that would perform at the very least on par with my Buffalo III.

Of course, to do that one has to run the 4490s in software mode.

As a matter of fact, it is generally preferred to run a 4490 in software versus hardware mode, for several reasons.

To begin with, in software mode the 4490 supports DSD decoding. It goes as far as to support a “Volume Bypass” feature which bypasses most of the processing done on the DSD signal (a.k.a. “the ΔΣ modulator”), resulting in more pure sound. But of course we do lose the ability to do volume control in software.

Software mode also allows us to try out all of the supported SQ features, like the different “Sound Setting” modes.

At last but not least, we get digital hardware volume control.

This is the prototype that we designed, getting I2S input from an Amanero and being controlled by my custom STM32 controller (more on that in the near future).

I searched the Net for any ready-made code that would control the 4490, but I couldn’t find anything worthwhile, so I began virtually from scratch.

So, my Arduino code (a.k.a. “aKduino”) enables:

  • Controlling an AK4490 through the I2C bus.
  • Automatic switching between PCM and DSD. It does rely on getting a “DSD type signal” from our USB-to-I2S interface of choice. The 4490 by itself is not capable of determining whether its input is PCM or DSD.
  • Setting the volume (in 9 steps.. just to confirm that volume control does indeed work).
  • Selecting “Volume Bypass” for direct DSD processing.
  • Selecting the internal DSD filter’s cutoff frequency (50KHz or 150KHz).
  • Selecting one of the 4 available PCM filters.
  • Enabling or disabling the Super Slow filter.
  • Selecting one of the 3 available “Sound Quality” settings.
  • Displaying all of the registers’ settings (for troubleshooting purposes).

Software Requirements:

  • Nothing (for now)

Basic Hardware Requirements:

  • Any Arduino (*)

(*) I should note here that the AK4490’s datasheet states that all of its I/O pins are expecting 3.3V logic levels but there has been a large number of reported cases of 5V Arduinos working without problems. I’m too much of a coward to try that myself so I used level converters for my initial testing and eventually a custom STM32 board that uses 3.3V logic but you may want to try your luck with 5V logic levels. Just don’t blame me if your 4490 gets damaged in the process.

Currently the code is at v1.35: aKduino Code (83732 downloads )

Here is the revision history:

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.

Universal Signal Isolator Shield: Rev. 1.2

Since there has been a lot of interest in my Isolator shield these past few months, I have been optimizing its design.

The result of this optimization is this PCB:
Rev.-1.2-pic
It’s called “the Rev. 1.2”.

Nothing major has changed. The pinouts are still the same, the major components are the same, the functionality is essentially the same.

The changes are as follows:

  • New SPI header. It just passes through the SPI signals, nothing more. It does not connect to anything on the board.
  • New SPI_CS header. Useful only if / when connecting SPI peripherals.
  • Reset button. Because you never know..
  • New circuitry for the POWER_RELAY header. It now uses a MOSFET and it includes a diode for the reverse current coming back from the relay’s coil.
  • Decoupling cap for the IR receiver. Not absolutely necessary, but good to have.
  • More decoupling for the DC_UNR input.
  • Ground planes. Lower Arduino noise, at least in theory.

Here is the updated parts placement:
USI-parts-placement-rev1.2

And this is the updated BoM:

[table “” not found /]

Soon I will update the shield’s page with the new info.

They’re here!

I’m talking about my new Universal Signal Isolator PCBs:

USI_bare_slanted USIs_bunch

IMG_0320_res

I built one to test it out and everything seems to be working as it should. Next step is a page for the project, with schematics, a BoM and build instructions.

It is compatible with the current versions of both the ArDAM1021 and TFT HiFiDuino projects.

For now you can find more info in this post.

 

Universal Signal Isolator shield for Arduino DUE & MEGA

A few years back I designed a little Arduino shield who’s main function was to provide electrical isolation between an Arduino and a DAC (specifically a TPA Buffalo III).

The years have passed and my needs have changed with the introduction of the dam1021 DAC and its serial interface. My first though was to design a new shield specific to the dam but then I said “why not design a universal isolator shield?”. It would provide electrical isolation for both I2C as well as serial signalling.

Thus was born the Universal Signal Isolator shield for Arduino DUE & MEGA:

v0.97_crop

OK, it does look a lot more complicated than my first shield but remember, you only need to solder in the parts that your DAC actually needs.

So, what does this thing do?

1) Electrical isolation of I2C signals, complete with support of 8 isolated inputs or outputs (via an MCP23008 IC). Three of the MCP’s pins are high current outputs (up to 100mA).

2) Electrical isolation of up to 2 serial ports (implemented with an Si8642).

3) Electrical isolation of the second I2C interface of the DUE (implemented with an ADUM1250).

4) Powered either by 5VDC, 8-15VDC (non-regulated) or 7-12VAC (includes support for on-board rectification and filtering).

5) Support of a 5VDC power relay (up to 100mA).

6) Header for connecting a Nextion display.

7) On-board EEPROM memory (24LC256).

8) And of course full compatibility with the previous shield (same pinouts for the encoders, IR, TFT, etc.).

I will release the Eagle files once I have confirmed that the shield works as expected (I’m waiting for the first (and hopefully last) batch of PCBs).