Electrical – Convert PWM to Analog using a DAC chip in order to emulate a Potentiometer for audio

arduinoaudiodacpotentiometerpwm

I'm trying to control audio level/gain (from line or amplified signal) using an Arduino. I do not want to use SPI, for this project I can only use the PWM outputs, thus I do not want to use a digital pot. I found some related questions here, but they do not fully explain how this approach applies to audio applications.

From the PWM I know I can use a low pass filter, but I want to save time and space using a DAC chip. One option is the TDA1543 (http://www.docethifi.com/TDA1543_.PDF).

So my questions are:

  1. How do I connect the PWM and audio in/out using the DAC TDA1543?
  2. Will this approach work as an audio pot controlled by PWM or is there a more straightforward option?

The TDA1543 has 8 pins:

1: bit clock input

2: word select input

3: data input

4: ground

5: voltage

6: left channel voltage output

7: reference voltage output

8: right channel output

Where do I connect the PWM, and audio in and out? I believe I also need to indicate the resistance somehow or add resistors such as in a 10K pot (amplified) or 100K pot (line).

Any help will be very much appreciated!!

Best Answer

To control audio signal gain with a PWM channel, simply connect the audio input and ground to the inputs of an analog SPDT switch, and connect the PWM signal to the switch's control input.

The output is fed to a low pass filter with a corner frequency somewhere between the top of the audio band of interest (say, 20kHz), and the PWM switching frequency (say, 100kHz). For cleanest waveform, a corner frequency of just over 20kHz - or a high order brick wall filter as used in early CD players.