This voltage-controlled LFO is based on the PIC 16F684, which is a pretty basic chip. Nonetheless, this LFO has more features than your average LFO. For a start, it can produce 7 basic waveforms, and also includes a noise source. It can also morph its waveforms under CV control, well beyond basic PWM.
There is an optional sample-and-hold module that can sample whatever is selected, the current waveform or the noise source. The LFO frequency, waveform selection, waveform distortion, and S&H rate are all voltage-controlled using 0-5V. The overall output level is also voltage-controlled.
The chip uses the analogue inputs of the PIC for CVs. These are fed to the internal A/D convertor, which samples each input every 150uS or so and converts the voltage to an 8-bit value. In order to avoid using an external D/A convertor for the output, the chip uses the built-in PWM module. The PWM output needs passing through a lowpass filter to convert the pulses back into an analogue output.
Using an external crystal with the PIC allows the chip to run at its maximum clock speed of 20MHz, and this means that the PWM module is able to produce a 19.5KHz sample rate at 10-bit accuracy. I’ve tested the LFO by feeding the output into the filter modulation input of a SH101. No digital artifacts are audible on the straight-line waveforms (Ramps, Triangle, Square), but there is a slight stepping on the curved waveforms at the lowest frequencies. The SPIKE waveform is the worse case, since it has the steepest gradients. I’m considering adding interpolation to remove this slight problem.
Later note: I’ve gone back to the code and reduced this problem significantly by concentrating the lookup table on the steepest parts of the SPIKE waveform. Similar tricks have been applied on other waves too, and the errors have been reduced by 33% to 70%, with the best increase on the SPIKE wave.
The WAVE DISTORT CV input can produce phase distortion of the LFO output. The waveform is regarded as being in two sections, usually half the total length of the waveform. By reducing the time one of these sections takes whilst increasing the time the other takes, it is possible to distort the waveform without altering its pitch.
If you’d like to build one, or like to know how I built mine, perhaps you’d like to look at:
- Firmware Flowchart
- Voltage-controlled LFO PIC 16F684 ASM code
- Assembled HEX code from above file
- Circuit Diagram
- VCLFO datasheet (includes circuit diagram, example waveforms, and chip pinout)
By way of explanation of the flowchart, perhaps it is worth saying that the code consists of two main sections:- An interrupt routine that runs the LFO and noise source and ensures a constant output sample rate and frequency, and a main code loop that polls the various A/D channels (CV inputs) in turn and converts their values to something useful for the code. It’s also worth pointing out that I did the flowchart diagram before I added the WAVE DISTORT CV feature, so that doesn’t appear.
Update: Current Version 9D
The chip still had quite a few pins free, so I felt I could add some more features. A couple of things weren’t in the original version:
- The SYNC input that resets the LFO waveform or S&H back to the beginning.
- The WAVE DISTORT input to bend the LFO waves out of shape.
I’ve also reworked the PWM filter to use a two-stage 4th order Bessel filter. This improves the performance and reduces digital noise on the output. I hadn’t studied filters much before, and the existing design I chose to use originally was a Chebyshev filter which has a steeper rolloff, but not such good high frequency performance. For this application, the rolloff isn’t so important, but high frequency performance definitely is.