Sine wave generation - logarithmic shaping

Discussion in 'General Electronics Chat' started by Veracohr, Jan 4, 2011.

  1. Veracohr

    Veracohr Thread Starter Member

    Joined:
    Jan 3, 2011
    Messages:
    259
    Greetings!

    Could anyone possibly explain, from National Semiconductor's AN-263 "Sine Wave Generation Techniques" page 11 - Logarithmic Shaping, how the "logarithmic relationship between Vbe and collector current in transistors" shapes a triangle wave to an approximation of a sine wave? Maybe my math isn't up to the task, but I don't see how a logarithmic response becomes a sine wave.

    http://www.national.com/an/AN/AN-263.pdf

    I wasn't able to get this shaper working, although admittedly I changed it based on what I have at hand. Still, I always understand circuits better when I know the why as well as the how.

    Thanks!
  2. thatoneguy

    thatoneguy AAC Fanatic!

    Joined:
    Feb 19, 2009
    Messages:
    6,356
    Location:
    Midwest USA
    It's math, essentially.

    integrate square wave = triangle wave
    integrate triangle wave = sine wave

    differentiate sine wave = triangle wave
    differentiate triangle wave = square wave

    When you integrate or differentiate some waveforms, you will often find a natural logarithm or exponent show up.
  3. bitrex

    bitrex Member

    Joined:
    Dec 13, 2009
    Messages:
    79
    The circuit you're looking at generates a sine wave from a triangle wave by using the properties of the differential pair of transistors contained in the LM394. The transconductance of a differential pair of transistors is defined to be:

     Gm = I_o*tanh(\frac{Vid}{2*VT})

    Where I_o is the tail current, Vid is the differential input voltage, and VT is the thermal voltage - 26 mV at room temeperature.

    In the case of this circuit, the output voltage will be approximately:

     V_o = \frac{RL*I_o*tanh(\frac{Vid}{2*VT})}{2}

    Where RL is the 100 ohm load resistor on the output. The division by 2 happens because you're only taking a single ended output, not a differential output.

    So the output voltage will be a function of the input voltage and the hyperbolic tangent. The first few terms of the Taylor series of the sine and hyperbolic tangent functions are:

    Sine:  x - \frac{x^3}{3!} + \frac{x^5}{5!} ...

    Hyperbolic Tangent:  x - \frac{x^3}{3} + \frac{2x^5}{15} ...

    If you compare the two Taylor series you will see that they are both linear to first order. What this means is that if you apply a triangle wave to a differential pair with a hyperbolic tangent transfer function, and keep the amplitude _low_, what you get out should be indistinguishable from a sine wave! That's the purpose of the two 5k resistors and the 200 ohm resistor in the circuit going into the differential pair - it's to divide down the triangle wave signal from the oscillator in an attempt to keep the circuit operating in the amplitude range where the output is a low distortion sine wave.

    You can take a look at this paper for some more of the math involving analysis of a similar circuit, including THD calculations:

    http://electrooptical.net/www/sed/TanhSineShaper.pdf

    The original National paper certainly doesn't explain the method very well, but the hyperbolic tangent approximation to a sine is what the circuit you refer to is using.
    Last edited: Jan 4, 2011
  4. Kermit2

    Kermit2 Well-Known Member

    Joined:
    Feb 5, 2010
    Messages:
    2,513
    Visualize the difference in a linear graph and a Log graph.

    The lines in a log graph get closer together as you go from 1 to 10.

    A sine wave shape on a linear graph will produce an almost straight line on a log graph.

    Therefore a linear voltage ramp (triangle wave) can generate a sine wave if the resistance (base/emitter) has a logarithmic response to current flow in the collector.

    When graphed linearly of course! :)
  5. Veracohr

    Veracohr Thread Starter Member

    Joined:
    Jan 3, 2011
    Messages:
    259
    Aha! Thank you bitrex!
  6. Veracohr

    Veracohr Thread Starter Member

    Joined:
    Jan 3, 2011
    Messages:
    259
    bitrex's explanation made sense but your simpler one doesn't. There's no capacitor in the circuit after the triangle-producing integrator. The notes specifically say "The LM394 dual transistor is used to generate the actual shaping..."
  7. Audioguru

    Audioguru New Member

    Joined:
    Dec 20, 2007
    Messages:
    9,411
    Location:
    Ontario, Canada
    It was a 40 years old way to make a pretty poor sine-wave.

    About 10 years ago I made a stepped sine-wave from a CD4018 digital IC. It had 10 steps. It made an "oversampled" sine-wave. Then I used a switched-capacitor 8th-order Butterworth lowpass filter IC to remove the remaining harmonics so the distortion was only 0.005% or less.
  8. Bill_Marsden

    Bill_Marsden Moderator Staff Member

    Joined:
    Mar 24, 2008
    Messages:
    19,253
    Location:
    Dallas, TX (GMT-5 w/ DST)
    As AudioGuru says, it can get you in the ball park without being perfect. I've used back to back diodes, and just looking at it it is hard to tell the difference. However, overlay it with a good sine wave and it jumps out at you.

    555 Function Generator
  9. Veracohr

    Veracohr Thread Starter Member

    Joined:
    Jan 3, 2011
    Messages:
    259
    I read that thread, and others here, but I wanted specifically to know about the logarithmic shaper thing. Not because it's better but because I wanted to know how it worked.

    All in my poor-man's quest to try getting a sine wave for testing purposes without having to buy a proper function generator. :rolleyes:
  10. Bill_Marsden

    Bill_Marsden Moderator Staff Member

    Joined:
    Mar 24, 2008
    Messages:
    19,253
    Location:
    Dallas, TX (GMT-5 w/ DST)
    Mine too, which is why I worked on that circuit (and will again). They sell a lot of function generator chips out there, which IMO is the best way to go around it. I don't like digital shaping circuits because the oscillator has to run at least 10X the output waveforms speed (probably more). If you are willing to truly shape the waveform you can use multiple diodes (8 or more) that slowly hand off the shaping duty when it enters the next circuits domain. Problem is, there are frequency response considerations, just because it works at one frequency doesn't mean it will work on another.

    The dual diode method I explored is close enough for me. If I need a precision sine wave I'll build something that does it from scratch, and not worry about the other waveforms.

    Bill's Index

    Sine Wave Oscillators A PDF abstract by TI
Similar Threads
Forum Title Date
General Electronics Chat Sine wave from microcontroller Oct 14, 2014
General Electronics Chat Summation of multiple sine wave Aug 12, 2014
General Electronics Chat Sine wave oscillator help Jul 26, 2014
General Electronics Chat Q: How can you verify if an inverter is a pure sine wave inverter? Jul 12, 2014
General Electronics Chat p2p Detection of Sine Wave Jun 16, 2014

Share This Page