Feedback between multivibrator and opamp integrator?

Thread Starter

hrs

Joined Jun 13, 2014
400
Hi,

When integrating the square wave of a two transistor multivibrator the resulting triangle wave slowly runs of to the positive or negative power rail depending on reference voltage (please refer to astable tri.png). I'm guessing this is due to the lack of feedback from the integrator back to the multivibrator. In contrast the attached opamp tri.png doesn't have this problem, probably because it has feedback.

Is there a way to apply feedback from the output of the opamp integrator to the multivibrator? I tried inserting the output of the opamp through a resistor into various points in the multivibrator without success.

P.S. I understand that the opamp in opamp tri.png should actually be a comparator but I can't find any push-pull comparators that are through-hole and accept more than 7V supply voltage. At higher frequencies the slew rate of the opamp square wave generator becomes noticeable making the trianlge no longer linear. This is why I'm trying out a discrete multivibrator.
 

Attachments

MrChips

Joined Oct 2, 2009
30,821
An integrator is doing integration, i.e. summing. That is the meaning of integration.
If the average value is non-zero, over time, the sum is going to hit the positive or negative supply rail.
Any DC offset in the signal will cause this to happen.

What you need is a "leaky" integrator, that is, a way to bleed off the accumulating sum.

Put a resistor across the integration capacitor.
 

Thread Starter

hrs

Joined Jun 13, 2014
400
An integrator is doing integration, i.e. summing. That is the meaning of integration.
If the average value is non-zero, over time, the sum is going to hit the positive or negative supply rail.
Any DC offset in the signal will cause this to happen.

What you need is a "leaky" integrator, that is, a way to bleed off the accumulating sum.

Put a resistor across the integration capacitor.
That works great (100k to 470k)! But then I wonder why don't the opamp based circuit or the circuit by crutschow require a leaky integrator?

How high in frequency do you want to go?

Below is the LTspice simulation of a triangle generator using LM339 comparators, running at over 200kHz.
200kHz is more than I was hoping for thanks :). When I was playing around something like this I never managed a nice looking square wave beyond ~50kHz out of it.
 

crutschow

Joined Mar 14, 2008
34,459
....But then I wonder why don't the opamp based circuit or the circuit by crutschow require a leaky integrator?
Because the integrator is part of a feedback loop that prevents the integrator output from going to the rails.
When I was playing around something like this I never managed a nice looking square wave beyond ~50kHz out of it.
Try reducing the value of RL to around 2kΩ.
 

Thread Starter

hrs

Joined Jun 13, 2014
400
Can the circuit from post #3 actually be made to work using a comparator as integrator?

In trying to figure out if the integrator would need to be in linear mode or not I concluded that it would need to be linear. Then I did some tests. Please refer to "linear comparator.png". In the simulation the comparator behaves just like an opamp. Building this circuit on a breadboard resulted in a ~600 kHz sawtooth-ish waveform. So apparently my LM339 model has its limitations.

Building "triangle generator.png" resulted in something not so great where there should have been a triangle and a flat line where there should have been a square wave.

Edit: And replacing the comparator (LM393) from "triangle generator.png" with a TL072 produced a nice square wave and a not so nice triangle because R3 150k is too low, but other than that it worked.
 

Attachments

Last edited:

crutschow

Joined Mar 14, 2008
34,459
Building "triangle generator.png" resulted in something not so great where there should have been a triangle and a flat line where there should have been a square wave.
I see no reason for not getting a square-wave from the circuit.
Can you post a picture of the waveform with voltage levels shown?
 

Thread Starter

hrs

Joined Jun 13, 2014
400
I've changed R3 from 150k to 180k as I don't have 160k. It's still using 2 9V batteries so I get a low impedance ref voltage. And the IC is bypassed from V+ to V-.

All photos are at 2V/div so top to bottom of the screen is from +8V to -8V. Time base is 2μs/div so the frequency is in the order of 100 kHz. The probe looks like it's correctly compensated for 1X and 10X. Scope set to DC-coupled.

#1 is the triangle output with the probe set to 1X.
#3 is the squarewave output at 1X, latched to V-.
I noticed the triangle output changed dramatically when setting the probe to 10X, see #2.
Then I noticed that if I grab the resistor lead of R2 at the output of the integrator, the squarewave shows up. See #4 and #5 at 1X and 10X respectively and also the schematic where that node is marked.
Therefore I put a 100pF cap from that node to V- with the resulting waveform in #6. At this point the triangle output looks alot like #1 at 1X and 10X.

Am I correct to think that an integrator must operate in linear mode whether it's an opamp or a comparator?
If so, what keeps the comparator from oscillating? Well ... mine still is but that's work in progress. Is the LM393 slow enough that you can sometimes get away with it? I'm not sure what the gain is of this integrator.
Would it help if I soldered this on a perfboard? I'm guessing I'm running into parasitic something of the breadboard.
 

Attachments

crutschow

