digitally controlled HiFi Amp with 4 way mixer


Though I am a musician I don’t care for calling an expensive hi watt stereo my own. For years I have used a homebuilt stereo amplifier built around the TDA1554Q IC (basically just this chip in a nice box) and I am still very happy with the sound quality. This amp serves as a computer desk sound system, which acts as a radio/movie sound sytem as well.

In the meantime the number of sound sources that I want to connect to my “stereo”  has increased … suddenly there was a tablet that I use as an internet radio, a music player demon that runs on a raspberry pi and from time to time I want to listen to a podcast that I downloaded to my smartphone.

So a next-gen desktop stereo should have multiple inputs … about four of them would be nice. Also when watching TV on my computer from the bed I don’t want to get up all the time if I just want to adjust the volume. I’d like to do it digitally … maybe use my smart phone as a remote control?

Let’s summarize:

  • 20 W stereo power amplifier

  • 4 way audio in

  • digital volume control interface


The amplifier section is trivial. You just buy a TDA1554Q, bolt it to the inside of an aluminum box, solder some resistors and capacities to the pins of the IC according to the application note in the datasheet and you have a small HiFi amplifier.

Because the volume control has to be digital, I’m using digital potentiometers. Sadly there are no (affordable) logarithmic digipots available. However I found this method which employs a linear potentiometer in combination with a fixed resistor to “fake” a logarithmic potentiometer.

Figure 1

Figure 1

According to the article the the ratio between R1 and R2 has to be between 1:7 and 1:10 for best results. I made some calculations with octave and played around with the ratio. I found no reason against the 10:1 ratio.

Figure 2

Figure 2

It’s obvious that the voltage divider response is not exactly linear, but in the middle range it’s really pretty okay. So using a digipot + fixed resistor should do just fine for a volume control.

Figure 3

Figure 3

So here you have the overview schema of the thing.  Four stereo input channels, each have two of the fakelog digipots to adjust the channel volume. Everything gets mixed together (per channel of course) and goes through a master volume fakelog digipot before it is fed to the power amplifier. All digipots are controlled via I2C by a small microcontroller, the ATtiny 2313 is absolutely sufficient here. The Tiny waits for commands coming in through a (one way) UART connection, driven for example by a Raspberry Pi. The UART input line is electrically decoupled with an optocoupler to keep common ground noise (from the Raspberry Pi) away from the sensitive audio electronics.

The build

So I started KICAD and clicked my schematics together:

main sheet

left wing


Now I spare you the details about routing, PCB manufacture and soldering … maybe just a few pics …

As you can see, I used the toner transfer method to produce the PCB. The routing was performed with help of autorouter.

Some details on the decoupled UART interface:

connection to raspberry pi or other UART transmitter

connection to raspberry pi or other UART transmitter

When connected to a Raspberry Pi or other UART output device, VCC and Tx lines are used (not GND). The UART interface is idle HI, so when connected to VCC and Tx, the LED in the optocoupler is off while the line is idle. The Phototransistor in the optocoupler is then wired as an inverter, so the output signal is a non-inverted UART signal again. This circuit is completely analog to the general MIDI interface definition.


Since the ATTiny2313 does not have a “real” I²C (or TWI, as it is called by Atmel) interface, you have to configure the USI (universal serial interface) inside the ATTiny to act as an I²C master controller. I found a very useful instructable to this topic: (thank you very much, doctek)

The microcontroller now listens on its serial port (4800 baud) for commands in the format:



… sets master vol to zero for left and right channel


… sets channel 4 input volume to 220 (left) and 180 (right)

On top of that you can also pull the master mute (MM) pin of the power amp:



so pretty straight forward 😀

User Interface

In the end, a command line access to the amp is nice to have, but not very user friendly. So I wrote a little CGI script in perl (using the fast-cgi module and mootools.js) that provides a graphical interface to the volume controls. SLIDERS! Access from my smartphone was no problem.


screenshot of web interface


The system works fine. The digital potentiometers make a little noise whilst “turning”, but who cares. I had some trouble finding a low noise wall pluggable 12V switching power supply. Some of them make my amp produce unpleasant squeaking sounds. After the first disappointment, I eventually discovered the power supply of a defective WiFi router to be suitable for my purposes.

The fake log pots perform ok. Not perfectly logarithmic, but trillions of times better than linear pots.


Schematics, entire KICAD project and firmware:

view project .git

or download project as .zip

2 responses to “digitally controlled HiFi Amp with 4 way mixer

  1. Pingback: Digitally controlled HIFI amp with 4 way mixer -Use Arduino for Projects·

  2. Pingback: Brute Force Computation for Cheap Log Digital Potentiometers | a c i d b o u r b o n·

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.