Author Topic: curious spikes on triangle waves created from square waves through integrator  (Read 13641 times)

0 Members and 1 Guest are viewing this topic.

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
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 too :)


I'm curious to know what causes these spikes and how to fix it.
« Last Edit: October 16, 2013, 07:07:27 pm by dentaku »
 

Offline Odysseus

  • Regular Contributor
  • *
  • Posts: 148
  • Country: us
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?
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
How low is that frequency, what kind of capacitor are you using, and what exactly is your circuit's schematic?
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline m12lrpv

  • Regular Contributor
  • *
  • Posts: 175
  • Country: au
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.
 

Offline w2aew

  • Super Contributor
  • ***
  • Posts: 1780
  • Country: us
  • I usTa cuDnt speL enjinere, noW I aR wuN
    • My YouTube Channel
Also, be sure to use power supply decoupling caps on the op amp's supply pins.
YouTube channel: https://www.youtube.com/w2aew
FAE for Tektronix
Technical Coordinator for the ARRL Northern NJ Section
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
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?


Also, be sure to use power supply decoupling caps on the op amp's supply pins.
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
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.php I used a 15nF cap instead of 22nF
I 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 WORK is to create a square wave in a software synth and plug the headphone output of my computer into the LM324 and I get a completely NON-Spikey triangle wave from the output so it works as it's supposed to, I just don't know how to do this using the 555 I guess :)

I'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.html

Also, be sure to use power supply decoupling caps on the op amp's supply pins.
 

Offline johansen

  • Super Contributor
  • ***
  • Posts: 1123
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.
 

Offline Circlotron

  • Super Contributor
  • ***
  • Posts: 3319
  • Country: au
WHAT DOES WORK is to create a square wave in a software synth and plug the headphone output of my computer into the LM324 and I get a completely NON-Spikey triangle wave from the output so it works as it's supposed to, I just don't know how to do this using the 555 I guess :)
Compare 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.
 

Online vk6zgo

  • Super Contributor
  • ***
  • Posts: 7699
  • Country: au
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.
 

Offline Simon

  • Global Moderator
  • *****
  • Posts: 18022
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
WHAT DOES WORK is to create a square wave in a software synth and plug the headphone output of my computer into the LM324 and I get a completely NON-Spikey triangle wave from the output so it works as it's supposed to, I just don't know how to do this using the 555 I guess :)
Compare 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.

That sounds quite plausible although I'm no expert
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
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 & B


If 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.
« Last Edit: October 22, 2013, 11:07:01 pm by dentaku »
 

alm

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

Offline johansen

  • Super Contributor
  • ***
  • Posts: 1123
try a non inverting integrator.
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
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.

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.
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
Interesting, thanks for the hint.
I just found this http://www.tradeofic.com/Circuit/3538-IMPROVED_NON_INVERTING_INTEGRATOR.html
I will try it tomorrow.

try a non inverting integrator.
 

Offline nickm

  • Regular Contributor
  • *
  • Posts: 79
Interesting, thanks for the hint.
I just found this http://www.tradeofic.com/Circuit/3538-IMPROVED_NON_INVERTING_INTEGRATOR.html
I will try it tomorrow.

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

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Throw a large resistor (100k - 1M...) across the capacitor.
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline R_G_B_

  • Frequent Contributor
  • **
  • Posts: 399
  • Country: gb
Do you have access to a spectrum analyser. Frequency domain analysis will help you locate the source of the problem.
R_G_B
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
I ended up trying out the one I mentioned earlier http://www.tradeofic.com/Circuit/3538-IMPROVED_NON_INVERTING_INTEGRATOR.html and 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.
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
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.

Do you have access to a spectrum analyser. Frequency domain analysis will help you locate the source of the problem.
 

Offline R_G_B_

  • Frequent Contributor
  • **
  • Posts: 399
  • Country: gb
Have you looked at the digilent analogue discovery. Quite handy to get started with.
R_G_B
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
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.

Have you looked at the digilent analogue discovery. Quite handy to get started with.
 

Offline dentakuTopic starter

  • Frequent Contributor
  • **
  • Posts: 881
  • Country: ca
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?


BUT
I 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 too loud and 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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf