Current regulator cannot be simulated in closed loop.


 

Hi all, I have a problem with a current regulator that I have designed and wanted to simulate with LTSpice before I build it.

Unfortunately it cannot be simulated in closed loop mode (U2 output connected to the 1k resistor next to it) but in open loop (U2 output not connected to the 1k resistor) it works very well.

I always get the error message: Singular matrix: check nodes u1:6 and u2:5  Iteration No. 2, I tried several changes with the SPICE control parameters. I only get "ifferent error messages:

Either "Time step too small" or "singular matrix". So I expect I do something fundamentally wrong but I have no idea what that could be. Please help.

The files I used for the simulations are stored here:

https://groups.io/g/LTspice/files/Temp/CurrentRegulator


 

Markus,

Please upload the LM324 model file you used too (LM324.MOD).  Even if you downloaded it from this group, there may be more than one version of the file.  We need the one you are using.

Can't try your simulation without it.

The "FAQ" file (https://groups.io/g/LTspice/files/z_yahoo/FAQ/faq_17-2.txt) has a large section about "Time step too small" errors.  Try it.

Andy


 

Andy,

thank you very much for the very quick reply. I have uploaded the LM324.MOD file. I will also have a look to the FAQ. I have already tried quite some ideas that I could find in the internet on the "Time step too small" error. But was not successful so far :-(.  What is strange to me is that I get different errors mainly related to the MOSFET I used (and I tried different ones ...) when I change some simulation parameters. And also the type of error changes. But the error
messages are not useful to me.


If you need some more comments about the concept of the regulator please tell me.
Thank you very much.

Markus


 

Hello Markus

You also need some .MODEL for the MOS. Or .SUBCKT, in which case the
prefix needs changing from MP to X.

At any rate, I changed the MOS and the opamp to ones available in the
default LTspice database (LT1006 and IRF7205, semi-random choices),
and everything works instantly. What's more, if you change the value
of R2 to be "R=1/(0.1m+2*time)" (copy everything inside the quotes,
without the quotes), you'll see how the output changes dynamically.
Note that This expression relies on the fact that you're stepping the
resistor from 10 to 11k, which makes the current values to range from
10k to ~100.

--
Vlad
______________________
ltspicegoodies.ltwiki.org v2:
quite universal analog/digital filter,
power electronics, signal processing,
easy to work with math functions,
digital models, and rants.


 

The LM324 output stage is non-linear (Class B). That may be why  the Time step error occurs. The output can be linearized, as explained in the data sheet.

======================================================================================
Best wishes John Woodgate OOO-Own Opinions Only www.woodjohn.uk Rayleigh, Essex UK
People have to be told in stark terms that they can disobey the Covid rules at the risk of their own lives,
but disobeying at the risk of others' lives is no less than a crime against humanity.
On 2020-10-26 13:23, Vlad wrote:
Hello Markus

You also need some .MODEL for the MOS. Or .SUBCKT, in which case the
prefix needs changing from MP to X.

At any rate, I changed the MOS and the opamp to ones available in the
default LTspice database (LT1006 and IRF7205, semi-random choices),
and everything works instantly. What's more, if you change the value
of R2 to be "R=1/(0.1m+2*time)" (copy everything inside the quotes,
without the quotes), you'll see how the output changes dynamically.
Note that This expression relies on the fact that you're stepping the
resistor from 10 to 11k, which makes the current values to range from
10k to ~100.


Virus-free. www.avg.com


 

On 26/10/2020 14:16, Markus Reinhardt via groups.io wrote:

thank you very much for the very quick reply. I have uploaded the LM324.MOD file. I will also have a look to the FAQ. I have already tried quite some ideas that I could find in the internet on the "Time step too small" error. But was not successful so far :-(.  What is strange to me is that I get different errors mainly related to the MOSFET I used (and I tried different ones ...) when I change some simulation parameters. And also the type of error changes. But the error
messages are not useful to me.


If you need some more comments about the concept of the regulator please tell me.
Thank you very much.
I chose a different MOSFET and substituted the LM324 for a default UniversalOpamp2 and the schematic simulates without a problem. Whether it's what you want, I can't say, but it works.

Beware all those old NatSemi/TI models - many were poorly written. It saves much time using the UniversalOpamp2 behavioural model, as it's guaranteed to work with LTspice and simulates much faster than any other realistic opamp model.

--
Regards,
Tony


 

Hello John,
Thank you for the interesting hints. The MOSFET IRF9Z34N I took from the latest version of LTSpice (where it is available) and I wanted to use it because I own a couple of it and have to use it. I wanted to use LM324 again because I have a couple of it left over and they seem to be useful with single supply, but I also have some LT1006 available, so probably  I will replay the LM324.
Thanks again.

Marku


 

Tony,

Thank you for the hints! I also changed for other MOSFETs, but that did not help much. I assume it is more about the LM324.

I will try other OpAmps now, at least in simulations to do a better analysis. The reason I chose LM324 was because I have a couple of those left over and wanted to use them in the true hardware. Probably I will finally replace the LM324 with LT1006 in simulation and hardware ...

Markus


 

On 27/10/2020 09:26, Markus Reinhardt via groups.io wrote:
I will try other OpAmps now, at least in simulations to do a better analysis. The reason I chose LM324 was because I have a couple of those left over and wanted to use them in the true hardware. Probably I will finally replace the LM324 with LT1006 in simulation and hardware ...
Why not just use the UniversalOpamp2? It can be adjusted to give similar performance to any proprietary device, and is guaranteed to work. Unless the circuit is ultra critical of opamp performance, it can be a waste of time worrying about other models. Your circuit is essentially DC, so bandwidth shouldn't be important. Additionally, many proprietary opamp models are not very good and you can waste a lot of time with an apparent problematic circuit when no such problem actually exists.

--
Regards,
Tony


 

O.k. I will try for sure now with UniversalOpamp2. I thought I should use the LM324 model which I expected to be closest to the hardware I intended to use (a real LM324),

at least closer than any universal ideal model, but I might be wrong if the LM324 model is not good as mentioned.

But I also do not know much about UniversalOpamp2 in comparison to true opamps.

I guess I will try simulations now with the UniversalOpamp2, optimize my circuit and parameters and then see if I can use LT1006 in simulation and hopefully in the final hardware.

Markus


 

The Universal opamp2 is not like the LM324, which has this special Class B output stage. Look at the data sheet to see how to make the output stage work in Class A, eliminating the sharp non-linearity at waveform zero-crossings that is probably causing your time step error.

======================================================================================
Best wishes John Woodgate OOO-Own Opinions Only www.woodjohn.uk Rayleigh, Essex UK
People have to be told in stark terms that they can disobey the Covid rules at the risk of their own lives,
but disobeying at the risk of others' lives is no less than a crime against humanity.
On 2020-10-27 09:15, Markus Reinhardt via groups.io wrote:

O.k. I will try for sure now with UniversalOpamp2. I thought I should use the LM324 model which I expected to be closest to the hardware I intended to use (a real LM324),

at least closer than any universal ideal model, but I might be wrong if the LM324 model is not good as mentioned.

But I also do not know much about UniversalOpamp2 in comparison to true opamps.

I guess I will try simulations now with the UniversalOpamp2, optimize my circuit and parameters and then see if I can use LT1006 in simulation and hopefully in the final hardware.

Markus


Virus-free. www.avg.com


 

On 27/10/2020 10:15, Markus Reinhardt via groups.io wrote:

O.k. I will try for sure now with UniversalOpamp2. I thought I should use the LM324 model which I expected to be closest to the hardware I intended to use (a real LM324),

at least closer than any universal ideal model, but I might be wrong if the LM324 model is not good as mentioned.
UniversalOpamp2 isn't "ideal". You can edit its specification in respect of open loop gain, gain-bandwidth, slew rate and a bunch of other mostly DC parameters.

But I also do not know much about UniversalOpamp2 in comparison to true opamps.
Be aware that "true" opamps are also mostly behavioural models because an accurate transistor level model discloses too much about their design.

I guess I will try simulations now with the UniversalOpamp2, optimize my circuit and parameters and then see if I can use LT1006 in simulation and hopefully in the final hardware.
--
Regards,
Tony


 

On 27/10/2020 10:19, John Woodgate wrote:
The Universal opamp2 is not like the LM324, which has this special Class B output stage. Look at the data sheet to see how to make the output stage work in Class A, eliminating the sharp non-linearity at waveform zero-crossings that is probably causing your time step error.
I would speculate that the class B output stage is almost certainly *not* causing the time step error. It may be a non-linearity, but it's not discontinuous. In any event, the circuit really operates at DC with DC loads, so it may not even be operating in class B.

The reasons old models like the LM324 cause problems include unconstrained internal nodes that can reach kV and poorly behaved "poly" controlled sources. Did I mention once that they don't even obey Kirchhoff's Current Law?

--
Regards,
Tony


 

I can only report my experience, which may be more relevant than speculation. The LM324 model that I use (from NatSemi) works OK except if it's used in Class B mode. I think it is discontinuous, or very nearly so: there is a flat line in the output waveform that doesn't' seem to have curved transitions at the ends. Avoiding Class B operation, I don't have any time step or other problems with it.

======================================================================================
Best wishes John Woodgate OOO-Own Opinions Only www.woodjohn.uk Rayleigh, Essex UK
People have to be told in stark terms that they can disobey the Covid rules at the risk of their own lives,
but disobeying at the risk of others' lives is no less than a crime against humanity.
On 2020-10-27 10:09, Tony Casey wrote:
On 27/10/2020 10:19, John Woodgate wrote:
The Universal opamp2 is not like the LM324, which has this special Class B output stage. Look at the data sheet to see how to make the output stage work in Class A, eliminating the sharp non-linearity at waveform zero-crossings that is probably causing your time step error.
I would speculate that the class B output stage is almost certainly *not* causing the time step error. It may be a non-linearity, but it's not discontinuous. In any event, the circuit really operates at DC with DC loads, so it may not even be operating in class B.

The reasons old models like the LM324 cause problems include unconstrained internal nodes that can reach kV and poorly behaved "poly" controlled sources. Did I mention once that they don't even obey Kirchhoff's Current Law?


Virus-free. www.avg.com


 

Markus and others,

I tend to agree that the unique behavior of the (real) LM124/LM324 is different enough from UniversalOpamp2, that it makes good sense to use the LM124 SPICE model in the simulation.  I might start with UniversalOpamp2 to get the simulation working the way you want it, then change to the LM124 model to (attempt to) model the actual hardware you intend to build.  Doing it this way might also reveal the inherent defects of the actual LM324, assuming that they are included in its SPICE model.  It might even be that its class-B output stage caused the simulation problem -- or part of it.  Just be aware that many models are flawed.

Looking at this LM124 model, it looks like it does not have some of the behavioral elements (such as IF() functions) that introduce serious discontinuities.  In fact, the behavioral elements it has appear to be "smooth" -- although one does have a high-order polynomial and they can sometimes be problematic outside the bounds of normal operation, which might drive the simulation into uncharted territory from which it can't recover.

There is an easy "fix" to the class-B output stage problem.  Some LM124 datasheets mention it, but some do not, even from the same manufacturer.  All it takes is 3 resistors, one per op-amp.  (I couldn't try it because I don't have the IRF9Z34N model, so I can't replicate the errors you had.)

Depending on where the "time step too small" and "singular matrix" errors happen, it might also help to add "Startup" to the .tran statement.  In extreme cases, "UIC" might also be needed, but avoid that unless absolutely necessary.

Andy


 

Hi all,
with the UniversalOpamp2 everything worked just fine as expected and designed. Unfortunately exactly the same schematic with LT1006 behaves very, very different ... I continue to analyze the reasons, but quite strange to me.

Best Regards,
Markus


 

Hello Markus

with the UniversalOpamp2 everything worked just fine as expected and
designed. Unfortunately exactly the same schematic with LT1006 behaves very,
very different ... I continue to analyze the reasons, but quite strange to
me.
Be careful about the settings and how you use it. Previous replies
already mentioned you have to taylor the settings in orderr to get a
good match, you can't just expect to place it in the schematic, click
run, and expect miracles. If you look in its datasheet, LT1006 needs a
unipolar supply, has a GBW of ~300-~500 kHz, and the slew rate is ~0.4
V/us for full swing (page 8). The output current is max 20 mA
according the the 1st page. Don't forget to use the level.3a or 3b for
better results. Set these and you should see more matching results.

--
Vlad
______________________
ltspicegoodies.ltwiki.org v2:
quite universal analog/digital filter,
power electronics, signal processing,
easy to work with math functions,
digital models, and rants.


 

On 10/28/20 11:59 AM, Markus Reinhardt via groups.io wrote:
Hi all,
with the UniversalOpamp2 everything worked just fine as expected and
designed. Unfortunately exactly the same schematic with LT1006 behaves
very, very different ... I continue to analyze the reasons, but quite
strange to me.
The LM324 isn't going to work well there because its inputs violate the
common mode range limit of Vcc-1.5.

I don't understand U3 as it is shown open loop. So no current regulation
possible at all.

Perhaps a little divide and conquer is in order here. Simulate parts
(current measurement for one) by themselves before trying the whole thing.


I have found from getting current regulators working in real life that
they always have stability and oscillation problems. Usually fixable
with a well placed capacitor.


--
http://davesrocketworks.com
David Schultz


 

Markus,

It would be worth your while to probe signals in your circuit.

Probe the differential input voltages of each op-amp.  Ideally they should be 0, but might be in the low millivolt range with 'real' (simulated) op-amps.  If it goes higher than that, it means that op-amp is open-loop and can't control its output, and the circuit has probably failed.

Probe V2out and Vgate.  Observe when the circuit is unregulated because one signal or the other is at 0V or at the rail.  When either happens, the circuit has probably failed.

I recommend not using .tran for this analysis.  Comment or delete that, and replace it with the ".op" command.  LTspice automatically plots as a function of the value of R2.  It's much more useful than staring at horizontal lines.

Andy


 

On Thu, Nov 14, 2024 at 08:10 PM, <marruhanu@...> wrote:
Hi andy,
 
could you please share the LM124 spice model here, if you still have it. 
 
No.
 
Andy