Single Supply Op Amp Integrator - Page 1
Forum section: electronics / beginners

author: FlyingHacker
author_rank: Frequent Contributor
timestamp: July 30, 2015, 08:44:11 pm
content: Is it possible to have a single supply op amp integrator?I have a 0.4Hz square wave from a 555 that is ~0-5v. I would like to convert it to a triangle wave around the same voltage range. Thoughts on this?I was thinking I could use an integrator. I can get this to work with a dual supply op amp, which is also inverting. This puts my triangle wave negative. (Actually I am getting some unwanted gain in my integrator, possibly due to wire resistance or tolerances.) I could then level shift this back up with a summing amplifier with unity gain. I could also invert it again if I needed to (in my case the inversion does not matter).Alternately, I could level shift my square wave to be AC (I don't think AC coupling capacitors will work well, as the frequency is < 0.5 Hz.) I could then integrate, and then level shift back up.I have tried RC on the output of the square wave, but this is the wrong shaped wave for my application. I would really like a real triangle (or pretty close).How would others approach this? I am a newbie to OpAmps, and trying to do this more as a learning experience than anything else. My experience lies in software. So doing this with the likes of an Arduino would be trivial. But I am interested in learning more about analog circuits.Thanks in advance.FYI: using an LM324.

author: TimFox
author_rank: Super Contributor
timestamp: July 30, 2015, 09:56:30 pm
content: You could place the non-inverting input at half the single supply voltage (with two resistors) and make a normal integrator with a resistor from the 555 and a feedback capacitor from the op amp output to the inverting input.Note that the peak-to-peak amplitude of the resulting triangle wave is proportional to the square wave period.More importantly, such a circuit has very high gain for the input DC component (difference between the DC value of the input square wave and the non-inverting input bias voltage). A feedback resistor in parallel with the capacitor decreases that gain, but louses up the square wave.A far better method is that used in traditional function generators. Make an integrator as above from the op amp and connect the integrator output (triangle wave) to the appropriate node of the 555 where it is compared against 1/3 and 2/3 of the supply voltage. Connect the output of the 555 to the integrator resistor through an appropriate inverter to get oscillation.This will give you a square wave from a good (constant-slope) triangle wave, which might work for your application. Change R or C or both of the integrator to change the frequency.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 30, 2015, 11:01:16 pm
content: For a function generator sort of application?You're making things worse for yourself: integration gets the correct waveform, but now the amplitude is proportional to frequency.How do you fix that? Variable gain amplifier? Is it open loop (say, driven by the same frequency adjustment signal that controls everything, or from a frequency-to-voltage converter)? Or closed loop (detects its own output amplitude, regulates to that)? And how accurate and fast can it be? Over what range?Not to beat on it -- these are difficult and interesting questions in their own right! But the solution for (what I assume is) your case, should be much simpler.The usual way to do it is to put the integrator first, and generate the square wave from that, not the other way around. This is what your 555 is doing already: it's just doing a crappy job, because it's wired as a crappy integrator.You could replace the charging resistor (whether you're doing it as a single resistor from pin 3 to pins 6+2, or with the divider from +V to pin 7 to pins 6+2) with a noninverting op-amp integrator (this sounds somewhat strange, but works just fine: see Howland current source), maybe with an added op-amp follower to reduce the effect of leakage through the 555 (which is what limits the wide-range or low-frequency performance of the 555).To make it electrically controllable (instead of by resistors), you can go an alternate route: using gated or switched current sources and sinks, instead of a transconductance circuit. Current sources and sinks are very easy to make from discrete transistors, and can be controlled over a very wide range (if not always a very accurate range as well). Here's an old example,Tim

