curious spikes on triangle waves created from square waves through integrator - Page 1
Forum section: electronics / beginners

author: dentaku
author_rank: Frequent Contributor
timestamp: October 16, 2013, 06:49:20 pm
content: I'm not building anything I particular, just making oscillators that aren't square wave generators.I found the old Forest Mims Engineers Mini-Notebook originally written in 1985 ( hey, electricity hasn't changed since 1985 so it's still useful) and found the "Single-Supply Integrator" than can make a triangle wave out of a square wave.I already had a 555 on my little breadboard so I plugged it's output into an LM358N integrator circuit and it definitely makes a triangle wave as long as the original square wave has an even pulsewidth, as I suspected.BUT...Why do I get little spikes at the corners of the triangles?I tried using an LM339N instead to create the square wave but it gives the same results as using the 555.I noticed that if I buffer the output of the 555 square wave circuit using the other half of the 358 as a "unity-gain follower" before putting it into the integrator makes it better but it's still spikey.w2aew doesn't get spikes in this video.At low frequencies it all gets weird tooI'm curious to know what causes these spikes and how to fix it.

author: Odysseus
author_rank: Regular Contributor
timestamp: October 16, 2013, 10:30:31 pm
content: The spikes are caused by the high slew rate of the square wave edge and the low slew rate of your opamp. Basically, the opamp is too slow to keep up. The LM358 has a measly slew rate of 0.25V/uS, while a more capable jellybean opamp like the TL072/82 has a slew rate of 13V/us.No idea about the low frequency thing. Maybe a grounding issue?

author: c4757p
author_rank: Super Contributor
timestamp: October 16, 2013, 10:42:27 pm
content: How low is that frequency, what kind of capacitor are you using, and what exactly is your circuit's schematic?

author: m12lrpv
author_rank: Regular Contributor
timestamp: October 17, 2013, 01:03:53 am
content: I have found with many of my own circuits that what I thought was overshoot was really just a grounding issue. When I moved the ground point for the probe to a different location the effect went away.I don't know what your vertical scale is but I suspect with the low frequency you're hitting the upper rail of the op amp output.I feel that Odysseus is right in directing you to the op amp slew rate as a big factor in what you're experiencing.

author: w2aew
author_rank: Super Contributor
timestamp: October 17, 2013, 02:48:55 am
content: Also, be sure to use power supply decoupling caps on the op amp's supply pins.

author: dentaku
author_rank: Frequent Contributor
timestamp: October 18, 2013, 12:12:58 am
content: So you mean to simply put a capacitor across the + and - strip on the breadboard?I tried that but it didn't make any difference. What type/size of cap would you recommend people use on a breadboard?Quote from: w2aew on October 17, 2013, 02:48:55 am

author: dentaku
author_rank: Frequent Contributor
timestamp: October 18, 2013, 12:46:48 am
content: I ended up trying an old MC1741 and got the same results.THEN I made one out of an LM324AN and this time I built it using two nine volts instead of one like I had been doing with the 358 and 741 so I could get +9,0,-9 and built pretty much exactly like the circuit from this page (fig, 6.6.9)http://www.learnabout-electronics.org/Amplifiers/amplifiers66.phpI used a 15nF cap instead of 22nFI still get the spikes though.Tonight I noticed that the square wave coming out of the 555 changes and has little spikes too when it's connected to the LM324.Tomorrow I'm going to try and buffer the 555's output somehow before connecting it to the LM324 integrator circuit.WHAT DOES WORKis to create a square wave in a software synth and plug the headphone output of my computer into the LM324 and I get acompletely NON-Spikey triangle wavefrom the output so it works as it's supposed to, I just don't know how to do this using the 555 I guessI'm doing this just out of curiosity and to learn new stuff by building oscillators out of salvaged electronics. I'm building things that make sound because I understand synths but don't really know how the oscillators and filters actually work.This page has a good example of what I'm seeing on my scope, except it's worse for me.http://www.tradeofic.com/Circuit/11040-FEEDBACK_AMPLIFIER_INTEGRATOR.htmlQuote from: w2aew on October 17, 2013, 02:48:55 am

author: johansen
author_rank: Super Contributor
timestamp: October 18, 2013, 01:54:28 am
content: the 555 has a nasty shoot through everytime the output changes.try isolating the 555 from the opamp by supplying it with its own filter cap, isolated from the opamp through an inductor.

author: Circlotron
author_rank: Super Contributor
timestamp: October 18, 2013, 02:27:54 am
content: Quote from: dentaku on October 18, 2013, 12:46:48 amCompare the speed of the rising and falling edges of the square wave from the headphone socket vs the 555. The 555 will be WAY WAY WAY faster, probably 100-200nS. This is so quick it probably goes around the opamp to it's output pin via the integrator cap and gives a spike output on the rising/falling input edge till the opamp wakes up and takes over.

author: vk6zgo
author_rank: Super Contributor
timestamp: October 18, 2013, 05:39:59 am
content: Just for chuckles,build a passive integrating circuit & poke the squarewave into it.It will obviously be lower level output than the op amp circuit,but if the spikes are missing,you know they were something to do with the op amp and/or its associated circuitry.If the 555 rise time is what causes the problem for the original circuit.,you can fix this by a series "R" & shunt"C" at the output pin,with CR chosen to give a similar rise time to that of the soundcard.

author: Simon
author_rank: Unknown
timestamp: October 18, 2013, 06:47:18 am
content: Quote from: Circlotron on October 18, 2013, 02:27:54 amThat sounds quite plausible although I'm no expert

