Arduino Forum

Using Arduino => Audio => Topic started by: bratan on Jan 25, 2014, 10:39 pm

Title: Sound gets distored when going thru digital pot
Post by: bratan on Jan 25, 2014, 10:39 pm
I've build remote volume control box that changes volume of the line signal passing thru it with help of MCP4241 10K digital pot. Everything seems great when source of audio was my TiVo, however when I connected Xbox 360 I noticed that something is very wrong with sound. Anything that has bass in it sounds very distorted (like speakers were ripped)... This especially clear during explosions...  Is this the nature of digital pots or I'm doing something wrong?  Can I add some components before or after pot to  fix this issue?
I'm attaching schematic, but it's pretty basic...

Edit: I think this is clipping :(
Title: Re: Sound gets distored when going thru digital pot
Post by: tmd3 on Jan 26, 2014, 04:31 pm
Intuitively, I suspect that the digital potentiometer requires that its inputs be between VSS and VDD, while the input signal is bipolar.  When the input signal is lower than VSS, the IC is outside its operating range, and it responds in some non-linear fashion.  I think you hear it most in bassy passages because the bass signal is usually very large compared to higher-frequencies, and the voltage gets further below VSS.

That view is bolstered by this line in the datasheet, found here - http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en531709 (http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en531709), page 5, "AC/DC Characteristics:"
Quote
Resistor Terminal Input Voltage Range (Terminals A, B and W)  Min: VSS  Max:VDD
.
To fix it, you'll have to offset the input signals.  Depending on how your amplifier is coupled, you might have to shift the output signals back to bipolar.
Title: Re: Sound gets distored when going thru digital pot
Post by: bratan on Jan 27, 2014, 04:23 pm

To fix it, you'll have to offset the input signals.  Depending on how your amplifier is coupled, you might have to shift the output signals back to bipolar.

Thank you so much!  But how do I offset input signal? Add a voltage divider?
Title: Re: Sound gets distored when going thru digital pot
Post by: CrossRoads on Jan 27, 2014, 04:31 pm
Yes, feed the signal thru a capacitor, to the junction of two 100K resistors between 5V and GND, so the junction sits at 2.5V going into the pot.
Then feed the pot output thru a cap again to the amplifier.
Title: Re: Sound gets distored when going thru digital pot
Post by: bratan on Jan 27, 2014, 04:33 pm

Yes, feed the signal thru a capacitor, to the junction of two 100K resistors between 5V and GND, so the junction sits at 2.5V going into the pot.
Then feed the pot output thru a cap again to the amplifier.

Awesome! So this is whats called bias offset right?  Do I need voltage divider on the output as well or just the cap?  Would 10uF cap be ok?
Title: Re: Sound gets distored when going thru digital pot
Post by: CrossRoads on Jan 27, 2014, 04:34 pm
Just a cap on the output to remove the DC offset.
10uF should be good. Experiment, see what sounds good.
Title: Re: Sound gets distored when going thru digital pot
Post by: bratan on Jan 28, 2014, 02:18 am
Does this look right? :)
Title: Re: Sound gets distored when going thru digital pot
Post by: CrossRoads on Jan 28, 2014, 02:24 am
C2-R6-R7 not wired correctly.
Polarity of C3/C4 are not wired the same.
Title: Re: Sound gets distored when going thru digital pot
Post by: bratan on Jan 28, 2014, 02:28 am

C2-R6-R7 not wired correctly.
Polarity of C3/C4 are not wired the same.


Ahhh my bad!
How about now? :)
Title: Re: Sound gets distored when going thru digital pot
Post by: CrossRoads on Jan 28, 2014, 02:39 am
I think you have all the polarized caps backwards; I think you want + connected to the source.
Definitely  + to the VDD pin, altho 0.1uF ceramic caps are not generally polarized.
Title: Re: Sound gets distored when going thru digital pot
Post by: bratan on Jan 28, 2014, 02:45 am
Yeah decoupling C5 is not polarized... I'm confused about polarized tho. I see I have C1 and C2 incorrect, current flows from R/L-in to the IC, but not sure about C3, C4...
Title: Re: Sound gets distored when going thru digital pot
Post by: tmd3 on Jan 28, 2014, 07:22 am
Maybe I'm missing something, but I see a problem with the voltage divider used for input voltage offset in this design.

Here's my take on the voltage divider:  The digital potentiometer's internal resistor - 10K, from the original post - is in parallel with the lower half of the voltage divider.  That makes the divider's DC voltage a lot lower than half of VDD, since the upper resistor is 100K, and the lower resistor figures to be about 9.1K.  That'll be OK as long as the input signal amplitude doesn't go above about .42V peak-to-ground.  If the signal gets bigger than that, the input to the digital potentiometer will be below VSS, outside the operating range.

I think that 10K connected between VDD and the input to the digital potentiometer, and no resistor connected between the potentiometer input and ground, will give a DC voltage of 2.5V.
Title: Re: Sound gets distored when going thru digital pot
Post by: CrossRoads on Jan 28, 2014, 07:59 am
Hmm, yeah, I was thinking about the pot as an active device, like an op amp.
How about if the line level is just ac coupled thru the pot then? Does it even need to be offset?

Title: Re: Sound gets distored when going thru digital pot
Post by: tmd3 on Jan 28, 2014, 01:06 pm
The part requires that the voltage on all three potentiometer pins be between VSS and VDD.  I see the voltage on the upper connection to the potentiometer going negative; it the potentiometer were linear under those conditions, the wiper would be negative, too.

I like the circuit in the revised schematic, attached.
Title: Re: Sound gets distored when going thru digital pot
Post by: CrossRoads on Jan 29, 2014, 04:47 am
That's what I drew up originally, but I waffled and couldn't decide how to derive the output.
Title: Re: Sound gets distored when going thru digital pot
Post by: bratan on Jan 29, 2014, 09:35 pm
Thanks guys! Got it working with help from you and guys at DIYAudio forums.
I also had to add (R5,R7) 47K resistors (towards ground) otherwise a little sound would bleed thru.   And R8/R9 100K resistor to bleed charge out of C3/C4 so it doesn't kill my speaker.
Learned how to use LT Spice emulator in the process, very useful!
But by solving one issue I created another one. Now every time I change volume I hear loud pop (higher volume, louder the pop). I read that it's problem with generic digital pots :(   It looks like I might have to switch to PGA2310 or something similar designed for audio...

Title: Re: Sound gets distored when going thru digital pot
Post by: CrossRoads on Jan 29, 2014, 10:11 pm
Ooh, wish you had an oscilloscope so we could see what was happening on the pop.
Gotta be the part going open circuit or closed circuit internally as it switches, something like that.
Title: Re: Sound gets distored when going thru digital pot
Post by: bratan on Jan 29, 2014, 10:26 pm

Ooh, wish you had an oscilloscope so we could see what was happening on the pop.
Gotta be the part going open circuit or closed circuit internally as it switches, something like that.


I have one actually, been using it to monitor sine wave while tweaking resistor values in this circuit... I'll see what I can detect with it..