Op-amp switching threshold problem

Thread Starter

mondo90

Joined May 16, 2025
125
How linear do you need your triangle-wave? If you class-D is open-loop then it needs to be really accurate. If you have feedback, then less so. Maybe a 555 might do it? Or if it has to be straight, a 555 and a couple of current sources?
Sounds like you suggest 555 with RC time constant to get a ramp but I am afraid it won't be accurate enough. I am not sure about the output feedback yet. In class D it is more challenging then AB. For now I think I would like to generate a clean triangle waveform of min 200khz (10x audio frequency). I used standard frequency formula and got R3 - 10k and C1 = 625pF for 200kHz:
1759128936133.png

But the problem is, with these values I only got ~60khz as you can see on the pop up window. Worse still, my amplitude is messed up as well - from perfect +/-1V to +/- 2.5 roughly. While I think I can explain the frequency problem by usage of op amp in place of a comparator, I wonder why the amplitude is messed up? After all the R2/R1 ratio should keep it constant? Or is it because it also doesn;t catch up with the speed of oscillation?

That depends if whoever made the model remembered them! Just add a voltage probe between the two inputs, and if it ever exceeds 0.6V in either direction they are missing. Just add them in with a couple of external 1N4148s and you'll see what will really happen.
Notice that each of the amps have one input grounded therefore it needs to exceed +/-1V Threshold to overcome the feedback ratio and we see it indeed happens from my waveforms. Looks like the diodes are not modeled then.
 

0ri0n

Joined Jan 7, 2025
173
But the problem is, with these values I only got ~60khz as you can see on the pop up window. Worse still, my amplitude is messed up as well - from perfect +/-1V to +/- 2.5 roughly. While I think I can explain the frequency problem by usage of op amp in place of a comparator, I wonder why the amplitude is messed up? After all the R2/R1 ratio should keep it constant? Or is it because it also doesn;t catch up with the speed of oscillation?
The slew rate of the LT1677 is only 2.5V/us. It takes the opamp 80% of the expected triangle 5us (200kHz) period, plus some additional time to get out of saturation, just to switch once between the 5V rails. That's not gonna work out like you hoped for. Your LTspice plot, showing a sine instead of triangle wave, with the wrong frequency and amplitude, confirms it.
The reality is you simply need a comparator with very low delay + push pull outputs in the square wave stage and, with very high probability, also a faster opamp in the integrating stage.
 

Thread Starter

mondo90

Joined May 16, 2025
125
I think I can find such a "fast" comparator in a local store. However for now I would like to get a general topology in place first. For that I have added one more comparator in order to modulate the PWM signal, and it looks OK (red signal below)
1760079605547.png

However, I got stuck on the final output stage. I can't get the low pass filter to reconstruct the signal waveform right. If I connect what the LC filter shown on my schematic the U3 output is heavily distorted, amplitude is gone too. How to cure it?

Thank you.
 

Ian0

Joined Aug 7, 2020
13,132
I think I can find such a "fast" comparator in a local store. However for now I would like to get a general topology in place first. For that I have added one more comparator in order to modulate the PWM signal, and it looks OK (red signal below)
View attachment 357002

However, I got stuck on the final output stage. I can't get the low pass filter to reconstruct the signal waveform right. If I connect what the LC filter shown on my schematic the U3 output is heavily distorted, amplitude is gone too. How to cure it?

Thank you.
That’s because a LT1677 won’t drive an 8Ω load. Before you get the output power stage built, use 1k, and adjust the L and C accordingly
 

MrAl

Joined Jun 17, 2014
13,708
I think I can find such a "fast" comparator in a local store. However for now I would like to get a general topology in place first. For that I have added one more comparator in order to modulate the PWM signal, and it looks OK (red signal below)
View attachment 357002

However, I got stuck on the final output stage. I can't get the low pass filter to reconstruct the signal waveform right. If I connect what the LC filter shown on my schematic the U3 output is heavily distorted, amplitude is gone too. How to cure it?

Thank you.
Is that schematic missing a connection between R4 and L1?
What does "1p" mean for L1.

Or, are you saying that the output of the LT1677 is distorted even without the load connected?