Joined Mar 14, 2008
34,459
Am I correct to think that an integrator must operate in linear mode whether it's an opamp or a comparator?
Half correct.
It operates in the linear mode as an integrator, but in the non-linear (switching) mode as a comparator.
It's quite possible that the LM339/393 Spice model I have does not properly represent its operation in the linear mode and that's why you have the integrator oscillations, so you may need to use a high-speed op amp for the integrator.
 

Thread Starter

hrs

Joined Jun 13, 2014
400
I have tried various other comparators baked into LTSpice and they all seem to happily operate in linear mode. Anyway, this exercise cleared up some of my confusion. Thanks for your help!
 

Thread Starter

hrs

Joined Jun 13, 2014
400
I've got a related thread going here but I think it's best to keep my triangle rambling confined to this one.

After updating it I have a triangle running at ~370kHz and about 13V peak to peak. Reducing C2 to 47pF and R5 to 15k increased the frequency by a lot, but also the amplitude, clipping the triangle. I guess the hysteresis of the comparator sets the limits at which the triangle switches. But with a low R5, C2 charges so fast an even narrower hysteresis band can no longer compensate for the triangle amplitude. In the below diagram I can pull out R2 and it hardly makes a difference.

What else can be done to limit the triangle amplitude?
EDIT: And since it keeps running without R2, does this mean the LM393 has a tiny bit of built-in hysteresis?

triangle generator.png
 
Last edited:

RichardO

Joined May 4, 2013
2,270
I guess the hysteresis of the comparator sets the limits at which the triangle switches. But with a low R5, C2 charges so fast an even narrower hysteresis band can no longer compensate for the triangle amplitude.

What else can be done to limit the triangle amplitude?
The reason the triangle amplitude is higher at higher frequencies is that there are delays in the feedback circuit.

Here is what happens...
When the triangle wave reaches the threshold the comparator output starts to change. Once the comparator output has completely changed from one state to the other, the op-amp can now start to integrate. But, the op-amp also has some delay so its triangle output does not happen immediately. Finally, the triangle is now back at the comparator input. For the entire time that the comparator and op-amp are delaying the triangle, the triangle is getting larger in voltage.

So, the way you get the triangle to stay at a constant amplitude at all frequencies is to have the delay small compared to the period of the triangle. One partial fix is to put a small capacitor across the input resistor to the comparator (R1 in your circuit). It will help a bit but the cap starts losing its effect as its impedance approaches the value of R1.

Try simulating the circuit with a faster op-amp and comparator and see what happens.
 

RichardO

Joined May 4, 2013
2,270
If the triangle wave looks okay, than all you likely need is a faster comparator.
Agreed. The op-amp is usually a small part of the delay.

You can learn a lot by speeding up the comparator. Once there are no more improvements with faster comparators, you can try changing to a faster op-amp.
 

Thread Starter

hrs

Joined Jun 13, 2014
400
The reason the triangle amplitude is higher at higher frequencies is that there are delays in the feedback circuit.

Here is what happens...
When the triangle wave reaches the threshold the comparator output starts to change. Once the comparator output has completely changed from one state to the other, the op-amp can now start to integrate. But, the op-amp also has some delay so its triangle output does not happen immediately. Finally, the triangle is now back at the comparator input. For the entire time that the comparator and op-amp are delaying the triangle, the triangle is getting larger in voltage.

So, the way you get the triangle to stay at a constant amplitude at all frequencies is to have the delay small compared to the period of the triangle. One partial fix is to put a small capacitor across the input resistor to the comparator (R1 in your circuit). It will help a bit but the cap starts losing its effect as its impedance approaches the value of R1.
Thanks RichardO! The how and why really helps. With a 47pF cap across R1 and various other changes I managed to get a nice looking triangle at around 440kHz, but at much lower amplitude than the square wave. I'll need to calculate the wave form slew rate at various frequencies and compare to the opamp slew rate. Much more experimentation to be done here. I tried 47, 100, 220 and 470 pF ceramic caps here without seeing any obvious difference but I need to take a closer look.
If the triangle wave looks okay, than all you likely need is a faster comparator.
You can learn a lot by speeding up the comparator. Once there are no more improvements with faster comparators, you can try changing to a faster op-amp.
The LM319 looks like an affordable step up, I'll buy some of those. I've got a few OPA2604s too, though from a dubious ebay source so might not be the real deal, but they are difficult to stabilize. The datasheet recommends tantalum caps which I don't have so I'll get some of those too. If you know of a fast cheap opamp you'd recommend, preferably DIP, I'd love to know!
 

RichardO

Joined May 4, 2013
2,270
The LM319 looks like an affordable step up, I'll buy some of those. I've got a few OPA2604s too, though from a dubious ebay source so might not be the real deal, but they are difficult to stabilize. The datasheet recommends tantalum caps which I don't have so I'll get some of those too. If you know of a fast cheap opamp you'd recommend, preferably DIP, I'd love to know!
The LM319 will definitely help. You will want to put a pullup resistor on the output to get a more symmetrical output voltage swing.

You can also reduce the resistor values around the LM319 to reduce the effects of stray capacitance. A solderless breadboard has a few picofarads between contact strips.

