Digital Potentiometer

One of my recent projects involved the building of a small 2.1 amplifier using some TDA power amplifier chips that I scrounged from a cast off electronics board.  Since I was able to decide how I wanted to control things, I chose to use a couple of digital potentiometer chips.  That lets me use a PIC (yeah!) and an IR control (double yeah!).  I talked briefly about a similar type of circuit in the post where I described how the Dell 5650 subwoofer uses a Voltage Controlled Attenuator (VCA).  The difference between a VCA and a digital potentiometer is that the VCA requires an analog control input while the digital potentiometer uses either digital control lines (to increment or decrement the volume) or a serial data interface.  For my project I decided to use a serial data version partly because it allowed me to directly set the desired value and partly because it provided more of a challenge.  In the end, it was actually pretty easy because the software was almost a duplicate of what I use for my 3-wire, 8-bit LCD interface.


Digital Potentiometer

The part I chose for the digital potentiometer is the MCP41xxx.  The “41” designation means that it contains a single digital potentiometer.  They also make an MCP42xxx series that contains a pair of digital potentiometers.  For my project I needed to control the left, right, and subwoofer volume so I needed three chips.  They were less than $1.25 each so no big deal.  The “xxx” portion of the part number signifies the full scale resistance of the potentiometer.  The ones I found readily available were the 100k version which is a reasonable choice for an amplifier volume control.

While the schematic shown above includes all of the stuff used to control my homebrew amplifier, I will only be talking about the digital potentiometer interface.  As I mentioned, the actual project uses three of the digital pots.  All three of them use the same control lines from the PIC but the subwoofer one has a separate chip select (CS).  The actual potentiometer connections are just like they would be with a manual potentiometer.  Just connect the input signal to the “top”, connect ground to the “bottom”, and route the “wiper” to the power amplifier input.

Interestingly, another useful application for these devices is as a digital to analog (D/A) converter.  In that case the “top” of the potentiometer would be connected to the + voltage supply.  If the + voltage is 5 volts, then the D/A will output values with a resolution of approximately 20 millivolts.  The resolution calculation is simply: Voltage/256.


The software link is listed below.  While it is targeted for the 16F688, it is easily ported to other versions of the PIC.  You will need to change the line that identifies the PIC version (LIST=) and the INCLUDE file but those are intuitive changes.  The __CONFIG line may also need tweaking just because one or two of the labels used are spelled differently in some of the INCLUDE files. 

As mentioned earlier, the software for sending data to the digital potentiometer is almost identical to what is used in my 3-wire, 8-bit LCD interface.  When the chip is selected it expects exactly 16 bits, each clocked on the rising edge.  The first 8 bits are the command which will always be 11H in my example.  The second 8 bits are the data bits which can range from 0-255.  The bytes are clocked most significant bit first.  One thing to keep in mind is that the digital potentiometer automatically presets to 50% (80H) when power is applied.  That means that the PIC will need to issue its own preset value if something other than 50% is desired.  In my example I preset the value at 25% when the amplifier is turned on.  The volume control gets set to zero when the power off command is received.  I increase or decrease the current value by 10 when the appropriate button is pressed.  That gives me a total of about 26 volume steps instead of 256.  That’s it for this post.  Check out my other electronics projects.

Digital Potentiometer SW