1
\$\begingroup\$

I'm trying to make a quick-and-dirty voltage-controlled volume control circuit, using a minimal number of components.

A microcontroller is outputting two 5V p-p, 625 kHz PWM signals: an audio waveform and a volume control voltage. Instead of building a full VCA circuit, I'm trying to do something simpler:

First, filter the volume PWM output to get a DC signal. Then use the digital (unfiltered) audio PWM signal to switch the volume signal. The result should be the audio PWM waveform, with its amplitude scaled down to the level of the volume signal. Lastly, filter it to get an analog audio output.

My question: what circuit should I use to do the switching? Tried a 74HC4066, and it kinda works, but I don't want to use an entire 4066 for just one switch. I was also thinking about an optocoupler, but I'd need one with very high bandwidth. How about a MOSFET like the 2N7000? I don't know much about MOSFET switching circuits though.

Any other ideas? A software implementation is my last resort, I want to avoid degrading the audio signal as much as possible.

\$\endgroup\$
  • \$\begingroup\$ You might look for smaller analog switched here. That is if the unused channels on 4066 annoy you so much. \$\endgroup\$ – Nick Alexeev Dec 28 '12 at 22:44
  • 1
    \$\begingroup\$ If you really want this to work right, you need to switch the input of the second filter between the voltage produced by the first filter and ground. If you just leave it open-circuited when the audio PWM signal is low, the output of the second filter will be distorted. So you really need two sections of your 4066, along with a complementary version of the audio PWM signal. \$\endgroup\$ – Dave Tweed Dec 29 '12 at 0:14
  • \$\begingroup\$ Even better, if you also create a complementary version of the volume-control PWM signal, you can switch between the original signal and this one, which will eliminate the DC shift that occurs with volume changes. \$\endgroup\$ – Dave Tweed Dec 29 '12 at 0:18
  • \$\begingroup\$ @Dave: I also realized that issue with the output going high impedance. What if I used an analog switch/BJT/MOSFET in an open-collector configuration, with a pullup resistor between the collector and V_vol? When the switch is closed, the output would be 0 volts, and when open it would be V_vol. The output wave would be inverted, but that can be fixed in software. \$\endgroup\$ – Matt Sarnoff Dec 29 '12 at 1:22
  • \$\begingroup\$ That would still be less than ideal, because the driving impedance would still be different in the two states. The impedance driving the second filter needs to be constant. \$\endgroup\$ – Dave Tweed Dec 29 '12 at 13:25
1
\$\begingroup\$

Yes, you can adjust the top of the PWM signal to effectively get volume adjustment. However, there are two problems with this:

  1. If the rising and falling edges are not symmetric then the signal will have some distortion. A CMOS digital output, like the PWM signal out of the micro, will be pretty symmetric, and any assymetry will be limited to a very narrow time window, which again ensures that the overall assymetry is small relative to the signal amplitude. With circuitry that has to allow for a variable top level, you probably won't have the same level of symmetry, and probably slower edges too.

  2. The volume setting will introduce a variable DC level on the AC signal. This will generally be slow enough so that most of it can be filtered out downstream, but it can cause problems if not thought about carefully.

I think a better scheme is to incorporate the volume control into the micro and produce the PWM already scaled to the desired volume. You can hook up a pot straight to the A/D input of the micro to give it volume input, and the rest is simple firmware. This has another advantage in that you can implement log volume if you want to. Log pots for the analog solution are getting harder to find nowadays, or more expensive when you do find them. Again, a digital processor can do this easily.

\$\endgroup\$
0
\$\begingroup\$

So using a MOSFET to switch the volume signal works, but...

  • a pullup resistor is required on the drain pin, so the circuit draws current when idle
  • the turn-on/turn-off times of the 2N7000 are too long, and it can't pass narrow pulses very well. This leads to pretty severe nonlinearity in the filtered output signal.

So I learned to stop worrying and love surface mount components, and used a 74LVC1G3157 SPDT analog switch. The audio PWM signal is connected to the control pin, switching the output of the '3157 between ground and the volume voltage. Even with a simple passive lowpass filter on the output, the results are quite good. There's still some nonlinearity in the filtered output signal, but it's definitely within acceptable limits.

\$\endgroup\$
0
\$\begingroup\$

Maybe a daft idea but if the PWM for volume and the PWM for audio are the same frequency then XOR them together. If the volume PWM is 50:50 then the audio result after filtering should be zero. I guess this means you can control the volume through zero loudness and if you keep on going lower than 50% mark the filtered audio inverts. Probably a nonsense idea!

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.