Author Topic: Triangle wave generator  (Read 15415 times)

0 Members and 1 Guest are viewing this topic.

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Triangle wave generator
« on: November 14, 2015, 02:07:44 pm »
I love to work with opamps, I tried to understand the working and the math and for the most part I get it right. With a little of experimenting I get what i'm looking for correct. I got stumped by this simple tringle wave generator, and I think it has to do with using single source power.
I need to generate a square wave at around 7.5kHz, it needs to be around 2.5V pp, but I can control that in the output with a pot, no big deal. I'm using a LM358, powering it with 18V.
Below is the schematics and what I'm getting on the scope. As you can see I cannot get the wave between the rails, is clipped top and bottom.
« Last Edit: November 14, 2015, 02:21:06 pm by dan3460 »
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21606
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Triangle wave generator
« Reply #1 on: November 14, 2015, 02:38:39 pm »
Increase the capacitor and decrease the integrator resistor.
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: Triangle wave generator
« Reply #2 on: November 14, 2015, 03:19:31 pm »
I tried a smaller cap, still the same result. I even used a jumper instead of the cap, changed the frequency but still off the rails.
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21606
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Triangle wave generator
« Reply #3 on: November 14, 2015, 03:33:31 pm »
Try less hysteresis (47k --> 22 or 10k)?

Note that the comparator isn't perfectly fast, but rather excruciatingly slow at this frequency, so you will not get ideal triangle wave amplitude, but more due to the time it takes to react.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: Triangle wave generator
« Reply #4 on: November 14, 2015, 04:02:36 pm »
I started to think that there is a limitation of the OPAMP. Up to about 2.5kHz I can get a fairly good tringle, as a play with the cap and integrator resistor, I started to get distortion. I probably going to need a different opamp for what I want to do.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Triangle wave generator
« Reply #5 on: November 14, 2015, 07:01:46 pm »
It's not just the op-amp but the comparator. Try using a 555 timer for the Schmitt trigger part and keep the LM358 as the op-amp. If that's not fast enough, try a faster op-amp, such as the NE5532.

EDIT:
Brain fart. The 555 is inverting. You need a non-inverting Schmitt trigger. The spare LM358 could be used to invert the signal.
« Last Edit: November 15, 2015, 10:04:04 am by Hero999 »
 

Offline onlooker

  • Frequent Contributor
  • **
  • Posts: 395
Re: Triangle wave generator
« Reply #6 on: November 15, 2015, 04:57:16 am »
I think the OP's 56p is too small to the degree that it has no more effect in that the RC constant (a few hundred kHz(?)) is no longer related to the actual frequency. That is, "parasitics" dominants now or the circuit is working now in a different osc mode(?).  If it is changed to 56n, you will have more normal triangle waves. At least, these are what LTspice will show, including OP's chopped waveforms.
« Last Edit: November 15, 2015, 05:38:17 am by onlooker »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Triangle wave generator
« Reply #7 on: November 15, 2015, 10:10:28 am »
I think the OP's 56p is too small to the degree that it has no more effect in that the RC constant (a few hundred kHz(?)) is no longer related to the actual frequency. That is, "parasitics" dominants now or the circuit is working now in a different osc mode(?).  If it is changed to 56n, you will have more normal triangle waves. At least, these are what LTspice will show, including OP's chopped waveforms.
The problem then becomes the resistor would need to be very low, just 2.6Ohms and the op-amp doesn't have the drive capability for such a low impedance.

The parasitic which is dominating is the op-amp's slew rate due to the internal compensation capacitor. The Schmitt trigger part of the circuit will first show this as the output needs to be a square wave which has a fast rise/fall time.

A comparator IC could be used for the Schmitt trigger, instead of the LM358. Ideally one with a push-pull output so no pull-up resistors are required which reduce the sourcing current capacity.
 

Offline onlooker

  • Frequent Contributor
  • **
  • Posts: 395
Re: Triangle wave generator
« Reply #8 on: November 15, 2015, 02:39:58 pm »
I was trying to say C=56p is way too small for f=7.5kHz.

The formular is approximately: f ~= 1/(2RC), or

C = 1/(2fR) = 0.5/(7500x2600) =  0.0256uF = 25.6nF

In other words, for 56p, the circuit is targeting a freq that is about 500 times of 7.5kHz,  which is quite beyond the 1MHz bandwidth or 5us edge of LM358. It could be that 56p was just a typo or calc error. The R=2.6k part can stay.


« Last Edit: November 15, 2015, 03:09:04 pm by onlooker »
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Triangle wave generator
« Reply #9 on: November 15, 2015, 02:53:43 pm »
Hi-speed triangular oscillators are usually done this way:

A reasonable speed opamp (like TL074, NE5534 or any faster modern one), then by using two separate fast (or can even be not so fast) comparators (LM311, LM319) you will set the two thresholds for the amplitude level and then feed the comparator outputs to an R-S flip-flop (usually 4013 or so can be enough). The output of the flop will be fed back into the integrator.

