Convert 33Hz of Square wave signal of (0 to 3.3V) to 33Hz of Triangular wave of (0 to 3.3V) using only Integrator circuit

MrAl

Joined Jun 17, 2014
11,388
Hello again,

Here is a circuit.

The calculations for R1 and C1 are:
R1*C1=1/(4*F)

where F is the frequency (33Hz) so if you are using R1=1.1k then you need C to be 1/145200 Farads.

C2 is selected to have reactance less than 1 percent of R1 at 20 times the frequency F (F=33Hz).
This value is not critical as long as it is large enough.

Note R2 was made to be 1 megohm (1000k) and the output still looked decent even though there is a small output offset. You may have to go lower than that though in the real circuit.

If you still get those spikes then try using the post filter shown in the lower right hand corner of the drawing. Connect it to the output, and you may end up needing a buffer or you could try lower values of R4 with proportionally higher values of C4.
Note the output shown in the drawing though, using the LM358 spice model i had did not show any spikes, but in real life there probably will be anyway so consider the output filter if so.


Integrator-2.gif
 
Last edited:

MrAl

Joined Jun 17, 2014
11,388
Thanks Everyone for all the inputs, it really helped a lot.
It might help someone else too so I am uploading the final result.
This is the final circuit and Wave form.
Hi,

That's great, but i dont think you should have the 1uf cap directly on the output of the first op amp because it's not really made for that kind of load. At least a small resistance between the output and the cap is a good idea like 200 ohms minimum.
 

crutschow

Joined Mar 14, 2008
34,280
can you please walk me through the calculation of how did you decide to get this mentioned values so that i will have a better understanding in future.
I just tried a higher value R2, to see if a reduced output loading would help since the input current equals the output current due to the negative feedback (and of course this required a lower value for C1 to keep the desired integrator time-constant).
Not sure why the lower output loading reduced the output spikes, but the 741 is a very old, slow op amp, and the problem may be related to that. A faster op amp would likely not have those spikes.

I increased the value of R3 since the 100k ohm value caused a small noticeable curve in the triangle-wave.

I realized that the offset voltage applied to the plus op amp input was equal to the average value of the input square-wave, and that's what the input capacitor generates at its output, so C3 became redundant.
 

MrAl

Joined Jun 17, 2014
11,388
Hello again,

The tiny spike at the tip of the triangle is most likely due to the somewhat low impedance path around the op amp from input to output. The total "instantaneous impedance" of the path is only 1k resistive and that is low enough to compete with the output impedance for really fast changes, so when the input changes polarity the feed through causes a tiny spike to appear at the output just before the op amp has time to respond and lower the output impedance dynamically.
What this means is that increasing the value of the input 1k resistor to 10k should reduce the spike to an acceptable level, but of course that means the feedback cap has to decrease by a factor of 10 also.
I would guess that the spike amplitude would decrease by about 10 fold also.
some real world ESR in each cap might help this situation but could also lead to another type of spike where the output ramps up normally but on input change suddenly jumps down (or up) quickly before it starts its normal ramp in the opposite direction.
At this point with all this in mind it would be interesting to see some real world scope pics.
 

crutschow

Joined Mar 14, 2008
34,280
The spike is related to the frequency response of the op amp and the rise time of the input signal.
In my simulation with an R1 (post #21) input resistor of 9k using a 741 amp, there is no spike for a 10μs rise/fall time, but there is with a 1μs rise/fall time, with the spike increasing as the rise/fall time is reduced.

To minimize the spike, you can add an RC input LP filter with about a 10μs time-constant, such as 1k ohm in series with 10nF to ground at the output of the signal generator, to roll off the rise/fall times.
You then subtract that resistor value value from the other input resistor value to maintain the integrator time-constant (giving an 8k value for R1 in this case).
 

MrAl

Joined Jun 17, 2014
11,388
The spike is related to the frequency response of the op amp and the rise time of the input signal.
In my simulation with an R1 (post #21) input resistor of 9k using a 741 amp, there is no spike for a 10μs rise/fall time, but there is with a 1μs rise/fall time, with the spike increasing as the rise/fall time is reduced.

To minimize the spike, you can add an RC input LP filter with about a 10μs time-constant, such as 1k ohm in series with 10nF to ground at the output of the signal generator, to roll off the rise/fall times.
You then subtract that resistor value value from the other input resistor value to maintain the integrator time-constant (giving an 8k value for R1 in this case).
Hi,

Of course the op amp is slower than the path AROUND the op amp for fast rising signals that's how they make their way around the op amp. When the non inverting terminal changes there is some finite non zero time before the output can react, which is exactly what i stated.

A low pass filter on the input brings in other problems and is not needed if the values are scaled as suggested previously. The capacitors can be considered dynamically resistive decreasing resistance with rise time, but the fixed resistor has no way of changing. Thus the fixed resistor limits the current through the path and given the static (at the time) output resistance/inductance the output can jump up based on the simple voltage divider effect. But if you want to play around with an input filter that's up to you but you'll have to make some other changes too in order to compensate for that.
 

MrAl

Joined Jun 17, 2014
11,388
Yes.
That's why the value of the following input resistor is reduced equal to the filter resistor, as I stated.
You don't, if the spike has been eliminated by other means, such as changing the input R or the op amp type.

Hi,

Well, the question was why would you want to add more parts if you dont have to, but that's ok i guess.

Anyway, here is what i think is a better solution. Note the wave generator polarity is reversed and it is also biased with a DC voltage of 1.65v. That +1.65v can come in various forms. If it is a voltage divider then the impedance (and also the generator impedance) is to be subtracted from the input 10k resistor and then that 10k resistor is made equal to the result of the subtraction. Note V4 is the input square wave that varies from 0v to +3.3v as before.
Also note the value of R2 may have to come down somewhat depending on the input offset of the op amp used.
One nice feature about this version is the start up time is less than one cycle, probably less than 1/2 cycle.
Of course this solution requires a floating generator but that is usually what is available in the lab. If not, then a floating 1.65v DC voltage reference would solve that issue by reversing the positions of the generator and voltage reference. The generator positive output would have to be the one grounded however.

A side benefit is the pesky spike at the tip of the triangle seems to have gone away.
This might be a little hard to explain seeing as the equivalent very short time circuit would just be the 10k resistor and around 20 ohm output impedance forming a voltage divider (for times on the order of less than 1us), but it was the same for the other circuit too. We could look into this.

TriangleFromSquare_20200222_062051.gif
 
Last edited:
Top