PWM fader experiment

I wanted to experiment with an audio fader based on the use of 2 analog switches. The switches are used to either choose the signal from source 1 or the signal from source 2 and connect it to a buffering op-amp. Have a look at the diagram:

The switches are switched on alternating with a high frequency. The duration a switch is ON determines the net amount of signal you hear from the connected source. By using pulse width modulation the duration can be changed and one can e.g. fade from one source to the other depending on the duty cycle setting of the control signal. I used an arduino nano and a logic inverter to control the switches. The PWM frequency is about 64kHz.

The code that does the fading looks something like this:

void fade(byte switch_control_port) {
  for (int duty_cycle = 0; duty_cycle < 256; pwm++) {
      cd4066.setSwitch(switch_control_port, duty_cycle);
      delay(SHORT_DELAY_TIME);    
  }
}

I made a video clip which shows the circuit on a breadboard and the signal traces of the pwm signal controlling the 2 switches on an oscilloscope.

In the background you can hear the audio fading from one signal source to the other and back while the PWM signal is varied repeatedly.

Note, if you lower the PWM frequency and use only one input signal, you basically have constructed something that sounds like a ring modulator. The switching of the CD4066 can be seen as the modulating frequency and the input signal as the carrier. So … if you want to make a ring modulator, this is one route you could take.

B.t.w. in the video at one point you can hear me sniff. That is not because I was emotionally moved that the circuit was working as well as I had hoped. It is simply because I had a cold at that time ;-).

8 Likes