This way you'll get a stable amplitude oscillator, which can be frequency tuned by a single resistor (capacitor) and has low distortion of the waveshape.

Here's an example:
« Last Edit: November 15, 2015, 03:06:44 pm by Yansi »
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Triangle wave generator
« Reply #10 on: November 16, 2015, 10:55:00 pm »
It looks quite complex.

In this case the NE5534 & LM311 should be good enough.
 

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: Triangle wave generator
« Reply #11 on: November 17, 2015, 04:34:40 pm »
I think the OP's 56p is too small to the degree that it has no more effect in that the RC constant (a few hundred kHz(?)) is no longer related to the actual frequency. That is, "parasitics" dominants now or the circuit is working now in a different osc mode(?).  If it is changed to 56n, you will have more normal triangle waves. At least, these are what LTspice will show, including OP's chopped waveforms.
Thanks for the answer, with the 56p it is oscillating at around 7.5kHz (should have included that with the picture). I will set up the rig on my bench again and try.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Triangle wave generator
« Reply #12 on: November 17, 2015, 11:13:21 pm »
onlooker tried to suggest increasing the feedback cap to a level where the parasitic capacitance of the circuitry becomes insignificant.

The circuit with two comparators and an RS flip-flop is not complex. It is just a proper way how to make amplitude stable (supply independent) triangle wave, without much distortion and with very good symmetry. Only the frequencly remains supply dependent, but that is also easily solvable by slightly modifying the circuit. The schematic is from a device where the exact and precise frequency wasn't a requirement, but stable amplitude certainly was.

The circuit from Hero999 has also a disadvantage of producing assymetrical waveshape. The ratio of the rising : falling slope duration here is given by R2, R9 (partialy by the positive feedback network of R8, R7).

//Of course my description of the problems with these circuits isn't exhaustive, there some more dependencies of some component values, and so. But you can get some rough idea, how do they work.
« Last Edit: November 17, 2015, 11:15:19 pm by Yansi »
 

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: Triangle wave generator
« Reply #13 on: November 18, 2015, 12:35:57 pm »
Thanks everyone, please excuse me but I forgot to add something and it is crucial.  :palm: I'm using single rail operation. I have not tried but I think if I setup the rig on a dual rail operation I will get the desired effect (maybe not).
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Triangle wave generator
« Reply #14 on: November 18, 2015, 05:19:09 pm »
Single rail operation doesn't change anything. Just bias the + input of the integrater and - input of the comparator to a half supply voltage. Just see the Hero999's schematic. It's exactly that. Same can be done for the more sofisticated circuit with the flipflop I have posted.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Triangle wave generator
« Reply #15 on: November 18, 2015, 11:13:49 pm »
The circuit from Hero999 has also a disadvantage of producing assymetrical waveshape. The ratio of the rising : falling slope duration here is given by R2, R9 (partialy by the positive feedback network of R8, R7).
Well you could make R7 as high as possible but then the value of C1 would need to  be very low.

Ideally you need a comparator with an output which saturates close to the power supply rails. It can be done with the LM311 and a few transistors.

 

Offline miguelvp

  • Super Contributor
  • ***
  • Posts: 5550
  • Country: us
Re: Triangle wave generator
« Reply #16 on: November 19, 2015, 12:45:48 am »
Since no one has linked these videos from w2aew I guess I will, since they are related to the subject and he explains very well how they work:




 

Offline pkplex

  • Contributor
  • Posts: 22
Re: Triangle wave generator
« Reply #17 on: December 09, 2015, 10:43:34 am »
Hello there.

I have just breadboarded the circuit in the w2aew's video and found some strange bits. The reference circuit can be seen here: http://www.qsl.net/w/w2aew//youtube/Adjustable_Sawtooth_Generator.pdf

