I am attempting to control speaker volume via a digital potentiometer, the problem being that audio signal goes both above and below 0V, for regular potentiometers this is no problem but for digital they cannot handle a signal below ground.
How can I shift the signal up to always be above 0V? I believe this is called biasing, so instead of -2V to 2V it'll be 0V to 4V. I have seen example circuits for this. So for me the more important question is do I have to shift it back down for the speakers to "understand" the signal again?
Answer
You can shift it like this if you don't have the center voltage already available:
simulate this circuit – Schematic created using CircuitLab
Or like this if you do:
You may recognize it as a highpass filter, which it is. In signal processing, DC (constant offset) is 0Hz, and is considered a frequency just like any other. Set the cutoff frequency well below the lowest point of interest.
As for the speakers, yes, you should offset it back, using the speakers' ground as the center point. You should probably add a buffer amp between the pot and the output, which you can take advantage of as an active highpass filter. This circuit takes that idea one step further by coaxing a linear pot into a somewhat decent log response, which is a little bit better suited for the way we naturally measure volume:
It may not be immediately obvious, but I used one of each variation. The input one is almost obvious - I'm using the digipot itself as R2 - and the other can be seen by realizing that the (-) input of the opamp is actively held at the speaker ground, which is the desired center point. Also, by loading the pot with R3 to ground, I can convert a linear response into a semi-log one.
The classic inverting opamp then takes the voltage that appears between C2 and R3 and puts it on the output with a gain of (-R4/R3). This means that you can make R4 variable in order to match the digipot's volume range with the speakers' volume range, which is generally a good idea in my opinion. Once set, it should never be moved again unless you change your setup, so it doesn't need to be anything fancy.
Two things to note:
- The opamp needs a wide enough power supply to cover the entire +/- voltage range that the speaker can handle, or that you care to give it. It can't go outside of its own supply.
- Power on/off transients typically go straight through this kind of filter because they're relatively high in frequency content. At this point in time, the cap is charged incorrectly for the required offset and so you might need some kind of over/undervoltage protection between C1 and the digipot and between C2 and the opamp. You can use a pair of zener diodes in reverse series from the signal to the center point if you have it and it's "stiff" enough compared to the supply rails, or you can use a shottkey diode from the signal to each supply rail of the device that it's about to go into.
No comments:
Post a Comment