Problem with OpAmp and Voltage Regulator SOLVED

Hello,

this simple model works fine (DC Sweep):

then I added some parts for a complete circuit and the sim shows a lot of spikes:

If I remove R2, the spikes are away, but the hysteresis, too...

Thanks, for help

Markus

by run8
July 02, 2012

Not sure what you're trying to do, but here's a few general observations.

Circuit 1:

The LM358 does not have a common-mode input range that reaches V+, it kinda poops out at about 1.5 volts below V+. So in a real circuit you can't tie either of the inputs to V+ (or V- ).

Circuit 2 is a bit better, with the inputs better scaled, however I don't see the point of feeding 90% of the unregulated voltage to the + input. That's not gonna work.

Pls see:

Which is maybe more like what you want to do. I removed some capacitors and feed theop amp with the full voltage, so it's able to sense its inputs.

Also put a diode to clamp the output, otherwise the rather wonky LM358 model puts out -60 volts, messing up the hysteresis action.

The simulation is still quite bizarre, with the - input being affected by what's at the + input. Weird.

by arduinohacker
July 02, 2012

Hi, I want to cut off a lead 24V Battery from load to prevent discharging below 21,6V. I need the hysteresis, because the battery voltage rises up with no load connected. The output stage is still missing in the design, a transistor switches a relay. Thx for reply and for help! Markus

by run8
July 02, 2012

BTW: where is the affection from - to + input? The - input is connected to the stabilized output of the lm317... i can't see it.

by run8
July 02, 2012

I misspoke! it's not just he op amp inputs that go funny, U_stab goes from 11.7 to 1.2 volts as the input goes from 23.6 to 23.8 -- impossible!

by arduinohacker
July 02, 2012

This might be a similar problem with timesteps being too short as discussed here:

https://www.circuitlab.com/forums/support/topic/2d4b2ku8/bugreport-opamp-output-gets-crazy-100v-with-feedback/

and:

https://www.circuitlab.com/forums/support/topic/86ufz43s/square-wave-generator/

In particular have a look at the example:

in the latter thread.

CL is very fussy about getting opamp circuits with positive feedback to simulate realistically. Schmitt triggers and relaxation oscillators built using schmitt triggers seem tricky to get to simulate properly.

by signality
July 02, 2012

Just wanted to let you know that our team is right now developing what we hope will be greatly improved transient simulator code (adaptive timesteps, better convergence properties, and special attention to getting this op-amp-with-limits situation resolved). It's tricky stuff, as there are lots of interacting nonlinearities, and we have an existing library of test circuits that have to pass as well.

Here's a little sneak peak of the development simulator's handling of one of these op-amp oscillators:

The simulator should be significantly less "fussy" once we complete our development and testing and are finally able to release these updates.

by mrobbins
July 02, 2012

Sorry, I'm spouting rubbish. I misunderstood your description of when you saw the spikes.

Your problem seems to be with the DC sweep and has nothing to do with timesteps.

You could try simplifying the circuit by replacing the LM317 with a voltage source and see if that helps.

by signality
July 02, 2012

@mrobbins,

Many thanks for that heads up. Improvements to the transient solver will be a great step forwards. There are clearly some problems with CL's DC sweep solver too. Will they be addressed in the same update or will that come at a later stage?

@run8, have a look at:

This replaces the opamp with a behavioural model which seems to work in the DC sweep.

I haven't tried it in the transient sim as your original circuit with an opamp seems to simulate in that. (My version may not work in CL because it is not always happy with the behavioural opamp in a transient sim: roll on those updates!)

Note however that I think you have the supply pins to the LM358 inverted. You had to flip the symbol vertically to get the +/- input pins the way you wanted so you have flipped the supply pins too.

:)

by signality
July 03, 2012

Ignore my comment about "I think you have the supply pins to the LM358 inverted".

I've just discovered that the supply pins on CL opamps are not polarity sensitive. You can set either supply pin to any voltage and the other to any other voltage and the model will correctly pick up which is the highest voltage supply limit and which is the lowest.

So if you set one pin to -5V and the other to +5V then the model will run with a high output limit of +5V and a low limit of -5V, irrespective of which supply pin is connected to the +ve and the -ve supply voltage.

In general, if you set either pin to Va and the other to Vb where Va > Vb then the model will operate with a high limit of Va and a low limit of Vb.

This is true even if Va > Vb > 0 or 0 > Va > Vb.

by signality
July 03, 2012

Funny, I don't get the correct Va Vb behavior on my test circuits. With the circuit above I get -50 volts out of the op amp on DC sweep, that's why I aded the diode clamp on the output.

On another circuit I was getting 63 gigavolts out.

I renew my request for a "real world" checkbox, where CL automatically puts X milliohms in series with each component lead, 1pF and 1 gig ohms to ground. That would help mitigate a lot of floating node and voltage sources going into short circuit errors.

by arduinohacker
July 03, 2012

Hi there, I think I have fixed the problem, the hysteresis was too large, so the opamp got out of range.

Here is a rework of the design, it works fine in the TD sim. Shoud I connect some Caps of 1u from the ops inputs to ground to preserve of oscillating problems?

Many thanks to all! Regards Markus

by run8
July 03, 2012

Okay, you're getting close. A few suggestions though:

  • A 10V zener would be a bit cheaper than a LM317. That saves you the cost of the diode, IC, and one capacitor

  • Do you really need the two potentiometers? Pots are expensive and they get dusty and unreliable after a while.

  • the LM358 isn't going to be able to drive the 2N2222 to the off condition-- the IC's specs are mighty vague, and the simulator is worse. Looking at the schematic of the LM358, it has two transistors CE and BE between the output and ground, so it's unlikely to be able to drive the output below 0.9 volts. The 2N2222 needs under 0.5 volts to be securely off. I would either:

(1) Put two diodes in series with the op amp output to drop the voltage by 1.2 volts, a 1K resistor in series to limit the base current to 10 mils or so, and a 470 ohm resistor to ground to bleed off leakage current.

(2) Or just a voltage divider- 1.8K in series, 470 ohms to ground.

(3) Or just use a real voltage comparator- they almost all have OC outputs that go down to 0.3 volts.

by arduinohacker
July 03, 2012

@run8, you probably don't need caps to ground on the opamp/comparator inputs. A cap from the + opamp i/p to ground defeats the purpose of the hysteresis because it slows the positive feedback down.

A cap from the - opamp i/p to ground might help reduce noise pickup but whether it helps or not is very layout & application dependent.

@arduinohacker, this is a demo of what I mean about the supply pins:

by signality
July 03, 2012

Hi there,

Many thanks for replies and tips.

A new rework of my design including your top tips:

I have replaced the lm317 by an Zener, is the dimension of R12 realistic? Then I have the 2N... changed with an N-Ch Fet that uses no base current. The OP is still the same (LM358), I want to use the TLC3702, but I don't know how I can simulate it, so just wrote the type in the schematic.

Regards Markus

by run8
July 04, 2012

Ah yes, that looks simpler and better. That comparator and MOSFET draw just microamps, so you don't need to push a lot of current thru the zener, the 14 mA or so is more than fine.

by arduinohacker
July 04, 2012

Post a Reply

Please sign in or create an account to comment.

Go Ad-Free. Activate your CircuitLab membership. No more ads. Save unlimited circuits. Run unlimited simulations.

About CircuitLab

CircuitLab is an in-browser schematic capture and circuit simulation software tool to help you rapidly design and analyze analog and digital electronics systems.