Assuming the load is connected...
When you look at the waveform on the output you have to realize that all the components play a part in the response. That includes R4, L1, C2 and R6, as well as any output impedance of U3.
Op amps CAN have nearly zero output impedance, but when they are in steep transition zones that can change dramatically. If the output is not too loaded though we can often assume zero output Z to start with, and modify it later if the need arises.
Assuming Z=0 for now, the output transfer function U3 output to Vout (vR6) is:
vR6=(VoutU3*R6)/(s*C2*R4*R6+s^2*C2*L1*R6+R6+R4+s*L1)

The impedance seen by the output of U3 is:
Z=(s*C2*R4*R6+s^2*C2*L1*R6+R6+R4+s*L1)/(s*C2*R6+1)

and this gets fairly low even when L1=0.1uH, around 15 Ohms at the fundamental frequency of 200Hz.

The LT1677 looks like it has a 20ma max output current, so for example with a 15 Ohm output load the max output voltage would be maybe 0.3 volts peak, so half of that is around 0.15 volts peak. You could try adjusting for 0.1 volts peak output to see if the distortion clears up. In the future though, you'd most likely need some sort of output buffer.
 

Thread Starter

mondo90

Joined May 16, 2025
125
@MrAl, @Ian0 thanks, my bad assuming the LT1677 will drive 8 Ohms. I Have corrected that and here is the updated version together with all key waveforms:
1760119429834.png

Since I don't have proper op amps for audio frequency my experiment here is a bit odd because it assumes the audio signal is 100 Hz only (still within audio spectrum though). However, as you can see the output waveform is still distorted a lot + resembles the input triangle more than a sine. Why is it happening?
 

Ian0

Joined Aug 7, 2020
13,132
@MrAl, @Ian0 thanks, my bad assuming the LT1677 will drive 8 Ohms. I Have corrected that and here is the updated version together with all key waveforms:
View attachment 357015

Since I don't have proper op amps for audio frequency my experiment here is a bit odd because it assumes the audio signal is 100 Hz only (still within audio spectrum though). However, as you can see the output waveform is still distorted a lot + resembles the input triangle more than a sine. Why is it happening?
Looking at your graph, it seems that your triangle wave is not much faster than 1kHz. Your output will switch at 5kHz and be modulated by your input signal. Your filter rolls off at 5kHz, so all that 1kHz energy is going straight through the filter.
For Class-D audio, your triangle wave should be several hundred kHz, and your filter 20kHz. That would mean that the filter removes most of the energy at the switching frequency, which is the frequency of your triangle-wave
 

Thread Starter

mondo90

Joined May 16, 2025
125
Looking at your graph, it seems that your triangle wave is not much faster than 1kHz. Your output will switch at 5kHz and be modulated by your input signal. Your filter rolls off at 5kHz, so all that 1kHz energy is going straight through the filter.
For Class-D audio, your triangle wave should be several hundred kHz, and your filter 20kHz. That would mean that the filter removes most of the energy at the switching frequency, which is the frequency of your triangle-wave
Yes, my triangle waveform is exactly 1khz. This should be enough for the input sine wave for 100 Hz (10x faster sampling). How did you calculate my output will switch at 5kHz?
 

Ian0

Joined Aug 7, 2020
13,132
Yes, my triangle waveform is exactly 1khz. This should be enough for the input sine wave for 100 Hz (10x faster sampling). How did you calculate my output will switch at 5kHz?
No, the output switches at the same frequency as the triangle-wave. The filter will roll off at about 1/(2π√(LC)) which is 5033Hz. The purpose of the filter is to remove the switching frequency, and output the restored analogue signal.
 

Thread Starter

mondo90

Joined May 16, 2025
125
No, the output switches at the same frequency as the triangle-wave. The filter will roll off at about 1/(2π√(LC)) which is 5033Hz. The purpose of the filter is to remove the switching frequency, and output the restored analogue signal.
Ok, I know what you mean, my calculations for the 3db frequency were a bit off, I have corrected them and it looks much better now:
1760135195622.png

The output waveform is far from being perfect still. I was trying to fix it with negative feedback formed by R5 and R7 but it didn't help a single bit. What can I do for that?
Also, is there an option to search the DB of part in Ltspicie for an fast enough op amp with a slew rate aproproate for this use case?

@crutschow, I have attached it, please take a look.
 

Attachments

MrAl

Joined Jun 17, 2014
13,708
@MrAl, @Ian0 thanks, my bad assuming the LT1677 will drive 8 Ohms. I Have corrected that and here is the updated version together with all key waveforms:
View attachment 357015