author: dentaku
author_rank: Frequent Contributor
timestamp: October 22, 2013, 03:33:24 pm
content: I did some more tests (with my limited knowledge of hardware) and yes, 555 square waves are not perfect SO I tried using the really nice square wave coming out of the CAL port of my ancient $40 oscilloscope and while it's better, I still get those spikes.I then tried to smooth out the slightly spikey looking square wave from the 555 by adding a large pot after a 100nF cap on the 555 output so I could adjust it and see what happens. It gives slightly rounded edges to the square wave until eventually I could make it look like a curvy triangle-ish wave. I'm assuming it just a simple lowpass filter of some sort like I use in synths all the time.The slightly filtered square wave output still produces a spikey (but better) triangle wave out of the integrator circuit. I was using a roughly a 2.5kHz signal.QUESTION: What's with the spikes that show up at the inverting input of the opamp?Here's what a square wave ends up looking like when I probe the inverting input of the opamp. It turns into a flat line with little spikes along it's length.This is what it looks like when I probe both the Input - and the Output pins and set my oscilloscope to A & BIf I set my oscilloscope to A - B of course it looks like what I want it to because it cancels out the spikes in Channel A from Channel B.Like I said, it gets much better if I use the nice clean square wave from the CAL port of my oscilloscope.

author: Unknown
author_rank: Unknown
timestamp: October 22, 2013, 03:55:18 pm
content: Very few people will have a monitor, let alone a browser window, that's 3000+ pixels wide, so please resize those pictures to a more reasonable size. Something like 800 pixels wide would probably be plenty to convey the information you want to convey. It's not very nice to waste bandwidth with 2-4 MB pictures, especially for people browsing via their phone.

author: johansen
author_rank: Super Contributor
timestamp: October 22, 2013, 08:12:02 pm
content: try a non inverting integrator.

author: dentaku
author_rank: Frequent Contributor
timestamp: October 22, 2013, 11:08:53 pm
content: I hate it when people post images larger than a browser windows too. Imageshack changed their interface since last time I used it and I assumed I was posting links to 640X480 images but I guess I wasn't.I edited my original post to use smaller images.Quote from: alm on October 22, 2013, 03:55:18 pm

author: dentaku
author_rank: Frequent Contributor
timestamp: October 22, 2013, 11:16:56 pm
content: Interesting, thanks for the hint.I just found thishttp://www.tradeofic.com/Circuit/3538-IMPROVED_NON_INVERTING_INTEGRATOR.htmlI will try it tomorrow.Quote from: johansen on October 22, 2013, 08:12:02 pm

author: nickm
author_rank: Regular Contributor
timestamp: October 23, 2013, 01:41:00 am
content: Quote from: dentaku on October 22, 2013, 11:16:56 pmAny DC offset, which includes the input offset of the integrator, is going to send the output to the rail. That circuit won't work as is.

author: c4757p
author_rank: Super Contributor
timestamp: October 23, 2013, 01:43:14 am
content: Throw a large resistor (100k - 1M...) across the capacitor.

author: R_G_B_
author_rank: Frequent Contributor
timestamp: October 24, 2013, 08:17:34 pm
content: Do you have access to a spectrum analyser. Frequency domain analysis will help you locate the source of the problem.

author: dentaku
author_rank: Frequent Contributor
timestamp: October 24, 2013, 11:17:16 pm
content: I ended up trying out the one I mentioned earlierhttp://www.tradeofic.com/Circuit/3538-IMPROVED_NON_INVERTING_INTEGRATOR.htmland I get spikes with this one too. It works quite well if I adjust the frequency just right and make sure the signal going into the integrator isn't too (in audio terms you would say loud) but it's too finicky and not useful across even the smallest range of frequencies. The .22nF cap in fig.2 seems to be a mistake. 0.22uF is more likely and it's what works for me.I was wondering if it was something to do with my old $40 B+K 15MHz oscilloscope so I plugged it into the line-in of my computer and the peaks and troughs of the wave look strange there too, just not with the tall skinny spike because I'm assuming the soundcard isn't even capable to capturing something like that.This was just an experiment in making something other than a square wave, which there seem to be billions of different ways.I have one more simpler non-inverting integrator I want to try so I'll probably try it tomorrow.

author: dentaku
author_rank: Frequent Contributor
timestamp: October 24, 2013, 11:20:49 pm
content: Not a standalone piece of hardware spectrum analyser if that's what you mean. I'm lucky to have an oscilloscope.I use the spectrum analyser plugin built into Ableton Live sometimes but that's just for audio.Quote from: R_G_B_ on October 24, 2013, 08:17:34 pm

author: R_G_B_
author_rank: Frequent Contributor
timestamp: October 25, 2013, 08:33:32 am
content: Have you looked at the digilent analogue discovery. Quite handy to get started with.

author: dentaku
author_rank: Frequent Contributor
timestamp: October 25, 2013, 01:44:07 pm
content: I've looked at some of the demo videos for that a while ago. It looks like it would be nice for someone like me who's really only interested in audio devices.Quote from: R_G_B_ on October 25, 2013, 08:33:32 am

author: dentaku
author_rank: Frequent Contributor
timestamp: November 09, 2013, 12:43:25 am
content: OK, I finally tried some more at integrating a square wave and getting a clean triangle wave from it.I found a TL082CP in an old Furuno Loran C unit and it definitely works better than opamps salvaged from radios.I guess the TL082 is just better suited at doing this?BUTI actually got a plain old LM358 to only produce rather tiny spikes by choosing just right size cap (22nF) and making sure that the squarewave signal wasn't tooloudand found the spikes can be filtered out by connecting a tiny cap from the output to ground. I'm assuming this just makes a simple lowpass filter that slightly rounds off the tops of the triangles along with the high frequency spikes.Here's how it looks with the LM358.