Engineering Black-box design to create sawtooth waveform

  • Thread starter Thread starter peasngravy
  • Start date Start date
  • Tags Tags
    Design Waveform
AI Thread Summary
The discussion centers around synthesizing a sawtooth waveform using a black box and Fourier series. The user is struggling with the application of Fourier algorithms and circuit design, specifically regarding the use of op-amps and the scaling of sinusoidal inputs. Key points include the need for a summing amplifier configuration and the importance of correctly calculating gains for each input signal based on their respective frequencies. The conversation also touches on the necessary adjustments for op-amp power supply and the significance of including a DC offset in the output. Overall, participants are collaboratively troubleshooting the circuit design to achieve the desired waveform.
peasngravy
Messages
72
Reaction score
6
Homework Statement
FIGURE 2(a) shows a ‘black box’ that is to partially synthesise a ‘sawtooth’ waveform of FIGURE 2(b) by using the Fourier series
algorithm:
Relevant Equations
v(t) = 2/pi(sin.omega.t)
Hi

I received some great help yesterday and i was hoping someone would be able to help me out again today

Note: the given equation is very long and would look very messy without being typed in the correct format so I didn't enter the entire thing in the relevant equations box; instead it is included in the screenshot below

1603982937839.png

I am not sure at all what is being asked of me here. There are no Fourier algorithms in any of my notes so I am struggling with what I can do with this.

What I know so far is that the amplitude is 5 volts, and the frequency is 1000hz (1 cycle per ms on the graph).

Could someone please explain how I should use the Fourier algorithm to find my answer?

Thanks
 
Physics news on Phys.org
peasngravy said:
Homework Statement:: FIGURE 2(a) shows a ‘black box’ that is to partially synthesise a ‘sawtooth’ waveform of FIGURE 2(b) by using the Fourier series
algorithm:
Relevant Equations:: v(t) = 2/pi(sin.omega.t)

Hi

I received some great help yesterday and i was hoping someone would be able to help me out again today

Note: the given equation is very long and would look very messy without being typed in the correct format so I didn't enter the entire thing in the relevant equations box; instead it is included in the screenshot below

View attachment 271794

I am not sure at all what is being asked of me here. There are no Fourier algorithms in any of my notes so I am struggling with what I can do with this.

What I know so far is that the amplitude is 5 volts, and the frequency is 1000hz (1 cycle per ms on the graph).

Could someone please explain how I should use the Fourier algorithm to find my answer?

Thanks
Yoiks! My first inclination would be to use an "integrate and dump" circuit; I'm not sure what they want you to do with the FS approximation and opamps. Are you allowed to use transistors too, or just opamps and passive components?
 
  • Like
Likes peasngravy
It doesn't really state either way but I would suspect just passives and opamps. It really does seem a few levels above the rest of the questions
 
Step back a bit and take a broader look at it.
1603991855684.png

The sine functions are already given as inputs to the box. The "formula" is a weighted sum of them...
 
  • Like
Likes peasngravy and berkeman
So the formulas then become
5sin(1000*t)
5sin(2*1000*t) and so on?

t is obviously time, but what time do I need to use for these figures?
 
gneill said:
Step back a bit and take a broader look at it.
View attachment 271811
The sine functions are already given as inputs to the box. The "formula" is a weighted sum of them...
Oh jeeze, I missed that. Thanks!
 
peasngravy said:
So the formulas then become
5sin(1000*t)
5sin(2*1000*t) and so on?

t is obviously time, but what time do I need to use for these figures?
As gneill says, you are provided the sinusoidal signals as inputs. It looks like you just need to scale each input appropriately and combine them... Can you say what kinds of opamp circuits would be used for each of those functions? And are there ways to simplify it down to just a few or one opamp?
 
  • Like
Likes peasngravy and gneill
berkeman said:
As gneill says, you are provided the sinusoidal signals as inputs. It looks like you just need to scale each input appropriately and combine them... Can you say what kinds of opamp circuits would be used for each of those functions? And are there ways to simplify it down to just a few or one opamp?

I think it will just be a very basic summing amplifier

I did find this page which looks like it may be of some help for the circuit http://www.ecircuitcenter.com/Circuits/opsum/opsum2.htm

But I don't even know where to begin with those sinusoidal signals as an input - could you give me a couple of pointers on what I should do there?

It's the time part I am unsure about. How do I know what value of time to put into the equation? Do I just pick the time it takes for one cycle, i.e. 0.001 seconds?
 
