6
\$\begingroup\$

enter image description here

enter image description here

The figure illustrates appox sine function by the equation. How does this work? I could guess that quarter cycle of sine wave (0- pi/2) is approximated by the linear equation.

\$\endgroup\$
4
  • 6
    \$\begingroup\$ It's an R-2R digital to analogue converter - the digital word presented to the switches defines the output voltage. It doesn't inherently produce a sine wave output. \$\endgroup\$
    – Andy aka
    Sep 26, 2020 at 7:57
  • \$\begingroup\$ where did this come up? \$\endgroup\$
    – P2000
    Sep 27, 2020 at 6:20
  • 1
    \$\begingroup\$ Can you link the source? This looks like a very old method of approximating sin/cos, also maybe some errors in it. \$\endgroup\$ Sep 27, 2020 at 9:26
  • 1
    \$\begingroup\$ The circuit itself isn't a sine approximator, it's an anything approximator. Just put in the right digital word, and out comes an analogue equivalent. If you distort the digital word according to the apparently simple equation, then you get something that's a bit more sine than straight line. However, the equation involves a division, which is something to be avoided like the plague in digital circuits. Far better to do a lookup table, or indeed Taylor series approximation, than use a division to achieve something pretty bad. \$\endgroup\$
    – Neil_UK
    May 30, 2022 at 12:59

4 Answers 4

6
\$\begingroup\$

You are correct – the sine wave is approximated by the equation.

So there are two questions: does the circuit implement that equation, and how good of a sine approximation is it?

The answer to the first question is yes, the circuit does have this transfer function.

The R-2R ladder implements a D-A converter with a gain of 0 to 1, which is what you’re calling theta. Allow me to just call that a gain stage with gain G:

enter image description here

So to implement your A value of 0.56312, we’d pick R2 and R1 in a ratio of 0.56312/1, or something like R1 = 10K, R2 = 5.6K.

Now, how good of a sine wave can we do? Letting G go from 0 to 1 and back to 0 we see the top half of the resulting “sine”. Here is what the result is for various values of A:

enter image description here

It does appear that for a properly chosen A (around 3) the waveform does take on a reasonable facsimile of a sine. It doesn’t seem like 0.56312 is a particularly good value so I’m not sure where that came from.

If my math is correct then you’d want to make A about 3 (R2 = 3*R1) and figure out how to get the negative part of the sine, perhaps by inverting the input Ei, or allowing G to go negative. I’ll leave that as an exercise to the reader or other answerers.

Cool idea!

CONTINUED: @P2000 - thanks - corrected my cos typo.

Going a little further:

You can't get the symmetrical negative waveform by inverting Ei or allowing G to go negative: I don't know whose dumbass idea that was. Just run the theta up and down again and invert Eo this time.

My eyeballing estimate of A=3 being about the best was pretty far off: it turns out 1.2 has the least error vs. a true sine:

enter image description here

ANOTHER EDIT: @gari – to address your follow-up question as to how to extend to 4 quadrants.

The digital control (theta) only goes from 0 to 1, and that maps to the first quadrant. Ramping theta back down from 1 to 0 gets the second quadrant, no problem so far. For 2nd and 3rd quadrant we do the same thing (theta from 0 to 1 to 0) but invert the final output Eo. We could use “signed-magnitude” for our theta. Say it’s 8 bits: bits [6:0] go from 00-7f-00-7f-00 and sign bit 7 goes from 0-0-0-1-1. The sign bit would control a stage after Eo that inverts or passes it through.

enter image description here

