# Can anyone explain how this circuit generates a staircase waveform form a square wave?

#### Abdi Rahman

Joined Apr 23, 2018
5
Hi everyone, I have this circuit below which I have absolutely no idea how it works. I can't really visualise where the current is flowing and how the circuit obtains a staircase waveform from a square wave, I was wondering if anyone could help me out and its been annoying me for me a while.

#### Attachments

• 15.2 KB Views: 6
Last edited by a moderator:

#### ericgibbs

Joined Jan 29, 2010
13,227
hi Abdi,
Welcome to AAC.
Is there another photo image, the link shows the same circuit as the image you have posted.

Is this a college assignment.?

E

Last edited:

#### Abdi Rahman

Joined Apr 23, 2018
5
Ah my bad I only wanted to post that single circuit, I'll remove the extras, this is for a college assignment with this circuit being a small part of the overall assignment.

#### crutschow

Joined Mar 14, 2008
27,405
The opamp is configured as an integrator that integrates the pulses through the capacitor with the two diodes acting as a negative peak rectifier.

xox

Joined Mar 10, 2018
4,057
When the pulse goes high C1 takes on a charge proportional to the width of
pulse and V of pulses, current coming thru D1. When pulse goes low C1 charge
is essentially transferred to C2 via D2.

Regards, Dana.

#### Jony130

Joined Feb 17, 2009
5,241
When the square wave gen goes high from 0V to +2V the C1 capacitor will quickly charge to +2V

But when the square wave gen goes to the low state from +2V to 0V. Already charged C1 capacitor pulls down his right plate (and D2 cathode) below ground potential (-2V). Hence Op Amp starts to charge C2 capacitor to brings his inverting input voltage to ground.

xox

#### crutschow

Joined Mar 14, 2008
27,405
Below is the LTspice simulation of the circuit.
Note that the voltage at node 1 (junction of two diodes) does not go to -2v, as Jony130's picture shows, since the negative voltage's C1 capacitor current is going through D2 to the virtual ground input of the opamp.
Thus the voltage at node 1 goes from one diode drop above ground to one diode drop below ground.

#### crutschow

Joined Mar 14, 2008
27,405
Can we see the waveform the circuit is producing?
Other than what I posted?

#### BR-549

Joined Sep 22, 2013
4,938
What does the yellow peak out at?

#### crutschow

Joined Mar 14, 2008
27,405
What does the yellow peak out at?
About 450mV, due to the peak diode current being only 40μA.
I'm using the simulator default slow rise and fall time of 100μs on the input square-wave, which reduces the peak current.

#### Abdi Rahman

Joined Apr 23, 2018
5
Thank you so much guys!

#### MrAl

Joined Jun 17, 2014
8,360
Hi everyone, I have this circuit below which I have absolutely no idea how it works. I can't really visualise where the current is flowing and how the circuit obtains a staircase waveform from a square wave, I was wondering if anyone could help me out and its been annoying me for me a while.

View attachment 151555
Hello there,

Welcome to the forum.

With many circuits including this one it is often informative to understand the basic theory behind the circuit as well as the circuit itself. The basic theory shows the behavior in the simplest possible terms. The circuit is merely one particular implementation.

For this circuit the base theory is that of an ideal capacitor (which is also an ideal current integrator) being charged by an ideal current source where the current source turns on and off at regular intervals. So it's theoretically equivalent to a pulsing current source in parallel with an ideal capacitor.
What happens is the cap is initially discharged, with zero voltage across it. The first current pulse comes, and that charges the cap a little through dv=i*dt/C where dt is the 'on' time of the current source and dv is the change (increase here) in voltage. When the pulse goes away, the current source turns off which makes it effectively an open circuit. The cap, being ideal, holds its charge indefinitely so the voltage stays at the first level until the next pulse comes along. When the next pulse comes along, another current pulse is applied to the cap and so it charges up to the next voltage level (the next step) which will be twice the first step because it's the same current level being applied. Now the cap has 2x the voltage across it. The pulse again goes off, the cap holds that 2x voltage, then the pulse comes back on again and charges the cap up to the next voltage level which is again the same as the first so now the cap is charged up to 3x the original voltage stop voltage. This process continues indefinitely and if we take a step back and look at the cap voltage over time we see it is ramping up in steps where we see one more step with every current pulse.
If the pulses are always the same current level and the time is the saime period, the steps are uniform and so they look like a staircase.
Also, if you start to apply negative current pulses the staircase will start to step down more and more.

It is informative to try this in simulation. All you need is a current source that can pulse on and off and a capacitor.

The non ideal circuit (with op amp) has various deficiencies from the ideal case above, but the op amp functions mainly to turn the voltage pulses into current pulses and that is what charges the capacitor.
The diodes (if really needed) would only be there to rectify the input voltage if it happened to go negative and that probably means that the op amp output will eventually saturate.

One thing to note is that we dont loose any charge when the pulse turns off. In the ideal case this is a good thing because that is what holds the voltage constant during 'off' times. In the non ideal case though this can be a design killer because the charge keeps building up. Thus we need some way to bleed off that charge eventually. This is sometimes done with a 'switch' like a relay or FET and sometimes with a resistor that 'bleeds' off some of the charge after each cycle. With the resistor however, the steps do not come out exactly uniform however because the cap is no longer an ideal integrator.

Last edited:
xox

#### BR-549

Joined Sep 22, 2013
4,938
I think it's a cup(C2) filling a bucket(C1). We can vary the number of cups needed to fill the bucket.......by changing how much we put in each cup.(pulse length) We could also change cup size. C2 capacitance.

And you can change bucket size too. We should be able to empty a bucket this way too.