Inverting Op-amp signals and Sawtooth waveform generation

  • #1
I’ve been asked to create a sawtooth wave form with four input voltages. After doing this I then added a second op-amp to both change the range of the wave form from -/+5v to -/+2.5 and DC offset of 2.5v to create a wave form that ranges from 0v – 5v as required by the question. For the most part I think I’m close enough with my result apart from the second op-amp seems to of “flipped” the wave form and I can’t quite figure out why and how to solve the issue.

I've included a picture of my circuit, wave form after the first op-amp and after the second op-amp.

Any help would be appreciated


View attachment 286448View attachment 286449View attachment 286450
 

Answers and Replies

  • #2
berkeman
Mentor
60,390
10,698
Hi Callum,

I moved your thread to the schoolwork forums from the EE forum, and something about that move messed up your attachments. Could you please re-attach them or add a new reply with them? Also, they were pretty hard to read (when they still existed) -- Is there some way to make the bigger and darker? Thanks.
 
  • #3
.Scott
Homework Helper
2,859
1,128
Could you redo your pictures. I can't read them.
More resolution is required - and the pictures only occupy the top left 10% of the available canvas.
 
  • #4
Could you redo your pictures. I can't read them.
More resolution is required - and the pictures only occupy the top left 10% of the available canvas.
Yeah sorry about that by the i tried to change it but it would not up date. Ae these better?

pic1.png
fiststage opamp.png
Secondstageopamp.png
 
  • Like
Likes Delta2, berkeman and .Scott
  • #5
berkeman
Mentor
60,390
10,698
Whew, much better, thanks!

So you mention synthesizing a "sawtooth" waveform with the 4 voltage sources. You've done a good initial job of doing that, but do they want it to be more like a straight sawtooth instead of stepped? Can you say what you could change/add to the circuit to make it more like a traditional sawtooth?

1627062467090.png
 
  • #6
Whew, much better, thanks!

So you mention synthesizing a "sawtooth" waveform with the 4 voltage sources. You've done a good initial job of doing that, but do they want it to be more like a straight sawtooth instead of stepped? Can you say what you could change/add to the circuit to make it more like a traditional sawtooth?

View attachment 286459
This is the full question as i was given.

Untitleds.png
 
  • #7
berkeman
Mentor
60,390
10,698
Ah, in that case it looks like you are doing the correct synthesis.
 
  • Like
Likes Callum Plunkett
  • #8
Yeah i think im on the right track with it, so im quite relieved someone else thinks im some where near.
Cheers.
 
  • #9
Joshy
Gold Member
387
172
The last op-amp has positive feedback. Isn't that going to be a problem?
 
  • #10
berkeman
Mentor
60,390
10,698
The last op-amp has positive feedback. Isn't that going to be a problem?
Good catch! I saw that the simulation output for X2 looked reasonable, so didn't check the schematic in detail. But yeah, with the opamp inputs inverted like that I don't see how the simulation isn't just hitting the rails...
 
Last edited:
  • #11
bob012345
Gold Member
884
286
Good catch! I saw the simulation output for X2 looked reasonable, so didn't check the schematic in detail. But yeah, with the opamp inputs inverted like that I don't see how the simulation isn't just hitting the rails...
Op amps invert the signal so you can just use one more with a unity gain to flip it back.
 
  • Haha
  • Skeptical
Likes DaveE and berkeman
  • #12
berkeman
Mentor
60,390
10,698
Op amps invert the signal so you can just use one more with a unity gain to flip it back.
I'm pretty sure you're kidding. An opamp with the inputs reversed so that the feedback is postive is a comparator, not a linear amplifier.
 
  • #13
bob012345
Gold Member
884
286
I'm pretty sure you're kidding. An opamp with the inputs reversed so that the feedback is postive is a comparator, not a linear amplifier.
A summer gives the negative of the sum. You add another op amp stage to invert that signal.
 
  • #14
berkeman
Mentor
60,390
10,698
A comparator slams to the +/- power supply rails when the difference between its inputs is positive or negative. Are you suggesting that a comparator can be used as a linear amplifier like an opamp that uses negative feedback?
 
  • #15
bob012345
Gold Member
884
286
A comparator slams to the +/- power supply rails when the difference between its inputs is positive or negative. Are you suggesting that a comparator can be used as a linear amplifier like an opamp with negative feedback?
No. I just thought the issue was the signal was flipped as in multiplied by a minus sign. I was telling how to make it positive.
 
  • #16
berkeman
Mentor
60,390
10,698
No. I just thought the issue was the signal was flipped as in multiplied by a minus sign. I was telling how to make it positive.
Okay, that's fair. The quote of mine that you used was agreeing with the catch by @Joshy about the incorrect connection of the 2nd opamp. The question about the inversion or whatever of the signal was in a different post.
 
  • #17
bob012345
Gold Member
884
286
Okay, that's fair. The quote of mine that you used was agreeing with the catch by @Joshy about the incorrect connection of the 2nd opamp. The question about the inversion or whatever of the signal was in a different post.
That's fine. Sorry for the misunderstanding.
 
  • #18
bob012345
Gold Member
884
286
This is the full question as i was given.

