Convert Differential PWM to Differential Audio with Volume Control

Thread Starter

Sensacell

Joined Jun 19, 2012
3,773
Context: I am working on an STM32 project and am now trying to add audio output to the project.
I am planning on using the PAM8302A Class-D audio amplifier to drive the speaker, which has a differential audio input.

Converting the 250 kHz PWM from the MCU to analog audio is simple- just an RC filter, differential PWM requires two filters - to provide a differential audio signal.

Now the tricky part: I need to control the output volume from a DC Control voltage.

I sketched up an idea that seems workable- but always I seek the perspective of others.
Using two small signal MOSFETs, I convert the PWM to open-drain, with matched pullups. The pullup resistors are tied to a variable DC voltage- the voltage on the drains are now a variable-amplitude square waves.
An RC low-pass removes the carrier, leaving a differential analog signal, this gets AC coupled into the two inputs of the class-D amp.

I was trying to imagine if this could be done simpler with some switching diodes, need to ponder this...
The diodes are fast- I am concerned that the 20-50 nS propagation delay of the MOSFET might introduce some nasty distortion, especially near the ends of the duty cycle range?

I don't need great control linearity, and the volume does not need to go all the way to zero.
Clicks and pops when switching this on-and-off are not wanted, it needs to be low power when OFF as well.

Comments invited!

32698.jpg32698.jpg
 

Attachments

Last edited:

Ian0

Joined Aug 7, 2020
13,109
Why can't you read the control voltage with the MCU's A/D then multiply the signal that is generating the PWM by the control voltage before it is sent to the timer?

If that doesn't work, get a pair of SPDT analogue switches, connect the PWM to the control input of the analogue switch.
Buffer the control voltage with an op-amp and connect to the N/O side of the analogue switch, and connect the N/C side to ground.

Must the PAM8302 have a differential input? Can't you connect one side to ground and drive the other?
 
Top