I had a bit of fun with this project. It uses the phase accumulator (DDS) idea. Instead of button (which would have required a display of some sort) I’m using an analog value to select the waveform. I’m using the 10bit resolution of the ADC to avoid bit manipulation and odd scaling (although you can right shift the phase_incr_lfo1 value to make it bigger and have a higher frequency) ( something as this : phase_incr_LFO1 = (ten_bit_result << 2) + 1;)
The 16 bits timer is used for the varying sampling rate and for incrementing the phase accumulator with the phase_incr. Originally I used the two 8 bit timers in PWM but the RC filters were annoying on high frequency (for a LFO).
Phase accumulators are quite a nice thing, here’s a video from Cornell’s Bruce Land :
I’m using a PCF8591P I2C DAC at the moment, good for the job but I’d like a dual DAC for two independent LFOs. The final project will contain a MCP4802 from microchip. I may also use one PWM to output some kind of random noise…
The code is just about messing around with the sampling rate of the timer1. It can go from (very) stupidly slow (some kind of 0.0001 seconde) to 80hz. This is scaled in three level (I don’t like having a pot to cover such large range) with a dual led. I’m using the internal 8Mhz clock. Maybe I’ll try to increase the range into the audio frequencies to use it as a lofi crappy Low VCO (but the digital crap will be massive, let alone the Nyquist theorem, unless you put a big filter after it…what you do in synth anyway…).
There’s another control called the “trash button” which reduce the bit resolution of the ouput, if you want to go 4bit into dirty land. Not very funny unless there’s a need for more stepped waveform. However it is nice to crap things up in the audio range ! (you’ll find an array of “bit_mask” but actually only the more destructive ones are interesting)
The code is here : https://github.com/ThebigDickhead/AVR_PROG/tree/master/LFO
I hope to work a bit more on it and add stuff as an attack/decay for both LFO, make something compact with lot of features in a small HP range. Of course, the output should be modified to suit the 10Vp-p standard. No schematic because the project is in progress (with million others…) and it’ll just be about additional op-amps and scaling trimers.
Now I really need to find a way to grow money … any ideas?