View attachment 286461
Does the output have to be just like fig 2b (going between 0 and 5V) or just similar in shape? Are other DC biases allowed? I take it the input biases all have to be 5V as given. I ran it in LTSpice and got what you got but it's not clear how literal they want it.
 
  • #19
Baluncore
Science Advisor
9,700
4,138
Did you consider simply adding a DC current to the AC harmonic currents at the summing input?
That way it provides the offset without needing a second op-amp.
 
  • Like
Likes Callum Plunkett
  • #20
DaveE
Science Advisor
Gold Member
1,737
1,376
A summer gives the negative of the sum. You add another op amp stage to invert that signal.
Op-amps have nearly infinite gain, so they will always have a circuit wrapped around them. It is easy to make a summer with positive gain, negative gain or any mixture you like, as in a differential configuration. They can do lots of different things. For example:

20210723_211547~2.jpg


This allows you to easily figure out how to do all sorts of summing, subtracting, level shifting, inverting with 1 amp and nearly zero effort. You just need to keep it balanced for the zero algebra option.

edit: also, IF IT'S BALANCED, the ground for the output is the ground at the lower R4, which can be different from the grounds for the inputs (with some common mode limitations, of course). However, "balanced" is relative; variations in the real resistor values will degrade the CMRR, sometimes significantly. There are other configurations which have much better CMRR, like instrumentation amps.
 
Last edited:
  • Like
Likes Callum Plunkett, bob012345 and Delta2
  • #21
bob012345
Gold Member
884
286
Here is my version of it. I can't get a decent, readable screenshot of the output but it goes between 0 and 5V.


Screen Shot 2021-07-24 at 4.39.28 PM.png


output.png
 
Last edited:
  • #22
DaveE
Science Advisor
Gold Member
1,737
1,376
Good work!

A couple of comments: These aren't corrections, more like refinements, like how the pros would do it slightly differently.

1) It is considered bad design practice* to use the power supply voltages for anything except to power devices. Any connection into the signal path like the offset function you needed in this problem is a bad idea. The power supply voltages (usually) aren't intended to be very precise, they are noisy, and can create some really annoying cross coupling between different parts of the system. For example, if this circuit was used in an audio synthesizer, you would probably have lots of hum, pops & clicks, or and other noise at the output (in addition to your triangle wave) that was injected into your signal path through R6. So, in practice you would add a voltage reference of some sort (Zener diode, IC, etc.) to provide a clean and stable reference voltage for your offset.

* In the real world "bad design practice" means a circuit that mostly works but may have problems like low reliability, poor performance, hard to build, expensive, etc. (i.e there are better ways to do it).

2) It's much harder to buy a 3.5KΩ resistor than a 3.48KΩ resistor. Same for many other common values. Resistors are most often supplied with EIA standard values (usually the 1% tolerance for analog designs, in my experience). This really doesn't matter for homework problems or understanding. Theoretically useless, but how the real world works. Similar to choosing nut and bolt sizes. As an aside, I can usually immediately tell if a schematic was drawn by a very experienced engineer by things like this. You really wouldn't learn about these details until you had to choose resistors from a standard list (your stock room, distributors, etc.). For example, go online to your favorite distributor (I like digikey.com) and search for a 3.5KΩ 1% 0805 SMT resistor, see how many choices there are. Then do the same for 3.48KΩ.

3) If you adjusted your offset so that the output didn't go below 0V ever, then there would be no need for a negative power supply, you could replace it with a ground connection. You would have to choose an op-amp that can output 0V though, but these are common.

If you have lots of free time and you want a puzzle to solve, try this design using an LM10 op-amp with it's built-in reference and single supply capability. That might be how I would do it.

edit: These are especially not corrections, since this is clearly an unrealistic exercise. No one actually makes triangle waves by starting with 4 synchronized sinewaves. Even if those sinewaves already existed in my design, I wouldn't use them for this.
 
Last edited:
  • #23
Baluncore
Science Advisor
9,700
4,138
Fourier synthesis of the sawtooth waveform is a difficult exercise because there are so many harmonics, and they fall off too slowly. Saw = f1/1 + h2/2 + h3/3 + h4/4 + h5/5 + , , ,

Notice how, each time another harmonic is added to the synthesis, it inverts and attenuates the error function. Since the number of harmonics is sharply limited, I would attenuate the higher given harmonics so as to eliminate the reversals in slope on the rising ramp. That would slightly increase the fall-time, but it would significantly reduce the error function.

That error function minimisation could also be achieved by including a Miller integrator capacitor across the op-amp feedback resistor, but that might be break the rules of the exercise.
 
  • #24
Baluncore
Science Advisor
9,700
4,138
Here I have replaced the coefficients {10k, 20k, 30k, 40k} with {10k, 22k, 40k, 70k} to take the bumps out of the ramp.
Sawtooth_Synthesis.png
 

Related Threads on Inverting Op-amp signals and Sawtooth waveform generation

  • Last Post
Replies
5
Views
2K
  • Last Post
Replies
3
Views
3K
Replies
3
Views
987
  • Last Post
Replies
4
Views
2K
Replies
7
Views
912
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
11
Views
1K
  • Last Post
Replies
1
Views
8K
Replies
1
Views
1K
Replies
10
Views
3K
Top