LTSpice OpAmp oscillator - Page 1
Forum section: electronics / projects

author: steaky1212
author_rank: Regular Contributor
timestamp: February 08, 2012, 11:41:03 am
content: Hi,I've got this circuit in LTSpice and its not working quite how I expect it to.QuoteThe idea is that the output is supposed to oscillate as perhttp://hyperphysics.phy-astr.gsu.edu/hbase/electronic/square.htmlI only get a single pulse out, and then the inverting input settles just above that of the non-inverting input, and the output doesnt toggle again.Any ideasSteaky

author: jahonen
author_rank: Super Contributor
timestamp: February 08, 2012, 11:53:32 am
content: I think that the circuit in question requires a bipolar supply.Regards,Janne

author: steaky1212
author_rank: Regular Contributor
timestamp: February 08, 2012, 11:56:29 am
content: Janne,Thanks for the reply. The op-amp is a single-supply rail-rail opamp.Turns out I needed to change some of my values to get a decent oscillation.I went withQuoteThis gave me an on time of ~700ms, and a period of ~4.8s

author: jimmc
author_rank: Frequent Contributor
timestamp: February 08, 2012, 06:03:46 pm
content: You still need bipolar supplies even with a single supply OP-AMP.Think about what happens to the inputs when the output is low if there is no -ve supply.If you want a single supply rail split use two resistors for R2 (56k in your first cct), one to +ve supply the other to ground. (Junction to R3 as before)Jim

author: IanB
author_rank: Super Contributor
timestamp: February 08, 2012, 06:18:18 pm
content: Yes, the grounded end of R2 in the spice circuit needs to be at a voltage halfway between V+ and V- on the op amp supply.R3 and R2 form a voltage divider between V+ and GND or V- and GND depending on whether OUT is at V+ or V-. GND cannot be at either V+ or V- itself or this won't work. GND must be half way between V+ and V-.

author: steaky1212
author_rank: Regular Contributor
timestamp: February 09, 2012, 10:17:22 am
content: So thanks for all the comments.The opamp I was originally using was the LT1006S8 with is a single supply rail-to-rail opamp. My understanding of this is that it is unipolar and can be powered from Vcc and Gnd - saturating at each rail.The lowest power comparitor I could find was the LMC7215, so I dropped the spice definition file into LTSpice, and modified some of the values of components. Here is what I've come up with for a start...As you can see, it is pulsing nicely, and fairly regularly. I'm sure there are some modifications that will give lower power usage - so hitting LTSpice again.

author: jimmc
author_rank: Frequent Contributor
timestamp: February 09, 2012, 10:37:07 am
content: Simple simulations don't tell the whole story; please think about how the circuit works (or doesn't).Assume the output has just switched to 0v, the non-inverting (+) input will immediately be at 0v.C2 will then discharge to 0v taking the inverting (-) input with it.Both inputs are now at 0vand the state of the output is undefined, it will depend on the input offset voltage which varies from device to device.If you have a device with a positive offset , the circuit will work; if it's negative you're out of luck.Jim

author: ejeffrey
author_rank: Super Contributor
timestamp: February 09, 2012, 11:07:39 am
content: Quote from: steaky1212 on February 09, 2012, 10:17:22 amUsing a rail-to-rail opamp is only the first and easiest step to making a single-supply circuit. You absolutely cannot take a generic opamp circuit designed for use with a split supply, replace the opamp with a rail-to-rail device and connect -V to ground. The circuit you have described requires split supplies to work regardless of the type of opamp you use.Your circuit can easily be modified to work in a single supply configuration by adding a single resistor from the non-inverting input to V+. This resistor should be the same value as the one from the non-inverting input to V- (R2 in your earlier schematic, R7 in the newer one). This will correctly bias the operating point of the circuit to the mid-rail voltage. You should reduce your resistor values back to sane numbers as well.

author: steaky1212
author_rank: Regular Contributor
timestamp: February 09, 2012, 11:28:28 am
content: LMC7215 typical input offset voltage is typ 1mV, max 6mV.So I've changed the values around again (mainly due to the ones in my part box).I've included another resistor on the non-inverting input to Vcc which should take care of the undefined output stuffI also added a diode and resistor in parallel with the inverting feedback to give a non 50/50 duty cycle.How "bad" are simulators, as I am using the current draw of the circuit to give an indication of battery life?

author: ejeffrey
author_rank: Super Contributor
timestamp: February 09, 2012, 01:46:59 pm
content: Quote from: steaky1212 on February 09, 2012, 11:28:28 amSimulators are generally pretty accurate at analyzing well designed circuits. The main problem with simulators is garbage in, garbage out. If you don't give it good models of your components, including any parasitic effects that are important for your operating regime you won't get good results. If you don't set reasonable operating conditions, you won't get good results. If you feed it a bad circuit whose behavior is set by uncontrolled parameters like the input offset voltage, you will get bad results.You must always interpret the results critically. If a simulator says that your opamp will output 100 volts or 100 amps, you have to recognize that simply means you gave it a defective circuit and also did not set current and voltage limits on the supply. Simulators are a powerful and useful tool, but they don't replace brain cells or an understanding of circuits are supposed to work.

author: Bored@Work
author_rank: Super Contributor
timestamp: February 09, 2012, 02:08:47 pm
content: As a general rule, reality always trumps a simulator.If your circuit works in reality, but not in SPICE, guess who is wrong? Certainly not reality.If your circuit doesn't work in reality, but does work in SPICE, guess who is wrong? Again, certainly not reality.

author: ejeffrey
author_rank: Super Contributor
timestamp: February 09, 2012, 03:45:32 pm
content: Quote from: BoredAtWork on February 09, 2012, 02:08:47 pmI agree with the latter, but not necessarily the former. A circuit that works in reality but not in SPICE may be OK, but that is a very good hint that you may have done something horribly wrong. A circuit that appears to work but relies on some parasitic element may stop working tomorrow, or with a new batch of parts. Technically of course the simulator is still 'wrong' in that its results are not the same as your measurement, but in reality the problem is with neither the simulation or the measurement but your circuit.At the very least if you come up with a circuit that appears to work but simulates poorly you need to bang the hell out of it. Make sure it works over the full range of temperature, input signals, and loads, and with a selection of active devices to make sure you didn't just get lucky with the perfect device.Really, if you bothered to make a simulation and it disagrees with reality you should figure out what aspect of your circuit isn't being simulated accurately. Then you should either fix the simulation, or have a coherent explanation of why simulation is not practical. If you aren't prepared to do this, skip simulation altogether, it is just a waste of time.

author: Bored@Work
author_rank: Super Contributor
timestamp: February 09, 2012, 07:36:25 pm
content: Quote from: ejeffrey on February 09, 2012, 03:45:32 pmMaybe you have done something wrong in SPICE? Or SPICE does something wrong?For example, it can sometimes be incredibly difficult to get an oscillator started in SPICE. You need to artificially insert energy here and put a little imbalance there just to pacify the software. While in reality the oscillator will start without problems. I consider it a waste of time to appease a piece of software that just does an approximation of reality. When I know it works I couldn't care less if SPICE thinks otherwise.

author: Neilm
author_rank: Super Contributor
timestamp: February 09, 2012, 07:49:03 pm
content: Quote from: BoredAtWork on February 09, 2012, 07:36:25 pmI have always assumed that turning on an oscillator is what caused the imbalance as the various parts power up. This is very hard to simulate in Spice, although I suspect it could be done. I have seen Spice used to model a transformer - down to inter-turn and inter-layer capacitance.Neil

author: jahonen
author_rank: Super Contributor
timestamp: February 09, 2012, 07:56:06 pm
content: I think that the imbalance can be done with suitable initial conditions by saying .ic V(nodeX)=3.142 or similar statement to establish a biased starting point.Regards,Janne

author: jerry507
author_rank: Regular Contributor
timestamp: February 09, 2012, 08:53:39 pm
content: No noise modeled into your spice simulation is a pretty standard mistake in modeling an oscillator. Even if your oscillator meets all the stability criteria for oscillation, the real world noise which would normally provide the initial signal the loop gain amplifies does not exist. Initial DC biases will work, as will single shot pulses.A circuit that works in reality SHOULD also work in spice, but you have to take a lot of care in modeling it properly. This is the biggest criticism of CAD in electronics work.