Black-box design to create sawtooth waveform

  • Topic: Engineering 
  • Thread starter Thread starter peasngravy
  • Start date Start date
  • Tags Tags
    Design Waveform
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
49 replies · 6K views · last reply
Yes, the diagram shows a peak amplitude of 5V and you said the bade frequency is 1kHz. You increase the frequencies of each AC Source as shown in the FS. Can you paste a screenshot of your AC Source definition for the first one?
 
  • Like
Likes   Reactions: peasngravy
Physics news on Phys.org
berkeman said:
Yes, the diagram shows a peak amplitude of 5V and you said the bade frequency is 1kHz. You increase the frequencies of each AC Source as shown in the FS. Can you paste a screenshot of your AC Source definition for the first one?
Screenshot of a Choose Source dialog box with the Sine tab selected, showing Frequency 159, Delay 0, Phase -0, Theta 0, Peak 2.5, Offset 0, with Enable AC checked and Enable DC unchecked.


(i spent far longer than I should have trying to post this reply by hitting OK on the screenshot :smile:)
 
From the problem statement figure, you want the frequency of the first one to be ##2\pi f## where f=1kHz, the frequency of the 2nd source to be twice that, and so on. And the peak amplitude of each is 5V, no?
 
BTW, that Fourier Series for the sawtooth wave doesn't look quite right to me, but I'm looking into that more now. If you can post your circuit after setting up the 4 AC Sources and the output waveform that it generates, that would be a help.
 
Ok so I set up the sources with the following frequencies, and got this:
6283
12566
18849
25132LTspice schematic of a summing amplifier: four sine sources V1 to V4 each feed a 100k input resistor into the inverting input of op-amp X1 (TL081), with feedback resistor R5 200k, and a graph of X1-inn voltage against time in mSecs showing a repeating multi-peak waveform between about 5.7 V and 6.8 V.

Regarding the peak, you're right of course, I just overthought that one, forgetting that i was only looking for half of a wave
 
peasngravy said:
Ok so I set up the sources with the following frequencies, and got this:
6283
12566
18849
25132

View attachment 271863
Remember that you have to scale each resistor divide ratio to match the FS coefficients...

Also, when I use a simple Excel spreadsheet to plot the FS function you are given, it's closer to an inverse sawtooth instead of a sawtooth waveform. And of course it doesn't include the offset and scaling yet to give you the 0-5V sawtooth waveform that you are asked to produce with your circuit:

Plot of a truncated Fourier series sum titled Chart Title, showing a periodic waveform with peaks near 1.0 and troughs near -1.0 on a vertical axis from -1.5 to 1.5. Above it is the equation v(t) = (2/π)(sin(ωt) + ½sin(2ωt) + ⅓sin(3ωt) + ¼sin(4ωt) + ...).


When I use the FS from Wikipeda for a forward sawtooth waveform (including the offset and scaling for the Amplitude = 5V), it looks a lot closer once the initial startup phase is done...

Formula for a sawtooth wave as a Fourier series: x(t) = A/2 minus A/pi times the sum from k=1 to infinity of (-1)^k sin(2 pi k f t)/k, where A is amplitude, above a plotted chart titled Chart Title showing a wavy curve that rises and drops repeatedly between about 0 and 5.


Is there some way to verify with the instructor or TA whether that is the right FS that they want you to use in the problem statement?
 
Attachments
  • Spreadsheet chart of a Fourier series sawtooth approximation, with the formula x_sawtooth(t) = A/2 - (A/pi) times the sum over k of (-1)^k sin(2 pi k f t)/k, where A is amplitude; the plotted curve shows repeated ramps with overshoot and ringing, and the vertical axis runs from 0 to 6.
    1604080764096.png
    7.3 KB · Views: 236
The problem statement doesn't specify any particular value for ##\omega##, so I think you're free to choose anything you like. For example you could make the base frequency equal to 1000 Hertz and not worry about the associated angular frequency. That will make setting up your simulation easier. Frequencies for the voltage sources can then just be: 1000, 2000, 3000, 4000 (Hertz)

Edit: Looking again at the problem statement I see by the waveform diagram that they want a 1 ms period for the sawtooth. A 1000 Hz base frequency will at least get you close, and you can always fine tune the base frequency once you've sorted out the circuit design.

The problem statement didn't say that the given Fourier sequence was for a sawtooth of the exact form desired. It might well be an inverted version of the desired waveform and centered about zero volts. An inverting op-amp configuration might be a real benefit here :wink:

Using Mathcad to perform the summation:

Mathcad plot of f(t) against t in seconds, a periodic waveform with a sawtooth-like shape from a four-term Fourier sum; y-axis from -6 to 6, t axis 0 to 3x10^-3 seconds.

Negating the function and adding a suitable offset value to "pull up" the minimum:

Plot of -f(t) + Offset against t in seconds, showing a periodic sawtooth-like waveform with stepped rises, repeating three times from 0 to 3×10^-3 s, with the y-axis ranging from -2 to 10 and Offset := 4.8571 printed above.

Still have the function maximum value to deal with since we want the peak to be around 5 V, but that's just fiddling with the stage gain.
 
Last edited:
  • Like
Likes   Reactions: berkeman
My brain is pretty fried by now, so thank you for your patience. I am getting there slowly but surely, I think

How do I relate my gain to the frequencies though?

Sorry for all the stupid questions - again, this is all very new to me, I think I'm too old to learn new stuff :biggrin:
 
peasngravy said:
How do I relate my gain to the frequencies though?
You don't! For this circuit, without reactive components, the gain will be independent of the signal frequency.

This will hold true for ideal components (which you are simulating here), but in the real world you'd want to remain within a given op-amp's operating bandwidth. Outside of the "flat" region gain will roll off and phase shift with frequency will need to be considered. Such topics are likely outside of the scope of your current course. Maybe next term :smile:
 
Fortunately for me there won't be another term! This course is just something I did for my own benefit. I started it a couple of years ago when i was made redundant and thought I should do something to fill the time. Got another job pretty quickly though so its been much slower progress than I hoped

So regarding the gain - do I just want to divide the 4 inputs so that each one gives 1.25v?
 
gneill said:
It might well be an inverted version of the desired waveform and centered about zero volts. An inverting op-amp configuration might be a real benefit here
Hah! That would be pretty smart to use the FS for the inverted Sawtooth, in order to save one opamp stage in the final circuit. I need to remember that trick... :smile:
 
peasngravy said:
So regarding the gain - do I just want to divide the 4 inputs so that each one gives 1.25v?
You can adjust the gain overall by simply altering the feedback resistor, no?
 
berkeman said:
Hah! That would be pretty smart to use the FS for the inverted Sawtooth, in order to save one opamp stage in the final circuit. I need to remember that trick... :smile:
More than that, it also avoids dealing with the negative and positive terms separately!
 
  • Informative
Likes   Reactions: berkeman
Do you think my circuit looks correct then, other than adjusting the feedback resistor?

I have now gone for the 1k, 2k, 3k and 4k frequencies like you said

Schematic of an op-amp summing circuit in Multisim: four AC sine sources V1 to V4 at 1k, 2k, 3k and 4k, each through a 10k input resistor R1 to R4 into the inverting input of a TL081 op-amp, with a 20k feedback resistor R5 and ±15V supplies, output labelled X1-out.

Obviously I still need to add the offset and deal with the inverted output but i can do that once i get the correct waveform (which currently looks like this:)
Simulator plot of X1-out in V against Time in mSecs, 2 mSecs per division, red trace oscillating between about 13.506 V and 13.534 V with a repeating irregular pattern of sharp dips and peaks.
 
peasngravy said:
Do you think my circuit looks correct then, other than adjusting the feedback resistor?
You still need to adjust the series resistors for each of the AC Sources to get the FS coefficients. That is one reason you don't have a near-sawtooth waveform yet...

Schematic of an op-amp summing circuit in simulation software: four AC sine sources V1 to V4 at 1k, 2k, 3k and 4k each feed a 10k input resistor R1 to R4, joined at one node into the inverting input of a TL081 op-amp with a 20k feedback resistor R5, output labelled X1-out.
 
I have messed around with those but I am at a loss at what to try now. Should they be something like 10k, 20k, 30k and 40k?
 
peasngravy said:
I have messed around with those but I am at a loss at what to try now. Should they be something like 10k, 20k, 30k and 40k?
Yeah, something like that... :smile:
 
  • Like
Likes   Reactions: peasngravy
berkeman said:
Yeah, something like that... :smile:

I tried this circuit on different software and it's almost exactly what I'm after!

I was using simetrix - when I build the exact same circuit on circuitlab online, I get a completely different waveform
 
Thank you so much for your patience today and for staying with me - I have no idea why that software shows the waveform differently but at least I am there now.
 
  • Like
Likes   Reactions: berkeman