# Offset when trying to convert square to triangular wave

Hi I constructed a circuit to create a 1Hz square wave with LM741 Opamp. The first part makes that and it makes it perfectly.

But I need to convert it to a 8Vpp triangular wave. Without any offset, I simulated the circuit below in LTSpice it was flawless. But in real life I got some weird offset from the output of the triangular wave converter.

Figure I implemented, first part creates 1Hz 21 Vpp zero offset square wave,2nd part convert this into a triangular wave with 8Vpp:

In real life it has 8.2 Vpp which is very good for me but it starts from -6 to +2 (it has -2 V offset)

How can I get rid off this offset?

Better one:

• Please learn how to export graphics from the simulator. Taking a photo of the computer screen doesn't give very good results. Commented Dec 19, 2019 at 15:48
• I think that looks very good. Anyway, make the 2nd op amp a summing amplifier, and use the 2nd voltage to put the offset where you want it. Or, use capacitive coupling so the incoming signal centers itself. (Altho the cap may distort it some). Commented Dec 19, 2019 at 15:52
• My wild guess, you use ideal 330uF and 10uF caps!!!
– AKR
Commented Dec 19, 2019 at 15:52
• For taking a photo from computer screen answer ; I am sorry but I am unable to reach any computer or ossiloscope. For summing amplifier thing my offset of -2V was a rough measurements it changes sometimes its not constant And yes I used ideal in LTSpice how can I use non-ideal models ? Commented Dec 19, 2019 at 16:13
• "But I need to convert it to a 8Vpp triangular wave." - why? Commented Dec 19, 2019 at 18:34

Integration isn't memoryless, and can be influenced by initial conditions, in this case the voltage across the cap. My guess is that there was some stray voltage on the cap that causes your signal to swing around that offset. On integrators it's not uncommon to see a switch used to discharge the capacitor to make its initial state 0V. Try shorting the cap just before operation and see if the offset is reduced.

Others have explained the need for nonpolar capacitors, but you are doing things backwards. You don't try to convert a square wave to a triangle wave, you make a triwave oscillator of the right frequency and amplitude. There is already a useable waveform on C1, you just need to change the ratio of R2 and R3 so it has the right amplitude. This will change the frequency so recalculate the value of R4 to bring it back to 1Hz. Make it closer to 1M so you have a chance of finding a suitable capacitor.

If you are using a 10uF electrolytic capacitor, it won't be happy with more than a volt or so reverse bias and will create a large offset, which will be multiplied by 5 in the integrator. Similarly, the 330uF will not be happy with reverse bias.

You can get around the first by connecting the capacitor (-) terminal to the negative rail, but for the integrator you would need a non-polar electrolytic, or to increase the resistor values to more like 130K/680K for R4/R5 and use two 10uF electrolytics in series (back to back). Or use 68K/330K and a 10uF film capacitor.

10uF ceramics are available but they have so much voltage coefficient your results will be quite bad (very nonlinear triangle wave and much higher amplitude and frequency than expected for ideal caps).

• I don't have an access to those to be honest is there a better way ? like capacitor and resistor differentiator etc Commented Dec 19, 2019 at 17:22

That's the classic problem you get when trying to drive an integrator from a square wave.

The integrator's output will drift towards one supply or the other and may eventually saturate because:-

1) Square wave is not perfectly symmetrical (square). The saturation limits for the square wave generator are not symmetrical.

2) The integrator op amp has input offset voltage and input bias currents.

You can't use a polarised cap because it is being to charged to both polarities. Use a non-polarised cap or keep cap value lower and use a non-electrolytic.

Below is a favoured way of generating a triangle wave. It uses a non-inverting schmitt trigger driving an integrator.

Triangle wave output amplitude is set by ratio of R1 to R2.

Frequency is set by R3*C1 time constant.