Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Digital sine wave generation

13 views
Skip to first unread message

Tim Shoppa

unread,
Mar 30, 2006, 1:54:24 PM3/30/06
to
While my obsession is still digital sine wave generation, I'd like to
note that the resistor values in AOE 2nd Ed, 9.38, for the twisted-ring
counter weighting resistors are not the best values to choose in the
E96 series. They're not bad but not the best.

If someone wants to check, I think Lancaster's _CMOS Cookbook_ has the
same resistor values as AOE. Can't find my copy of Lancaster's book at
this moment.

What is in AOE is:

Q1: 57.6K
Q2: 30.9K
Q3: 23.7K
Q4: 22.1K
Q5: 23.7K
Q6: 30.9K
Q7: 57.6K

My search has shown that you get 80% less sum-of-squares error if you
instead use these standard E96 values:

Q1: 30.1K
Q2: 16.2K
Q3: 12.4K
Q4: 11.5K
Q5: 12.4K
Q6: 16.2K
Q7: 30.1K

The matching with these values makes it worthwhile to use 0.1% or even
better resistors (which are actually affordable and available these
days!)

It appears to me that a generic 74HC595 output has an output impedance
of 40 or 50 ohms at room temperature and currents under 1mA and 5V Vcc,
and at these impedances it is actually very slightly better to use the
11.5K-12.4K-16.2K-30.1K range rather than the ten-times-higher
115K-124K-162K-301K.

Tim.

bill....@ieee.org

unread,
Mar 30, 2006, 5:11:00 PM3/30/06
to

I think that you are about to find about Gibbs oscillations. If your
values are sine x/x (sinc) you are going to find that you want to
applying a Hamming raised cosine window (which it looks as if Win and
Don have done) to eliminate the ringing in the frequency response that
you get by truncating the shift register (Gibbs oscillations).

http://www.daqarta.com/EEX06.HTM

--
Bill Sloman, Nijmegen

Tim Shoppa

unread,
Mar 30, 2006, 9:27:20 PM3/30/06
to
bill....@ieee.org wrote:

> Tim Shoppa wrote:
> I think that you are about to find about Gibbs oscillations. If your
> values are sine x/x (sinc) you are going to find that you want to
> applying a Hamming raised cosine window (which it looks as if Win and
> Don have done) to eliminate the ringing in the frequency response that
> you get by truncating the shift register (Gibbs oscillations).
>
> http://www.daqarta.com/EEX06.HTM

I don't think that's what I'm writing about Bill. The synthesizer in
question uses those 7 resistors (4 different values, really very
clever) to synthesize a 16-step approximation to a sin wave. The values
synthesized are "just" sin(pi/16),sin(3*pi/16), etc. The shift register
runs at exactly 16 times the resulting sine wave frequency.

sinc(x) comes in when you're windowing and the sampling rate is not a
simple harmonic of the signal, right? Interesting stuff but not
relevant to my much simpler application.

Tim.

bill....@ieee.org

unread,
Mar 31, 2006, 3:53:42 AM3/31/06
to

You are running a square wave through a shift register, and using the
resistors to set up the coefficients for an FIR low pass filter. That's
exactly what I was doing (in another context) and I spent a long time
recalculating all the resistors and soldering in the new set.
Beleive me (and Win Hill and Don Lancaster), it is relevant to your
application.

--
Bill Sloman, Nijmegen

Tim Shoppa

unread,
Mar 31, 2006, 7:57:21 AM3/31/06
to
bill....@ieee.org wrote:
> You are running a square wave through a shift register, and using the
> resistors to set up the coefficients for an FIR low pass filter. That's
> exactly what I was doing (in another context) and I spent a long time
> recalculating all the resistors and soldering in the new set.
> Beleive me (and Win Hill and Don Lancaster), it is relevant to your
> application.

OK, Bill, this is what I'm saying: to synthesize a sine wave with 16
steps, choose the values so that what comes out is sin(phase) for 16
equally spaced phases from 0 to 2pi. This is exactly the way the
resistors were chosen in AOE. I'm only saying that I chose some E96
resistors that implement this a factor of five better (in terms of
mean-square error) than the set in AOE. The ratios are all the same to
within a percent, it's just that my proposed set is better at achieving
the ideal voltage ratios.

Tell me how this is different than what's in AOE 9.38? Or the approach
of any other DDS sine wave synthesizer?

And then tell me how what you do is better. Are your first 14 harmonics
zero? Or are you spreading out the badness so that some harmonics below
the 14th are nonzero, but such that your synth plus low-pass filter
combo is more effective at reducing THD in the end because your higher
harmonics have been chosen to be lower?

Tim.

bill....@ieee.org

unread,
Apr 1, 2006, 11:16:47 AM4/1/06
to

Good question. Since I was filtering psuedo-random noise back in 1977,
it is going to be difficult to answer this question. From what I can
recall, the truncated sinc sequence gave a sharper low frequency
cut-off (with some ringing) followed by a rather poor and oscillating
cut-off at higher freqencies, while the raised-cosine windowed sequence
did not cut off as sharply at low frequencies, but gave a pretty much
monotonically increasing cut-off with increasing frequency.

If you only want to synthesise a narrow range of sine wave frequencies,
the amplitude of the high frequency harmonics isn't too important - you
can always filter them out with a low pass filter. IIRR, my circuit did
relay on a Sallen and Keys two-pole to get rid of the last of the high
freqncy junk, with switchable capacitors to handle decade changes in
frequency range, but I had to change the resistor values to get the
customer happy.

--
Bill Sloman, Nijmegen

Tim Shoppa

unread,
Apr 2, 2006, 9:54:50 AM4/2/06
to
bill....@ieee.org wrote:
> Tim Shoppa wrote:
> > OK, Bill, this is what I'm saying: to synthesize a sine wave with 16
> > steps, choose the values so that what comes out is sin(phase) for 16
> > equally spaced phases from 0 to 2pi...
> > [...]

> > And then tell me how what you do is better. Are your first 14 harmonics
> > zero? Or are you spreading out the badness so that some harmonics below
> > the 14th are nonzero, but such that your synth plus low-pass filter
> > combo is more effective at reducing THD in the end because your higher
> > harmonics have been chosen to be lower?
>
> Good question. Since I was filtering psuedo-random noise back in 1977,
> it is going to be difficult to answer this question. From what I can
> recall, the truncated sinc sequence gave a sharper low frequency
> cut-off (with some ringing) followed by a rather poor and oscillating
> cut-off at higher freqencies, while the raised-cosine windowed sequence
> did not cut off as sharply at low frequencies, but gave a pretty much
> monotonically increasing cut-off with increasing frequency.
>
> If you only want to synthesise a narrow range of sine wave frequencies,
> the amplitude of the high frequency harmonics isn't too important - you
> can always filter them out with a low pass filter.

Bill -

