So I am designing a cheap and simple sound device using the Atmega32U4 uC and stumbled across one problem.

I am using the 10-bit PWM output of the uC to output audio and I want the user to be able to control the output volume using buttons, not a discrete potentiometer. A typical solution would be to just decrease the PWM output duty; but that way I am losing the already low resolution - by decreasing the output volume only by 10dB I already get 60% lower output voltage, and, therefore, I am entering the 8-bit resolution territory already.

That's why I started looking for a cheap hardware volume decreasing solution and I don't want to use a digital potentiometer, since they are relatively pricey. In the end, I came up with the solution shown below; basically, it uses two uC PWM outputs, one to control the volume (VOLPWM) and one to output the audio (OUTPWM); the VOLPWM gets heavily integrated and then the Q1 switches according to the OUTPWM between ground and the VOLPWM output voltage. Notice that the output integration happens after the Q1+R2 pair, pure PWM signal enters the Q1 base.

I've also considered using a push-pull pair instead of Q1+R2, however, I wasn't able to get a decent low level output.

My questions are:

  1. Are there any better solutions to my problem?

  2. Won't the similar value of R2 and R5 be problematic?

  3. What could be the other cons of my solution?

Dual PWM solution

  • \$\begingroup\$ Do you have anything to limit base current in Q1? \$\endgroup\$
    – Colin
    Oct 31, 2018 at 8:52
  • \$\begingroup\$ @Colin nope, but you're right, maybe adding a series 1k resistor would be better \$\endgroup\$
    – sx107
    Oct 31, 2018 at 12:33

1 Answer 1


That's actually pretty good — you've created a multiplying DAC.

The biggest problem I see is that the integrator time constant varies with whether Q1 is on or off — when it's on, you have only R5 in the circuit, but when it's off, you have R2 + R5 in series. To minimize the effect of this, make R5 a couple of orders of magnitude larger than R2. (Reduce the value of C2 to compensate.)

  • 1
    \$\begingroup\$ Any other ways to reduce the R2-R5 effect? If I will increase R5, I'll have to decrease the C2 accordingly and I am not sure how the integrator will operate with a several pF capacitor in it's feedback and with the low currents that the R5 will produce. \$\endgroup\$
    – sx107
    Oct 31, 2018 at 1:44
  • 1
    \$\begingroup\$ Thanks, by the way, for saying that it is called a multiplying DAC, I'll look into it. \$\endgroup\$
    – sx107
    Oct 31, 2018 at 1:53
  • \$\begingroup\$ @sx107 I know this is an old thread, but wondering if you went any further with this and if so what component values you settled on? \$\endgroup\$
    – Ian Bland
    Feb 11, 2022 at 0:07
  • 1
    \$\begingroup\$ @IanBland Worked perfectly. The values on the schematic are more or less the same as I've settled on, though I think I've replaced the output integrator with a follower and a rc filter. \$\endgroup\$
    – sx107
    Mar 24, 2022 at 23:23
  • \$\begingroup\$ Interesting, thanks! \$\endgroup\$
    – Ian Bland
    Mar 26, 2022 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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