# Practical integrator using op-amp

I'm trying to simulate a practical integrator using NI Multisim 741 op-amp. But I dont quite understand a variation in my waveform.

I'm applying a 1 kHz, 5 V sinusoidal signal as input to the op-amp. The output in theory should be a perfect cosine wave? But the cosine wave I'm getting seems to start a bit below and then move upwards. Why is this? The output is as below:

As seen here, the first cycle is a bit below. Why is this happening?

Also, if I change the value of the capacitor from 1 uF to 1 mF, the output wave shifts upward a bit. But shouldn't only the amplitude of the output wave change due to the different scaling? Why is it shifting upwards?

Also, changing the value of the capacitor to 1 nF, we don't have the cosine wave at all but a phase inverted sine wave. This is again weird to me:

• This answer explains it, even if it's for a different circuit. (possible duplicate?) In rest, it's about the phase response of the circuit. Try an .AC analysis and you'll see exactly what magnitude and phase different frequencies will have. Commented Nov 2, 2022 at 17:01

It is very difficult to make a perfect integrator, so you need to decide what compromises are acceptable.

This is an inverting integrator (note that the signal goes to the minus opamp input). Change the input to a square wave and it will be obvious.

Without a resistor across the cap, tiny biases may cause the output to drift to the rail. If the resistor value is too small, the integrator won't work for low frequencies. If it is too big, it may take too long for the initial DC level to subside.

Try plotting in the frequency domain to see the effect of various RC combinations. The circuit behaves as an integrator for frequencies where the phase shift is 90 degrees.

simulate this circuit – Schematic created using CircuitLab

• In fact, the circuit will exhibit a phase shift of 90 deg at one single frequenvy only. This is due to the fact that in practice there is no ideal integrator (which would require an open loop gain of infinity). In addition, the parallel resistor R2 disturbs the integration function. But it should be noted, that such a resistor is NOT required when the integrator is part of an overall negative feedback loop (which is often the case in filter and oscillator circuits as well as control loops)
– LvW
Commented Nov 2, 2022 at 19:48
• If the NI 741 is accurate, the results will be very poor. The 741's high offset and leakage will push the capacitor all the way + or - quickly. Check the difference with something like an LM308. Basically analog computing of integration integration takes a perfect op-amp. Plus you need to set the initial conditions, like the constant you get when integrating mathematically. You also need a very low noise low leakage and high quality cap. Commented Nov 2, 2022 at 23:27

This is an integrator:

simulate this circuit – Schematic created using CircuitLab

What you have built is not an integrator. The presence of R2 in your circuit turns it from an integrator into a voltage amplifier with gain −1, which attenuates frequencies above a few hundred Hertz and introduces all the phase shifts associated with such a low-pass filter.

For this low-pass filter, there is a range of frequencies of input for which the phase shift will be 90°. Outside of that range you can expect phase shift to be different from 90°. Your 1kHz input apparently lies slightly outside that range, and consequently, you see the not-quite-90° phase shift in your output.

By changing C1 to 1nF, what you have done is set the cut-off frequency of this low-pass filter near 1MHz. At the comparatively low frequency of 1kHz (the frequency of your test signal), the impedance of C1 is so high compared to R2, that R2 dominates, and C2 might as well not even be there. To such an input signal, the circuit appears to be:

simulate this circuit

That's a classic inverting amplifier, with gain of $$\-\frac{1000}{1000}=-1\$$, and that's why you see the output is just an inverted version of the input.

When you integrate $$\sin(t)\$$, you don't get $$\cos(t)\$$, you get $$\cos(t)\ + c\$$, where $$\c\$$ is the constant of integration. That constant is directly related to the initial charge on capacitor C1 at time $$\t=0\$$. This means you will initially see an offset in the output sinusoid, but R2 will tend to bleed away average charge on the capacitor that contributes to that offset, and the result is that eventually the output sinusoid becomes centered around 0V. Interestingly, if the input were a cosine function like $$\cos(t)\$$, this constant is 0, because the anti-derivative of $$\cos(t)\$$ is $$\-sin(t)\$$, and $$\-sin(0)=0\$$.

Your circuit won't behave as you expect an integrator to behave, because it's not an integrator. It's a low pass filter, with gain approaching −1 at low frequencies, and approaching 0 at high frequencies. However, the larger R2 is, the closer to an integrator you get. When R2 is infinity, then you have an integrator.

In most integrator applications, the biggest problem to overcome is the non-idealness of the components involved. The op-amp doesn't have infinite input resistance. It doesn't have zero output resistance. It has limited bandwidth and slew rate, and worst of all, it has input offset voltage.

This latter imperfection causes integrators to accumulate an error in the output over time, meaning that even with zero input, the output rises or falls, slowly and linearly, until the op-amp saturates. The most common fix is to install a very large resistance across the feedback integration capacitor, to "bleed" away any accumulated erroneous charge. That's why you see R2 present in most integrator implementations. However, 1kΩ is way too small. The resistance we use is usually of the order of megohms.

Technically, for the circuit to still be an integrator, the resistance R2 must be much larger than the impedance of C1 at all frequencies for which the system is expected to operate. Otherwise its "bleeding" action becomes significant, and detrimental. In other words, C1 must be the dominant (low) impedance in that parallel pair for all frequencies of interest.