Friday, August 2, 2024

PWM Chorus Control

    I'm a fan of synths that have analog choruses built in. The Juno 106 and Poly 800 are two popular examples. Strangely, neither gives you proper rate or depth controls for the chorus. I thought it would be interesting to not just include these controls, but to store them in a synth's patches. This means that the CPU needs a way to interact with the chorus circuit.

    In the modern day, we have a number of options for adding digital control to an analog circuit. A DAC can bridge the gap if the circuit is already voltage controlled. A digipot can do the same if it's resistance controlled. A less common, and more interesting approach, is to pulse width modulate(PWM) a CMOS switch. We already looked at Pearl's use of this in their Drum-X.

Switches as resistors

    A CMOS switch can act somewhat like a variable resistor when turned on and off very quickly. The more time it's on (relative to off) the lower the effective resistance. That's all PWM is: a change of the on-time relative to the off-time (duty cycle). Two of these variable resistances can be put together and used like a potentiometer. The trick is to increase the resistance of one, while decreasing the other. The idea being that the total resistance should stay roughly the same, and only the ratio of resistances changes.

PWM

    The nice thing about pulse width control is that it's easy for most microcontrollers to generate. Virtually all of them have timers with special facilities to output a variable pulse width signal. At the same time, it's quite easy to generate a PWM signal in an all analog circuit. You can simply compare a CV source to a saw carrier wave. The output will be a pulse wave where the width is proportional to the CV amplitude.

PWM diagram from PCBhaven

Chorus circuit

    I'm working with a clone of the Ibanez CS9 chorus pedal, branded as a KMISE Classic Chorus. The pedal generates a triangle wave that it then uses to modulate the clock of a delay line. The rate control adjusts the frequency of this triangle wave LFO, while the depth adjusts the amplitude. Here's the corresponding portion of a very similar chorus circuit:


LFO with rate and depth potentiometers


Switches as potentiometers

    Notice that both the rate and depth are controlled with potentiometers set up as voltage dividers. This means we need to fake four separate resistances and maintain the ratios we discussed before. We can make this much simpler by using double-throw CMOS switches, like the ones in the CD4053 IC.

    Each throw is provided by its own switch internally, but the two are set up to have opposite states: one is open while the other is closed. So, they will also maintain opposite duty cycles when we PWM the pair. If one is closed 25% of the time, the other will be closed 75%, always "adding up" to 100%. This equates to resistance, meaning they will always maintain the same total resistance between them. This makes it easy to use the two throw switches together as one potentiometer.

Rate control

    Let's apply this to the rate knob. You can think of one throw as giving the maximum rate, and the other giving the minimum rate. You can see a small hitch when the PWM signal is low. This is the time spent at the minimum speed. If we do this very quicky, the hitches become negligible, and the rate averages out based on the ratio of time spent at the two extremes.


 

Depth control

    Now we'll look at the depth knob. If we use the same trick, we don't get the same tiny hitches; We get deep bites taken out of our signal.


slow carrier PWM

    This is exaggerated by the slow PWM carrier frequency used to illustrate the result. In practice we use a much faster carrier, and the results are less dramatic. Bites are still take out, but they're much narrower, and more rapid. More rapid means they're high(er) frequency noise, and we can lowpass them away. Notice that the schematic already has a lowpass filter on the output of the depth knob: R34 & C20. If we probe after this lowpass, we see (in yellow below) a much more normal triangle with a lower amplitude based on the PWM duty cycle. You can think of the low pass as having stolen some of the peaks to fill in the valleys.

fast carrier PWM with filtering

 

Hardware

    The ubiquitous Arduino can give us the two PWM signals. The analogWrite() function can be used to generate 980Hz PWM signals on pins 5 & 6. This is quite slow in the audio world, but still fast enough relative to our slow LFO, and lowpass filter. So, if you use an Arduino as the brain for your synth, it would be able to store and recall your chorus settings. It would only need a humble CD4053 to actually control the chorus. No passives required.

    The 4053 includes three double-pole switches, meaning we have one free after controlling rate and depth. This last one can be used to switch the effect on and off. It could be PWM'd to mix the wet and dry signal, but it would require a very high carrier frequency to allow the full audio spectrum to pass through unaffected. Note that some choruses already include a way to turn the effect on/off via a digital signal. This clone happens to use "true bypass" instead.


 

Other ideas

    Instead of controlling the LFO, we could have replaced it entirely. This might be a good option if your micro is well equipped to generate its own LFO output. This also opens up the possibility of new waveforms.

    Or we could have generated CV and converted it into PWM instead of generating the PWM signal directly. This would make more sense for a micro that can't generate any (additional) PWM outputs, or is already set up to generate a large number of CV signals. Many synths multiplex one DAC to multiple outputs, and it would be easy to tack on two more for the chorus.

No comments:

Post a Comment