Tri 2 Sin

Magnus Danielson magnus at analogue.org
Wed Jun 10 01:14:37 CEST 1998


>>>>> "PP" == Paul Perry <pfperry at melbpc.org.au> writes:

 PP> I must say I am enjoying all this thread.. makes up for a lot..
 PP> now I am not a mathematician.. but I feel intuitively that there must
 PP> exist (where is that backwards E when I need it?) a circuit
 PP> based around one or 2 multipliers that would produce a sine from
 PP> a triangle by an approximation method using a polynomial expansion..
 PP> back in the days of analog computers and hardware shortages, plenty of
 PP> tricks like this existed.

Sure... you could do it that way, but that would be more expensive and
probably cause more distorsion...

Taking an idea just right out of my head playing around with a sawtooth
input (just for a change) you could derive an triangle and square
(this square is by necessity 90 degrees out of phase with the normal
square you get from a triangle...) I tested it with the following
Octave/Matlab code:

# Number of FFT frequency points including DC and fundamental
N = 100;
# Some preparations
N2 = N * 2;
N21 = N2 - 1;
N212 = N21/2;
a = 0:N21;
# This is the ramp or sawtooth input, normalized to be -1 to 1
ramp = (a - N212)/N212;
# This is our triangle waveshaper as being convenient in Octave code
tri = abs(ramp) * 2 - 1;
# This is our square waveshaper as being convenient in Octave code
sq = ramp./abs(ramp);
# This is the magic formula! The squarewave is used to change the sign.
sine = ((tri.*tri)-1).*sq;
# Here comes the THD measurement using FFT and some crued tricks.
f = abs(fft(sine));
f = f(1:N);
# RMS of overtones
sqf = f .* f;
#  Remove DC component
sqf(1) = 0;
#  Remove fundamental
sqf(2) = 0;
#  RMS of overtones
pov = sqrt(sum(sqf));
#  RMS of fundamental
pfu = f(2);
#  RMS of total
p = sqrt(pov**2 + pfu**2);
# Harmonic distorsion in %
THD = 100 * pov/p

This method gives a Total Harmonic Distorsion of 3.48%.

It is not neat, but you do it with one or possibly two multipliers.

The neat thing thought, is that the amplitude of the outgoing sine is 1.
With some care can the amplitude relation be kept in a real analog design.

This is at all achieved by using the propper approximations formulas
but rather buy taking the image of an square function and mapping it
around in the head. It can be done, but it will not be the neatest
hardware to get the wanted sine conversion...

If using the Taylor serie for sine you get

              3    5    7
             x    x    x
sin(x) = x - -- + -- - -- + ...
             3!   5!   7!

Making a very coarse cut in the series and taking just

              3
             x
sin(x) = x - --
             3!

We get a very rude sine:

# This is the magic formula! The squarewave is used to change the sign.
sine = tri - (tri.**3)/6;
# Here comes the THD measurement using FFT and some crued tricks.
f = abs(fft(sine));
f = f(1:N);
# RMS of overtones
sqf = f .* f;
#  Remove DC component
sqf(1) = 0;
#  Remove fundamental
sqf(2) = 0;
#  RMS of overtones
pov = sqrt(sum(sqf));
#  RMS of fundamental
pfu = f(2);
#  RMS of total
p = sqrt(pov**2 + pfu**2);
# Harmonic distorsion in %
THD = 100 * pov/p

The THD shows up to be 7.15%, not very optimal...

Now, while fooling around with the proportions of the third component
I found that dividing with 2.792 instead of 6 where much more optimal:

sine = tri - (tri.**3)/2.792;
f = abs(fft(sine));
f = f(1:N);
sqf = f .* f;
sqf(1) = 0;
sqf(2) = 0;
pov = sqrt(sum(sqf));
pfu = f(2);
p = sqrt(pov**2 + pfu**2);
THD = 100 * pov/p

This gives a THD of 0.52853% or there about... not too bad.

The cursuit that would be needed for this would include two
multipliers for which only one needs to be 4-quadrant and the other
may be 2-quadrant. One is used to get the x*x component and the other
gets takes this and x and generates the x*x*x component, then follows
a summing amp that takes the x and a dampend x*x*x to generate the
output sine. It could be wise to have the output level as well as the
dampend x*x*x component trimable in a (very) narrow range.

I know that there is more ways of achieving sine like effects like the
one mentioned in Burr-Brown's "The Handbook of Linear IC Applications"
but it will require some tricks to become usefull and I am right now a
little too tired to do them for you in Octave code...

Hope you are inspired by this...

Cheers,
Magnus




More information about the Synth-diy mailing list