Digital Controls for a Manual Audio Amp

Introduction: Digital Controls for a Manual Audio Amp

Recently I thought of an application where I need a small amplifier for TV audio and decided to dust off some cheap audio amplifier modules that were sitting in my junk box. Of course the simple TV amplifier grew to encompass a radio tuner, an MP3 player, and an option for a CD player. That meant the addition of source selection capability for the audio inputs. I then wanted to be able to control the amplifier using a simple IR remote. Since I was going to have remote control I figured that I might as well add digital volume controls as well. When all was said and done, I ended up with a fairly inexpensive box that took care of all of those requirements. Even if you don’t want to build the amplifier there is information here on controlling analog switches and digital potentiometers that may be useful for some other project you have in mind.

Step 1: Hardware

The small audio amplifier modules I have are only mono so I needed to use two of them for this project. Adding the capability to power them on/off via IR control required the addition of a cheap relay module. You can’t drive a relay directly from an Arduino pin but these modules have a low current interface that is designed for that purpose. Volume control and input selection required a bit more work and are described further on. The IR control input is the one I detailed in a previous Instructable (“Simple IR Remote Controls”), with the code values and actions customized for my application.

There are two versions shown here, one using the ATtiny85 and the other using the ATtiny84. The ATtiny85 has limited pins available for output control, with three pins required just for the digital potentiometer controls, one pin for the IR input, and one pin for the amplifier power control. The amplifier control goes to the enable input of the relay module. This design is only good for a single audio source but it doesn’t require the extra circuitry for source selection. The ATtiny84 has an extra six pins so it allows for all of the controls of the ATtiny85 circuit as well as controls for source selection. That is the version that I built for this Instructable.

Step 2: DC Power

The amplifier module uses 12 volts and needs at least a couple of amps of capability. That voltage is routed through the relay module to provide controlled on/off for the amplifiers. The digital logic (including the relay module) requires 5 volts so I routed the 12 volts to a standard 7805 voltage regulator. Because of the surge created when the amplifiers are turned on, I added a 1000uf capacitor on the 5-volt power input to the digital logic as well as .01uf capacitors between 5 volts and ground in a couple of places by the logic chips.

Step 3: Volume Control

The amplifier modules have analog volume controls that vary the level of the input signal. Instead of trying to replace them with digital controls, I put the digital controls in line with the manual ones. The chips I used are digital potentiometers MCP41100. These chips have a single 100k ohm potentiometer that is varied by sending in a serial command string. There are other varieties of these chips, in different values, and also in a dual potentiometer package. The digital potentiometer acts like a hardware one with input connections at each end and a variable resistance wiper output in the middle.

Potentiometers come in a variety of tapers. The most common is the linear taper which means that the resistance varies on a 1:1 basis with the movement of the wiper. That means that a 25% movement of the wiper corresponds to 25% of the total resistance and a 75% movement corresponds to 75% of the total resistance. That works great for things like a variable power supply. Our ears, however, are not linear so other potentiometer tapers can make it seem like a 25% wiper movement sounds like a 25% change in sound level, and so on, up through the full scale of the potentiometer. Typical names for some of these tapers are “audio”, “log”, and “inverse-log”. The “log” and “audio” tapers are generally interchangeable names. A graph of typical taper curves is shown is the first picture.

When I did a couple of rough measurements on the manual amplifier potentiometers I discovered that the resistance seemed to follow the “log” taper at the low end, the “inverse-log” taper at the high end, and was at 50% right in the middle of the wiper movement. In other words, it followed an S-shaped pattern that started off slow in change, increased in rate of change through the middle section, and then slowed again as it approached the maximum resistance. That presented a bit of a problem because the digital potentiometer chips I used are linear taper. I got around that by defining step sizes in the software that approximated values on the S-curve plot.

As can be seen in the second picture, I created a spreadsheet that allowed me to calculate digital potentiometer commands to simulate the S-curve change of the manual potentiometer. What I actually created was a reverse S-curve so that the resistance goes from maximum to minimum as the command value decreases. Reversing the value order or reversing the signal connections on the MCP41100 would produce a standard S-curve. I found the basic S-curve formula online and then tweaked the formula values to approximate the curve I measured on the manual potentiometer. I have included the spreadsheet here so you can play with it yourself.

As can be seen on the front of the box, the manual volume controls for the amplifiers are still available for use. Just remember that they are in series with the resistance from the digital potentiometers. I found it handy to be able to set the manual controls at half level to limit the potential volume going to my small bookshelf speakers. You may want to set them to the full on position if you want maximum volume capability for larger speakers.

Step 4: Input Selection

Input selection allows for connecting multiple audio sources to the amplifier inputs. To do that digitally I selected the common CD4066 analog switch. Analog switches are different than digital switches because they can faithfully pass variable signal levels like our audio inputs and can pass the signals in either direction. Analog switches can have a single input/output or they can route one input to multiple outputs or vice versa. The CD4066 has four independent input/output switches which made it perfect for my project. Two chips are needed for the stereo amplifier with the right channel of each audio source going to one chip and the left channel of each audio source going to the other chip. Each of the four analog switches in each chip has a separate enable but the left and right enables for each audio source are wired in common.

Most audio inputs can be directly connected to the amplifier with no problem. I did, however, run into an issue with the audio from my TV. Older TVs often had a designated set of RCA jacks for audio output but most new models have only digital audio and a headphone jack. I’ve used the headphone jack previously with no problem but when I connected it to the input of my amplifier box I got a lot of pops and crackles. Apparently some audio sources float the ground pin of the 3.5mm stereo connector at something other than the main ground of the device. When I grounded it to my amplifier it protested so a simple audio isolation transformer was required. I bought one like the one shown above for less than $10.

Step 5: MP3 Player

As can be seen, there are three audio inputs on the back of the amplifier box. The fourth audio source comes from a cheap MP3 player module I had laying around. The module can also play micro SD cards but I removed that holder from the board before mounting the player in my amplifier box. The module has its own power amplifier but that only produces mono sound. The earphone jack on the module is stereo so that is what I wired to my controller board. I also had to wire a controlled power source for the module but I was able to do that with a small signal transistor instead of a relay.

One other thing to note about the module is that it doesn’t remember where it was in the playlist if the power goes off. That means that a standard flash drive will always restart from the first song. I got around that by plugging in an iPod which does keep track of the playlist position. The iPod power switch remains off and it powers on and plays through the USB connection the same as if it was connected to a computer.

Step 6: Software

The software uses the baseline IR remote software I detailed in a previous Instructable and adds control for the digital potentiometers, analog switches, MP3 player power, and amplifier power. The analog switches just require an enable and the enable line also gets routed to a front panel LED. The digital potentiometers require a command string for the setting of the resistance value with the value ranging from 0-255. The volume steps are contained in a defined table and an initial step into that table is also defined as a default value. The default value is selected whenever the amplifiers are turned on or when a new source is selected. The volume control commands simply step up or down in the table values.

Step 7: Conclusion

As I mentioned earlier, the digital volume control and input source selection techniques may be useful for other applications you might have. For instance, you could add multiple inputs and/or volume control for audio going to a color organ. They should also be usable to create a remote controlled interface for an old commercial audio amplifier. Instead of routing the audio output to a barebones amplifier module like I did, just plug it into one of the audio input jacks on the back of the commercial amplifier.

Automation Contest

Participated in the
Automation Contest

Be the First to Share


    • Sewing Challenge

      Sewing Challenge
    • Micro:bit Contest

      Micro:bit Contest
    • Unusual Uses Contest

      Unusual Uses Contest