Scaling PWM amplitude by switching an analog DC voltage


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.

Best Answer

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.