Feb 8, 2016

VCO part 2: waveshaping

This is the second part on my VCO module, following part 1 here. This post shows the waveshaping to convert the saw-tooth output from the oscillator core to triangle, sine and square/pulse waves. The pulse and triangle wave circuits are taken almost directly from Yusynth, but the sine shaper is different. An alternative waveshaping circuit with suboscillator will follow in part 3.

Circuit diagram

(For personal use only)

Here is the complete circuit diagram of the submodule. It's main input is Saw in from the VCO core, and it outputs pulse, triangle and sine waveforms. The green lines show the waveforms used to turn the sawtooth into a triangle wave. In addition a spare op-amp U2a is used as "attenuverter" to give bipolar control over the FM control voltage input. 

Pulse wave

To create a square/pulse wave with pulse-width modulation, only a comparator is needed, comparing the sawtooth wave to the pulse-width CV voltage. This is done by U1b. The CV voltage is created by U1a, which adds two inputs (typically a pulse width potentiometer and a PWM input) in inverting configuration. R3, R4 and R5 form a voltage divider, to scale the opamp output range (about +/- 10.5 V) to a bit less than +/- 5 V, which is the amplitude of the saw. It is a bit luxurious to use a separate summing opamp, but the advantage is that it nicely clips the CV signal. Note that R3 and R4 could be replaced by a single 150 kOhm resistor, but I did not have that at hand. Finally, the saw-tooth coming out of U1b is attenuated by R6, R7 and buffered by U2b. 

Triangle wave

The saw-to-triangle converter is a classic full-wave precision rectifier composed of U1c and U1d. U1c is a half-wave precision rectifier, acting as an inverter for the positive part of the input, and blocking the negative part. U1d then sums two times the inverted half-wave with one time the original sawtooth, creating a triangle. U1d also doubles the amplitude, and subtracts an offset (set by trimmer R18), such that the final saw-tooth output goes from +5V to -5V. I used 100k resistors (all 1%) in parallel and series to get 50k and 200k, respectively.

Of the few saw-to-triangle circuits I tried, this one worked by far the best, but it is not perfect and a small glitch is visible at one turning point of the triangle. The capacitor C3 forms a low-pass filter together with R15+R16, which helps to reduce the glitch. It has a very conservative cut-off frequency of 36 kHz, which is far above the audio range, but it still has some effect as the glitch propagates further in the circuit. C3 could be increased to 47 pF or 100 pF depending on taste.

Sine wave

The triangle-to-sine shaper uses the same JFet distortion circuit discussed in this LFO circuit. R19 is used to adjust the amplitude, and thus the shape of the sine wave. U2c buffers (and inverts) the signal, and again forms a 36 kHz low pass filter to reduce the glitch in the triangle. The output of the JFet circuit is amplified (and again inverted) by U2d, to roughly +/-5V amplitude. The final amplitude depends on the JFet used, and it may be needed to adjust R26 accordingly. U2d also forms again a 36 kHz low pass filter, and the final sine output is almost glitch-free.

Panel connections

The diagram below shows the connections between the front panel and the two modules (this one and the VCO core).

I created a fairly compact panel layout (8 HP), using multiple functions on the knobs. The "PWM" knob sets the pulse-width when no input is connected, and attenuates the PWM input otherwise. A second PWM input is available, since there was a free spot on the panel. Similarly, the "FM" knob acts as attenuverter for the FM input (switched between linear or exponential), but acts as a fine tune when no FM input is connected. These double functions sacrifice a bit of functionality in favor of compact size, so this is a matter of taste (in fact, I used a more spacious layout for a second VCO).

Panel layout (right) and separate core (bottom left) and waveshaping (top left) boards.

Trimming procedure

There are 4 trimmers in total, two on each board. 

The V/Oct trimmer (R11 on the core board) is independent of others. It is somewhat tricky to setup, I find the easiest is to use a keyboard/synth with CV out (or midi to CV converter), and listen to the VCO and the synth together, so one can tune by the beatnote. Best is to start with a rather high frequency, say 3 kHz. Here R11 should have almost no effect (check this). Tune the VCO with the frequency knob here, and then go to a few octaves lower, and tune again but now by adjusting R11. Iterating this a few times should get good tuning. Then check all octaves and make fine adjustments.

The waveshaping should be configured in order: 
  1. First, set R23 on the core board to have a symmetric saw wave around 0V. Then look at or listen to the triangle wave, and adjust R23 to minimize the glitch. This can be done fine by ear, just try to cancel high frequencies as much as possible.
  2. Next, adjust R18 on the waveshaping board to center the triangle output around 0V. If it was so far off that the triangle was clipping, go back to step 1 and adjust that again.
  3. Finally, listen to the sine output, and adjust R19 and R18 iteratively until you get the best sine wave. This can be done again by ear, minimizing overtones, or with a spectrum analyzer program such as this, minimizing the total harmonic distortion (THD) measurement. I got values below 1%.
  4. You might do another round of R23 (core board), R18, R19 to get even lower THD on the sine wave, but check that you like the triangle sound as well.


Below are the triangle and sine waveforms. They have quite small "glitching" on the top of the waveform. On this module I used C1 = 10pF, C2 = 10pF and omitted C3. However, I recommend using the values shown in the schematic above, as they will further reduce the glitch without affecting the audio signal. You can also see the sine wave has larger amplitude (vertical scale is about 2V/div on both plots), which I originally left as they sound with a similar perceived loudness. However, it would also make sense to reduce R27 to make the sine amplitude match the +/- 5V "standard" for eurorack VCOs (if you want exactly 5V, you have to adjust R27 for each module to compensate for the JFet tolerances).

The next figure is a spectrum of the sine wave. While it is not a perfect sine (especially in the logarithmic dB scale you see a lot of harmonics), it comes quite close for a waveshaping circuit. The second harmonic is more than 40 dB below the fundamental, which means its amplitude is more than 100 times smaller. The total harmonic distortion is 0.8%.

(The thick peaks around 4000 Hz and16000 Hz are extra noise in the measurement, unrelated to the VCO).