<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi,
<p>I was working out how to generate a sine wave LFO in my MIDI2CV converter
without wasting loads of PIC CPU on floating point maths routines, and
I managed to work out the following simple algorithm (written in tcl -
great language for quickly trying out ideas):
<p>set dy 0
<br>set ddy 1
<p>set y 0
<br>set t 0
<br>while {$t <= 100} {
<br> incr y $dy
<br> incr dy $ddy
<br> if {$dy >= 10 || $dy <= -10} {
<br> set ddy [expr {0 - $ddy}]
<br> }
<p> set valueAtTimeT($t) $y
<br> incr t
<br>}
<p>This produces what _looks_ like a perfect sine wave (see gif below),
and it got me thinking about analog triangle to sine converters.
Basically the above algorithm increments "y" by the level of a triangle
wave ("dy" is following a triangle wave pattern, symmetrical about 0).
That is to say the gradient of a sine wave is a triangle wave about 0.
I'm not sure that this sounds totally right to me (although the result
looks like a sine) - I don't remember enough maths from school unfortunately.
<p>Now isn't the rate of voltage change (voltage gradient) across a capacitor
proportional to the current charging/discharging it? So a triangle
wave through a resistor, into a transistor-pair current mirror, charging/discharging
a capacitor would produce a perfect sine wave.
<p>Does this work? I can't remember ever seeing a triangle to sine
converter circuit like this.
<p>Just some ramblings of my brain ... ;-)
<p>Seb
<br>
<p><img SRC="cid:part1.3DA610ED.432086F0@is-uk.com" height=190 width=600></html>