\$\endgroup\$
8
  • \$\begingroup\$ upvote for td127 and all others. That is great analysis. I was curious of getting into this equation from first principles. I mean, now that the equation is deciphered. But how to derive this equation? \$\endgroup\$
    – gari
    Sep 27, 2020 at 9:33
  • \$\begingroup\$ very nice derivative td127, a surprise to others. Threre's a "typo" in the final expression for "co". (BTW @gari your upvote doesn't show?) Where does that rational expression to approximate sin come from? It's not Taylor or Pade. Matches by form sort-of, but derivatives at 0 and 1 are terribly incorrect. \$\endgroup\$
    – P2000
    Sep 27, 2020 at 15:06
  • \$\begingroup\$ Nice! I get 1.194 for minimum RMS error and 1.159 for minimum absolute error (over 100 points for 0..\$\pi/2\$). \$\endgroup\$ Sep 27, 2020 at 20:40
  • \$\begingroup\$ The font of the original looks like the old Texas Instruments or National Semi datasheets, possibly an app note from an old DAC but I couldn't find it. I'm curious where the original 0.56312 value came from... maybe it was chosen to optimize for something other than min RMS error. Min THD maybe? Seems unlikely. But then, this whole scheme seemed unlikely. \$\endgroup\$
    – td127
    Sep 28, 2020 at 2:39
  • \$\begingroup\$ In the 70s and 80s there used to be D/A with built-in "rotary conversion" or "voltage phase" conversion. Maybe something there. I also couldn't find this particular circuit. It's cool - as you say- (but crude). That value is awfully close to pi/2-1 which could occur in a Pade sequence. \$\endgroup\$
    – P2000
    Sep 28, 2020 at 5:47
3
\$\begingroup\$

If people are still interested on the extension of the sin approx beyond \$0 \leq \theta \leq 1 \$ , and in general in analog approximations of trigonometric functions, I have found (from discussions on other forums) that there is (was) an IC doing exactly this. It was the Analog Devices' AD639, based on the IEEE paper, 'A monolithic microsystem for analog synthesis of trigonometric functions and their inverses' by Barry Gilbert.

The implementation of the sin function in the paper and in the chip is very different from the one shown here but it might be interesting.

\$\endgroup\$
2
\$\begingroup\$

Might be a Sine Generator if the resistor Network is calculated in a way so an digital input angle from 0-90° is resulting in correct steps of a sine. guess with Ei you can supply either 0 or 1 to select sine or cosine.

I am to lazy to recalculate the circuit, but the formulas must be the amplification defined by R1, R2 as these are constant and A is a constant.


Old

Without going into details, this looks like a digital to analog converter to me. You may produce a sine if the digital signal provides resembles a sine - or whatever form you want.

Sine signals can be generated digitally with cordec or bkm algorithms.

a analog circuit to generate some form of sine needs oscillation at least plus signal shaping is also needed, so one or more energy storage like capacitance or inductance must be present. So this is definitely not a sine (any signal) generator. Signal must be provided digitally

\$\endgroup\$
2
  • \$\begingroup\$ Can you please explain the equation and where does it come from? \$\endgroup\$
    – gari
    Sep 26, 2020 at 7:28
  • \$\begingroup\$ @gari changed my answer... \$\endgroup\$
    – schnedan
    Sep 26, 2020 at 7:45
1
\$\begingroup\$

This circuit is a standard resistive ladder for converting a binary representation of a digital value into an analogue signal. The switches allow the complement of the number to be presented for conversion perhaps to perform a conversion like sin(x)=cos(pi/2-x) where pi/2 is scaled to 1.

There is a fixed output for a given binary input. The only way to get a sine value would be to compute the binary representation upstream and then apply it to the ladder. Clocking through a sequence of computed values could be used to generate a sine wave at the output.

To actually compute the sign value for a given input x would require a circuit the could perform a summation of powers of x (with an appropriate scaling mapping). The power series for sine x is given by:

sin x = x − x^3/3! + x^5/5! - x^7/7! + ....

Clearly there is nothing like that happening here.

I think there is some information missing here also as I cannot make any sense of the equations presented for sin(phi) or the value of the constant A.

\$\endgroup\$
1
  • \$\begingroup\$ derivation please. Is it taylor series approximation? \$\endgroup\$
    – gari
    Sep 28, 2020 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.