Sir this is a Wendy’s.
This problem is still bugging me because I want to be ableo to make a good sounding square-wave oscillator with PWM and a comparator is the best way to implement this AFAIK.
I managed to reproduce the problem using a very simple experiment. Basically, I’m using my signal generator to feed a triangle wave directly into a comparator, which is also getting a steady voltage configurable using a pot. I send the output directly to my scope and output module. Check out the video:
To my surprise, when I send a square from the signal generator into my comparator, the output is a perfect square wave that has nice squary high-end to it. When I send my triangle wave into the comparator, it sounds different and more muffled and I can see slow rising edge on my scope too.
The TL074 chip is one I got from Germany so it should be decent. Can it be the capacitance in the cables? Should I add some caps next to the TL074? I’m really at a loss as to why this is happening.
I did this simulation
It claims to be simulating a TL08x. How accurately, I don’t know. But the fact the triangle wave rises slower than square wave on input means the output will rise more slowly too. This is what I get:
So about 2 µs for the (100 Hz) square wave and about 28 µs for the triangle. I can’t tell from the video, is that much faster than what you see?
@analogoutput Thanks for the simulation. I repeated the experiment in circuitlab and I’m getting similar results.
If you pause the video around 40 sec, you can see that the rising edge takes about 0.25ms, which should cause distortions around 4Khz so that is clearly audible. This is an order of magnitude slower than what circuitlab suggests. See pic below:
However, when I look at the datasheet, I see that the TL074 should have a slew rate of 13V per microsecond, which is over 250 times better than what I’m seeing in practice.
I ran a test in circuitlab and putting two comparators in series will result in a nice square wave. However, I rather don’t want to add yet another opamp to my VCO and first I want to understand what is happening here.
Can any expert shed some light on this?
The slew rate would apply to the case where you apply a square wave to a comparator, not a triangle wave. It corresponds to what I see in the simulation where it goes -12 V to 12 V in about 2 µs with a square wave input.
I grabbed a TL072 out of my stash and took a look at it with a ~100 Hz square wave and triangle wave going in. The other op amp input was connected directly to ground:
That corresponds pretty well with the simulation, about 2 µs for the square wave input and about 30 µs for the triangle wave. It does look like yours is too slow though I’d be more confident of that if I saw it on a shorter scope time scale.
(I guess it’s similar to what you show in the first post of this topic? Is that the same op amp?)
I noticed the non inverting inputs on the unused sections of your TL074 are floating — in principle they should be grounded, with the inverting inputs connected to outputs (as yours appear to be). I doubt that has anything to do with what you’re seeing though.
I managed to fix the edge rise/fall by swapping the inputs to the comparator opamp!
First, I had the PWM reference voltage (from the knob) connected to the inverting input and the audio input to the non-inverting input and this resulted in rising falling edges that take 150+ microseconds. When I swap them around and connect audio to the inverting input instead, I get about 30-ish microseconds and a much crisper tone as well.
So apparently, a TL074 does not completely operate in a symmetrical fashion. Looking forward to hear your theories about this. Circuitlab does not simulate this behaviour so it is probably not very well known.
Thanks for all your help in this topic!
Unfortunately when I do that (and I switched from a TL072 to a TL074 just in case it mattered) I still see 30 µs either way.
Have you tried it with the reference pin tied to ground instead of a control voltage? I don’t know why that should matter but it’s the only thing I can think of that’s different between our setups.
I just wanted to weigh in here on possible fake TL074s from Amazon. I built a VCF some weeks ago that had some resonance and distortion issues that I chalked up to a mistake I probably made, but when I made a VCO around the AS3340 recently, I had a TON of distortion and clipping.
I rebuilt the VCO circuit on a breadboard and had the same issues. I swapped the TL074 IC with every one in the batch (I think I got 10) and had the same problems. I then had issues getting my CV voltages where I wanted them from a teensy DAC and PWM pin, which confused me because I used the same circuit from another project, but that one used a digikey TL072.
With all this, I decided to order 15 TL074 ICs from mouser and when I swapped the IC in the VCO with the mouser op-amp and the clipping and distortion went away. The output signal was very clean. So I went ahead and swapped out all the TL074s for the mouser chips and it resolved all of those problems listed above.
I’m not sure what chips I got from Amazon, but they are either faulty, or rebranded.
I got back to playing with my breadboarded VCO because I would like to design and order PCB’s for it so I also revisited this problem. It seems that allthough I managed to improve the clarity of my square-wave, doing the pulse signal myself using a comparator is really not as good as using the built in pulse output from the AS3340.
You can clearly hear it in this video. First the native 3340 pulse and then my own using the TL074:
I tried basing my pulse on the saw wave instead of triangle and that resulted in this interesting finding:
You see that the rising edge is slow but the falling edge is quite fast because the input signal also drops fast. I was under the impression that the chip’s slew rate was the bottleneck but it can do much faster. Though you can see that even the falling edge has a slight slowdown.
Still, it takes 20us for the rising edge to happen, as opposed to the 2us
So I think that even my “better” TL074’s are bad (I got them from reichelt). Where can I get ones that are fantastic and according to spec?
Not quite sure how to interpret the numbers there: What is the horizontal scale (ms/µs per division (square))? 20 µs?
Looks like the yellow trace is 4 Vpp (±2 V) so presumably isn’t directly the output of a comparator, what’s in between? Have you looked at the comparator output directly?
Thanks for the swift reply !
It says it in the bottom left corner. Horizontal scale is 20us.
The signals have indeed a different amplitude. My TL074 pulse (yellow) is 4Vpp while the AS3340 output is 8Vpp and scaled a bit to make it fit nicely on the screen.
I believe I still had a high-pass filter sit in the middle when I took this measurement for AC coupling. The bleu signal comes straight out of the 3340 and sits between 0 and 8 V. After AC coupling, its centered and then I connect it to the comparator.
Why? Are you powering the op amp with ±2 V? The output ought to be (somewhat close to) rail to rail.
Here is what I see with a TL072 I got from Tayda:
Time scale here also is 20 µs/div and both channels are 5 V/div. Op amp output (blue) is close to ±12 V. Rise is slower than fall, but under 10 µs, fall is maybe 1 µs. With a pulse wave the rise is faster:
but it’s not as fast with a sine wave:
It does take finite time for a comparator to switch on a slow rising input — depending on the open loop gain of the op amp, there is a narrow time window when the input is close enough to threshold that the op amp output is within the ±12 V range and follows the input upward. So you expect it to rise slower on slower rising inputs. (There’s more to it than this, though. You see both op amps rising while the input is going through too big a range for the above to explain it. They also doesn’t rise linearly like the input does. So something else is going on, but I don’t know anything more about the theory than that.)
I didn’t adjust things for a particularly careful match. Looks like your ramp wave goes up about 8 V in about 15x20 = 300 µs. Mine goes up about 10 V in about 150 µs. So mine’s rising roughly twice as fast, actually more than twice, and my op amp rise time is more than twice as fast. Seems to be about the same performance, then.
Added: That input pulse wave wasn’t particularly fast itself. Here’s a faster, digital pulse input. Op amp rise and fall both are about 1.5 µs. (Colors are switched here — blue is input, magenta is op amp.)
Something I was surprised by and have no explanation for: The rise and fall times depend on the comparator threshold. With a very low threshold (~100 mV) the rise time is fast, ~1.5 µs, but the fall time is very long.
As the threshold is raised the rise time stays about the same but the fall time shortens until it too is about 1.5 µs at a threshold around 2 V:
Once the threshold goes above about 3 V the rise time lengthens and the fall time stays short. At close to 5 V threshold the rise time is very long:
No idea why.
Added more: Anyway, the rise and fall times for a comparator topology depend on stuff external to the op amp. Per the datasheet the slew rate is measured with a unity gain amplifier topology:
(No word on where to get the special op amps that have the inverting and noninverting inputs misaligned.) I’m seeing a rise time (0 to 5 V) well under 1 µs:
The fall has a funny kink in it but is a similar speed:
This is in line with the minimum 8 V/µs, typical 13 V/µs from the datasheet.
Thank you for your excellent response. And apologies because I didn’t share all the information about the circuitry.
I take the AS3340 sawtooth and AC couple it so it is centered. Then I use an opamp as a comparator. After that, I use a voltage divider to get it to a more desirable Vpp and then I buffer it. This is what you are seeing on the pictures i posted previously. I felt that the voltage divider and the extra buffer were not relevant because they are clearly not causing the problem. However, you need to know about them to interpret the oscilloscope photo.
there is a narrow time window when the input is close enough to threshold that the op amp output is within the ±12 V range and follows the input upward
Yeah I figured something like that. But I expected the TL074 to be faster at this.
I have TL074CN chips I bought from aliexpress and I have TL074L which I have bought from reichelt. With a 4Vpp triangle wave from the AS3340, the rising edge from -12V to 12V takes about 50us (same for falling edge).
If I switch to the TL074L, there is a good improvement. The rising edge is now 20us. I’m sowing the falling edge but its identical to the rising edge.
Unfortunately, I don’t have a digital signal generator so I came up with another experiment. I decided to put two comparators in series, where the second one receives the output of the previous one (through a 100k resistor) which is compared to ground. This improves the rising and falling edges considerably. Here you see a comparison between the output of the first comparator and the output of the second:
So now we arrive at approx 5us for a ~22V rising edge. I’m not using the 2K / 100pF load mentioned by the datasheet but this is still not as good as the minimum 8 V/µs but its not too far off. If I add a third comparator in series, there is no further improvement, whic suggests that ~5us is as fast as it gets with this opamp.
I just tried adding the datasheet load to a single opamp comparator and it didn’t make much of a difference. If anything, the situation got slightly worse compared to no load.
I guess I can conclude that my TL074CN’s are garbage and my TL074L’s are not terrible but still not entirely up-to-spec. I’m considering to get another batch of opamps and compare them too.
Sounds about right. A non inverting amp with a fast rising/falling input makes a better speed check but the double comparator is OK provided the threshold is set to minimize it. TL074L I guess is a Unisonic part vs. TL074CN which is TI — if it’s genuine! The part I used above was a TL074CN.
Sorry to bump an old topic, but this thread is one of the more recent ones I could find on the web regarding this issue. I recently purchased TL074CN op-amps from both Mouser and Digikey, and neither of them can reproduce a 20 kHz square wave when configured as a voltage follower. I have a hard time believing both Mouser and Digikey would be distributing fake chips, but I’ve been pulling my hair out trying to figure out what’s wrong here. I also purchased TL072CP op-amps and they have no problems with the 20 kHz square wave. The relevant specs are exactly the same as the TL074CN, so I’m not sure what’s going on here. Any input would be appreciated.
Are the unused op amps in the chip properly connected (+ input to ground, - input to output)?
Yes they are. Also it’s being powered off a 12V supply.
±12 V?
What are the details of the input signal — low and high voltages? And what kind of rise/fall times do you see on the output?
It’s a single supply 12V. The input signal is being generated by a 555 timer which is powered by the same supply, so the signal is close to 12V. I attached a picture of what the output looks like.
Right now I just tried it again but this time used a voltage divider on the input signal to drop its voltage in half and now the TL074 works. What a surprise/relief, sort of. I guess the problem is related to the input voltage being too high?
But now my question is, why doesn’t the TL072 have any issues with the same input signal? Thanks for any insight into these op-amps.
TL074 output:
Yeah, the TL07x isn’t rail to rail so what happens at both ends of your square wave, near both your power voltages, isn’t guaranteed to be good.
The TL072 and TL074 having the same specs isn’t really relevant when the inputs are out of spec.
For either, to be sure it’ll behave well, the input range should be maybe 2 V to 10 V. (The datasheet doesn’t show valid voltage ranges for a single supply, so it’s hard to say.) If you need to deal with a 0 to 12 V square wave and use a single 12 V supply, you need something like an MCP6024 [edit: No, not that, see below] or other rail to rail device.