author: FlyingHacker
author_rank: Frequent Contributor
timestamp: July 30, 2015, 11:57:17 pm
content: Thanks for your reply.Quote from: TimFox on July 30, 2015, 09:56:30 pmI did try this. Not sure what my issue was, but the triangle wave then only went from 1/2 the supply voltage up to the supply voltage (so the amplitude was half of the 555 square wave, and shifted up by 1/2 the square wave amplitude). I did not try, say, increasing the gain in this case. It is possible I only tried this with a single supply.Quote from: TimFox on July 30, 2015, 09:56:30 pmYes, this is something I did not realize, but makes sense. Hence why I am getting my hands dirty with this stuff to discover all those little gotchas...Quote from: TimFox on July 30, 2015, 09:56:30 pmThis kind of makes sense (just barely a little). I think I need to try it. What is then oscillating? The Op Amp, or the 555?Actually, not sure I understand how this gets hooked up. Any chance you have a picture/diagram, or a link to one?Thanks.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 31, 2015, 01:41:22 am
content: Well, soon as my DNS updates... in the mean time if you don't mind the dirty URL,http://65.31.177.22/tmoranwms/Circuits_2008/Triangle.gifYou might need some other references to understand the building blocks of this circuit, but it's current mirrors on the left, a buffer in the middle, and a differential amplifier (a simple discrete comparator or op-amp, depending on how you use it) on the right. It's wired for positive feedback, so it's acting as a comparator with hysteresis.As shown, this circuit covers a whopping 4.5Hz to 6MHz in a single range!The triangle wave appears on the capacitor Ct voltage (or preferably, the source of the JFET, since that's buffered), and the square wave on the 2N4403 collector.Tim

author: FlyingHacker
author_rank: Frequent Contributor
timestamp: July 31, 2015, 03:59:21 am
content: Wow. Thanks for the schematic. What is the type of the NPN transistor on the far left? Is that another 2N4401?Is is possible to substitute 2N2907 and 2N2222 for the 2N4403 and 2N4401 transistors you have here? That and some higher voltage transistors (and 2N3904s) are all I have at the moment.I guess I should build this up and look at it on the scope to learn how it works.BTW, the purpose of the circuit is not actually a function generator, per se. Though I would take another homebrew function generator, and enjoy learning about it. I have one old function Generator (F34) I got off eBay, which has pretty decent features for my purposes.The end goal is to drive 10 transistors that ramp from 0-5V up and down continuously, but each one ~36 deg out of phase with the previous. They will drive some display devices to generate a continuous wave like pattern. My plan was to make an oscillator at ten times the frequency and then use a 4017 counter as a way to get ten phase shifts. This would be at the square wave level. Then I would convert those squares to triangles or finally sine waves (as well as mix a few different frequencies for a water ripple type effect) That is why I was starting with a square wave. In my research I did not find any great solutions for phase shifting signals in the 1 HZ or slower range.It would be really easy to just drive them from a uC directly with PWM, or with a shift register and DACs. For some reason I thought it would be fun to try to do this analog. I obviously need further study.Thanks.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 31, 2015, 05:24:47 am
content: Quote from: FlyingHacker on July 31, 2015, 03:59:21 amUmm, dang, it isn't labeled, is it? Yes, I think it was 4401.QuoteYes, certainly. Though I don't knowwhyyou'd want to..2907 and 2222 are ancient, and along with 3055 and a handful of others, should be left to the historical dustbin; not that 3904 or 4401 are all that much better, but their spec sheets have some important lines that were missing from their predecessors.3904/6 would be more suitable for the circuit, really, but give or take some difference in top speed, practically anything will do. Only the current mirrors and diff pair need to be somewhat matched (same type). Between those, ah, 6 groups, you can use almost whatever you want for each...QuoteAs you can see, that was a natural environment for itQuoteHmm, interesting. See, consider this -- if nothing else, you must have one "state" for each output (LED, or group of them, if you've got sets arranged in wavefronts or something), which means many oscillators, or phase shifters, or something like that.That's not completely fair, because you can cheat if you're okay with a single phase shifted sine. You can build a quadrature oscillator, and use the I (in phase) and Q (out of phase) components to build a linear combination: 100% I + 0% Q = 0 degrees, the first LED; 80.9% I + 58.7% Q = 36 degrees, the second LED; and so on (simply cos and sin of the desired angle).Or instead of a dual output oscillator, build one oscillator, and phase shift it. Which is fine at constant frequency -- just as using an integrator to triangle-ize a square wave is fine at constant frequency, but tricky if it needs to be variable. There are "all-pass" phase shift networks you can design and build, but they're finicky, and hard to make for a wide range. You might be better off with a second oscillator, running in lockstep via phase locked loop, but its response time won't be great, if the frequency needs to change quickly (as might be the case for a function generator).By the way, you'll probably want not just a simple sine wave, but a biased sine wave (so the LED is some varying degree of on; minding that, strictly speaking, a sine goes positive and negative, see), and furthermore, it should probably be weighted for visual effect, not just linear but some function like squared or exponential, to match the eye's visual response. (Or, from another context: gamma correction.)So, yes, doing this thoroughly analog might be quite involved: if you want DC drive to each LED, you need to replicate all the drive and correction hardware, and that's just to get a single undulation from one phase shifted oscillator. You need more oscillators and more linear combinations (well, at least that's easy -- just linear mixing with an op-amp) to get more complex patterns.You're not completely screwed. If you don't mind the LEDs being, on average, dimmer (perhaps you turn up the drive current a bit past ratings to compensate), you can time-share one driver among N LEDs using a multiplexer. The sources need to be multiplexed, so that still doesn't help much, but the interesting part comes when you consider the signal source: a binary series of mixing resistors might be used, instead of the fixed phase angle resistors you'd use above. The exact count might be pulled from an EPROM, which is driven from an address counter doing the LED count. So each LED in turn is lit by its corresponding phase angle(s) as needed. Ah, of course, this is starting to look more and more digital...Or you might go the other route and absorb another pair of functions together. Instead of applying gamma correction to the LED current, drive them all at full current, and pulse width modulate it with an exponential time delay: created simply by feeding an RC circuit from a pulse and sensing the threshold with a comparator. The RC circuit charges along an exponent, so the on-time is exponential against the threshold. Boom, instant gamma correction! This is a perfect combination with multiplexing, too, though you still need the thresholds to be computed with the phase angles thing.Taking it from another direction, perhaps instead of a smooth "moving eye" (or Night Rider style) display, you meant the "ripples" more literally: an impulse starts on one location and propagates outward. You could use a chain of bandpass filtered amplifiers for this: down the chain, the frequency components are attenuated and propagated differently, leading to a fast "bloop" at the input side, leading to softer and more gradual ripples down the line. Now, this needs quite a lot of "state" components -- namely, resistors and capacitors, which remember what part of the wave they're on, essentially. But it has the potential to be the most general, just stack a bunch together and poke at it with a master oscillator.Which is also interesting if you simply speed it up: at audio frequency, such a circuit will have a bell-like timbre to it! You can add feedback taps to represent reflections and (limited) reverberations; minding that true reverberations take hundreds or thousands of cycles worth of delay, and you'll only get, at best, N cycles worth, for N stages, so it won't really sound like reverb unless you get really carried away with it. But as a single toned instrument, it could be an interesting addition to a synth panel.Tim

author: FlyingHacker
author_rank: Frequent Contributor
timestamp: July 31, 2015, 07:57:22 am
content: Actually, the display devices are IN-13 Nixie tube "bar graphs"... So the voltage to the transistor will drive the "level" of the tube up and down. I thought ten of them side by side oscillating up and down with two or three sine waves of different (low) frequencies added together would look pretty cool.Of course the easy way is a uC, but we could do a hybrid... Make one (or more) sine wave oscillators... Then use an ADC to convert those to digital (4-6 bits is probably enough if they are smoothed with capacitors). Feed that into one or more shift registers with a delay of a clock or two for each tube (for the phase shift). So tube one would get no shift, tube two a shift of two, tube three a shift of four, etc. Then convert that back to Analog to drive the tube transistors. Of course that is so close to doing it digitally there is not a ton of point in doing it that way, other than to prove it could be done.QuoteI thought the 2n2222 was just a higher current version of the 2n3904. I realize these are old. What are the modern go-to NPN and PNP bipolars? 2N4403 and 2N4401 ? I just bought some of the 2N2907 and 2N2222 units because they were popular in circuits I found online, and I found them bulk/cheap on eBay. Their data sheets looked like they would be adequate for most uses.Quote

author: Zero999
author_rank: Super Contributor
timestamp: July 31, 2015, 09:00:45 am
content: The usual way to do this is to have a Schmitt trigger between the input and output of the integrator.http://www.play-hookey.com/analog/generators/triangle_waveform_generator.html

author: FlyingHacker
author_rank: Frequent Contributor
timestamp: July 31, 2015, 04:50:46 pm
content: Quote from: Hero999 on July 31, 2015, 09:00:45 amThanks for the reply. I will try this.So with this circuit it says the amplitude of the resulting triangle is less than the square wave. Is the amplitude of the triangle still dependent upon the frequency?

author: T3sl4co1l
author_rank: Super Contributor
timestamp: July 31, 2015, 06:01:16 pm
content: Schmitt trigger -- another term for comparator with hysteresis. Same as my above circuit, and same as the 555 with the addition that the 555's voltage thresholds are a little better defined.Tim

author: dentaku
author_rank: Frequent Contributor
timestamp: July 31, 2015, 09:40:08 pm
content: By the way, a 555 is actually quite a bit more than you need to generate the square wave in the first place.A 40106 or 7414 Scmhitt Trigger inverter only needs a capacitor and a resistor(trimpot) to generate a square wave plus you get 6 of them in one IC.http://www.electronics-tutorials.ws/waveforms/tim29.gifhttp://circuit-diagram.hqew.net/Triangle-and-Squarewave-Generator-by-IC-40106_10393.html