INTRO
This blog has been sort of a notebook for me to write down my own learning with Arduino and the TPA boards. Therefore the information presented assumes that the reader’ is learning at a pace equal to mine.
Beginners are overwhelmed with the amount of information here so this post is to help those by outlining the basics of building a controller board for the superb kits produced by Russ and Brian of Twisted Pear Audio. TPA is also developing a controller for their products so this is an alternative to their solution utilizing low cost, and widely available parts. (As of July 2011 April 2013, the TPA controller board in not yet available, so this is the only “ready-to-run” option)
Basically, all modern audio chips have a software interface and they communicate with a micro-controller through a communication protocol called “I2C”. I have chosen the Arduino platform because I am not a programmer and Arduino is geared towards that audience. In addition, the Arduino community provides a lot of help for beginners and non-programmers.
HIFIDUINO is about building a controller that can talk to those audio chips. So far I’ve interfaced to the OPUS DAC with the WM8741 and the Buffalo II boards. But the same platform can be used to interface to other chips such the WM8804 spdif interface and even the brand new TI PCM51x2 DACs with lots and lots of features that are available only through s/w programming.
The controller consists of:
Arduino board
NOTE: if you use Arduino UNO R2, there is a potential bug: http://hifiduino.wordpress.com/code/#comment-718
Any official board or clone will work. The current (v.09) code size is about 14K bytes, so even the bottom of the line Arduino will work. All of he following models work: UNO, Dueminalove, Seeeduino v.2.2, NANO and others. I have used the UNO and the Dueminalove. I have even used the Freeduino. If you want to be dead sure that it will work, then purchase the latest official Arduino UNO (R3 or above)
The Freeduino with a companion stationary shield
Rotary encoder
The rotary encoder is used to change volume and settings. In theory, you can use any “quadrature” or “gray code” encoder. However, I find that the preferred characteristics of the encoder are:
- About 30 cycles per turn. This gives a good “feel” when changing the volume, changing 30 db per revolution -not too fast or too slow
- Built-switch. The switch is used to change from volume control to DAC settings control. This is not mandatory, you can implement with a separate switch
- A rotary encoder with “clicks” is preferred because you can feel the clicks when you select the different settings. I tried a rotary encoder without “clicks” and it does not work well because selection of the different settings take advantage of pushing the encoder to activate the switch. Often one you push the switch you can also inadvertently move the encoder. Rotary encoders without detentes (“clicks”) are not recommended.
I use a Panasonic model that has been discontinued, but available from Electronic Goldmine. Other candidates are: Bourns PEC11, BI EN12. The current version of the code (v.09) does not require that you build a debouncing circuit as the debouncing is done in the software (I had used the rotary encoder without hardware debouncing or a long while, but I finally added the debouncing capacitors).
LCD display
The code assumes a 20×4 LCD. Any LCD that is compatible with the HD44780 protocol will work with the code: Do a search for “20×4 LCD HD44780″ on eBay. The one I purchased is from Sure Electronics. You can also purchase directly from their website: [link]. Nowadays it is available pretty much everywhere. Here is another good source: iTeadStudio
As it turned out, a larger portion of the code is the user interface and it assumes a 20×4 LCD. Thus, if you use a different form-factor LCD (for example a 16×2 LCD, you will have to overhaul a lot of code.
NOTE: if you use Arduino UNO R2, there is a potential bug: http://hifiduino.wordpress.com/code/#comment-718
IR receiver and a remote control
The code supports the Apple Aluminum Remote. Any IR receiver should work. However, I would recommend the Vishay TSOP32438 because it is designed for the 38KHz frequency used by the Apple Remote. The 32438 model also provides noise immunity. Additional information: [link]
Here is a good article on “how to choose IR receiver”: [link]
In fact, any one of these would work:
A level converter from 5V to 3.3V for the I2C lines
This part maybe optional. As the I2C inputs of the Buffalo are “supposed to be” 5v tolerant, but the data sheet does not say specifically and I have not determined that to be the case with 100% certainty. (You can easily build it if you do not wish to buy the module)
You can build your own level shifting by following this diagram from this document [link]
I Made my own here: [link]
GET GOING
The best use of this project is for you to experiment with your own choice of components and ideas. You can reuse whatever part of the code you wish (as I have reused code from other contributors. -This is the spirit of open hardware and software of the Arduino community). If you do this you will find that the audio hobby is not just about changing cables, capacitors and power supplies
However, if you wish to just replicate what I have done, this is what you do:
- Get familiar with the Arduino development environment. At the minimum you must know how to compile code and upload to an Arduino. The Arduino tutorials listed in the side bar are a good start.
- Procure the parts above and hook them up according to the different hookup diagrams in this blog. The current code does not require that you build a debouncing circuit for the rotary encoder so you can skip the debouncing circuit
- IR receiver hookup
- Rotary encoder hookup (follow the “no H/W debounce” diagram)
- LCD hookup
- Level converter hookup
- Download the latest version of the code from the code tab. Compile and Upload to the Arduino
- Done!
This is what my controller looks like:
User Interface summary
Here is a very nice summary of an older (v. 09) user interface from マルチチャネルDAC製作記 blog and in particular this post [link]
I have updated the user interface a bit: http://hifiduino.wordpress.com/2012/01/09/code-compatible-with-arduino-1-0/
Newer versions are a refinement. But the overall user interface is pretty much the same
NOTE: if you use Arduino UNO R2, there is a potential bug: http://hifiduino.wordpress.com/code/#comment-718
EASY ORDER (DIGIKEY)
Arduino UNO R3: 1050-1024-ND [link]
ANOTHER IMPLEMENTATION
Here is another implementation of the controller with a hand made Arduino “shield” to facilitate connections: LCD, Arduino, shield, rotary encoder and IR receiver.
The shield has the following components:
- 5V to 3.3 Level translator with external pull up resistors (1.5K ohm) and local 0.1 uF power supply (5 and 3.3V) bypass. This will ensure clean I2C signals. External pull ups may or may not be required. Depends on your environment.
- Potentiometer for LCD contrast adjustment
- Potentiometer that adjust the current to the base of a transistor controlling the brightness of the LCD
- Arduino reset button (since the reset button of the Arduino is covered by the shield)
- Underneath, I had implemented a debouncing circuit for the rotary encoder. The code does not need the hardware debouncing circuit since it uses s/w debouncing, but it does not hurt.
The external 1.5 Kohm I2C pull up resistors were added afterwards to solve a noisy I2C connection. In most cases, the internal pull-up resistors or the pull-up resistors built-in in the level translator board should be good enough. I had also added power supply bypass capacitors to further clean up the I2C lines.
The h/w debounce circuit was built in accordance to a BOURNS “Signal Conditioning Technical Note” paper [link]. This is not required by the current version of the code because s/w debouncing is used. However, it is always a good idea to reduce spurious interrupts.
Connecting the LCD
Connecting the rotary encoder (with switch)
I find this rotary encoder very good. With solid clicks and good feel. You really need a rotary encoder with “clicks” because it is also used to make adjustment. I had also used an encoder without clicks and as you push the encoder to actuate the switch and make selections, you would also slightly rotate the encoder making inadvertent adjustments.
More info on rotary encoders:
Connecting the IR receiver





























Hi! Great blog just burned the last 2 hours reading your posts.
Even though I have some experience with Arduinos and a little with DACs (working in a laboratory) I was wondering if you could recommend a easy guide of a full built to get started (including some links where to order stuff).
Thx in advance
Michael
I enjoyed writing the blog
The information here tells you what to buy and where…
The software described here works with the buffalo DAC. You can check http://www.twistedpearaudio.com
Hi, this is fantastic! Thanks for posting all this. I want to build my own 5v – 3.3v converter and see in the above photo that you have done the same. Can you point me in the right direction to a circuit diagram or list of components etc?
Cheers!
Added info in the post…
Hi GLT, Your work here is much appreciated as in diyaudio. Thanks a lot!
I’ve added “the system” to my diyinhk es9018 v.5 DAC. I use sainsmart uno R3 with large 20×4 LCD. Nothing has any frills! I made hifiduino successfully work in a way, only with one problem: the DAC requires reset once hifiduino starts, and each time when something is attempted to be changed (such as volume and other settings) through the remote or rotary encoder. Some basic nut or bolt is loose I suppose!!
If you have any insight what might be the culprit or which direction should I look will be very helpful.
Thanks in advance.
Tell me more. What happens right after you power both the DAC and Arduino. Usually you can start them at the same time. If you can externally mute the outputs, you can startup the DAC first and then Arduino. Also, I would recommend having all the wiring as twisted pairs (I2S and I2C) and make sure no wires crosses over the DAC chip
Thanks for your answer. At the moment I have seperate power supplies for the DAC and Hifiduino unit with seperate switches, but starting them at the same time will not be a problem and eventually it will get the power from DAC psu. The problem with any interaction of Hifiduino with the DAC causing stalling I think may be due to current I2C wiring, which I haven’t tried to perfect it yet. Do you think using pull up resistors on SDA SCL lines will be any help? My DAC is very clean, with all seperate Salas shunt regulators after two stage inline regulation, etc. although everything is still on test setup, with minimized and careful wirings. I’ll try powering up both units at the same time and work on I2C line and I’ll post more info later
Thanks again.
F. Arhun
I haven’t encountered any scenario where I have to reset the DAC. When there are problems, I’ve had to reset the ARduino. In certain environments, adding pull up resistors to the I2C would be beneficial. Check out this post: http://hifiduino.wordpress.com/2013/03/25/new-version-of-code-2/
I also made me a small system with a DIYHK PCB.
No leveltranslater used, because the DAC’s I2C pins are 5V convertible.
I use an I2S signal, and I can see the samplerate is changing on the display (Means the system is communicating with the DAC and I’ts running), but I can’t measure any output of the DAC. I use 100 ohms resistors on the output, but I assume I should be able to measure something else than a DC voltage?
Do I need to remap the DAC different compared to the BII DAC?
Great page btw.
If you are using the I2S inputs of the diyinhk board, there is nothing to change. How are you measuring? Unless you have an oscilloscope, it is not easy to measure music with a voltmeter…
I just found your great block. I wonder if your code can be used with Buffalo 32s
I believe it should work as is. Just try it.
Thanks. Order Arduino board and other parts already. Should be fun.