First of all I am using an LM358 instead of a comparator ( I don't have any on hand at the moment ), I am using a BC 547 and a BC 557 for the transistors, and 10k pots to adjust the current on the collectors, and also 10k resistors for the divider and feedback on the opamp.

So it seems to work well, and during my playing around I found it had a strange lull in the rising and falling edges of the output of the LM358. These edges seemed to line up to the voltage of the capacitor ( hopefully this can be seen in the scope screenshot ).

Can someone explain what is going on here? My first guess is that its some kind of shenanigans related to the diodes switching from reverse to forward bias or vice versa.. is this the case?

And the slope of the opamp's output seems a bit slow.. I know I should be using a comparator here, but I thought it would be a bit sharper than that.. any suggestions in this area?

Thanks

 

Offline pkplex

  • Contributor
  • Posts: 22
Re: Triangle wave generator
« Reply #18 on: December 09, 2015, 02:23:06 pm »
So after some more mincing around and what not, I have discovered that my probes seem to affect the circuit.

So both probes are on 1x. One probe is on the capacitor, and the other I use to probe pins on the opamp.

So if I probe the non inverting input, the oscillation stops regardless of 10x or 1x. If I probe either the output of the opamp, or the inverting input with 1x, the circuit keeps going, though I notice a frequency difference of about 1Khz ( in this case output is 11Khz to 12Khz ).

However if I change the probe to 10x, the circuit stops oscillating on either the opamp output, or the opamp inverting input.

Any ideas what's going on here?
 

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: Triangle wave generator
« Reply #19 on: December 09, 2015, 04:09:20 pm »
Where is the ground of the probes connected?
 

Offline pkplex

  • Contributor
  • Posts: 22
Re: Triangle wave generator
« Reply #20 on: December 09, 2015, 04:10:29 pm »
to psu/circuit ground
 

Offline dan3460Topic starter

  • Frequent Contributor
  • **
  • Posts: 326
  • Country: us
Re: Triangle wave generator
« Reply #21 on: December 09, 2015, 06:08:21 pm »
Can you post pictures of the setup?
 

Offline dom0

  • Super Contributor
  • ***
  • Posts: 1483
  • Country: 00
Re: Triangle wave generator
« Reply #22 on: December 09, 2015, 07:54:15 pm »
x1 probe is about 60.. 80 pF to ground
x10 probe is about 12 pF to ground
,
 

Offline pkplex

  • Contributor
  • Posts: 22
Re: Triangle wave generator
« Reply #23 on: December 09, 2015, 10:58:52 pm »
Here we go, hopefully clear enough
 

Offline pkplex

  • Contributor
  • Posts: 22
Re: Triangle wave generator
« Reply #24 on: December 10, 2015, 02:59:27 am »
I dug around and happened to find some quad 2 input NAND schmitt triggers in a box, and chucked that in place of the LM358. Muuuuuuuuuuch nicer rise times, and I can adjust the output frequency a lot easier with the full range of the 10k potentiometers rather than having to change the cap all the time.

However probing the output of the shmitt trigger, and changing it to 10x, still buggers up the oscillation. Requires a beverage and further investigation :)
 

Offline pkplex

  • Contributor
  • Posts: 22
Re: Triangle wave generator
« Reply #25 on: December 10, 2015, 11:14:41 am »
Current circuit, with a 1nF cap it works from around 20Khz to around 400Khz without rounding the triangle waveform. Much fun :)

Thanks w2aew :)
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: Triangle wave generator
« Reply #26 on: December 11, 2015, 01:05:27 pm »
The LM358 makes a rubbish comparator/Schmitt trigger.

If board space is an issue, the 555 timer could be used but note the higher power consumption and the possible need for extra decoupling capacitors, unless a CMOS variant is used.
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Triangle wave generator
« Reply #27 on: December 13, 2015, 04:19:18 pm »
Whats the advantage of this circuit using separate current sources and the switchbridge?

Same results (or nearly similar) can be obtained with the learn-book basic two opamp triangle wave circuit, if you just replace the integrator's input resistor with potentiometer: wiper on comp. output  and ends through diodes to the opamp input.  Or if you want to set the rising/falling slopes separately, then two pots and again two diodes. Simple, easy, working too.

But sure, the diode switch bridge and current source/sink is more entertaining for a beginner. The biggest disadvantage being the nonlinear current setpoint by the trimpots in the emitors. And note there's an error in the PDF from W2AEW on page 4: misslabeled outputs.
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2731
  • Country: ca
Re: Triangle wave generator
« Reply #28 on: December 13, 2015, 05:12:43 pm »
Hi,

The original schematic is not too far off.

It will work if a faster op-amp is used. It needs at least 3 MHz of GBW and 10V/us of slew rate. The TL084 etc will work.

I also had to adjust the values, but I ended up with 2.5V p-p at 7.5kHz






Regards,

Jay_Diddy_B
 

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1780
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
Re: Triangle wave generator
« Reply #29 on: December 13, 2015, 10:26:13 pm »
<snip>
 And note there's an error in the PDF from W2AEW on page 4: misslabeled outputs.

Where's the error in my pdf?
YouTube channel: https://www.youtube.com/w2aew
FAE for Tektronix
Technical Coordinator for the ARRL Northern NJ Section
 

Offline Yansi

  • Super Contributor
  • ***
  • Posts: 3893
  • Country: 00
  • STM32, STM8, AVR, 8051
Re: Triangle wave generator
« Reply #30 on: December 14, 2015, 07:24:55 pm »
I apologize, my fault. I have looked again, no problem. Maybe I was too tired and sleepy  when I checked last time.

By the way, you have a great YouTube channel, good source of inspiration.  :-+
 

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1780
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
Re: Triangle wave generator
« Reply #31 on: December 14, 2015, 09:30:49 pm »
I apologize, my fault. I have looked again, no problem. Maybe I was too tired and sleepy  when I checked last time.

By the way, you have a great YouTube channel, good source of inspiration.  :-+

Thank you.  I do my best to keep errors out of my videos and support materials, but sometimes they do slip by - so I am happy to hear when someone finds a problem so that I can go back an fix it.
YouTube channel: https://www.youtube.com/w2aew
FAE for Tektronix
Technical Coordinator for the ARRL Northern NJ Section
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf