3

I designed a simple class D amplifier based on theory (output stage not pictured):
KiCad schematic

Layout(ish, the board was modified in a few places, the whole top part is a separate PCB soldered into where some really bad design was dremeled out): pcb layout The IC not on the schematic is LTC3261.

After assembling it I measured the inputs and outputs of the comparator with an oscilloscope and noticed some unexpected oscillations:

oscilloscope capture 1 is -, 2 is +, 3 and 4 are the outputs.
What causes those? How should I eliminate them?

EDIT: I added a 470K feedback resistor which partially solved the problem (accidentally swapped channels 1 and 2): second capture Is there anything else I should try?

EDIT2: I accidentally found out the ringing is gone when measuring only the outputs (with no resistor added) indicating the oscilloscope is at fault somehow? Shouldn't the 13pF capacitance be too small to cause such a strong effect? oscillogram with outputs without ringing

Chumanista
  • 159
  • 2
  • 10
  • Have you bypassed the ICs? Comparators have very high gain; if you don't swamp any stray feedback with hysteresis (which is probably not a good idea for a class D amp) then you need to be careful about circuit layout and stray ground loops. – TimWescott May 30 '19 at 22:15
  • @TimWescott Yes, there are 2.2uF bypass capacitors near every IC on the board. – Chumanista May 30 '19 at 22:17
  • I mean, the frequency of the triangle wave is 500kHz so not _quite_ audio but mostly because I had no idea what I really needed. I'll add smaller capacitors in parallel and report back. – Chumanista May 30 '19 at 22:26
  • These are nanosecond risetime comparators and amplifiers with hundreds of MHz of bandwidth. 2.2uF caps (even 100nF sometimes) have too high an inductance for the such high speed components. With those risetimes, layout also matters. Why are you even using such components for audio? Low propogation delays and transition times are nice, but the higher speed the component, the more oscillations are a problem. – DKNguyen May 30 '19 at 22:26
  • Adding caps of different values in parallel introduces anti-resonance spikes which can make things worse. You casually mentioned adding capacitors...is this on a breadboard? If so, the breadboard inductances can make things difficult for such high speed components. – DKNguyen May 30 '19 at 22:32
  • 1
    No, it's on a PCB but 1206 is pretty simple to stack. – Chumanista May 30 '19 at 22:33
  • So stacking didn't really help, I have 220nF, 100nF 10nF and 1nF (all ceramic), what to try next? – Chumanista May 30 '19 at 22:39
  • Add a small resistor between the input and non-inverting terminal of the comparator for hysteresis. – DKNguyen May 30 '19 at 22:40
  • How small is small and which input? – Chumanista May 30 '19 at 22:41
  • Sorry, I meant a large resistor. Small resistors increase positive feedback and make for a stronger hysteresis but also makes the comparison less accurate as a result. But you can just calculate the hysteresis you want. http://www.ti.com/lit/ug/tidu020a/tidu020a.pdf Make it a bit more than the noise present in your input. – DKNguyen May 30 '19 at 22:43
  • The PDF seems to deal with the cases where the reference is set by a resistor divider which is not really the case here, does that change anything? – Chumanista May 30 '19 at 22:45
  • A bit. Either way it's making the signal on the non-inverting terminal need to fight harder to flip the comparator. It's all relative. Moving reference and fixed input vs moving input and fixed reference. Does the comparator really know the difference? Your hysteresis might vary a bit with your input signal though. – DKNguyen May 30 '19 at 22:48
  • @DKNguyen I added a feedback resistor, it seems to have helped somewhat (image in the post). – Chumanista May 30 '19 at 23:02
  • Is it better? it's hard to compare since you're zooming in compared to the first image. Just keep increasing the hysteresis by decreasing the resistor value...I guess. Zoom in hard and see if there is a 1:1 relationship between the input oscillations and the output oscillations. – DKNguyen May 30 '19 at 23:04
  • I have discovered something else. It I just measure the outputs and not the inputs 90% of the ringing is gone, which seems to indicate the measurement disrupts the circuit somehow. – Chumanista May 30 '19 at 23:08
  • What if you probe just one input line at a time? Maybe the AD8038 is having trouble driving the capacitive load. Is your probe 10x or 1x? – DKNguyen May 31 '19 at 00:09
  • A 500 kHz circuit with a 4 ns comparator on a single-sided pcb? Say no more, say no more. If you MUST do this, at least have the decency to make the ground a relatively wide loop all the way around the board. If you want it to work, a ground plane is virtually mandatory, so you need a double-sided board. At the least. – WhatRoughBeast May 31 '19 at 00:24
  • @DKNguyen stock Rigol probes at 10x. I'll check one input. – Chumanista May 31 '19 at 09:30
  • @WhatRoughBeast I mean, it seems to work without probes on the input. And one sided board was practically a project requirement (college assignment). – Chumanista May 31 '19 at 09:31
  • Probing just one input causes significantly less ringing than both. The audio input is more sensitive than the sawtooth. – Chumanista May 31 '19 at 09:52
  • @Chumanista - Well, if you must, you must. If you're in a position to redo the entire board, I'd suggest moving the two output pins (JP1 and JP3) up near the comparator and C8 up and inwards. This would allow you to run your ground all the way around the periphery of the board to form a bad ground plane - bad is better than none. However, if you're stuck with a single trace, what's the green trace connecting +5 down near the bottom? – WhatRoughBeast May 31 '19 at 18:34
  • @WhatRoughBeast TBH I don't _need_ this to work perfectly, it is already good enough to pass the course. I'm just trying to learn as much as I can at this point. If I were to redesign it I'd order a proper 2 layer board. That "trace" is a placeholder for where a jumper goes. And the output pins are really jumpers to the output stage. – Chumanista May 31 '19 at 19:22

2 Answers2

2

Comparators need hysteresis (positive feedback) or need to be designed to be stable in the linear region.

Real signals are noisy and will jump above and below the comparator thresholds or hang around in the linear region and cause those oscillations. That's probably why you're getting oscillations on your output waveforms.

Oscillations on your input waveforms might be due to insufficient decoupling at high frequencies while the comparator is going crazy in the linear region.

DKNguyen
  • 54,733
  • 4
  • 67
  • 153
0

What is the power-supply-rejection of this comparator, at 10MHz or 100MHz? About 0dB.

Install a 3.3 ohm resistor in the comparator VDD path, and bypass the VDD pin to the (3?) GNd pins and to bottom of the Volume Control.

Use a Ground plane.

Another feedback path is the internal GND rail and -VDD rail and +VDD rail of the comparator; output ESD diodes will couple to each of those comparator rails, which will bound around, and then couple the rail trash to both the analog input pinds thru the ESD diodes on Vin+ and Vin-

I suggest 100 ohm resistors located right at the comparator, in series with Q and qx outputs.

Also bypass Vin with 100pF right at Vin pin; and isolate that pin from the opamp with 1Kohm resistor.

analogsystemsrf
  • 33,703
  • 2
  • 18
  • 46
  • Could you explain the changes you are suggesting in more detail so that I can figure it out myself next time? – Chumanista May 31 '19 at 09:53