# Reasons for a simulated circuit to oscillate when the physical circuit does not

I am building a circuit to drive a solenoid with current control. I am driving it with a circuit based on the improved howland current pump.

Interestingly my simulated circuit displays a large amount of ringing on fast step inputs and I spent a good deal of time trying to stabilise the circuit by adding a capacitor across R5 (this worked but slowed down the response more than I would like), however when I physically build the circuit the ringing did not occur even without the extra capacitor.

I am used to this working the other way around with the "ideal" simulation exhibiting stability and the physical circuit oscillating.

What factors can lead to this.

I am suspicious of a few candidates.

• Poor spice models (However I am using TI Spice with TI's own component models)
• Stray capacitance damping things (this is constructed on a breadboard)
• Are these "fast step inputs" even in any way realistical? There is no point in simulating things like 1fs rise times... Jan 24, 2016 at 22:24
• I just double checked this, my physical edge of "touch wire against other wire" is faster than my simulated circuit 20ns for the physical, 5us for the simulated (which in an electrical sense isn't that fast) Jan 24, 2016 at 22:28
• touching one wire against another is by no means a step response. Look at it with a scope, it is a weird unpredictable curve. Think about the problems you can have with switch bounce and then how much worse just touching two cables is physically. Jan 24, 2016 at 22:31
• By touching two cables, I mean I have one wire pressed into a breadboard, and slide the other against the same hole to make firm contact, it is a bit rounded with a touch of overshoot, but no bouncing, and I would expect it to be more strenuous for the circuit though than a perfectly even, slower signal. Jan 24, 2016 at 22:37
• It is often about the frequency content, the sharper your "bends" are in a simulation, the more high frequency content there is, that does not exist in reality. Jan 24, 2016 at 22:39

Your model of the solenoid is very simple- perhaps there is a lot of distributed capacitance across the coil. Try simulating that with some dozens of pF across the coil. Also, perhaps there is a cable between the circuit and the solenoid with even more parallel capacitance.

Breadboards are not really great for this sort of thing, possibly you're getting some EMFs across the connections that are mucking things up (or stabilizing them!)- in particular I would suggest getting the high current paths off the breadboard (which probably means everything for such a simple circuit).

It's possible the op-amp model is not perfect (typically they're macromodels and don't attempt to model the behavior exactly- in return for which you get an answer faster, even if it's not quite right). But I would expect this kind of application would be right in their wheelhouse.

• I had thought about that and attempted that as a method of stabilisation, trying values up to very large capacitance values, and it only worked to a limited effect, and only when using capacitances that were large enough present a significant load to the op-amp. Measuring my physical coil I have a capacitance of 800nF. Jan 24, 2016 at 22:42
• That's quite a substantial capacitance! Jan 24, 2016 at 22:48
• Other possibilities are something to do with the power supplies. You've got perfectly 'stiff' power supplies on there, a bit of resistance (as in a breadboard, and modified by whatever bypass capacitors you are (?) using, will have some effect. What is the characteristic frequency of the ringing? That will give you a huge clue as to where the problem (or lack of problem) might lie. Jan 24, 2016 at 22:50
• I have 470uF electrolytic between the +-15V power rails and ground, and 0.1uF between the rails and ground right next to the op-amp. Jan 24, 2016 at 23:06
• The frequency seems dependant on the inductance of the load, and based on my simulation my physical circuit should ring at about 1Khz and die out after 10ms. Jan 24, 2016 at 23:14

A Howland current pump is not a particularly good way to generate a constant current in a solenoid -- a better way (assuming you only need unidirectional current) is to use a MOSFET with a current-sense resistor in the source to GND, the inductor in the drain to supply, and drive the gate with the opamp.

The Howland pump requires the R ratios to be quite accurate -- is it possible that the real ones do not match so well ? Try simulate with one of the 1k's 5 % higher or lower.

Also, if you have a fault, the inductor could generate high voltage transients -- you might add diodes from the inductor to each supply to protect the opamp.

• The final circuit will have protection circuitry, in this case I do need bipolar drive, and high side sense. I also have tried similar circuits with instrumentation amplifiers feeding a signal back to effectively a follower amp. But still got the oscillation, my theory was the op-amps just swing too quickly for the slow response of the load. Jan 24, 2016 at 23:11
• Also being a low quantity circuit the plan was to use 0.1% resistors and try to select good pairs. Jan 24, 2016 at 23:16