I've come to the conclusion that you are solving a different problem
(bandpass of a noisy signal) than the one I'm obsessed with
(synthesizing a sine wave where the clock is an exact multiple of the
output frequency).

Nothing against what you did, I'm sure it was interesting, and it is
related in an abstract way to what I'm doing (your parallel with FIR
filters has some relevance in a sort-of upside down way, because I'm
starting out with a digital clock that has no noise beyond jitter in
the 10-20 ns range).

But what I'm doing is hoplelessly more simplistic. JUST choosing
optimal E96 resistor values to give good approximations for sin(phase)
for equally spaced steps.

Tim.

Mochuelo

unread,
Apr 2, 2006, 11:23:05 AM4/2/06
to
On 30 Mar 2006 18:27:20 -0800, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>bill....@ieee.org wrote:
>> Tim Shoppa wrote:
>> I think that you are about to find about Gibbs oscillations. If your
>> values are sine x/x (sinc) you are going to find that you want to
>> applying a Hamming raised cosine window (which it looks as if Win and
>> Don have done) to eliminate the ringing in the frequency response that
>> you get by truncating the shift register (Gibbs oscillations).
>>
>> http://www.daqarta.com/EEX06.HTM
>
>I don't think that's what I'm writing about Bill. The synthesizer in
>question uses those 7 resistors (4 different values, really very
>clever) to synthesize a 16-step approximation to a sin wave. The values
>synthesized are "just" sin(pi/16),sin(3*pi/16), etc. The shift register
>runs at exactly 16 times the resulting sine wave frequency.

I understand, and sounds interesting. How do you connect the 7
resistors to distinguish 16 different phase instants? What is AOE?

Best,

Michael A. Terrell

unread,
Apr 2, 2006, 11:29:51 AM4/2/06
to
Mochuelo wrote:
>
> What is AOE?


A book that is mentioned quite often in this newsgroup.


--
Service to my country? Been there, Done that, and I've got my DD214 to
prove it.
Member of DAV #85.

Michael A. Terrell
Central Florida

The Phantom

unread,
Apr 2, 2006, 12:22:01 PM4/2/06
to
On 2 Apr 2006 06:54:50 -0700, "Tim Shoppa" <sho...@trailing-edge.com> wrote:


>Bill -
>
>I've come to the conclusion that you are solving a different problem
>(bandpass of a noisy signal) than the one I'm obsessed with
>(synthesizing a sine wave where the clock is an exact multiple of the
>output frequency).
>
>Nothing against what you did, I'm sure it was interesting, and it is
>related in an abstract way to what I'm doing (your parallel with FIR
>filters has some relevance in a sort-of upside down way, because I'm
>starting out with a digital clock that has no noise beyond jitter in
>the 10-20 ns range).
>
>But what I'm doing is hoplelessly more simplistic. JUST choosing
>optimal E96 resistor values to give good approximations for sin(phase)
>for equally spaced steps.
>
>Tim.

Could you post a schematic showing how the resistors are connected to the
digital IC over on ABSE?

bill....@ieee.org

unread,
Apr 2, 2006, 1:01:01 PM4/2/06
to

The Art of Electronics by Horowitz and (Win) Hill. ISBN: 0521370957. It
is on special at Amazon at the momnent fpr $70 new, and from $45 used -
there are five used copies on offer, and a bunch of sellers offering
new copies from $62.

Originally written as a tesxtbook for training physicists at Harvard in
electronics, so aimed at the brigher student. Cambridge University in
the U.K. used it as an undergraduate test for their electronic
engineers.

--
Bill Sloman, Nijmegen

bill....@ieee.org

unread,
Apr 2, 2006, 1:21:14 PM4/2/06
to

Right, but what you are doing is producing a staircase apprixiation to
a sine wave.

If you take the staircase that you are going to synthesise, and do a
Fourier analysis on it, you will find - as you intend - a large
component at 1/16th of your clock frequency, very small components at
the first few harmonics of that frequency - due to the tolerances on
your resistors, and the limitations of working within the E96 grid,
followed by quite large harmonics at the clock frequency and its
harmonics.

You cna understand this intuitively by subtracting your desired sine
wave from your staircase approximation, which leaves you with a series
of sawteeth, whose amplitude is at a maximum around 0 and 180 degrees,
and whose polarity reverses from 0 to 180 degrees.

At present you are tinker with the staircase to minimise the harmonics
below the clock frequency. You can equally tinker to minimise the
harmonics above the clock frequency.

If your clock frequency is stable and never gets changed, then a fancy
multipole filter is the better way of getting rid of the higner
harmonics,

Even better is to use an integrator to synthesise the sine wave as
series of straight lines of variable slope - though the amplitude then
depends on the value of your integrating capacitor, and you might need
a precision rectifier and feedback loop to get an absolutely stable
amplitude over temperature.

--
Bill Sloman, Nijmegen

Ken Smith

unread,
Apr 2, 2006, 1:23:59 PM4/2/06
to
In article <esqv22t4oss42ef76...@4ax.com>,
Mochuelo <cucafera@RE_MO_VE_THIStelefonica.net> wrote:
[...]

>I understand, and sounds interesting. How do you connect the 7
>resistors to distinguish 16 different phase instants?

I'm not sure what he did but here's how I did it for less states:

You make a "shift register" that does this:


State Bits
0 0 0 0 <----
1 1 0 0 !
2 0 1 0 !
3 0 1 1 !
4 1 1 1 Repeats
5 0 1 1 !
6 0 1 0 !
7 1 0 0 !
8 0 0 0 ---->

Obviously, there is at least one bit hidden inside this part. In this
circuit, you only need 3 resistors to get 8 points on the curve.

If you want to use a switched capacitor filter to smoothen it out, a tap a
few more up the chain will give the clock for it. The nice thing about
that is that when you slew the clock speed, the internal time constants
move with it and the node voltages are uneffected. The result is that it
doesn't generate the low frequencies.

--
--
kens...@rahul.net forging knowledge

Don Lancaster

unread,
Apr 2, 2006, 2:11:28 PM4/2/06
to
http://www.tinaja.com/glib/msintro1.pdf

--
Many thanks,

Don Lancaster voice phone: (928)428-4073
Synergetics 3860 West First Street Box 809 Thatcher, AZ 85552
rss: http://www.tinaja.com/whtnu.xml email: d...@tinaja.com

Please visit my GURU's LAIR web site at http://www.tinaja.com

bogax

unread,
Apr 2, 2006, 2:39:09 PM4/2/06
to

The Phantom wrote:

> Could you post a schematic showing how the resistors are connected to the
> digital IC over on ABSE?

http://www.scitech.pwp.blueyonder.co.uk/Digital-Sine-Wave-Generatio.gif

http://www.intersil.com/data/an/an9780.pdf

bogax

unread,
Apr 2, 2006, 2:50:23 PM4/2/06
to
Don Lancaster wrote:

> http://www.tinaja.com/glib/msintro1.pdf

Jeezus-Dammit that's ugly!

Is it supposed to look like a power point slide show?

(you usually do better)

Mochuelo

unread,
Apr 3, 2006, 6:40:28 AM4/3/06
to
On 30 Mar 2006 10:54:24 -0800, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>While my obsession is still digital sine wave generation, I'd like to


>note that the resistor values in AOE 2nd Ed, 9.38, for the twisted-ring
>counter weighting resistors are not the best values to choose in the
>E96 series. They're not bad but not the best.
>
>If someone wants to check, I think Lancaster's _CMOS Cookbook_ has the
>same resistor values as AOE. Can't find my copy of Lancaster's book at
>this moment.
>
>What is in AOE is:
>
>Q1: 57.6K
>Q2: 30.9K
>Q3: 23.7K
>Q4: 22.1K
>Q5: 23.7K
>Q6: 30.9K
>Q7: 57.6K
>
>My search has shown that you get 80% less sum-of-squares error if you
>instead use these standard E96 values:
>
>Q1: 30.1K
>Q2: 16.2K
>Q3: 12.4K
>Q4: 11.5K
>Q5: 12.4K
>Q6: 16.2K
>Q7: 30.1K

Ok, I know which circuit you mean. When you talk about sum-of-squares
error, you mean between the staircase and the sinusoid? If that's the
case, that is not a good criterium. You should look at the spectrum of
the staircase signal. If you have Matlab (or equivalent), you can
compute the fft of your signal and see which resistor values give you
the lowest THD, for instance. You can easily include the effect of the
resistor tolerances to see if the circuit will be viable or not. The
effect of the output impedance of the shift register stages is more
difficult to be taken into account because the resistance is not
constant. I would clock manually the circuit, measure the output
voltage with a good DMM, solve a system of equations, and find the set
of resistor values that more or less "calibrate" the circuit.

But I don't like very much this structure. Using pairs of resistors
that should have matching values (but in fact will never have) is not
the most "compact" way of doing this.

Best,

The Phantom

unread,
Apr 3, 2006, 10:08:22 PM4/3/06
to
On 30 Mar 2006 10:54:24 -0800, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>While my obsession is still digital sine wave generation, I'd like to


>note that the resistor values in AOE 2nd Ed, 9.38, for the twisted-ring
>counter weighting resistors are not the best values to choose in the
>E96 series. They're not bad but not the best.
>
>If someone wants to check, I think Lancaster's _CMOS Cookbook_ has the
>same resistor values as AOE. Can't find my copy of Lancaster's book at
>this moment.
>
>What is in AOE is:
>
>Q1: 57.6K
>Q2: 30.9K
>Q3: 23.7K
>Q4: 22.1K
>Q5: 23.7K
>Q6: 30.9K
>Q7: 57.6K
>
>My search has shown that you get 80% less sum-of-squares error if you
>instead use these standard E96 values:

What voltage levels did you determine give the best approximation to the
sine wave?

The Phantom

unread,
Apr 4, 2006, 3:05:59 AM4/4/06
to
On 30 Mar 2006 10:54:24 -0800, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>While my obsession is still digital sine wave generation, I'd like to


>note that the resistor values in AOE 2nd Ed, 9.38, for the twisted-ring
>counter weighting resistors are not the best values to choose in the
>E96 series. They're not bad but not the best.
>
>If someone wants to check, I think Lancaster's _CMOS Cookbook_ has the
>same resistor values as AOE. Can't find my copy of Lancaster's book at
>this moment.

I analyzed the problem with some assumptions. I assumed the counter was
some kind of logic like CMOS that can swing the outputs rail to ground with
zero output impedance (I didn't consider the 40 or 50 ohms you mention
below). To do the mathematical analysis I assumed the rail voltage was 2
volts, so that the output sine wave's most negative voltage was zero, and
the most positive voltage was 2 volts. In other words, a standard
mathematical sine wave with a 1 volt offset. I assumed 16 steps. I
computed the sum-of-squares error with only half of the sine wave
(Sin[t]+1), namely, that portion from t=-pi/2 to t=pi/2. The
sum-of-squares error was computed by integrating from the left edge of each
step to the right edge and doing this for all 8 steps of the half sine
wave, then adding the 8 results. The integrand was (Sin[t]+1-Vn)^2, where
Vn was the output voltage of the circuit for the steps starting at t=-pi/2,
n=1 to 8.

>
>What is in AOE is:
>
>Q1: 57.6K
>Q2: 30.9K
>Q3: 23.7K
>Q4: 22.1K
>Q5: 23.7K
>Q6: 30.9K
>Q7: 57.6K

For this set of resistors, I got a sum-of-squares error of .0211462.

>
>My search has shown that you get 80% less sum-of-squares error if you
>instead use these standard E96 values:
>
>Q1: 30.1K
>Q2: 16.2K
>Q3: 12.4K
>Q4: 11.5K
>Q5: 12.4K
>Q6: 16.2K
>Q7: 30.1K

For this set of resistors, I got a sum-of-squares error of .0211649,
slightly larger than the previous set.

>
>The matching with these values makes it worthwhile to use 0.1% or even
>better resistors (which are actually affordable and available these
>days!)
>
>It appears to me that a generic 74HC595 output has an output impedance
>of 40 or 50 ohms at room temperature and currents under 1mA and 5V Vcc,
>and at these impedances it is actually very slightly better to use the
>11.5K-12.4K-16.2K-30.1K range rather than the ten-times-higher
>115K-124K-162K-301K.
>
>Tim.

I found that the minimum sum-of-squares error that this circuit with the
7 resistors can give is .0205938. If I use the following standard value
resistors, the error is .0205970:

Q1: 57.6K
Q2: 36.5K
Q3: 28.0K
Q4: 26.1K
Q5: 28.0K
Q6: 36.5K
Q7: 57.6K

I also found that if one selects for the desired output voltages the
value of (Sin[t]+1) at the time midpoints of the steps, the sum-of-squares
error is .0206273.

There is a subtlety that leads to a small error when comparing all these
values. Each stepped approximation should be normalized by dividing by the
magnitude of the fundamental component in the given stepped approximation
before computing the sum-of-squares error, but I didn't do this (yet; I may
later, but the error isn't large).

With this much number crunching involved it's easy to make a mistake, but
these are the results I got with a reasonable amount of care.

Once you pass this stepped sine wave through almost any kind of low-pass
filter I suspect the result from these various cases will be
indistinguishable in terms of waveshape purity.

The Phantom

unread,
Apr 4, 2006, 10:37:37 PM4/4/06
to

As far as I know, minimizing sum-of-squares gives the same result as
minimizing THD.

Mochuelo

unread,
Apr 4, 2006, 11:59:59 PM4/4/06
to
On Tue, 04 Apr 2006 19:37:37 -0700, The Phantom <pha...@aol.com>
wrote:

>On Mon, 03 Apr 2006 12:40:28 +0200, Mochuelo
><cucafera@RE_MO_VE_THIStelefonica.net> wrote:
>>Ok, I know which circuit you mean. When you talk about sum-of-squares
>>error, you mean between the staircase and the sinusoid? If that's the
>>case, that is not a good criterium. You should look at the spectrum of
>>the staircase signal. If you have Matlab (or equivalent), you can
>>compute the fft of your signal and see which resistor values give you
>>the lowest THD, for instance.
>
> As far as I know, minimizing sum-of-squares gives the same result as
>minimizing THD.


If the minimization processis such that you can make the error as
small as you want, yes. Otherwise, not necessarily.

We are clearly in the latter case, since our delta t is fixed
(period/16) and we are choosing resistors from a set of standard
values.

In cases like this one, you may find that the set of resistors that
minimizes the THD is not the same as the set of resistors that
minimizes the sum of squared errors. Since the good criterium is
spectrum based, it doesn't make much sense wasting effort doing LSE.
LSE can provide a good starting point to be used in an iterative
algorithm that minimizes harmonic contents.

Best,

Tim Shoppa

unread,
Apr 5, 2006, 6:19:40 AM4/5/06
to

If you get the LSE "perfect" with the 16-step/7-resistor design, then
the first fourteen harmonics are ZERO.

Higher harmonics are NON-ZERO, actually pretty large, and (as long as
you're limiting yourself to 7 resistors and equal-spaced steps and want
the first 14 harmonics to be zero) you have NO CONTROL of them
because... you've only got 16 fixed-spacing steps!

