## a quest to build a sine+cos LFO

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: Joe., luketeaford, lisa, Kent

slow_riot
Super Deluxe Wiggler
Posts: 4002
Joined: Tue Jun 30, 2009 8:58 pm
Location: uk
For better settling time/start up, diode clip the signal and feed this back positively into one of the integrators.

Similar technique as given above which uses the the zener diodes to seperate the highest and lowest excursions to stop the equation from saturating, but instead giving it a little boost when it is at it's lowest energy potential.

Works remarkably well.

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
ok, so i did a bit of reading, and heres what ive got:

- decay time = 4*RC/damping ratio
- so for oscillation (damping ratio = 0), decay time is infinite
- R6+R7 can only make it less stable (any resistance here less than infinity gives negative damping ratio, and increasing ampitudes)
- R8/R5 can only make it more stable (any value of R8/R5 greater than zero gives positive damping ratio, and decreasing amplitudes)
- it is the subtraction of these two feedbacks that gives a total damping ratio that can go positive or negative. so you fix one, and then subtract the other from it.
- the damping ratio for this circuit is (where R = R6+R7):

d = [R8/(R5+R8)]*[1+R1/(2*R)] - R1/(2*R)

- the starting damping ratio is for the circuit without the diodes present, which gives d = -0.044, which is pretty small.

the zener method that fitzgreyve showed is pretty good, as there is a sharp transition between no feedback and 1:1 feedback (although this does lend to some distortion). the 33k in that schematic should probably be going from the inverting pin to the first integrator output (R6+R7 in the other schematic). also, the no feedback (and therefore startup time) condition is set almost exclusively by the 33k.
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
thanks guys, but to me it all sounds like I ought to give up on sines and try out some triangle oscillators :(
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
ok, now that i have some equations, i can do some optimisation. the zener version looks like a whole lot of distortion, so i will focus on the diode version (which are easier to come by as well).

- the distortion is controlled by the ratio of R6 to R7, with larger R6 being less distortion.

- the initial ramp up time is controlled by R1/(R6+R7), with larger R6+R7 giving longer ramp up time. since R6+R7 effectively becomes larger as the amplitude increases due to the diodes, it doesnt follow the above equations. from simulation ive found it to be approximately 10*T*(R6+R7)/R1, where T is one period of oscillation. this assumes R8 is small compared to R5.

- the final amplitude is where R8/(R5+R8) is balanced out by the effective impedance of the diodes and R6 and R7. so you want a low R8/(R5+R8) to help with start up, but not so low so that the output ampitude needs to overdrive the diodes (causing distortion) to get the impedance of R6 to increase (it does this by decreasing the amplitude of the signal seen by R6, making the thevenin equivalent resistance bigger for a fixed voltage). so starting with R8/(R5+R8) < 1/10 is a good place.

at any rate, i found these values to be pretty good:

R6 = 2.2k
R7 = 10k
R8 = 2.2k
R5 = 33k

the distortion isnt too bad, and it warms up in 14 oscillator periods. granted, at 0.1Hz, this is still 2 minutes, but i dont think there is any escaping this without paying a heavy distortion penalty, or adding more components.
openmusiclabs.com

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
take a look at my most recent values, and see what you think. if 10 cycles seems too much, then sinewave shapers is probably the way to go, but that will be more components, probably 6 opamps and some logic ICs.

not to be blasphemous here, but a small microcontroller would be the least expensive and smallest footprint way to generate decent sinewaves, particularly for an LFO.
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
thanks for all the trouble, I'll try it out on a breadboard.

but how about that startup circuit that would quickly charge one or both of the capacitors at powerup? would that be possible without complicating the rest of the circuit?

btw when thinking about shaping a triangle, I planned to just use a LED softlimiter to slightly round-smooth the tip of the triangle like this: http://tinyurl.com/y4fd8oan
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
yes, you can add a pre-charge switch of some sort (could even be manual, and connect to all of the oscillators at once), but it wont change the settling time, it just changes the starting position. so it will still take a few minutes to settle down, but rather than having to ramp up from 0V, it will start at 4.5V (for example) and then take a few minutes to get to 5V.
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
that's pretty good, thanks!
only about a minute at this low frequency:

although the first output is a bit skewed (rise is faster than fall) but that's not a big deal
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
this is what happens when I manually apply 12V at the negative input of the third opamp (U2A) for a second at powerup (I tried to disconnect the 12v as soon as I plugged in the power)

it appears to settle pretty quickly, but I'd rather use some circuit that would apply the 12v for a fraction of second automatically than do it manually

spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
the settling time is exactly the same, it just starts at a higher voltage. in both graphs it takes around 5 cycles to settle. but, if you want to do that, connect the collector of a transistor to pin2 of U2A. then put the emitter to -Vee. now put a resistor from the base to -Vee (10k or 100k should be fine), and a capacitor from the base to +Vcc (0.1uF might be ok, but the bigger the longer the reset pulse). so now when it turns on, the voltage rails rising puts charge into the transistor for a bit, until the cap charges up and it shuts off.
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
thank you thank you thank you!!!
your starter works so well I could even change the resistor values to the originals

the starter resistor value needs to be tuned to the capacity of C1 and C2, for this test I found out 12kOhm is best for C1=C2=4uF (with 100nF starter cap, VR1A and VR1B = 1MOhm resulting in f = ~0.04Hz)

spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
I breadboarded the core of yusynth quadrature lfo (without the output buffers and invertors and without the exp CV input) and it also takes a while to reach full amplitude, but with the startup circuit hack it starts instantly at full amplitude and also seems slightly more reliable (with the previous circuit the startup was sometimes insufficient and sometimes it overshot).

I wonder how quickly does the doepfer A-143-9 start at the lowest frequency or even if it's built around a similar architecture

With 1uF caps and about 1uA into the amp bias inputs of the LM13700 I got around 0.01Hz (0.002Hz with ~0.1uA and 16.6 Hz with 1.9mA) - btw what's the max current I should use?

There's around +0.2v DC offset, could it be because I didn't pay much attention to the tolerances and matching of the components?
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
2mA is the listed absolute maximum for the LM13700, but i wouldnt run it above 1mA, as it really starts to degrade linearity. typically i like to run with 250uA or maybe 500uA as the top.

as for the offset, perhaps its a mismatch in the zeners?
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
thanks.

I tried swapping the zeners around, even combining different zeners (4.7 and 6.2) but it only affects the total peak to peak amplitude, not the offset.

deliberate mismatching of the caps only causes one of the outputs to be slightly weaker

I matched the 820 resistors to within 0.2%, didn't change anything

my PSU does seem to have a slight positive offset, but even when I added a small resistor and made the offset to be negative it didn't change the output sine offset

I also tried a different PSU and found out the starter circuit doesn't work with it, probably because it takes longer for the PSU to start than the starter hack needs. I'm wondering if the fourth unused opamp could be somehow used. The problem with the starting hack is that when the resistor or the capacitor has a slightly higher value and it's allowed to work for too long, the resulting charging voltage is too high and the output oscillations initially have a higher amplitude than needed and it takes a while to settle, so maybe if the final initial charging voltage could be precisely regulated, it wouldn't be so sensitive to the amount of time the oscillator cap is exposed to the starter charging

maybe if it still worked as a state variable filter it could be started by using some simple oscillator (based on the fourth unused op amp) as input into the filter
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

slow_riot
Super Deluxe Wiggler
Posts: 4002
Joined: Tue Jun 30, 2009 8:58 pm
Location: uk
I think the state variable is the most important analog configuration, it's like the proton or DNA - i.e. the ultimate mathematical building block, it's just a shame it's so parts heavy and sensitive.

The triangle VCO has the amplitude stabilized by the comparator, or whatever you use to clamp it at least, and is much easier to work with, but it has more limited uses and forces your hand with how you use it. The SVF can be expanded enormously, into solving complex partial differential equations that would tie up even the most overspecced DSP chip.

Suggestions:

I wouldn't worry about the PSU at this stage. Opamps are quite tolerant to a wide variety of PSU conditions, and anything that does care should be subregulated.

I would get the basic RC constants as close to ideal as possible. That means matching the caps, resistors in both the integrators, the in the inverter (this only needs to match to itself so the gain is as close -1.0000 as possible)

What opamps are you using? Because of the successive integration stages offset tends to accumulate in the SVF. You certainly need to use JFET input types for the integrators. As a last resort you can AC couple it out, e.g. that's what X7 is doing here:

https://aethermachine.files.wordpress.c ... gain51.png

I've never tried a dual pot, so I'm not familiar with how the mismatch between tapers effects things.

It's a big leap in the state of the art, but I saw this oscillator topology recently, which is a more simple implementation of the kind found in the HP8903 distortion analyzer, where the peak of the sine is sampled at the zero crossing of the cosine, and this is use to determine the amplitude per cycle.

http://mike-wsm.org.uk/ldo.html

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
tl074

I'll try to swap it in case it's defective or use tl084 if I have one

but more than the 0.5v dc offset I'd much rather solve the slow starting. The starter transistor hack looked promising, but it's too sensitive to other conditions to work reliably
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
you can try putting an offset trimmer on one of the opamps, that should allow you to null out any offset in the circuit. to get everything right, you might need 2 trimmers, as you have 2 outputs.
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
OK I don't know what I'm doing, so be merciful with me but I came up with this abomination:

First, the problem is that trying to charge that capacitor by applying voltage to the opamp negative input causes the opamp to extremely rapidly rise the output voltage, so it's very easy to overshoot the desired target amplitude when some conditions are just slightly different from when the charging circuit was calibrated and then it takes a long time to settle down to the stable amplitude.

So what if I used the fourth remaining unused opamp as a comparator to detect when the output amplitude is close enough to my desired target and use the comparator output to turn off the charging circuit - like this:
import https://www.dropbox.com/s/9qy7cqmx7ldiw ... k.txt?dl=0 into http://www.falstad.com/circuit/circuitjs.html (File > import from dropbox)

In this simulation this takes about <5us

I'll find out whether this works in practice too later today. Even if this works I'm sure there is a better way... but I don't know any better
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
I definitely deprecated the comparator idea because in the span of those couple of hundreds of nanoseconds from powerup it would have to work the power is still too unstable for it to work reliably. Instead I increase the amp bias input current for the OTA for a couple of seconds which increases the oscillation frequency and stabilizes the output amplitude quickly.

Also I noticed that when applying just a tiny current to the OTA's diode bias input (on the order of ~30uA) the resulting waveform looks significantly more sine-like instead of triangle-like (I haven't done any exact measurements yet, just looking at the waveforms on a scope) (it also slightly lowers the frequency even further).

However I have really no idea what I'm doing here and the LM13700 datasheet says "the differential input voltage must be <60mVpp when the linearizing diodes are used", but in this (yusynth quad lfo) application the voltage swing is at least 16Vpp, I wonder if it will be a problem... EDIT: wait according to the falstad simulation the difference between +and- inputs of the OTA is 57mV max

I don't need a perfect sine anyway for my very slow LFO, I just don't want a SIN+COS output (creating a 45degree phase shift) to be a significantly different waveform than the SIN and COS outputs (it looked like a fat sine without the linearizing) I'll post some screenshots later
Last edited by charonme on Tue Mar 26, 2019 4:22 am, edited 1 time in total.
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
this is how the startup looks like (purple is one of the SIN or COS outputs, yellow is SIN+COS inverted)

low frequency with linearizing (constant 30uA current):

without:

high frequency with linearizing:

without:
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
the linearizing diodes seem to help a lot. its looking pretty good.
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
there might be some imperfections of the breadboard and jumpwires at play here, because on different days it acts slightly different (eg yesterday the positive top part looked more spiky than the negative bottom part) and today after trying a higher linearizing current one of the outputs suddenly has higher amplitude on the positive (top) part (looks almost like a positive dc offset) (regardless of the linearization)
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO

guest
Super Deluxe Wiggler
Posts: 4489
Joined: Mon Aug 19, 2013 11:49 am
could be temperature effects in the clamping circuit or startup circiut. once its going, you could remove the startup transistors, and see if it changes anything (if its on a breadboard).
openmusiclabs.com

charonme
Wiggling with Experience
Posts: 327
Joined: Tue Mar 11, 2014 3:35 am
Location: BA, Slovakia (EU)
well the breadboard I used is definitely defective, I discovered one part when pushed from the bottom was messing with the circuit so I reorganized that part and now it's more stable.

Also I realized an XY plot is much better at visualising the OTA linearization difference (I upped the linearization to about 0.1mA and reduced R13 and R18 to 68kOhms to keep the frequency range to 6Hz-23minutes)

inputs phase shifted by 90deg from each other (SIN and COS)

without linearization:

inputs phase shifted by 45deg from each other (SIN and SIN+COS)

without linearization:

btw I don't know why the plot is a discontinuous patch of blotches instead of a nice thin line. I tried different scope settings with no luck
spotify, bandcamp
Heptaphasis - DIY 3HP 7-phase quadrature sine LFO