1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

why sawtooth instead of square wave for class D amplifier?

Discussion in 'General Electronics Chat' started by mik3ca, Sep 22, 2017.

  1. mik3ca

    mik3ca Member

    Joined:
    Jun 24, 2017
    Messages:
    213
    Likes:
    1
    I ended up playing around with a couple mosfets, a LM393 comparator, NE555 timer, and other stuff and I made myself a decent amplifier, but the inputs I used for the comparator were a square wave running at about 1Mhz and the audio source itself via a capacitor. I also connected a resistor voltage divider to the same input and this divider made things work well. (example: I made the input at ultra low volume and can hear the same thing very loud at the output)

    Now I'm curious. In my design, I used a square wave as an input to the comparator. On the web, the majority of the designs use a sawtooth or triangular wave input. I'm curious. Why is the triangular wave input preferred? What is the disadvantage with a square wave input?
     
  2. Les Jones

    Les Jones Well-Known Member

    Joined:
    May 15, 2015
    Messages:
    1,474
    Likes:
    191
    Location:
    Lancashire UK
    With a triangular wave connected to one input of the comparator and the audio connected to the other input the output of the comparator will be a PWM signal whose duty cycle represents the instantanious level of the audio signal. I don't see how it could work with a square wave input.

    Les.
     
    • Agree Agree x 1
  3. AnalogKid

    AnalogKid Well-Known Member

    Joined:
    Sep 22, 2011
    Messages:
    1,135
    Likes:
    161
    Location:
    Ohio - GMT-5
    With no schematic it is impossible to say.

    ak
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,319
    Likes:
    1,230
    Location:
    Cardiff, Wales

    Perhaps parasitics / bandwidth-limitation caused some low-pass filtering whereby the edges got knocked off the square-wave so that it became an approximation of a triangular wave. That would result in crude PWM.
     
  6. AnalogKid

    AnalogKid Well-Known Member

    Joined:
    Sep 22, 2011
    Messages:
    1,135
    Likes:
    161
    Location:
    Ohio - GMT-5
    AN LM393 probably is slow enough internally to triangle-ize, or at least trapezoid-ize a 1 MHz input.

    ak
     
  7. kubeek

    kubeek Well-Known Member

    Joined:
    Mar 11, 2006
    Messages:
    1,510
    Likes:
    189
    Location:
    Prague, Czechia (not Chechnya)
    In my opinion Les Jones is closest to the actual point being asked, but let´s see what mik3ca has to say about it.
     
  8. MrAl

    MrAl Well-Known Member Most Helpful Member

    Joined:
    Sep 7, 2008
    Messages:
    11,049
    Likes:
    961
    Location:
    NJ
    Hi,

    I agree that Les provided the answer, but the other suggestions that the LM393 device is too slow are also good. I would definitely look at that because the slew rate could actually be defeating the purpose of creating a class D amp in the first place because the output can not be a clean PWM and thus the efficiency of the amp will not approach a true class D amp so all is for nothing.
    A quick rough efficiency measurement would show some problems.
     
  9. schmitt trigger

    schmitt trigger Active Member

    Joined:
    May 24, 2009
    Messages:
    912
    Likes:
    85
    If the pullup resistor is large, this is exactly what will happen.
    But without schematics or scope waveforms, we are blindfolded.
     
  10. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,623
    Likes:
    479
    Location:
    L.A., USA Zulu -8
    Correction.
    All the designs use a sawtooth.
    None use a square-wave.
    Because a true square-wave will not work to make a proper PWM signal from the audio input.
    See above.
     
  11. AnalogKid

    AnalogKid Well-Known Member

    Joined:
    Sep 22, 2011
    Messages:
    1,135
    Likes:
    161
    Location:
    Ohio - GMT-5
    I think Les and I said the same thing. Due to a non-refreshed page, I did not see his post before I wrote mine.

    ak
     
  12. AnalogKid

    AnalogKid Well-Known Member

    Joined:
    Sep 22, 2011
    Messages:
    1,135
    Likes:
    161
    Location:
    Ohio - GMT-5
    Sure about that? A lot of them look like triangle-wave-based to me.

    ak
     
  13. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    Correction to your correction :D

    All designs use a triangle wave - a saw tooth would mean massive distortion - not the 100% of a square wave, but at least 50%.
     
  14. AnalogKid

    AnalogKid Well-Known Member

    Joined:
    Sep 22, 2011
    Messages:
    1,135
    Likes:
    161
    Location:
    Ohio - GMT-5
    Disagreement with your correction to his correction.

    The only difference between saw and triangle waves is a faster leading edge. There still is a linear relationship between elapsed time into a wave cycle and the percentage of the total wave area under the curve. With a positive-going saw wave (narrow peak at the top) of 2 V p-p and incoming audio of 2 V p-p, both into a fast comparator, the range of output rectangular wave pulse widths still is 0% to 100% of the saw wave period (note - theoretically perfect comparator).

    For low-distortion PWM, the pulse frequency should be much greater than the highest audio freq. In terms of instantaneous values, the comparator sees a fast periodic waveform (saw or tri) on one input, and a slowly varying DC level on the other. For an instantaneous audio waveform value of 1.5 V, the comparator output will be a 25/75 rectangular wave (or 75/25 depending on how the inverting and non-inverting inputs are assigned), for *either* carrier wave.

    ak
     
    Last edited: Sep 23, 2017
  15. alec_t

    alec_t Well-Known Member Most Helpful Member

    Joined:
    Jul 10, 2011
    Messages:
    9,319
    Likes:
    1,230
    Location:
    Cardiff, Wales
    LTspice thinks there is very little difference in distortion for the two wave shapes.
     

    Attached Files:

  16. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    39,324
    Likes:
    653
    Location:
    Derbyshire, UK
    I would disagree, a sawtooth has near instantaneous transition in one direction, and a slow ramp in the other.

    But regardless, all class-D amps (of this type) use triangle waves - why would you want to use something that would be inferior?.
     
  17. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,623
    Likes:
    479
    Location:
    L.A., USA Zulu -8
    Yes, I meant sawtooth or triangle. :oops:

    And, just to be clear, we are talking about the internal modulator waveform, not the waveform out of the modulator (which is a PWM square-wave).
    I think there may be some confusion on that point.
     
  18. crutschow

    crutschow Well-Known Member Most Helpful Member

    Joined:
    Mar 14, 2008
    Messages:
    10,623
    Likes:
    479
    Location:
    L.A., USA Zulu -8
    How is a sawtooth inferior?
    A critical factor in the distortion generated by the PWM modulator is the linearity of the ramp of either the sawtooth or the triangle-wave.
    If they both are equally linear, then they will produce equal output distortion.
     
  19. AnalogKid

    AnalogKid Well-Known Member

    Joined:
    Sep 22, 2011
    Messages:
    1,135
    Likes:
    161
    Location:
    Ohio - GMT-5
    Which is what I said
    To clarify, for waves of the same amplitude and frequency, a saw wave has a much faster leading edge. Mucho incredibly zoomy faster. But the area under both curves is the same, which is why the modulation noise is the same.
    ak
     
  20. ronsimpson

    ronsimpson Well-Known Member Most Helpful Member

    Joined:
    Apr 17, 2007
    Messages:
    7,365
    Likes:
    973
    Location:
    Loveland, CO USA
    Agree that a nice linear ramp is better but, I enclose the PWM in a feedback loop, (error amp) so this distortion should be removed.
     
    Last edited: Sep 23, 2017
  21. schmitt trigger

    schmitt trigger Active Member

    Joined:
    May 24, 2009
    Messages:
    912
    Likes:
    85
    I believe we have managed to utterly confuse the OP............:D
     

Share This Page