Any real analysis has to include the effect of the low-pass filter that
follows our primitive DDS. My decoupling (saying "first we get rid of
the first 14 harmonics in synthesis to make the work of the low-pass
filter easier") may indeed be primitive and not a good decoupling.

If you have any reference to real designs or published literature that
do DDS-like (e.g. equally spaced steps) or other numerically-controlled
oscillator sine-wave synthesis and do NOT simply choose sin(phase) for
equal phase spacing, I'm very interested. DDS has become very popular
over the past decade or so but none of the published designs or chips
I've seen use anything but sin(phase) for equally-spaced phase in their
lookup table.

I'm not completely disinterested in designs that use diode-limiting on
triangle waves (you will note that these often do use non-equal spaced
steps) but I'm convinced that I'm already doing better than all of
those. I'm also convinced that I do much better than
8038's/XR-2206's/etc (which are essentially "slope and trip-point
synthesizers")

Don's "Magic Sine Waves" seem interesting but there's a lot more steps
going on in his PWM than his accounting says there are :-). And I'm
working with fairly conventional microprocessors and logic so his
methods run out of steam real quick above a kHz or so (whereas the
16-step-7-resistor thingy is good to several MHz, a place that magic
sine waves will not go).

Tim.

The Phantom

unread,
Apr 5, 2006, 9:10:55 AM4/5/06
to
On 5 Apr 2006 03:19:40 -0700, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>Mochuelo wrote:

The SW4024 family of inverters made by Xantrex
http://www.xantrex.com/web/id/45/p/1/pt/18/product.asp
generates a waveform that is a stepped sine approximation. The amplitude
of the steps varies with load, so the timing and number of steps is varied
to keep the complete waveform approximately 120 VAC. The way the THD
varies with the number of steps is surprising.

Tim Shoppa

unread,
Apr 5, 2006, 11:06:00 AM4/5/06
to

The Phantom wrote:
> >If you have any reference to real designs or published literature that
> >do DDS-like (e.g. equally spaced steps) or other numerically-controlled
> >oscillator sine-wave synthesis and do NOT simply choose sin(phase) for
> >equal phase spacing, I'm very interested. DDS has become very popular
> >over the past decade or so but none of the published designs or chips
> >I've seen use anything but sin(phase) for equally-spaced phase in their
> >lookup table.
>
> The SW4024 family of inverters made by Xantrex
> http://www.xantrex.com/web/id/45/p/1/pt/18/product.asp
> generates a waveform that is a stepped sine approximation. The amplitude
> of the steps varies with load, so the timing and number of steps is varied
> to keep the complete waveform approximately 120 VAC. The way the THD
> varies with the number of steps is surprising.

Maybe I should've written "that do sine wave synthesis and do a good
job" :-). Admittedly their load is a lot more reactive than mine...

I'm surprised at their published waveform, too. With those big pips at
the top and bottom of each sine wave, it's looking more like a triangle
than a sine! By my calculation that amplitude of that pip should be a
percent or two, and it's looking more like 15 percent in their
published curve!

In that respect it looks a little bit like the distortion that comes
out of an 8038 etc. (although I know that uses an entirely different
method.)

Tim.

The Phantom

unread,
Apr 5, 2006, 12:00:13 PM4/5/06
to
On 5 Apr 2006 08:06:00 -0700, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>


>The Phantom wrote:
>> >If you have any reference to real designs or published literature that
>> >do DDS-like (e.g. equally spaced steps) or other numerically-controlled
>> >oscillator sine-wave synthesis and do NOT simply choose sin(phase) for
>> >equal phase spacing, I'm very interested. DDS has become very popular
>> >over the past decade or so but none of the published designs or chips
>> >I've seen use anything but sin(phase) for equally-spaced phase in their
>> >lookup table.
>>
>> The SW4024 family of inverters made by Xantrex
>> http://www.xantrex.com/web/id/45/p/1/pt/18/product.asp
>> generates a waveform that is a stepped sine approximation. The amplitude
>> of the steps varies with load, so the timing and number of steps is varied
>> to keep the complete waveform approximately 120 VAC. The way the THD
>> varies with the number of steps is surprising.
>
>Maybe I should've written "that do sine wave synthesis and do a good
>job" :-). Admittedly their load is a lot more reactive than mine...
>
>I'm surprised at their published waveform, too. With those big pips at
>the top and bottom of each sine wave, it's looking more like a triangle
>than a sine! By my calculation that amplitude of that pip should be a
>percent or two, and it's looking more like 15 percent in their
>published curve!

Where did you find the waveforms (URL)?

Tim Shoppa

unread,
Apr 5, 2006, 12:53:19 PM4/5/06
to

Figure 18 in http://www.xantrex.com/web/id/602/docserve.asp

The little bippy peak on top might be there to satisfy some specific
class of load. I am not an AC inverter guru but my understanding is
that certain loads only care about a couple aspects of the input
waveform and not all.

Tim.

Mochuelo

unread,
Apr 5, 2006, 1:06:09 PM4/5/06
to
On 5 Apr 2006 03:19:40 -0700, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>Mochuelo wrote:
>> If the minimization processis such that you can make the error as
>> small as you want, yes. Otherwise, not necessarily.
>>
>> We are clearly in the latter case, since our delta t is fixed
>> (period/16) and we are choosing resistors from a set of standard
>> values.
>>
>> In cases like this one, you may find that the set of resistors that
>> minimizes the THD is not the same as the set of resistors that
>> minimizes the sum of squared errors. Since the good criterium is
>> spectrum based, it doesn't make much sense wasting effort doing LSE.
>> LSE can provide a good starting point to be used in an iterative
>> algorithm that minimizes harmonic contents.
>
>If you get the LSE "perfect" with the 16-step/7-resistor design, then
>the first fourteen harmonics are ZERO.

The even harmonics are of course zero, by construction, but the odd
ones are not, unless you call "8*10^-4" zero (and having assigned the
value "1" to the fundamental).

With the AOE values {57.6 30.9 23.7 22.1 23.7 30.9 57.6}:
harmonic[ 0] : 0.0000000000 (-234.4 dB)
harmonic[ 1] : 1.0000000000 ( 0.0 dB) Fundamental
harmonic[ 2] : 0.0000000000 (-319.7 dB)
harmonic[ 3] : 0.0005555000 ( -65.1 dB) <-- not zero
harmonic[ 4] : 0.0000000000 (-335.2 dB)
harmonic[ 5] : 0.0008047148 ( -61.9 dB) <-- not zero
harmonic[ 6] : 0.0000000000 (-344.6 dB)
harmonic[ 7] : 0.0001848441 ( -74.7 dB) <-- not zero
harmonic[ 8] : 0.0000000000 (-335.2 dB)
harmonic[ 9] : 0.0001437676 ( -76.8 dB) <-- not zero
harmonic[10] : 0.0000000000 (-349.0 dB)
harmonic[11] : 0.0003657795 ( -68.7 dB) <-- not zero
harmonic[12] : 0.0000000000 (-344.7 dB)
harmonic[13] : 0.0001281923 ( -77.8 dB) <-- not zero
harmonic[14] : 0.0000000000 (-336.6 dB)
harmonic[15] : 0.0666666676 ( -23.5 dB) <-- large
harmonic[16] : 0.0000000000 (-669.5 dB)
harmonic[17] : 0.0588235305 ( -24.6 dB) <-- large
harmonic[18] : 0.0000000000 (-338.8 dB)
harmonic[19] : 0.0000877105 ( -81.1 dB) etc
harmonic[20] : 0.0000000000 (-349.1 dB)
...

With your values {30.1 16.2 12.4 11.5 12.4 16.2 30.1}:
harmonic[ 0] : 0.0000000000 (-228.8 dB)
harmonic[ 1] : 1.0000000000 ( 0.0 dB) Fundamental
harmonic[ 2] : 0.0000000000 (-323.8 dB)
harmonic[ 3] : 0.0000046094 (-106.7 dB) <-- not zero
harmonic[ 4] : 0.0000000000 (-328.6 dB)
harmonic[ 5] : 0.0003879629 ( -68.2 dB) <-- not zero
harmonic[ 6] : 0.0000000000 (-331.2 dB)
harmonic[ 7] : 0.0000764662 ( -82.3 dB) <-- not zero
harmonic[ 8] : 0.0000000000 (-341.2 dB)
harmonic[ 9] : 0.0000594737 ( -84.5 dB) <-- not zero
harmonic[10] : 0.0000000000 (-335.7 dB)
harmonic[11] : 0.0001763468 ( -75.1 dB) <-- not zero
harmonic[12] : 0.0000000000 (-338.2 dB)
harmonic[13] : 0.0000010637 (-119.5 dB) <-- not zero
harmonic[14] : 0.0000000000 (-340.7 dB)
harmonic[15] : 0.0666666676 ( -23.5 dB) <-- large
harmonic[16] : 0.0000000000 (-655.0 dB)
harmonic[17] : 0.0588235305 ( -24.6 dB) <-- large
harmonic[18] : 0.0000000000 (-342.9 dB)
harmonic[19] : 0.0000007278 (-122.8 dB) etc
harmonic[20] : 0.0000000000 (-342.6 dB)
...
Better, but not perfect.

Intuitively speaking, you can't cause (other than by chance) n perfect
independent zeros with m adjustable variables, being n>m. m equals 4,
for you. If the value of each variable can be chosen from a set with a
_finite_ number of possible values, as is your case (if you want to
use standard E96 values), the situation can only be worse.

What I was saying is that, assuming that your choice minimizes the sum
of squared errors (which I haven't checked), in general, there may be
a _different_ choice that causes the THD to be lower than in your
case. If I have time I will try to find an example to prove this.


>Higher harmonics are NON-ZERO, actually pretty large, and (as long as
>you're limiting yourself to 7 resistors and equal-spaced steps and want
>the first 14 harmonics to be zero) you have NO CONTROL of them
>because... you've only got 16 fixed-spacing steps!
>
>Any real analysis has to include the effect of the low-pass filter that
>follows our primitive DDS. My decoupling (saying "first we get rid of
>the first 14 harmonics in synthesis to make the work of the low-pass
>filter easier") may indeed be primitive and not a good decoupling.
>
>If you have any reference to real designs or published literature that
>do DDS-like (e.g. equally spaced steps) or other numerically-controlled
>oscillator sine-wave synthesis and do NOT simply choose sin(phase) for
>equal phase spacing, I'm very interested. DDS has become very popular
>over the past decade or so but none of the published designs or chips
>I've seen use anything but sin(phase) for equally-spaced phase in their
>lookup table.
>
>I'm not completely disinterested in designs that use diode-limiting on
>triangle waves (you will note that these often do use non-equal spaced
>steps) but I'm convinced that I'm already doing better than all of
>those. I'm also convinced that I do much better than
>8038's/XR-2206's/etc (which are essentially "slope and trip-point
>synthesizers")
>
>Don's "Magic Sine Waves" seem interesting but there's a lot more steps

I don't like using the word "magic" for non-magic things. For the same
reason, delta-sigma modulation could be called magic modulation, the
fast Fourier transform could be called the magic transform, etc. For
me, it is like saying "this is so complex that it has to be called
'magic.'" It is ok if I'm talking to a 10-year old kid, but not if I'm
talking to engineers.


>going on in his PWM than his accounting says there are :-). And I'm
>working with fairly conventional microprocessors and logic so his
>methods run out of steam real quick above a kHz or so (whereas the
>16-step-7-resistor thingy is good to several MHz, a place that magic
>sine waves will not go).

If you need to work with low ratios (clock/output_f), maybe you can
run a long simulation to find the optimum sequence of 0s and 1s (and
even the values of resistors, if you want to work with more than two
levels) that produce the signal with the spectral contents that you
want. Just brute force would work (for low ratios), but a minimization
algorithm would help.

Best,

>
>Tim.

Tim Shoppa

unread,
Apr 5, 2006, 2:00:35 PM4/5/06
to
Mochuelo wrote:
> On 5 Apr 2006 03:19:40 -0700, "Tim Shoppa" <sho...@trailing-edge.com>
> wrote:
>
> >Mochuelo wrote:
> >> If the minimization processis such that you can make the error as
> >> small as you want, yes. Otherwise, not necessarily.
> >>
> >> We are clearly in the latter case, since our delta t is fixed
> >> (period/16) and we are choosing resistors from a set of standard
> >> values.
> >>
> >> In cases like this one, you may find that the set of resistors that
> >> minimizes the THD is not the same as the set of resistors that
> >> minimizes the sum of squared errors. Since the good criterium is
> >> spectrum based, it doesn't make much sense wasting effort doing LSE.
> >> LSE can provide a good starting point to be used in an iterative
> >> algorithm that minimizes harmonic contents.
> >
> >If you get the LSE "perfect" with the 16-step/7-resistor design, then
> >the first fourteen harmonics are ZERO.
>
> The even harmonics are of course zero, by construction, but the odd
> ones are not, unless you call "8*10^-4" zero (and having assigned the
> value "1" to the fundamental).

Well, the odd ones would be zero IF we got all the resistor ratios
perfect. I generally don't get to pick values that aren't standard E96,
but with 0.01% E96 values available off-the-shelf maybe it'd be good to
use some series combinations.

I didn't mean to confuse things: all I ever meant to claim was that my
E96 values were better than those in AOE. And I think they're the best
you can get with E96 values... they happen to be several times better
than the next-best combination. (Sort of like how 355/113 is a
surprisingly good approximation to pi...)

I always wrote "perfect" in quotes because I was using it in the same
idealized sense (ignoring E96 limitiations) that the text in AOE uses.

It is actually a bit surprisng that by choosing appropriate E96
resistor values (2% between each step approximately) that you can get
the largest of the first fourteen harmonics down to 0.03% of the
fundamental. And the third harmonic (probably the most important for
real-world non-brick-wall low-pass filters) comes out at 0.0004% of the
fundamental.

Thank you for running the Fourier analysis, BTW. It's reassuring to see
that a factor of four better in sum-of-squares really does translate
into all the harmonics being 6dB or more down. I'll try to trundle
through the other E96 combinations and see if any happen to be
particularly better at getting the third and fifth down way low,
probably at the expense of picking up some strength in the seventh,
ninth, etc.

Tim.

The Phantom

unread,
Apr 6, 2006, 8:02:53 AM4/6/06
to
On 5 Apr 2006 11:00:35 -0700, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

How do you calculate the sum-of-squares error?

>
>I always wrote "perfect" in quotes because I was using it in the same
>idealized sense (ignoring E96 limitiations) that the text in AOE uses.
>
>It is actually a bit surprisng that by choosing appropriate E96
>resistor values (2% between each step approximately) that you can get
>the largest of the first fourteen harmonics down to 0.03% of the
>fundamental. And the third harmonic (probably the most important for
>real-world non-brick-wall low-pass filters) comes out at 0.0004% of the
>fundamental.

Did you just do an exhaustive search, starting at the beginning of the
E96 series? I can't find any other sets that are as good. The only one
that even comes close is:

Q1: 34.8K
Q2: 18.7K
Q3: 14.3K
Q4: 13.3K
Q5: 14.3K
Q6: 18.7K
Q7: 34.8K

The attenuations of the harmonics are:

3rd -97 dB
5th -65 dB
7th -74 dB
9th -76 dB
11th -71 dB
13th -109 dB

Even better however, is to slightly modify your values to:

Q1: 30.1K
Q2: 16.257K
Q3: 12.46K
Q4: 11.5K
Q5: 12.46K
Q6: 16.257K
Q7: 30.1K

Then the attenuations are:

3rd -108 dB
5th -87.5 dB
7th -80.7 dB
9th -82.9 dB
11th -94.4 dB
13th -121 dB

You're going to have some good tempco resistors to hold that kind of
suppression of the harmonics. And, of course, I didn't take into account
the output resistance of the gates, etc.

>
>Thank you for running the Fourier analysis, BTW.

I got the same numbers he did; we each must have got it right, or we made
exactly the same mistake!

Tim Shoppa

unread,
Apr 6, 2006, 9:00:57 AM4/6/06
to
The Phantom wrote:
> How do you calculate the sum-of-squares error?

It was just the sum of the squares of the deviation between the
synthesized voltage and the actual value of sin(phase) for each of the
phases pi/16, 3*pi/16, etc.

There are many many tools and techniques for minimizing sum-of-squares
error. I just sort of use it by default, without thinking, in any sort
of fitting etc. In many cases it is not the correct error to minimize,
but it's almost always the easiest fit, so a lot of us use it as a
measure without any real justification.

> Did you just do an exhaustive search, starting at the beginning of the
> E96 series?

Sort-of. I knew the "perfect" resistor ratios, and would choose a
"base" E96 value, look up the nearest E96 choices for the other 3
resistors, and then use those. Yeah, this isn't the best if the perfect
value comes exactly between two E96 choices, but then those
combinations are not going to be the best of the bunch either.

Because the ideal resistor values span a roughly 3:1 range I allowed
two adjacent decades of E96 values.

> Even better however, is to slightly modify your values to:
>
> Q1: 30.1K
> Q2: 16.257K
> Q3: 12.46K
> Q4: 11.5K
> Q5: 12.46K
> Q6: 16.257K
> Q7: 30.1K

The "perfect" ratios are to 8 digits (normalized to R1=100K):

R1: 100K
R2: 54.1195982K
R3: 41.4213457K
R4: 38.2683326K

With E96 resistors available off-the-shelf with 0.01% tolerances these
days, somebody who was really obsessed with this could probably find
some series or parallel combinations that hit these to an obscene
number of digits.

But... it's sort of like 355/113 being a surprisingly good
approximation to pi. Yeah, you can tell me that 52163/16604 is better,
but it's not better by much!

Tim.

The Phantom

unread,
Apr 6, 2006, 2:02:27 PM4/6/06
to
On 6 Apr 2006 06:00:57 -0700, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>The Phantom wrote:


>> How do you calculate the sum-of-squares error?
>
>It was just the sum of the squares of the deviation between the
>synthesized voltage and the actual value of sin(phase) for each of the
>phases pi/16, 3*pi/16, etc.

Ok, this clears up some confusion I had. It sounds like you're saying
that you took the difference between the value of sin(pi/16) and the output
of the network and squared it, did the same for the the other 15 points and
added up the squares.

I did things a little differently. I integrated the square of the
difference between the sine function and the step value from the network
for all 16 intervals (actually I did 8 and multiplied by 2), whereas you
only took the values at the midpoint of the intervals. Do I properly
understand what you did?

What did you take to be the rail voltage for calculating the output of
the network? I took it to be 2 volts, so that the sine function I was
approximating was just the standard mathematical sine with an offset of 1.

And, in the interest of seeing if I can duplicate your results, what did
you get for the sum-of-squares of the two resistor sets in your first post?

>
>There are many many tools and techniques for minimizing sum-of-squares
>error. I just sort of use it by default, without thinking, in any sort
>of fitting etc. In many cases it is not the correct error to minimize,
>but it's almost always the easiest fit, so a lot of us use it as a
>measure without any real justification.
>
>> Did you just do an exhaustive search, starting at the beginning of the
>> E96 series?
>
>Sort-of.

In your previous post, you said: "I'll try to trundle


through the other E96 combinations and see if any happen to be
particularly better at getting the third and fifth down way low,
probably at the expense of picking up some strength in the seventh,
ninth, etc."

What I'm wondering is whether you just stopped when you hit the 30.1K,
etc. set, or if you checked all the E96 values. Your comment makes it
sound like you didn't check them all.

I also checked all the E192 values, and didn't find anything better than
your set.

>I knew the "perfect" resistor ratios, and would choose a
>"base" E96 value, look up the nearest E96 choices for the other 3
>resistors, and then use those. Yeah, this isn't the best if the perfect
>value comes exactly between two E96 choices, but then those
>combinations are not going to be the best of the bunch either.
>
>Because the ideal resistor values span a roughly 3:1 range I allowed
>two adjacent decades of E96 values.
>
>> Even better however, is to slightly modify your values to:
>>
>> Q1: 30.1K
>> Q2: 16.257K
>> Q3: 12.46K
>> Q4: 11.5K
>> Q5: 12.46K
>> Q6: 16.257K
>> Q7: 30.1K
>
>The "perfect" ratios are to 8 digits (normalized to R1=100K):
>
>R1: 100K
>R2: 54.1195982K
>R3: 41.4213457K
>R4: 38.2683326K
>
>With E96 resistors available off-the-shelf with 0.01% tolerances these
>days, somebody who was really obsessed with this could probably find
>some series or parallel combinations that hit these to an obscene
>number of digits.

Where I said "slightly modify", I was thinking that one could put 57 ohm
resistors in series with the 16.2K and 60 ohms in series with the 12.4K to
partly satisfy that obsession. It does pull down the magnitude of that 5th
harmonic quite a bit. :-)

Tim Shoppa

unread,
Apr 6, 2006, 2:16:46 PM4/6/06
to
The Phantom wrote:
> What did you take to be the rail voltage for calculating the output of
> the network? I took it to be 2 volts, so that the sine function I was
> approximating was just the standard mathematical sine with an offset of 1.

I rescaled the rail voltage so that for each resistor combination, the
sum-of-squares would be minimized. This means that it was less than the
peak of the sine. If I got sin(7*pi/16) right, then it'd be 0.9807 for
example. I think this step is necessary to make heads or tails of the
least-squares minimization; otherwise you aren't really minimizing the
harmonics but some other measure that's off by 2 percent.

> In your previous post, you said: "I'll try to trundle
> through the other E96 combinations and see if any happen to be
> particularly better at getting the third and fifth down way low,
> probably at the expense of picking up some strength in the seventh,
> ninth, etc."
>
> What I'm wondering is whether you just stopped when you hit the 30.1K,
> etc. set, or if you checked all the E96 values. Your comment makes it
> sound like you didn't check them all.

Checked all of them. Like I said, the resistor range of 3:1 means that
there you'll have to go out of the decade for some of them.

> I also checked all the E192 values, and didn't find anything better than
> your set.

Interesting data point, thanks!

> Where I said "slightly modify", I was thinking that one could put 57 ohm
> resistors in series with the 16.2K and 60 ohms in series with the 12.4K to
> partly satisfy that obsession. It does pull down the magnitude of that 5th
> harmonic quite a bit. :-)

Note that the output impedance of a typical HC shift register (e.g.
HC595) is in the 40-60 ohm region for small currents, Vcc of 5V, and 25
deg C and this makes the decade scale I chose for
57.6K/30.9K/23.7K/22.1K a particular sweet spot. It looks like it helps
elsewhere too!

Tim.

bogax

unread,
Apr 6, 2006, 3:53:24 PM4/6/06
to
Tim Shoppa wrote:

> Sort-of. I knew the "perfect" resistor ratios, and would choose a
> "base" E96 value, look up the nearest E96 choices for the other 3
> resistors, and then use those. Yeah, this isn't the best if the perfect
> value comes exactly between two E96 choices, but then those
> combinations are not going to be the best of the bunch either.
>
> Because the ideal resistor values span a roughly 3:1 range I allowed
> two adjacent decades of E96 values.

No doubt letting a computer do an exhaustive search for you
would be easiest.

When I did it (with 5% values) I plotted the standard values on
a log scale, then the ratios on the same log scale on a
different piece of paper and slid it along the standard values
plot looking for a best fit.

Mochuelo

unread,
Apr 7, 2006, 6:02:17 AM4/7/06
to
I've done an exhaustive search on two consecutive decades of the E96
series, looking at the spectral contents of the resulting signal, and
the best[*] combination is yours, {115 124 162 301}. Congratulations
:-). It took 5.2 hours on my AMD XP @ 1800, with Matlab v7.

