I'm tasked to reproduce the following signal

using only Op Amps (and resistors).

I'm pretty sure I must add two signals, the square and triangular waveforms, it is just pretty hard to figure out how to twist the signal from -8V to 0V.

I've tried to get the transfer function according to a square waveform signal V2 (-6V min to 0V max, freq=1Hz) and a tringular waveform V1 (0V min, 2V max, freq=1Hz) with this, I get the following output Vo:

Vo = -2V1-2V2-4

Which satisfies the following table EXCEPT AT POINT V1=0,V2=0

    V1  V2   V0
    2   -6   8
    2   -6   4
    2    0  -8
    0    0  -4   <---HERES THE PROBLEM ! (Should be zero)
    0   -6   8

What would I do?

Both the square and the triangular are provided as input signals, the circuit does not generate them just process them to give as a result the signal shown in the figure. It is for a project so it's kind of a homework and I'm working hard on it right now. Both amplitud and time domain are equally important.

  • 2
    \$\begingroup\$ is the square wave provided as an input signal or should the circuit generate it too? is this a homework question? is the amplitude or time-domain fidelity more important? \$\endgroup\$
    – markrages
    Aug 27, 2012 at 6:05
  • \$\begingroup\$ Using only op-amps? Surely you're allowed to use resistors as well? \$\endgroup\$
    – In silico
    Aug 27, 2012 at 6:56
  • \$\begingroup\$ Yes of course, the constraints are opamps and resistor only. \$\endgroup\$
    – Favner
    Aug 28, 2012 at 2:31

4 Answers 4


The positive slope of the triangle wave needs twice the gain of the negative slope, this can't be done in an opamp and resistors circuit without some trick:

enter image description here

Signal s1 = triangle wave, 0 V to +4 V
Signal s2 = square wave, 0 V to +12 V
Signal s3 = s1/2 + s2/2, 0 V to +8 V

This is where the trick comes in. The triangle wave's slopes are symmetrical, and we need them different. Trick: use a rail-to-rail opamp with a \$\pm\$12 V supply. We'll use that to clip the top of the s3 waveform.

Signal s4 = 2 \$\times\$ s3 (clipped), 0 V to +12 V
Signal s5 = Vout = s4 - 8 V + s1, -8 V to +8 V

Schematic, just 2 opamps and 9 resistors:


  • 1
    \$\begingroup\$ Brilliant! That's a nice solution. \$\endgroup\$ Aug 27, 2012 at 16:52
  • \$\begingroup\$ Indeed this is a nice an 'simpler' solution (without using integrators, half wave rectifiers, etc) Am I right if suppose you were adding/mixing signals and adjusting in amplitude for the desired amplitude output and you eventually did find out that subtle trick. I ask this since need to develop or figure out a technique (preferably a known technique) to design with op-amps for this specific case. Thank you. \$\endgroup\$
    – Favner
    Aug 27, 2012 at 19:00
  • \$\begingroup\$ @Madman - Thank you! Though I think it's more of a dirty trick than a brilliant one :-). I quickly realized it had to be something like this. I thought about it all day, and I can't see any other solution, at least not with just resistors. (Oli's a cheater! :-)) \$\endgroup\$
    – stevenvh
    Aug 28, 2012 at 11:57
  • \$\begingroup\$ @stevenvh: bounty awarded based on clever solution within the constraints. Kudos for Oli Glaser for original use of opamp as diode. \$\endgroup\$ Sep 3, 2012 at 14:04

Another option is this circuit, which uses the same number of opamps as Stevens but works slightly differently.
It relies on different gains for the positive/negative swings (achieved with the diodes in the feedback circuit)
R2, R5 and R11 attenuate and shift the -6V-0V signal to -2V-2V, whilst presenting an impedance of 1kΩ to the opamp input. R7 and R8 are to set the different gains for the positive/negative swings.
The two components (positive/negative tapped from points "POS" and "NEG") of the final signal are then summed and inverted by the opamp U2, and you have your output signal.



Circuit Sim

You can see the input signals (blue/red) and the output signal (green) in the top graph. In the bottom you can see the positive and negative components (pink/light blue) which are summed by U2.

EDIT - So no diodes then?

Just for fun, and to keep within constraints, here is the same circuit but using an opamp with input protection diodes instead ;-)

Circuit 2

And here is the simulation:

Circuit 2 Sim

I included the current through the opamp inputs to show the diode action. The output is the same as the first circuit. In theory this should work with any opamp with non-current limited diode to rail input protection.

  • \$\begingroup\$ The constraints are only opamps and resistors, but I don't know if there are other solutions then than my dirty trick. I'd like to see one though. \$\endgroup\$
    – stevenvh
    Aug 27, 2012 at 23:45
  • \$\begingroup\$ @Steven - Ah, I was assuming it was opamps and passive components, rather than just resistors, since at first the question just said "only opamps", then included "and resistors" when In silico commented. Hopefully the OP can clarify whether diodes are allowed. I think yours is an excellent solution either way, I was just adding an alternative for interest. \$\endgroup\$
    – Oli Glaser
    Aug 27, 2012 at 23:56
  • \$\begingroup\$ @Oli Glaser I've edited my original question by adding "(and resistors)" after seeing the comment of In silico. The constraints were always opamps and resistors (and obviously the input signals) other than that was not allowed, nonetheless it is another good alternative to this ugly/hairy problem :) \$\endgroup\$
    – Favner
    Aug 28, 2012 at 2:09
  • 1
    \$\begingroup\$ @Oli Glaser - What simulator did you use there? \$\endgroup\$
    – Favner
    Aug 28, 2012 at 7:15
  • 1
    \$\begingroup\$ @Aaargh! That's even a badder cheat than mine! :-) It costs you two extra opamps though. Maybe you can replace the resistors by opamps as well? ;-) \$\endgroup\$
    – stevenvh
    Aug 29, 2012 at 7:15

What makes this problem tricky is that you don't just have the sum of a triangle wave and a square wave. The negative steps of the square wave are -12 V, but the positive steps only +8 V.

Trying to create the final signal as a composite of several signals as Steven and Oli suggested is perfectly valid and may in fact be the best answer. However, here is a different way to think about this problem.

Consider a capacitor that can be charged and discharged with fixed currents, and can also be clamped high and low "instantly" to +8 and -8 volts. Just to pick something, let's use a 10 nF capacitor for example. To discharge it by 4 V in 1 ms would require -40 µA. To charge it 8 V in 1 ms would require +80 µA. You could have separate -40 and +80 microamp sources that are enabled at the right time. However, it's probably easier to to have a fixed -40 µA source and a switchable +120 µA source.

Everything can be driven from a 500 Hz square wave. the 120 µA current source is enabled when the square wave is positive (during 1-2 ms and 3-4 ms in your diagram). The low side clamp is enabled for a short time from the rising edge of the square wave, and the high wide clamp from the falling edge. Since the voltage is reset to one of the clamp limits once per millisecond, this method nicely avoids runaway if the steps and ramps don't add up to exactly zero per cycle.

This is not a schematic, just a diagram of the general concept. I have NPN and PNP transistors for the clamps only to show the general idea. There would be more required, like a diode and/or resistor, to reset C2 and C3 in time for the next use if bipolar transistors are actually used. Current sources can be created with opamps, and there are various ways to switch one on and off.

Again, this is a concept only with the details left as a exercise. However, I think this could be workable depending on a lot of stuff you haven't told us, like accuracy, output drive, speed of the edges, etc. I could get into more specifics if this is a direction you are interested in.

  • \$\begingroup\$ Do I understand you correctly that the current sources are for the slopes, and the transistors/capacitors for the steps? I know it's only a concept, but can this provide feedback so that it doesn't runaway, like if the negative steps would be only 2 V different from the positive ones? \$\endgroup\$ Aug 29, 2012 at 12:46
  • \$\begingroup\$ @Federico: Yes, the current sources provide the ramps and the two clamps the "instantaneous" steps. As I said, this doesn't run away since the output is clamped to a fixed voltage once every ms. Errors don't accumulate past the clamp events. \$\endgroup\$ Aug 29, 2012 at 12:52

What about adding an offset to the square wave to make it asymmetric, then integrating it with an op amp and subtracting that from the original square wave. I can't quite work it out, but it feels like a viable approach.

  • 1
    \$\begingroup\$ Integrating requires a capacitor, so that's a no-no. Besides, an asymmetric rectangle wave will create different rising and falling slopes won't be 1 ms long, so adding them to the 50 % square wave won't give you a nice result. \$\endgroup\$
    – stevenvh
    Aug 30, 2012 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.