Last edited:
peasngravy said:
I think it will just be a very basic summing amplifier
That sounds right, but I'd like to see your attempt at including the scaling in that summing amplifier...
peasngravy said:
I did find this page which looks like it may be of some help for the circuit http://www.ecircuitcenter.com/Circuits/opsum/opsum2.htm
That's close, but it's an inverting topology summing amplifier. You can look for a non-inverting version or follow that one with a unity-gain inverting opamp stage...
peasngravy said:
It's the time part I am unsure about. How do I know what value of time to put into the equation? Do I just pick the time it takes for one cycle, i.e. 0.001 seconds?
peasngravy said:
What I know so far is that the amplitude is 5 volts, and the frequency is 1000hz
To draw the opamp circuit, you don't need to worry about that. I'm guessing you are asking about the simulation part of the question. To be honest, I don't know offhand if you want ##\frac{\omega}{2\pi}## to be the 1kHz frequency or if you want twice or half of that. It's easy to just try the different values in your simulation to verify which choice gives you the right waveform.

(You could also look up the Fourier Series expansion of that waveform to see what value of ##\omega## then are using. I'm too lazy to do that right now...) :smile:
 
  • Like
Likes peasngravy
  • #10
I was asking about those as I thought I may need that to work out the input voltages at each resistor at the input. I suppose I could go for 1v and see what happens

I am going to give this a go tomorrow in that case, as it's getting late here. I will start off with a 4 resistors, 1k, 2k, 3k and 4k and use a bit of trial and error from there. I will keep reporting back as no doubt I will get stuck again... :)
 
  • Like
Likes berkeman
  • #11
t is obviously time, but what time do I need to use for these figures?

Since analog devices are continuous-time devices (within their bandwidth), you don't need to worry about the "t" in the Fourier representation, it disappears; i.e. it becomes an infinite sum of infinitesimals, which ends up being unity here.
 
  • #12
I am having a go at this now without too much luck.

I tried calculating 4voltage inputs, with the equations 5sin(1000), 5sin(1000*2), 5sin(1000*3) and 5sin(1000*4) as I didn't really know what else to do. I made each of these signals 1000, 2000, 3000 and 4000hz
 
  • #13
Don't worry about specific input voltage values for a particular instant in time. The black box circuit won't contain any time-dependent components like capacitors or inductors. It's simply a summing circuit. You just want to have the summing inputs have the appropriate weights (gains).

The time-dependent part comes when you simulate the system with Spice. It provides built-in voltage sources where you can simply supply the required voltage and frequency, and everything is then handled for you.
 
  • #14
So where I've got to is this:

As there are 4 inputs then ωt, time interval, is 0.25ms

So
5sin(ωt) = 5sin^-1 (0.25) = 1.25v, 14.5°
5sin(2ωt) = 5sin^-1 (2*0.25) = 2.5v, 30°
5sin(3ωt) = 5sin^-1 (3*0.25) = 3.75v, 48.6°
5sin(4ωt) = 5sin^-1 (4*0.25) = 5v, 90°

Gain = Vout/Vin = Rf/Rin

Gain of 1st input = 5/1.25 = 4 = rf/rin
If i make Rf 10k, then Rin = 10k/4 = 2.5k

And follow this on for the rest of the inputs - am i on the right track?

PS - is there a way to type equations so they appear correctly as fractions?
 
  • #15
peasngravy said:
PS - is there a way to type equations so they appear correctly as fractions?
Yes. Click on the "LaTeX Guide" link below the Edit window to see how to type equations here.

You can also click Reply on my post to see how I wrote this fraction:

Gain of 1st input = ## \frac{5}{1.25} = 4 = \frac{r_f}{r_{in}}##

(or on a separate line): $$ \frac{5}{1.25} = 4 = \frac{r_f}{r_{in}}$$
 
  • #16
peasngravy said:
So
5sin(ωt) = 5sin^-1 (0.25) = 1.25v, 14.5°
5sin(2ωt) = 5sin^-1 (2*0.25) = 2.5v, 30°
5sin(3ωt) = 5sin^-1 (3*0.25) = 3.75v, 48.6°
5sin(4ωt) = 5sin^-1 (4*0.25) = 5v, 90°
I don't think you need that for anything. Can you show us the opamp schematic with the resistors labeled? Have you started drawing your simulation circuit yet?
 
  • Like
Likes peasngravy
  • #17
this is my schematic so far with those gains, but it doesn't have the correct waveform yet

1604068465552.png
 
  • #18
peasngravy said:
this is my schematic so far with those gains, but it doesn't have the correct waveform yet

View attachment 271849
The input voltages should all have an amplitude of 5V, since those are the inputs to your block. And this is still an inverting topology, so to get the correct waveform you will need to invert the output (and maybe add an offset?)... Oh, and you will need wider power supply rails than just +/-5V, especially with a TL081 opamp -- Can you say why? :smile:

1604068690919.png
 
  • #19
Oops I just checked the TL 081 requirements and it needs a supply of +/-7-36V
 
  • #20
peasngravy said:
Oops I just checked the TL 081 requirements and it needs a supply of +/-7-36V
Yeah, it's definitely not a rail-to-rail opamp, but it should be fine for this simulation. I'd just set its rails to +/-15V to give plenty of headroom.
 
  • #21
I changed this now - I am just learning about op-amps now so I will make many more of these silly mistakes, unfortunately!

I changed that, and flipped the op-amp around, but I get nothing like what I am looking for. I added a dc offset at the inverting terminal.

I feel like I am way out of my depth with this right now :(
 
  • #22
peasngravy said:
I changed that, and flipped the op-amp around, but I get nothing like what I am looking for. I added a dc offset at the inverting terminal.
Can you post your updated schematic? And be careful -- the gain of a non-inverting summing stage is different from that of an inverting stage...
 
  • #23
Offset is set to -6 right now but I've just been messing around with different values for it for now

just editing to add - op amp rail supply is now +- 15, i just forgot to change the name of the terminals
 
Last edited:
  • #24
I just want to say i appreciate all the help you have given me so far. The theory side of this stuff is all new to me
 
  • Like
Likes berkeman
  • #26
So if i want the sum of the 4 inputs to be 5v, with a 5 volt input to each one, I would need them all to have a gain of -4 right, giving 4 inputs of 1.25V making a total Vin of 5v?

So a feedback resistor of 10k, with each input resistor being 2.5k, this would give me a gain of -4?

As Gain = Vin/Vout = -(Rf/Rin)
 
  • #27
peasngravy said:
So if i want the sum of the 4 inputs to be 5v, with a 5 volt input to each one, I would need them all to have a gain of -4 right, giving 4 inputs of 1.25V making a total Vin of 5v?

So a feedback resistor of 10k, with each input resistor being 2.5k, this would give me a gain of -4?

As Gain = Vin/Vout = -(Rf/Rin)
The gains for each component (sin waves of different frequencies) are given in your first post as the Fourier Series coefficients...

1604076029855.png
 
  • #28
I see - so those 4 voltages I calculated from the sin functions earlier should be how I calculate the gains i need?

i.e. 5/1.25
5/2.5
5/3.75
and 5/5 ?
 
  • #29
peasngravy said:
I see - so those 4 voltages I calculated from the sin functions earlier should be how I calculate the gains i need?

i.e. 5/1.25
5/2.5
5/3.75
and 5/5 ?
Something like that. Once you get the sawtooth waveform, you can fine tune the coefficients to get the 2.5V peak amplitude (plus remember to include the 2.5V constant offset term, both in the FW (which they omitted in the problem statement) and in your opamp circuit).
 

Attachments

  • 1604076660788.png
    1604076660788.png
    15.6 KB · Views: 170
  • #30
These need to be AC supplies with set frequencies right? otherwise i'll never get a waveform
 
  • #31
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 peasngravy
  • #32
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?
1604079151684.png


(i spent far longer than I should have trying to post this reply by hitting OK on the screenshot :smile:)
 
  • #33
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?
 
  • #34
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.
 
  • #35
Ok so I set up the sources with the following frequencies, and got this:
6283
12566
18849
251321604080586814.png

Regarding the peak, you're right of course, I just overthought that one, forgetting that i was only looking for half of a wave
 
  • #36
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:

1604080805568.png


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...

1604080998094.png


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

  • 1604080764096.png
    1604080764096.png
    7.3 KB · Views: 195
  • #37
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:

1604082119566.png

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

1604082459044.png

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 berkeman
  • #38
Yeah I think i will email him about that actually!
 
  • #39
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:
 
  • #40
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:
 
  • #41
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?
 
  • #42
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:
 
  • #43
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?
 
  • #44
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 berkeman
  • #45
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

1604086441265.png

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:)
1604086503702.png
 
  • #46
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...

1604086774037.png
 
  • #47
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?
 
  • #48
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 peasngravy
  • #49
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
 
  • #50
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 berkeman

Similar threads

Replies
3
Views
2K
Replies
7
Views
2K
Replies
13
Views
2K
Replies
6
Views
2K
Replies
15
Views
6K
Replies
3
Views
2K
Replies
6
Views
5K
Back
Top