[*] Criterium:
- The maximum |S(f)| is located in the bin f=1/(16*Tclk). I will call
this |S(f_1)|.
- The ratio |S(f_1)|/|S(f_worst)| is maximum, where f_worst=k*f_1 and
k is the value out of {2,3,4... 14} for which |S(f_worst)| is highest.
- I considered only combinations for which Ra <= Rb <= Rc <= Rd. That
meant some extra speed. The values end up as [Rd Rc Rb Ra Rb Rc Rd].

The ratio for the best combination is -68.20 dB (k=5), as I said in a
previous post.

This is interesting :-)

Best,

The Phantom

unread,
Apr 7, 2006, 9:10:59 AM4/7/06
to

Could you post the next best 2 or 3 that you found? Also, you might
search the E192 series; let the computer run while you're in bed. :-)

Tim Shoppa

unread,
Apr 7, 2006, 10:19:40 AM4/7/06
to
Mochuelo wrote:
> I've done an exhaustive search on two consecutive decades of the E96
> series, looking at the spectral contents of the resulting signal, and
> the best[*] combination is yours, {115 124 162 301}. Congratulations

Thank you :-).

> :-). It took 5.2 hours on my AMD XP @ 1800, with Matlab v7.

> - I considered only combinations for which Ra <= Rb <= Rc <= Rd. That
> meant some extra speed. The values end up as [Rd Rc Rb Ra Rb Rc Rd].

