Sine wave generation - logarithmic shaping

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

  1. Veracohr

    Thread Starter Active Member

    Jan 3, 2011

    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.

    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.

  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    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


    Dec 13, 2009
    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:

    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

    Senior Member

    Feb 5, 2010
    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

    Thread Starter Active Member

    Jan 3, 2011
    Aha! Thank you bitrex!
  6. Veracohr

    Thread Starter Active Member

    Jan 3, 2011
    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

    New Member

    Dec 20, 2007
    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. Wendy


    Mar 24, 2008
    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

    Thread Starter Active Member

    Jan 3, 2011
    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. Wendy


    Mar 24, 2008
    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