Since I don't have proper op amps for audio frequency my experiment here is a bit odd because it assumes the audio signal is 100 Hz only (still within audio spectrum though). However, as you can see the output waveform is still distorted a lot + resembles the input triangle more than a sine. Why is it happening?
Hi,

You have to look at the transfer function of your output filter, including the load R6.
When we do this, we find that the cutoff frequency is close to 11205Hz. That is too high to filter out the required harmonics of the rectangular wave out of the LT opamp.

If you assume that the highest audio frequency is only 100Hz (for initial testing) then your filter cutoff could be possibly as low as 200 to 300Hz, but the lowest switching frequency Fsw would be maybe 500Hz. It looks like maybe your Fsw is 600Hz perhaps? That's good, but then the filter cutoff frequency has to be much lower than 11kHz.

You have to also avoid LC resonance. As you did you included a series resistance R4 which is great. You may also want to use a spread spectrum technique that modulates the switching frequency slightly, like maybe plus or minus 20 percent. So in this case that would mean going from maybe 500Hz to 700Hz centered on your target of 600Hz.
You could look into this later if you like.
 

crutschow

Joined Mar 14, 2008
38,525
Below is the circuit modified with a typical high frequency op amp to generate an approximate 100kHz PWM frequency, driving the equivalent circuit for a typical 8Ω speaker.
The E1 VCVS acts as an ideal gain-of-one power amp to drive the low speaker impedance.
The yellow trace shows the speaker current.
The 100kHz ripple in that current will be inaudible, of course.

1760200400315.png
 

Attachments

Ian0

Joined Aug 7, 2020
13,132
LT1633 is another op-amp that's not advisable to use as a comparator, because of the clamping diodes across the inputs.
Screenshot from 2025-10-11 18-04-29.pngbut @crutschow's skill as a designer means he carefully chose the values of R1 and R2 to prevent the voltage between the inputs exceeding 1.2V
 

crutschow

Joined Mar 14, 2008
38,525
LT1633 is another op-amp that's not advisable to use as a comparator, because of the clamping diodes across the inputs.
I didn't look into that.
I just picked an op amp fast enough to demo a 100kHz sawtooth in the sim, not that it would necessarily be one to use in an actual circuit.
 

Ian0

Joined Aug 7, 2020
13,132
I didn't look into that.
I just picked an op amp fast enough to demo a 100kHz sawtooth in the sim, not that it would necessarily be one to use in an actual circuit.
I've seen SPICE models with those diodes missing. So they work as comparators in SPICE but not in real life.
 

Thread Starter

mondo90

Joined May 16, 2025
125
@crutschow, thank you for that. I wonder, if you increased the carrier frequency why didn't you also increase the input signal frequency? If you had done that, you would have seen the output gain is gone with input as low as 1kHz:
1760203648446.png

Did you forget and left the LP filter values for 1khz?
Also, I have added the 8Ohm speaker in parallel to your speaker model but I think this 8 ohms are already in R5 right?

@Ian0, thanks for keeping an eye on the easily overlooked clamping diodes issue.
 

crutschow

Joined Mar 14, 2008
38,525
the output gain is gone with input as low as 1kHz:
I see no loss (below):
Did you forget and left the LP filter values for 1khz?
There is no "filter", only the speaker equivalent circuit, which is basically valid over the speaker's operating frequency range.
this 8 ohms are already in R5 right?
It's mostly R4.
The speaker' equivalent model emulates the complete speaker impedance.
Adding another 8 ohms destroys that model.
If it needed that, I would have added it.

1760206284294.png
 

Thread Starter

mondo90

Joined May 16, 2025
125
There is no "filter", only the speaker equivalent circuit, which is basically valid over the speaker's operating frequency range.
Oh, this is because you are tracing a current on R4, sorry I missed that. However, is that a correct way to apply the PWM directly into the load? Theoretically the PWM output should go through a low pass filter to remove the switching frequency right?
Also, for 1kHz your output sill looks OK with 3A P2P, however increase it to 20kHz and you get:
1760207055652.png
 

Ian0

Joined Aug 7, 2020
13,132
Because the speaker is an inductor, there is no specific need for any filtering, the inductance of the speaker does the filtering for you.
However, if your amplifier and speaker are not in the same place, or you have no control over what anyone might connect to the amplifier, then a filter is a good idea. It eliminates the radiation of interference from the cables, and it prevents anyone from connecting a really capacitive speaker and blowing it up.
 
Top