That search is way way too broad in my opinion. Common sense tells you
what the ideal ratios for Rd:Rc:Rb:Ra are. So you don't have to search
all 96*96*96*96 combinations. After you pick one resistor, the ideal
ratios tell you what the other three must be close to. And if they
aren't particularly close, then they aren't going to be a good choice.

Tim.

Mochuelo

unread,
Apr 7, 2006, 10:47:54 AM4/7/06
to
On Fri, 07 Apr 2006 06:10:59 -0700, The Phantom <pha...@aol.com>
wrote:

> Could you post the next best 2 or 3 that you found?

The problem is that, for memory reasons, the program recorded new
information only when it found a combination better than the best one
so far. So, the last row is meaningful (it is the combination or one
of the combinations that yield the best result, with the restrictions
mentioned), but the second to last is not, because it depends on the
search path. There is no guarantee that it is the second best
combination.

My last rows were:

[ Ra Rb Rc Rd] SFDR14 : har3 har5 har7 har9 har11
har13

...
[ 100 105 140 249] -53.95 : -54.4 -76.6 -54.0 -56.1 -83.4
-67.0
[ 100 105 140 255] -55.11 : -66.4 -62.9 -55.1 -57.3 -69.7
-79.0
[ 100 105 140 261] -56.28 : -61.0 -56.3 -56.4 -58.6 -63.0
-73.6
[ 100 107 140 261] -61.21 : -72.7 -61.2 -69.0 -71.1 -68.0
-85.3
[ 102 110 143 267] -64.05 : -67.8 -64.1 -79.5 -81.6 -70.8
-80.4
[ 115 124 162 301] -68.20 : -106.7 -68.2 -82.3 -84.4 -75.0
-119.3

