Class D and triangle wave linearity

Discussion in 'General Electronics Chat' started by Wendy, Dec 22, 2011.

  1. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,766
    2,536
    There was a discussion not too long ago about the possible distortion from a RC triangle wave compared to a linear triangle wave. I'm attempting to see if there is any using my usual graphic approach.

    If anyone remembers this thread, such as Ron H, point me to it please.

    [​IMG]

    The RC waveform was done to scale using this thread, and was done to scale. It is as precision as I can make it. It appears there is very little difference between the two, though I would be the first to admit that the resolution is too low.

    To me it appears it would be very usable.
    .
     
    Last edited: Dec 22, 2011
  2. bertus

    Administrator

    Apr 5, 2008
    15,649
    2,348
    Hello Bill,

    You might take a look at the attached.
    From page 11 and on there is the talk about this non-linearity.

    Bertus
     
  3. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    Here is the thread. I never posted the results of my distortion sim, and it's on my computer in in idaho, while I'm presently in Georgia, visiting my grandkids for Christmas.
    I'm currently working on duplicating the sim. The distortion gets worse as the time constant increases as a proportion of the period.
     
  4. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    I agree they are extremely close.

    I will also admit being curious as to how a Class D amp would sound with the RC "Sharktooth" vs pure triangle.

    Sometimes our ears disregard minor changes (mp3 compression), yet can pick up the right kind of distortion at low levels (tubes vs transistors, allegedly)

    I'm no good at MATLAB, maybe somebody that is can take a 10 second chunk of a song (string quartet, no pre-distorted stuff), then process it to Class D via both Triangle and RC triangle waves with everything else as equal as possible. Once that is done, put both outputs through a low pass filter and come up with a distortion percent. Can this be done in MATLAB?
     
  5. crutschow

    Expert

    Mar 14, 2008
    13,056
    3,245
    The non-linearity in the sawtooth would introduce some harmonic distortion into the output filtered waveform which is a no-no, of course, to any audiophile. You'd have to do an A-B listening test to determine how much triangle non-linearity you can have before it becomes noticeable or objectionable.

    Since it's relatively easy to generate a very linear sawtooth using an op amp integrator and a couple of comparators, I see no good reason to use an RC exponential for this purpose.
     
  6. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,766
    2,536
    One thing, the 555 exponential triangle wave (as shown) is taking the sweet spot out of the curve. While far from perfect, it is also the best triangle wave you can make using this technique.

    Something that may be worth trying, is to have a side by side comparison of a sine wave generated by both techniques to see if the distortion is visible.
     
  7. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,766
    2,536
    No hurry, but I am interested in seeing the results.
     
  8. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    If nothing else, make a guitar pedal that mixes the sharktooth waveform somehow, somebody will like the sound. :D
     
  9. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    It ain't real purty, but here's a way of getting a triangle with a 555, a couple of trannies, and a bunch of diodes.:p

    I'll post some results on the distortion using an exponential ramp soon, probably sometime on Friday.
     
  10. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,766
    2,536
    I've seen it done with simple current mirror (two transistors, one resistor). It is a ramp, but a linear ramp works as well as a linear triangle.

    I'm going to draw up a crude Class D just for kicks.
     
  11. Ron H

    AAC Fanatic!

    Apr 14, 2005
    7,050
    657
    I ran the sim with a 1kHz signal at almost 100% modulation, and a 100kHz PWM carrier, so that it could handle the audio band, and so I could filter out the carrier and still see the distortion-related harmonics, which are the odd harmonics of 1kHz. The filter is a 10 pole Butterworth, with Fc=15kHz.
    I ran both a 100kHz linear triangle and a 100kHz exponential triangle, scaled to cover the range between 1/3 and 2/3 Vcc, where Vcc is 6V (actually, I used ±3V, so the triangles swing between -1V and +1V, but the results are the same).
    Note that the 3rd harmonic distortion with the exponential triangle is about 40dB down from the peak.

    Here is the subckt for the behaviorial comparator, Compb:
    Code ( (Unknown Language)):
    1. .subckt compb 1 2 3 4 5
    2. *
    3. .param Ron=1k Roff=1Meg Vt=0 Vh=0
    4. S1 N001 3 1 2 pullup
    5. S2 N001 4 2 1 pulldn
    6. C1 N001 0 1f
    7. R1 5 0 30
    8. G1 0 5 N001 0 {1/30}
    9. .model pullup SW (ron={Ron} roff={Roff} vt={Vt} vh={Vh})
    10. .model pulldn SW (ron={Ron} roff={Roff} vt={Vt} vh={Vh})
    11. .ends compb
    12.  
     
  12. crutschow

    Expert

    Mar 14, 2008
    13,056
    3,245
    Interesting result. Harmonic distortion products 40dB down would be 1% distortion -- audible but perhaps tolerable for casual listening.
     
  13. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,766
    2,536
    I know, shoot through is going to be a problem, especially with the Schmidt Triggers. I may build it to see how much of a problem it is.

    [​IMG]
     
  14. tom66

    Senior Member

    May 9, 2009
    2,613
    214
    Just make sure when testing these designs to have a rock solid Vcc. Any changes in Vcc will be directly reflected onto the output.

    Also it's unnecessary to have a push pull design unless your Vcc is too low to provide a decent output. You could use a capacitor to couple the signal. The filter inductor might be optional, as the speaker itself acts as part of the filter, although not in all cases.
     
  15. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,766
    2,536
    The thing is, it is a pure LC filter that should block the carrier, which I'm thinking should be quite high (100Khz or so).

    I really do think shoot through is going to be a killer though. I have a back up plan or two to deal with it.

    I'll go for max Vcc on the chips, that will define the maximum power out. I probably need to buy a more powerful speaker.

    For those whom it isn't obvious, the pot is to balance the sides, and zero the voltage across the speaker when it is quiet.
     
  16. tom66

    Senior Member

    May 9, 2009
    2,613
    214
    Prototype? Put a bigger heatsink on the devices :D. Doing it properly? You can buy gate driver ICs like LTC4442 which have integrated shoot-through protection. You could use a high voltage at the middle node to inhibit the lower gate drive (use a Schmitt AND gate for the bottom) and vice versa for the top. Use a 22 ohm gate resistor to limit ringing.

    It's not just max Vcc but making sure the Vcc doesn't ripple or drop under heavy load. If it does, it will add distortion, unless you have feedback to compensate but it still won't be very good. I highly recommend high performance electrolytics (at least 1500u for 30W output @ 12V with 1m of power cabling) right near the battery/power input and you should decouple your MOSFETs with a 2.2u poly and 100n ceramic tied near the drain of the top FET to a good ground with the shortest possible leads. Note high performance != RadioShack specials. Low-impedance electrolytics only, preferably good manufacturers and not CapXon etc.
     
  17. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,766
    2,536
    You miss the point of projects like this, no specialized parts, minimum parts count. Keep It Simple Stupid (KISS). Done correctly you will not need heatsinks, the whole point of of Class D is PWM. The transistors are on/off, and not running in analog. Shoot though would be what generates heat, if the transistors lasted long enough.

    Ideally it should be easy to follow and understand, so new users can pick up on it.
     
    Last edited: Dec 25, 2011
  18. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Bill, why not use one of the standalone class-D amp chips that are already out there? There are a heck of a lot of them now and they are simple enough to use. :)
     
  19. Wendy

    Thread Starter Moderator

    Mar 24, 2008
    20,766
    2,536
    Again, this is not really the point. This not meant to be a practical circuit per se, but a teaching circuit. If it works it could wind up as a learning project.

    If I were truly serious about this I would definitely use a linear ramp generator.
     
  20. bertus

    Administrator

    Apr 5, 2008
    15,649
    2,348
Loading...