A word of warning. It is now time to quit using long insulated jumper wires in your circuit. I recommend using bare resistor leads left over from trimming the excess so they have short leads in the breadboard.

If you want more solderless breadboard tips let me know. :D
 

Thread Starter

hrs

Joined Jun 13, 2014
400
The LM319 will definitely help. You will want to put a pullup resistor on the output to get a more symmetrical output voltage swing.
Are you implying that an LM319 can do without? I thought all open collector comparators need a pull-up.

You can also reduce the resistor values around the LM319 to reduce the effects of stray capacitance. A solderless breadboard has a few picofarads between contact strips.

A word of warning. It is now time to quit using long insulated jumper wires in your circuit. I recommend using bare resistor leads left over from trimming the excess so they have short leads in the breadboard.

If you want more solderless breadboard tips let me know. :D
Will do :) I thought those SIP boards for your oscillator are a great idea!
 

RichardO

Joined May 4, 2013
2,270
Are you implying that an LM319 can do without? I thought all open collector comparators need a pull-up.
Will do :) I thought those SIP boards for your oscillator are a great idea!
Oops. I forgot that theLM319 is open collector. I was thinking of the LM361. Much faster and has totem-pole outputs but requires a -6V :eek: power supply in addition to the +5 volt supply.

You may be able to track down a NE521 or SN75107A. They are similar to the LM361 but can use -5 volts instead of -6 volts for the negative supply. Both appear to be available in DIP. :D


There is more here on my high frequency function generator circuits:
https://forum.allaboutcircuits.com/threads/thoughts-on-a-high-frequency-function-generator.142253/


p.s. In your circuit, I would change R1 to about 5K, R2 to about 10K and R3 to about 470 ohms. This will make your circuit on a solderless breadboard work more predictably at high frequencies. The triangle wave will be much larger in amplitude -- which is good.

p.p.s For your amusement, I have attached a schematic for a 10MHz function generator I made many years ago. (It uses the NE521 and lots of other old and obscure parts). I still use this generator as my main signal source. :D:D
 

Attachments

RichardO

Joined May 4, 2013
2,270
p.s. In your circuit, I would change R1 to about 5K, R2 to about 10K and R3 to about 470 ohms. This will make your circuit on a solderless breadboard work more predictably at high frequencies. The triangle wave will be much larger in amplitude -- which is good.
@hrs:
I realized that with these values, the TL072 may saturate on the output. R1 might be better at 1K ohms.

Note that the TL072 may not work well on only a 5 volt power supply. The data sheet recommends a minimum of +/- 5 volts (a total of 10 volts) for proper operation.
The OPA2604 has similar power restrictions. You really need an op-amp with rail-to-rail outputs to work properly on a single 5 volt power supply.

It is not as fast but I like the TLC272 and similar parts for single supply applications.


p.s. I realized that you are confusing different reasons for hysteresis in a comparator. To _prevent_ oscillations it is common to use a high value resistor, such as your 4.7Meg, in the positive feedback. In this case, you _want_ oscillation. You select the ratio of the input and feedback resistors to set the amplitude of the triangle wave.
 

Thread Starter

hrs

Joined Jun 13, 2014
400
@hrs:
I realized that with these values, the TL072 may saturate on the output. R1 might be better at 1K ohms.
From experimenting I didn't see much voltage gain for the triangle when lowering R1. I think the typical sink current for the LM393 is 16mA but I can't find it in the datasheet right now. This may be one reason crutschow has a 2k pull-up resistor.
But apart from these things, the reason for lowering this value is perhaps to reduce the time constant associated with stray capacitance of the breadboard?

Note that the TL072 may not work well on only a 5 volt power supply. The data sheet recommends a minimum of +/- 5 volts (a total of 10 volts) for proper operation.
The OPA2604 has similar power restrictions. You really need an op-amp with rail-to-rail outputs to work properly on a single 5 volt power supply.

It is not as fast but I like the TLC272 and similar parts for single supply applications.
I'm not too concerned with low supply voltages right now, for one because it allows me to properly drive most opamps that I have. The 16V comes from two dying 9V batteries. I came across the LM318 which has a very high slew rate, might be a good part.

p.s. I realized that you are confusing different reasons for hysteresis in a comparator. To _prevent_ oscillations it is common to use a high value resistor, such as your 4.7Meg, in the positive feedback. In this case, you _want_ oscillation. You select the ratio of the input and feedback resistors to set the amplitude of the triangle wave.
Yes, I see how the hysteresis thresholds set the triangle amplitude given a fast enough comparator. Going by your instructions I lowered the resistor values of the hysteresis ratio. This had great effect on the triangle amplitude though I don understand why.

Anyway, I get 600kHz now and the waveform isn't too bad. After de-sloppifying the breadboard the squarewaveform improved, but the triangle still has a slight nick at the tops. EDIT: The 47pF speed-up capacitor across R1 is missing from the diagram.
600kHz triangle generator.png 600kHz waveforms.JPG
EDIT2: P.s. Thanks for your 10MHz circuit! It is way beyond me but I'll study it and see if I can make sense of parts of it.
 
Last edited:
Top