So, it did find one other combination (besides Tim's) better than the
one in AOE (which has -61.9 dB), but maybe there are more. In fact,
there may be more than one combination with -68.20 dB, but my program
only showed the first one it found. If I rerun the program with a "<="
instead of a "<" I can find out if the best combination is unique or
not. Maybe tonight. I used the "<" to have a smaller log.

I put the Matlab script on
http://personal.cucafera.org/ng/johnson2sin_0044.m
but it includes very few comments.

>Also, you might
>search the E192 series; let the computer run while you're in bed. :-)

Only if I find a faster algorithm :-)

Best,

Mochuelo

unread,
Apr 7, 2006, 12:53:29 PM4/7/06
to
On 7 Apr 2006 07:19:40 -0700, "Tim Shoppa" <sho...@trailing-edge.com>
wrote:

>That search is way way too broad in my opinion. Common sense tells you


>what the ideal ratios for Rd:Rc:Rb:Ra are.

Hmmm... what do you call common sense? The solution of a system of
equations? I wouldn't call it that way. Besides, that system of
equations minimizes one thing, which is the LSE, and I didn't want to
assume anything about the LSE.

Frankly, can you find out the ratios doing only very few calculations?
How?

>So you don't have to search
>all 96*96*96*96 combinations.

I guess you meant 192^4 = 1.4*10^9. No, I "only" swept 5.8*10^7
combinations.

>After you pick one resistor, the ideal
>ratios tell you what the other three must be close to. And if they
>aren't particularly close, then they aren't going to be a good choice.

I know, but I didn't want to start assuming any ratios, and especially
ratios that were found with a goal in the time domain. I wanted to
look only at the frequency domain.

Best,

The Phantom

unread,
Apr 7, 2006, 4:23:40 PM4/7/06
to
On Fri, 07 Apr 2006 12:02:17 +0200, Mochuelo
<cucafera@RE_MO_VE_THIStelefonica.net> wrote:

Since the wave would likely be filtered by an analog filter, I think a
good criterion would be to attenuate the successive harmonics by a 6
dB/octave rolloff and compute the total power in the first 14 harmonics as
attenuated, the minimum of this power being the goal. And then attenuate
by 12 dB/octave, 18 dB/octave, etc. What fun! :-)

>
>Best,

The Phantom

unread,
Apr 7, 2006, 6:31:10 PM4/7/06
to
On Thu, 06 Apr 2006 11:02:27 -0700, The Phantom <pha...@aol.com> wrote:


>
> I also checked all the E192 values, and didn't find anything better than
>your set.
>

I made a dumb programming error, and missed some, including an ultra
cherry one.

Here are several from the E192 series that are quite good. I only show
the first 5 values; the last 3 are mirrors of the first 3, of course.

Series THD Att. of 3rd and 5th, dB

40.7K 22.1K 16.9K 15.6K 11.307170939% -123 -75

27.7K 15.0K 11.5K 10.6K 11.30717522% -81 -79

40.2K 21.8K 16.7K 15.4K 11.307174038% -80 -76

25.8K 14.0K 10.7K 9.88K 11.30717007% -81 -77
----------------------------------------------------------------------

The theoretical best distortion is 11.3071522645%, so we see that some of
these are getting pretty good.

The first one above beats the 30.1K 16.2K 12.4K 11.5K series with respect
to all the harmonics through the 13th; I didn't check any more.

I found these by starting at the beginning of the E192 series of values
and comparing the theoretical ratios wanted with the four closest from the
E192 series, computing the mean square sum of the ratios of each
theoretical value to the E192 value, and looking for small results. I did
it on a hand calculator in about 5 minutes (5 minutes after the program was
written and debugged; that took an hour!)

Ken Smith

unread,
Apr 7, 2006, 9:37:24 PM4/7/06
to
In article <haid329cfo6runpke...@4ax.com>,
The Phantom <pha...@aol.com> wrote:
[....]

> Since the wave would likely be filtered by an analog filter, I think a
>good criterion would be to attenuate the successive harmonics by a 6
>dB/octave rolloff and compute the total power in the first 14 harmonics as
>attenuated, the minimum of this power being the goal. And then attenuate
>by 12 dB/octave, 18 dB/octave, etc. What fun! :-)

That assumes no notches are used. I would expect that you would want to
optimize the filter, adding notches if that leads to a better answer.

Pick the resistors, do an FFT of the result, design some reasonable
filter, find the weighted results and repeat for each resistor
combination. Fortunately computers don't get tired of calculating.


--
--
kens...@rahul.net forging knowledge

The Phantom

unread,
Apr 7, 2006, 9:45:32 PM4/7/06
to
On Sat, 8 Apr 2006 01:37:24 +0000 (UTC), kens...@green.rahul.net (Ken
Smith) wrote:

>In article <haid329cfo6runpke...@4ax.com>,
>The Phantom <pha...@aol.com> wrote:
>[....]
>> Since the wave would likely be filtered by an analog filter, I think a
>>good criterion would be to attenuate the successive harmonics by a 6
>>dB/octave rolloff and compute the total power in the first 14 harmonics as
>>attenuated, the minimum of this power being the goal. And then attenuate
>>by 12 dB/octave, 18 dB/octave, etc. What fun! :-)
>
>That assumes no notches are used.

The notches and whatever else might come to mind were included in the
"etc."

0 new messages